document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { window.shareData = { "imgUrl": "http://www.d-shang.com/static/d_shang/weixin/images/xrk.jpg", "timeLineLink":"http://www.d-shang.com/static/d_shang/weixin/index.htm", "sendFriendLink":"http://www.d-shang.com/static/d_shang/weixin/index.htm", "tTitle": "我想成爲你最好的邂逅,最難忘的回憶!", "tContent": "我想成爲你最好的邂逅,最難忘的回憶!", "fTitle": "我想成爲你最好的邂逅,最難忘的回憶!", "fContent": "我想成爲你最好的邂逅,最難忘的回憶!", "wContent": "我想成爲你最好的邂逅,最難忘的回憶!" }; // 發送給好友 WeixinJSBridge.on('menu:share:appmessage', function (argv) { WeixinJSBridge.invoke('sendAppMessage', { "img_url": window.shareData.imgUrl, "img_width": "640", "img_height": "640", "link": window.shareData.sendFriendLink, "desc": window.shareData.fContent, "title": window.shareData.fTitle }, function (res) { if('send_app_msg:cancel' != res.err_msg){ shareReport(); } _report('send_msg', res.err_msg); }) }); // 分享到朋友圈 WeixinJSBridge.on('menu:share:timeline', function (argv) { WeixinJSBridge.invoke('shareTimeline', { "img_url": window.shareData.imgUrl, "img_width": "640", "img_height": "640", "link": window.shareData.timeLineLink, "desc": window.shareData.tContent, "title": window.shareData.tTitle }, function (res) { if('share_timeline:cancel' != res.err_msg){ shareReport(); } _report('timeline', res.err_msg); }); }); // 分享到微博 WeixinJSBridge.on('menu:share:weibo', function (argv) { WeixinJSBridge.invoke('shareWeibo', { "content": window.shareData.wContent, "url": window.shareData.weiboLink }, function (res) { if('share_weibo:cancel' != res.err_msg){ shareReport(); } _report('weibo', res.err_msg); }); }); }, false) function shareReport(){ var pid = '80158'; var id = '1624'; var wechatid = 'fromUsername'; var url = '/magazine/magazine/ShareBack'; $.post(url, {pid:pid,id:id,wechatid:wechatid}, function(data){ if(data.status == 0){ // success // alert(data.message); finishDump(data.data); }else{ // failed // alert(data.message); } }, 'json'); } function FavoriteReport(){ var pid = '80158'; var id = '1624'; var wechatid = 'fromUsername'; var url = '/magazine/magazine/ShareBack'; $.post(url, {pid:pid,id:id,wechatid:wechatid}, function(data){ if(data.status == 0){ // success // alert(data.message); finishDump(data.data); }else{ // failed // alert(data.message); } }, 'json'); } function finishDump(data){ if(data){ if(data.redirect){ window.location = data.redirect; }else if(data.tel){ var tel_obj = $('<a href="tel:'+data.tel+'"></a>'); $(tel_obj).trigger('click'); } } }