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), nonceStr: WXDate.nonceStr, signature: WXDate.signature, 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