let url = encodeURIComponent(window.location.href.split('#')[0])
window.jssdkSign(url, (res) => {
console.log('微信配置信息', res)
window.wx.config({
debug: false,
appId: res.appId,
timestamp: res.timestamp,
nonceStr: res.noncestr,
signature: res.signature,
jsApiList: ['showMenuItems', 'updateAppMessageShareData']
})
window.wx.error(function (res) {
console.error(res)
})
window.wx.ready(() => {
window.wx.showMenuItems({
menuList: ['menuItem:share:appMessage'],
success: () => {
console.log('menuItem:share:appMessage成功')
this.updateShareInfo()
},
fail: (err) => {
console.error(err)
}
})
})
})
updateShareInfo () {
let shareInfo = this.shareInfo
window.wx.updateAppMessageShareData({
title: shareInfo.title,
desc: shareInfo.desc,
link: shareInfo.link,
imgUrl: shareInfo.imgUrl,
success: (res) => {
console.log('分享朋友设置成功==' + res)
},
fail: (err) => {
this.wechatShare()
console.error('分享朋友设置失败==' + err)
}
})
}