微信里如何判断页面被分享成功


有个活动页面需要用户分享成功后给用户一个sn编码用于抽奖,请问微信分享有回调函数吗

微信 JavaScript

Sora乌鸦 10 years, 3 months ago

 var shareData = {
    img_url: "",
    img_width: 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') {
    //分享完毕回调
    }
}

Ko君D日常 answered 10 years, 3 months ago

Your Answer