公众号开发自定义菜单跳转连接获取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_redirectapi

redirect_uri  跳转的连接中不能直接加#号。因此咱们加了path参数app

我是在main.js中获取code值而后传给后台的:this

 

 

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)}
相关文章
相关标签/搜索