fdb4f2b8 by fuenxin

update getUrl

1 parent 83954b2c
......@@ -4,51 +4,52 @@ angular.module('myApp')
$rootScope.isRendBike = false;
$rootScope.isLoadFinish = false;
$scope.unfinishOrder = {};
var code = getUrl('code')
var loginCode = function (code) {
if(code){
dingdaService.verifyThirdCode(code).success(function (res) {
globalService.saveData('loginCode', code)
if(res.meta.code == 200) {
dingdaService.verifyPhoneCode(res.data.mobile, res.data.code).success(function (data) {
if (data.meta.code == 200) {
data.data.userName = res.data.mobile;
globalService.saveData('user',data.data);
layer.open({
content: '登录成功',
time:1
});
setTimeout(function() {
window.location.href = window.location.origin + window.location.pathname
// location.reload();
} , 300);
} else if (data.meta.code == 401) {
layer.open({
content: data.meta.message,
time:1
});
// alert(data.meta.message);
// layer.msg(data.data.error);
return;
}
})
}
if(res.meta.code == 500){
$state.go('login', {}, {reload: true});
}
})} else {
$scope.userinfo = {};
$scope.userinfo.userName = "未登录";
$scope.userinfo.loginState = false;
}
}
var init = function() {
// globalService.init();
function getUrl(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
function getUrl(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
var code = getUrl('code')
var loginCode = function (code) {
if(code){
dingdaService.verifyThirdCode(code).success(function (res) {
globalService.saveData('loginCode', code)
if(res.meta.code == 200) {
dingdaService.verifyPhoneCode(res.data.mobile, res.data.code).success(function (data) {
if (data.meta.code == 200) {
data.data.userName = res.data.mobile;
globalService.saveData('user',data.data);
layer.open({
content: '登录成功',
time:1
});
setTimeout(function() {
window.location.href = window.location.origin + window.location.pathname
// location.reload();
} , 300);
} else if (data.meta.code == 401) {
layer.open({
content: data.meta.message,
time:1
});
// alert(data.meta.message);
// layer.msg(data.data.error);
return;
}
})
}
if(res.meta.code == 500){
$state.go('login', {}, {reload: true});
}
})} else {
$scope.userinfo = {};
$scope.userinfo.userName = "未登录";
$scope.userinfo.loginState = false;
}
}
$scope.userinfo = globalService.getData("user");
if(!$scope.userinfo ) {
loginCode()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!