|
|
@@ -20,34 +20,38 @@ export default {
|
|
|
onScan() {
|
|
|
this.getConfig()
|
|
|
const that = this
|
|
|
- wx.ready(function() {
|
|
|
- console.log('测试2222')
|
|
|
- wx.checkJsApi({
|
|
|
- // 需要使用的JS接口列表,在这里只需要用到scanQRCode
|
|
|
- jsApiList: ['scanQRCode'],
|
|
|
- success: function(res1) {
|
|
|
- if (res1.checkResult.scanQRCode) {
|
|
|
- // 当scanQRCode可使用时
|
|
|
- wx.scanQRCode({
|
|
|
- needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
|
|
- scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
|
|
- success: function(res2) {
|
|
|
- const result = res2.resultStr
|
|
|
- that.$emit('success', result)
|
|
|
- // console.log(res2.resultStr, '扫描的结果~')
|
|
|
- // window.location.href = result
|
|
|
- },
|
|
|
- error: function(response) {
|
|
|
- this.close()
|
|
|
- this.$nextTick(() => {
|
|
|
- that.$toast(response)
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ try {
|
|
|
+ wx.ready(function() {
|
|
|
+ console.log('测试2222')
|
|
|
+ wx.checkJsApi({
|
|
|
+ // 需要使用的JS接口列表,在这里只需要用到scanQRCode
|
|
|
+ jsApiList: ['scanQRCode'],
|
|
|
+ success: function(res1) {
|
|
|
+ if (res1.checkResult.scanQRCode) {
|
|
|
+ // 当scanQRCode可使用时
|
|
|
+ wx.scanQRCode({
|
|
|
+ needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
|
|
|
+ scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
|
|
|
+ success: function(res2) {
|
|
|
+ const result = res2.resultStr
|
|
|
+ that.$emit('success', result)
|
|
|
+ // console.log(res2.resultStr, '扫描的结果~')
|
|
|
+ // window.location.href = result
|
|
|
+ },
|
|
|
+ error: function(response) {
|
|
|
+ this.close()
|
|
|
+ this.$nextTick(() => {
|
|
|
+ that.$toast(response)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
},
|
|
|
async getConfig() {
|
|
|
const that = this
|