公眾號開發自定義菜單跳轉鏈接獲取code值、跳轉子頁面


 

 

https://open.weixin.qq.com/connect/oauth2/authorize?appid=aaaaaaa&redirect_uri=http://www.xxx.com/GDsellers/?path=commission&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect

redirect_uri  跳轉的鏈接中不能直接加#號。所以我們加了path參數

我是在main.js中獲取code值然后傳給后台的:

 

 

var urls = location.search;   //獲取url中"?"符后的字串
var theRequest: any = new Object();
if (urls.indexOf("?") != -1) {
var str = urls.substr(1);
let strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
if (theRequest.code) {
this.$store.state.wxCode = theRequest.code
console.log("code", theRequest.code)
}


免責聲明!

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



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