微信分享,二次分享無法正確獲取配置信息問題


 

  

url:https://m129.baojinjinfu.com/activity/share/index.html?id=538&from=singlemessage&isappinstalled=0

 

 

朋友圈   from=timeline&isappinstalled=0
微信群   from=groupmessage&isappinstalled=0
好友分享 from=singlemessage&isappinstalled=0

 

在連接后加上?&再進行分享,分享成功

url中紅色鏈接內容,是微信自動為分享鏈接添加的內容,目的是為了記錄分享來源

//js獲取url中參數值的方法
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } //二次分享時,微信會自動在url后加上&from=singlemessage&isappinstalled=0 var from = getQueryString('from'); var appinstall = getQueryString('appinstall'); var sec = getQueryString('sec'); var timekey = getQueryString('timekey'); if(from || appinstall || sec || timekey) { var tender_id = getQueryString('id'); window.location.href = "/activity/share/index.html?id="+tender_id; } function goAppShare() { if (userId === null || isApp === null) return; var callBackUrl="/activity/share/"+userId; $.ajax({ url: callBackUrl, type: 'GET', success: function(data){} }); } function goWXActivityShare() { //二次分享時,微信會自動在url后加上&from=singlemessage&isappinstalled=0 var from = getQueryString('from'); if(!from){ var acturl = '/activity/share/index.html?id=' + tender_id; }else{ var acturl = window.location.href; } var wechatUrl = "/wechat/jssdk/config"; var callBackUrl="/activity/share/success/"+tender_id; $.ajax({ url: wechatUrl, type: "POST", data: {acturl: encodeURI(acturl)}, cache: false, success: function (msg) { if (msg.code == '200') { wx.config({ debug: false, appId: msg.data.appId, timestamp: msg.data.timestamp, nonceStr: msg.data.nonceStr, signature: msg.data.signature, jsApiList: [ // 所有要調用的 API 都要加到這個列表中 'onMenuShareTimeline', 'onMenuShareAppMessage' ] }); wx.ready(function () { wx.onMenuShareTimeline({ title: wxShare.title, // 分享標題 desc: wxShare.msg, // 分享說明 link: wxShare.url, // 分享鏈接 imgUrl: wxShare.icon, // 分享圖標 success: function (msg) { $.ajax({ url: callBackUrl, type: "get", data: {}, cache: false, success: function (data) { $('.guide-mask').hide(); $('.share-guide').hide(); window.location.href = "/activity/share/index.html?id="+tender_id; window.location.reload(); } }); console.log('@--------------'); console.log(msg); console.log('@--------------'); } }); wx.onMenuShareAppMessage({ title: wxShare.title, // 分享標題 desc: wxShare.msg, // 分享說明 link: wxShare.url, // 分享鏈接 imgUrl: wxShare.icon, // 分享圖標 type: '', // 分享類型,music、video或link,不填默認為link dataUrl: '', // 如果type是music或video,則要提供數據鏈接,默認為空 success: function (msg) { $.ajax({ url: callBackUrl, type: "get", data: {}, cache: false, success: function (data) { $('.guide-mask').hide(); $('.share-guide').hide(); window.location.href = "/activity/share/index.html?id="+tender_id; window.location.reload(); } }); console.log('#--------------'); console.log(msg); console.log('#--------------'); } }); }); } } }); }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM