When sharing and calling the onMenuShareAppMessage method under Android, the custom link is successfully used, but the same code is still a link to this page under ios. When debug mode is turned on, everything is ok, and ios is also ok. I don’t know what the problem is. What's wrong, it's also called in wx.ready, and even settingTimeout for two seconds didn't work. I tried everything.
setTimeout(function() {
alert('已注册获取“发送给朋友”状态事件');
// 分享到朋友圈
wx.onMenuShareAppMessage({
title: '个人资料', // 分享标题
desc: '他(她)的病症信息。', // 分享描述
link: '<%=basePath%>/weChat/more/sharePage?'+queryString, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: '<%=basePath%>/images/weChat/ic_share.png', // 分享图标
type: 'link',
trigger: function (res) {
alert('用户点击发送给朋友');
},
success: function (res) {
alert('已分享');
},
cancel: function (res) {
alert('已取消');
},
fail: function (res) {
alert(JSON.stringify(res));
}
});
}, 2000);
Finally solved the problem, I changed the variables <%=basePath%> in link and imgUrl to fixed paths, and it’s easy to use
link should be consistent with the safe domain name. I don’t know how your
basePath
ishttps://mp.weixin.qq.com/wiki