收藏
回答

IOS真机调用scanQRCode没反应?开发者工具和安卓机都可以

回答关注问题邀请回答
收藏

2 个回答

  • demon.
    demon.
    2021-02-22

    公众号的

    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    
    // 进入页面获取配置
    this.$api.app.jsSdk().then(({ data: response }) => {
      wx.config({
        debug: response.debug,
        appId: response.appId,
        timestamp: response.timestamp,
        nonceStr: response.nonceStr,
        signature: response.signature,
        jsApiList: response.jsApiList,
      });
      wx.ready(() => {
        wx.checkJsApi({
          jsApiList: ['scanQRCode'],
          success: ({ checkResult }) => {
            if (checkResult.scanQRCode) {
              this.scanQRCodeApi = true;
            }
          },
        });
      });
    });
    
    //按钮点击后触发
    scanParcelCode(event) {
     
     wx.scanQRCode({
        needResult: 1,
        scanType: ['qrCode', 'barCode'],
        success: (res) => {
          let code;
          if (res.resultStr.startsWith('CODE')) {
            code = res.resultStr.substring(res.resultStr.indexOf(',') + 1);
          } else {
            code = res.resultStr;
          }
          this.checkParcelCode(code);
        },
        fail: () => {
        },
      });
      event.preventDefault();
      event.stopPropagation();
      return false;
    },
    


    2021-02-22
    有用
    回复
  • 😶
    😶
    2021-02-22

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2021-02-22
    有用
    回复 4
    • demon.
      demon.
      2021-02-22
      如下
      2021-02-22
      回复
    • demon.
      demon.
      2021-02-24
      你好?
      2021-02-24
      回复
    • 😶
      😶
      2021-02-24回复demon.
      可以上传一个代码片段, 我直接在开发者工具里面测试
      2021-02-24
      回复
    • demon.
      demon.
      2021-02-24回复😶
      代码片段不是小程序的吗? 我这是公众号。是这个链接
      https://app.e-smartship.com/order
      2021-02-24
      回复
登录 后发表内容
问题标签