<script type="text/javascript">
$(document).ready(function(){
document.getElementById("over").style.display = "block";
document.getElementById("layout").style.display = "block";
//判断是否之前走过授权
// var token = window.localStorage.getItem('token');
// if(token){
// window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
// }
var urlStr = window.location.href;
function GetRequest(urlStr) {
if (typeof urlStr == "undefined") {
var url = decodeURI(location.search); //获取url中"?"符后的字符串
} else {
var url = "?" + urlStr.split("?")[1];
}
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
}
var parms_1 = GetRequest();
var type = parms_1['type'];
if (type){
window.localStorage.setItem('type', type);
}
//判断是否之前走过授权
// var token = window.localStorage.getItem('token');
// if(token && window.localStorage.getItem('type') == 1){
// window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
// }
var oror = parms_1['code'];
if (oror){
mui.ajax(site_url + 'login', {
data: {
code: oror
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
success: function(data) {
window.localStorage.setItem('token', data.data.token);
if (data.data.user.phone != null) {
var types = window.localStorage.getItem('type');
if(types == 1){
// window.close();
window.location.href = '../common/supplyHall.html';
// window.close();
}else {
window.location.href = '../common/person.html';
}
} else {
window.location.href = '../person/bindMobile.html'
}
},
error: function(xhr, type, errorThrown) {
//alert(123)
}
});
}else {
window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx819031dbf71618be&redirect_uri=http://zhibo.cnewhl.com/pages/common/login.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
}
//$('#login').click(function(){
// var token = window.localStorage.getItem('token');
// // alert(token)
// if(token){
// window.location.href='http://zhibo.cnewhl.com/pages/common/supplyHall.html '
// return
// }
// window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx819031dbf71618be&redirect_uri=http://zhibo.cnewhl.com/pages/person/bindMobile.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect '
//})
})
</script>