url=Global.url;
formData.append('url',url)
fetch(webURL+'share',{method:'POST',body:formData}).then((response) => response.json()).then((responseText) => {
let configmsg={
debug: false,
appId: responseText.data.appid,
timestamp: responseText.data.time,
nonceStr: responseText.data.nonce,
signature: responseText.data.signature,
jsApiList: ['showMenuItems','hideMenuItems','onMenuShareAppMessage','onMenuShareTimeline']}
window.wx.config(configmsg);
window.wx.ready(function(){
window.wx.onMenuShareTimeline({
title: desc,
link:link,
imgUrl: 'http://gongzuolaile.oss-cn-beijing.aliyuncs.com/icon/logo.png',
success:function () {
console.log('success')
window.TDAPP.onEvent("分享",desc,Global.uid);
},
fail:function(){
alert('error')
}
});
});
})
路由用的是react-router,在第一次进入的时候将window.location.href保存为全局变量,每个页面获取签名的时候都是用的这个url,config都ok,第一次进入页面的时候分享也都正常,但是页面一旦跳转分享的链接等设置就又都为默认,config也都显示ok,已经排除签名失败、安全域名等问题。
这个问题已经困扰我很久了,恳请各位大神帮忙解决。