收藏
回答

config:invalid signature ?

小程序 web-view 调用 jssdk config 提示  {"realAuthUrl": "[https://xx.xx.com/wx/, https://xx.xx.com/wx/]", "errMsg": "config:invalid signature"}

request合法域名 和 业务域名 已配置 xx.xx.com

微信 JS 接口签名校验工具测试也是一致的


url 也是 获取正常的

export const initJWeiXin = async (jsList = []) => {
  // if (isWeiXin()) {
    console.log(window.location.href, 'href');


    const result = await getJWeiXinConfig(window.location.href.split('#')[0]);


    console.log(result, 'result');


    if (result.data.appId && result.status !== 200) {
      return console.log('请求异常');
    }


    window.wx.config({
      appId: result.data.appId,
      debug: true,
      jsApiList: [
        // 'checkJsApi',
        // 'onMenuShareAppMessage',
        // 'onMenuShareTimeline',
        ...jsList,
        // 所有要调用的 API 都要加到这个列表中
      ],
      noncestr: result.data.nonceStr,
      signature: result.data.signature,
      timestamp: result.data.timestamp,
    });


    window.wx.ready(function (res) {
      console.log('ready success', res);
      window.wx.checkJsApi({
        jsApiList: jsList,
        success: function () {
          console.log('checkJsApi success');
        },
      });
    });


    window.wx.error(function (res) {
      console.log('wx.error', res);
    });
  // }
};
回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容