求助,vue页面(history模式路由)使用js-sdk突然报invalid signature

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:04 824 0 全屏看文

AI助手支持GPT4.0

求助,vue页面(history模式路由)使用js-sdk突然报invalid signature
问题类型 API/组件名称 终端类型 微信版本 基础库版本
Bug wx.config 微信安卓客户端 6.5.3 1.2.0

按照官方排错文档仔仔细细排错了几遍,都没有发现问题。始终报invalid signature错误,报错也不详细,就一个invalid signature,我也不知道到底是哪里的问题。

之前是用hash模式路由,后来改为了history模式,但是给签名的url都是正确的,在微信js校验工具里面测试,签名也是正确的。

传入的地址是全地址,包含http://和路由地址。

麻烦各位大佬指点一下,但凡有一点办法,我也不会来这里求助。谢谢大佬们,下面放代码:

var strUrl = location.href.split('#')[0];$.ajax({    type: "Post",    url: "xxx",    data: JSON.stringify({        str: encodeURIComponent(strUrl)    }),    contentType: "application/json; charset=utf-8",    dataType: "json",    success: function(data) {        wxconifg(data.data);    },    error: function(jqXHR, textStatus, errorThrown) {}});function wxconifg(WXDate) {    wx.config({        debug: false,        appId: WXDate.appId,        timestamp: Number(WXDate.timestamp),   //1595837986        nonceStr: WXDate.nonceStr,   //7ba9788c-315d-4639-9176-a98cb607486d        signature: WXDate.signature, //d01eb9f4df70fbdf179bd3b45decd0b532bd9562        jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareQZone",            "getLocalImgData", "chooseImage"        ],        fail: (err) => {            console.log('wx.config_errpr:', err);        }    });    wx.ready(function() {        wx.onMenuShareAppMessage(objInfo);        wx.onMenuShareTimeline(shareInfo);    });    wx.error(function(err) {        console.log('wx.error:', err)    });}

Problem type API / component name terminal type wechat version basic library version bug wx.config The wechat Android client 6.5.3 1.2.0 has been carefully arranged several times according to the official troubleshooting document, but no problem has been found. I always report invalid signature errors, but they are not detailed. I don't know where the problem is with an invalid signature. In the past, the hash mode was used for routing, and then the history mode was changed. However, the URL for the signature is correct. The signature is also correct when tested in the wechat JS verification tool. The incoming address is the full address, including http: / / and routing address. Please give me some advice. If there is any way, I will not come here for help. Thank you guys, the following code: VAR strurl= location.href.split ('#')[0];$.ajax({    type: "Post",    url: "xxx",    data: JSON.stringify ({        str: encodeURIComponent(strUrl)    }),    contentType: "application/json; charset=utf-8",    dataType: "json",     success: function(data) {        wxconifg( data.data );    },    error: function(jqXHR, textStatus, errorThrown) {}});function wxconifg(WXDate) {     wx.config ({        debug: false,        appId: WXDate.appId ,        timestamp: Number( WXDate.timestamp ), //1595837986        nonceStr: WXDate.nonceStr , //7ba9788c-315d-4639-9176-a98cb607486d        signature: WXDate.signature , //d01eb9f4df70fbdf179bd3b45decd0b532bd9562        jsApiList: ["checkJsApi", "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareQZone",            "getLocalImgData", "chooseImage"        ],         fail: (err) => {             console.log () wx.config_ errpr:', err);        }    });     wx.ready (function() {         wx.onMenuShareAppMessage (objInfo);         wx.onMenuShareTimeline (shareInfo);    });     wx.error (function(err) {         console.log () wx.error :', err)    });}

回答:

社区技术运营专员-娇华:

你好,有对照这里提供的解决方法么?https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html

MADAO:已经按照这个每一步都是检查过的,获取签名的url动态获取,也写死测试过,都没用,是突然这样报错的,以前是能正常使用
社区技术运营专员-娇华:微信版本是6.5.3?更新至最新版本再试试,还有问题的话,提供下问题机型、系统版本、微信版本、复现问题的链接
MADAO:测试的每种机型都有这个问题,系统安卓和IOS都有,微信版本新旧都有,复现链接是:https://service-bak.hulucc.com/h5/huluappfront/fathersDay/camera    麻烦帮忙看看,谢谢了
MADAO:

求各位大佬不惜赐教,谢谢啦

-EOF-

AI助手支持GPT4.0