代码如下,如果使用['updateAppMessageShareData', 'updateTimelineShareData']进行开发,页面每次刷新自动触发分享成功,不得己只能改用即将废弃的接口
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
wx.config({
debug: false,
appId: "{$appid|raw}",
timestamp: "{$timestamp|raw}",
nonceStr: "{$noncestr|raw}",
signature: "{$signature|raw}",
jsApiList: [
'onMenuShareAppMessage',
'onMenuShareTimeline',
'onMenuShareQQ',
'onMenuShareQZone',
'onMenuShareWeibo'
]
});
wx.ready(function(){
var shareData = {
"imgUrl": '{$baseimg|raw}',
"link": '{$baseuri|raw}',
"desc": '{$site_title}',
"title": '{$site_title}',
success: function() {
}
}
wx.onMenuShareAppMessage(shareData);
wx.onMenuShareTimeline(shareData);
wx.onMenuShareQQ(shareData);
wx.onMenuShareQZone(shareData);
wx.onMenuShareWeibo(shareData);
});