向后台请求了(timestamp,nonceStr,signature)并调用了config(),但一直验证不通过,也通过http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign官方验证平台上校验了,没问题,但实际项目中,就是没有通过校验,无法正常调用自定义的分享接口,求哪位大哥,赶快帮忙看看,谢谢了 T T .....
const url = window.location.href.split('#')
const surl = encodeURIComponent(url[0])
apis.mine
.fetchJsSdkSign({ appId: process.env.VUE_APP_APPID, url: surl })
.then(res => {
if (res.code === 200) {
const data = res.data
Auth.instance.config({
debug: true,
appId: data.appId, // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1
jsApiList: dataJson.jsApiList
})
if (dataJson.hide) {
Auth.instance.ready(() => {
console.log('验证成功1')
Auth.instance.hideOptionMenu()
})
} else {
Auth.instance.ready(() => {
console.log('验证成功2', dataJson.options)
// Auth.instance.showOptionMenu()
Auth.instance.updateTimelineShareData(dataJson.options)
Auth.instance.updateAppMessageShareData(dataJson.options)
Auth.instance.onMenuShareTimeline(dataJson.options)
Auth.instance.onMenuShareAppMessage(dataJson.options)
})
Auth.instance.error(err => {
console.log('验证失败-err', err)
})
}
resolve()
} else {
showToast(res.msg)
reject()
}
})
前端encode,后端decode了吗