当前位置: 移动技术网 > IT编程>开发语言>Jquery > 微信网页授权获取code

微信网页授权获取code

2018年11月12日  | 移动技术网IT编程  | 我要评论

<script>
(function(){
var code = getquerystring('code');

if(code){
alert(code)
return false;

}else{
shouquan();
}

function shouquan(){
var redirect_uri = window.location.origin + window.location.pathname;
console.log(redirect_uri)

var appid = "wx70c81e11981cab3d";
var wx_link = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' +
redirect_uri + '&response_type=code&scope=snsapi_base#wechat_redirect';
console.log(1)
window.location.href = wx_link;
code = getquerystring('code');
}


function getquerystring(name){
var reg = new regexp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;

}
})()

</script>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网