const Appid='appid'
const code = theRequest.code
const redirect_uri =encodeURIComponent('http://192.168.10.90:8080/#/login') //重定向的地址并且进行编码
if (code == null ||code ==='') {
window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + Appid + '&redirect_uri='+redirect_uri+'&response_type=code&scope=snsapi_base&state=123#wechat_redirect'
}
//重定向以后code会出现在链接上
获取链接中code
var userip=returnCitySN["cip"]
var url = location.search; //获取url中"?"符后的字符串
var theRequest =new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for(var i =0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
}
}