fdb4f2b8 by fuenxin

update getUrl

1 parent 83954b2c
...@@ -4,51 +4,52 @@ angular.module('myApp') ...@@ -4,51 +4,52 @@ angular.module('myApp')
4 $rootScope.isRendBike = false; 4 $rootScope.isRendBike = false;
5 $rootScope.isLoadFinish = false; 5 $rootScope.isLoadFinish = false;
6 $scope.unfinishOrder = {}; 6 $scope.unfinishOrder = {};
7 var code = getUrl('code') 7
8 var loginCode = function (code) {
9 if(code){
10 dingdaService.verifyThirdCode(code).success(function (res) {
11 globalService.saveData('loginCode', code)
12 if(res.meta.code == 200) {
13 dingdaService.verifyPhoneCode(res.data.mobile, res.data.code).success(function (data) {
14 if (data.meta.code == 200) {
15 data.data.userName = res.data.mobile;
16 globalService.saveData('user',data.data);
17 layer.open({
18 content: '登录成功',
19 time:1
20 });
21 setTimeout(function() {
22 window.location.href = window.location.origin + window.location.pathname
23 // location.reload();
24 } , 300);
25 } else if (data.meta.code == 401) {
26 layer.open({
27 content: data.meta.message,
28 time:1
29 });
30 // alert(data.meta.message);
31 // layer.msg(data.data.error);
32 return;
33 }
34 })
35 }
36 if(res.meta.code == 500){
37 $state.go('login', {}, {reload: true});
38 }
39 })} else {
40 $scope.userinfo = {};
41 $scope.userinfo.userName = "未登录";
42 $scope.userinfo.loginState = false;
43 }
44 }
45 var init = function() { 8 var init = function() {
46 // globalService.init(); 9 // globalService.init();
47 function getUrl(name){ 10 function getUrl(name){
48 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 11 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
49 var r = window.location.search.substr(1).match(reg); 12 var r = window.location.search.substr(1).match(reg);
50 if(r!=null)return unescape(r[2]); return null; 13 if(r!=null)return unescape(r[2]); return null;
51 } 14 }
15 var code = getUrl('code')
16 var loginCode = function (code) {
17 if(code){
18 dingdaService.verifyThirdCode(code).success(function (res) {
19 globalService.saveData('loginCode', code)
20 if(res.meta.code == 200) {
21 dingdaService.verifyPhoneCode(res.data.mobile, res.data.code).success(function (data) {
22 if (data.meta.code == 200) {
23 data.data.userName = res.data.mobile;
24 globalService.saveData('user',data.data);
25 layer.open({
26 content: '登录成功',
27 time:1
28 });
29 setTimeout(function() {
30 window.location.href = window.location.origin + window.location.pathname
31 // location.reload();
32 } , 300);
33 } else if (data.meta.code == 401) {
34 layer.open({
35 content: data.meta.message,
36 time:1
37 });
38 // alert(data.meta.message);
39 // layer.msg(data.data.error);
40 return;
41 }
42 })
43 }
44 if(res.meta.code == 500){
45 $state.go('login', {}, {reload: true});
46 }
47 })} else {
48 $scope.userinfo = {};
49 $scope.userinfo.userName = "未登录";
50 $scope.userinfo.loginState = false;
51 }
52 }
52 $scope.userinfo = globalService.getData("user"); 53 $scope.userinfo = globalService.getData("user");
53 if(!$scope.userinfo ) { 54 if(!$scope.userinfo ) {
54 loginCode() 55 loginCode()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!