83954b2c by fuenxin

gst

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