收藏
回答

调用微信扫一扫报错config:invalid signature?

const self = this
      // console.log()
      const u = navigator.userAgent
      const app = navigator.appVersion
      const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/// ios终端
      let purl = ''
      if (isIOS) {
        purl = encodeURIComponent(window.localStorage.getItem('scanUrl'))
      } else {
        purl = encodeURIComponent(window.location.href.split('#')[0])
      }
      const params = {
        url: purl
      }
      getWxConfig(params).then(res => {
        console.log(res)
        const { appId, timestamp, nonceStr, signature } = res
        wx.config({
          debugtrue,
          appId,
          timestamp,
          nonceStr,
          signature,
          jsApiList: [
            'checkJsApi',
            'scanQRCode'
          ]
        })
        wx.ready(function() {
          // 判断当前客户端版本是否支持指定JS接口
          wx.checkJsApi({
            jsApiList: ['scanQRCode'],
            successfunction(res{
              // 为了兼容iOS扫一扫, 必须把wx.scanQRCode放在wx.ready的回调函数里面
              wx.scanQRCode({
                needResult1// 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
                scanType: ['qrCode''barCode'], // 可以指定扫二维码还是一维码,默认二者都有
                successfunction(res{
                  var result = res.resultStr // 当needResult 为 1 时,扫码返回的结果
                  self.invoiceStoreNumber = result
                }
              })
            }
          })
        })
      }, err => {})
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签