onShareAppMessage: function () {
let initInviterView = this.data.initInviterView;
let path = 'pages/home/home';
if(wx.getStorageSync("activitycode")){
console.log("执行1")
this.requestInvite().then((invitePageCode)=>{
console.log(invitePageCode,'invitePageCode')
path = `pages/activity/invitation/invitedPay/index?activitycode=${ wx.getStorageSync("activitycode") }&invitePageCode=${invitePageCode}`;
return {
title: initInviterView.stageBaseInfo?.wechatShareTitle,
desc: initInviterView.stageBaseInfo?.wechartShareText,
imageUrl: initInviterView.stageBaseInfo?.wechatSharePic,
path: path
};
}).catch(err=>{
return {
title: initInviterView.stageBaseInfo?.wechatShareTitle,
desc: initInviterView.stageBaseInfo?.wechartShareText,
imageUrl: initInviterView.stageBaseInfo?.wechatSharePic,
path: path
};
})
}
},
使用button中的open-type配合onShareAppMessage事件做微信转发功能,想在用户点击按钮的时候动态调一个接口获取参数,然后在path中拼接这个参数,但是未生效依旧会提供一个默认路径唤起面板
参考文档写https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareAppMessage-Object-object
这种情况要做异步处理,参考下面代码