Q:
有个活动页面需要用户分享成功后给用户一个sn编码用于抽奖,请问微信分享有回调函数吗
A:
var shareData = { img_url: "", img_ 200, img_height: 200, link: '', desc: '', title: '', appid: 0 }; document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { // 发送给好友 WeixinJSBridge.on('menu:share:appmessage', function(argv){ shareFriend(); }); // 分享到朋友圈 WeixinJSBridge.on('menu:share:timeline', function(argv){ shareTimeline(); }); }, false); function shareTimeline() { WeixinJSBridge.invoke('shareTimeline', shareData, function(res) { validateShare(res); _report('timeline', res.err_msg); }); } function shareFriend() { WeixinJSBridge.invoke('sendAppMessage', shareData, function(res) { validateShare(res); _report('send_msg', res.err_msg); }); } function validateShare(res) { if(res.err_msg != 'send_app_msg:cancel' && res.err_msg != 'share_timeline:cancel') { //分享完毕回调 } }