1.安卓配置成功,苹果端配置失败
2.其实只要在出错的地方刷新下页面就好了.
附上代码
sharediy(){
let _url = encodeURIComponent(location.href.split('#')[0])
console.log(_url)
let shareurl = _url
this.$common.weixin_config(_url).then(res => {
let data = res.data.data
window.wx.config({
debug: false,
appId: data.appId,
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: [ 'onMenuShareAppMessage', 'onMenuShareTimeline']
})
window.wx.ready(() => {
wx.onMenuShareAppMessage({ //分享给朋友
title: this.msg.data.title,
desc: this.msg.data.short_details, // 分享描述
link: this.links, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: this.msg.data.img_url, // 分享图标
success: function () {
// 设置成功
}
})
wx.onMenuShareTimeline({ // 分享到朋友圈
title: this.msg.data.title,
link: this.links,
imgUrl: this.msg.data.img_url,
})
})
window.wx.error(function(res){
location.reload() // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
})
})
}