dfa54f2b by ex

登录修改

1 parent b33eccea
1 <div ng-controller="mainController"> 1 <div ng-controller="mainController">
2 <div id="mapContainer" class="mapContainer" ng-controller="mapController"></div> 2 <div id="mapContainer" class="mapContainer" ng-controller="mapController"></div>
3 <div id="sliderMenu" class="sliderMenu" style="display: block;" 3 <div id="sliderMenu" class="sliderMenu" style="display: none;"
4 ng-class="{true: 'menuOpen', false: 'menuClose'}[$root.openMenu]"> 4 ng-class="{true: 'menuOpen', false: 'menuClose'}[$root.openMenu]">
5 5
6 <img src="images/slideMenuBackground.png"/> 6 <img src="images/slideMenuBackground.png"/>
......
...@@ -25,6 +25,14 @@ function isJson(str) { ...@@ -25,6 +25,14 @@ function isJson(str) {
25 } 25 }
26 return true; 26 return true;
27 } 27 }
28 function toJson(str) {
29 try {
30 var arr = str.split(2,str.length - 4)
31 console.log(arr)
32 } catch (e) {
33 return ''
34 }
35 }
28 // window.invokeJsPassCompanyCodeAndName = function(_params) { 36 // window.invokeJsPassCompanyCodeAndName = function(_params) {
29 // companyCode = _params.companyCode; 37 // companyCode = _params.companyCode;
30 // companyName = _params.companyName; 38 // companyName = _params.companyName;
...@@ -45,16 +53,7 @@ AppClient.prototype.getERCode = function (callbackName, callback, jsonStr) { ...@@ -45,16 +53,7 @@ AppClient.prototype.getERCode = function (callbackName, callback, jsonStr) {
45 this.appObj.getERCode('H5', jsonStr); 53 this.appObj.getERCode('H5', jsonStr);
46 } else { 54 } else {
47 this.appObj.callHandler("getERCode", iOSData, callback); 55 this.appObj.callHandler("getERCode", iOSData, callback);
48 this.appObj.registerHandler('postERCode', function(data, responseCallback) { 56
49 layer.open({
50 content: JSON.stringify(data),
51 time: 10
52 });
53 // log('ObjC called testJavascriptHandler with', data)
54 // var responseData = { 'Javascript Says':'Right back atcha!' }
55 // log('JS responding with', responseData)
56 // responseCallback(responseData)
57 })
58 } 57 }
59 }; 58 };
60 AppClient.prototype.getGPS = function (callbackName, callback, jsonStr) { 59 AppClient.prototype.getGPS = function (callbackName, callback, jsonStr) {
...@@ -70,27 +69,7 @@ AppClient.prototype.getGPS = function (callbackName, callback, jsonStr) { ...@@ -70,27 +69,7 @@ AppClient.prototype.getGPS = function (callbackName, callback, jsonStr) {
70 this.appObj.getGPS('H5', jsonStr); 69 this.appObj.getGPS('H5', jsonStr);
71 } else { 70 } else {
72 this.appObj.callHandler("getGPS", iOSData, callback); 71 this.appObj.callHandler("getGPS", iOSData, callback);
73 this.appObj.registerHandler('postGPS', function(data, responseCallback) {
74 72
75 var res = JSON.parse(data)
76 layer.open({
77 content: data,
78 time: 2
79 });
80 layer.open({
81 content: JSON.stringify(key),
82 time: 2
83 });
84 var key = res['testKey']
85 layer.open({
86 content: JSON.stringify(key),
87 time: 2
88 });
89 // log('ObjC called testJavascriptHandler with', data)
90 // var responseData = { 'Javascript Says':'Right back atcha!' }
91 // log('JS responding with', responseData)
92 // responseCallback(responseData)
93 })
94 } 73 }
95 }; 74 };
96 // 75 //
...@@ -108,10 +87,6 @@ if(window.android) { ...@@ -108,10 +87,6 @@ if(window.android) {
108 appClient = new AppClient(window.android, true); 87 appClient = new AppClient(window.android, true);
109 // 此处可以调用一些init的方法 88 // 此处可以调用一些init的方法
110 } else { 89 } else {
111 layer.open({
112 content: '初始化',
113 time: 2
114 })
115 function setupWebViewJavascriptBridge(callback) { 90 function setupWebViewJavascriptBridge(callback) {
116 if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); } 91 if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
117 if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); } 92 if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
...@@ -126,6 +101,6 @@ if(window.android) { ...@@ -126,6 +101,6 @@ if(window.android) {
126 appClient = new AppClient(bridge, false); 101 appClient = new AppClient(bridge, false);
127 // 此处可以调用一些init的方法 102 // 此处可以调用一些init的方法
128 }); 103 });
129
130 } 104 }
131 105
106
......
...@@ -2,20 +2,65 @@ angular.module('myApp') ...@@ -2,20 +2,65 @@ angular.module('myApp')
2 .controller('mainController',['$scope','$rootScope','dingdaService','$state','globalService',function($scope,$rootScope,dingdaService,$state,globalService){ 2 .controller('mainController',['$scope','$rootScope','dingdaService','$state','globalService',function($scope,$rootScope,dingdaService,$state,globalService){
3 3
4 $rootScope.isRendBike = false; 4 $rootScope.isRendBike = false;
5 $rootScope.isLoadFinish = true; 5 $rootScope.isLoadFinish = false;
6 $scope.unfinishOrder = {}; 6 $scope.unfinishOrder = {};
7 var init = function() { 7 var init = function() {
8 // globalService.init(); 8 // globalService.init();
9 function getUrl(name){
10 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
11 var r = window.location.search.substr(1).match(reg);
12 if(r!=null)return unescape(r[2]); return null;
13 }
9 $scope.userinfo = globalService.getData("user"); 14 $scope.userinfo = globalService.getData("user");
10 if(!$scope.userinfo) { 15 if(!$scope.userinfo) {
16 var code = getUrl('code')
17 if(code){
18 dingdaService.verifyThirdCode(code).success(function (res) {
19 if(res.mate.code == 200) {
20 dingdaService.verifyPhoneCode(res.data.mobile, res.data.code).success(function (data) {
21 if (data.meta.code == 200) {
22 data.data.userName = $scope.phoneNumberVal;
23 globalService.saveData('user',data.data);
24 // layer.open({
25 // content: '登录成功',
26 // time:1
27 // });
28 setTimeout(function() {
29 location.reload();
30 } , 300);
31 } else if (data.meta.code == 401) {
32 layer.open({
33 content: data.meta.message,
34 time:1
35 });
36 // alert(data.meta.message);
37 // layer.msg(data.data.error);
38 return;
39 }
40 })
41 }
42 if(res.mate.code == 500){
43 $state.go('login', {}, {reload: true});
44 }
45 })
46 } else {
11 $scope.userinfo = {}; 47 $scope.userinfo = {};
12 $scope.userinfo.userName = "未登录"; 48 $scope.userinfo.userName = "未登录";
13 $scope.userinfo.loginState = false; 49 $scope.userinfo.loginState = false;
50 }
51
14 } else { 52 } else {
15 $scope.userinfo.loginState = true; 53 $scope.userinfo.loginState = true;
16 // alert("getUnfinishedOrder") 54 // alert("getUnfinishedOrder")
17 dingdaService.getUnfinishedOrder().success(function(data , status){ 55 dingdaService.getUnfinishedOrder().success(function(data , status){
18 // alert(JSON.stringify(data)) 56 // alert(JSON.stringify(data))
57 if(data.meta.code === 401) {
58 layer.open({
59 content:'登录token失效,请重新登录',
60 time:2
61 })
62 return
63 }
19 if(data.data.unfinishedOrder.id) { 64 if(data.data.unfinishedOrder.id) {
20 $rootScope.isRendBike = true; 65 $rootScope.isRendBike = true;
21 $scope.unfinishOrder = data.data.unfinishedOrder; 66 $scope.unfinishOrder = data.data.unfinishedOrder;
...@@ -104,9 +149,9 @@ angular.module('myApp') ...@@ -104,9 +149,9 @@ angular.module('myApp')
104 $rootScope.openRing = false; 149 $rootScope.openRing = false;
105 $rootScope.$watch("openScan",function(newVal, oldVal){ 150 $rootScope.$watch("openScan",function(newVal, oldVal){
106 if(newVal !== oldVal && newVal) { 151 if(newVal !== oldVal && newVal) {
107 // if(!$scope.checkLogin()) { 152 if(!$scope.checkLogin()) {
108 // return; 153 return;
109 // } 154 }
110 155
111 // if($scope.unfinishOrder.status == 200) { 156 // if($scope.unfinishOrder.status == 200) {
112 // $state.go('tripDetail' , { orderId : $scope.unfinishOrder.id}); 157 // $state.go('tripDetail' , { orderId : $scope.unfinishOrder.id});
...@@ -114,15 +159,26 @@ angular.module('myApp') ...@@ -114,15 +159,26 @@ angular.module('myApp')
114 // } 159 // }
115 $rootScope.openScan = false; 160 $rootScope.openScan = false;
116 if(appClient){ 161 if(appClient){
117 appClient.getERCode('postERCode', function (res) { 162 appClient.appObj.registerHandler('postERCode', function(data, responseCallback) {
118 layer.open({ 163 layer.open({
119 content: JSON.stringify(res) + 'cb', 164 content: JSON.stringify(data),
120 time: 10 165 time: 10
121 }); 166 });
167 // log('ObjC called testJavascriptHandler with', data)
168 // var responseData = { 'Javascript Says':'Right back atcha!' }
169 // log('JS responding with', responseData)
170 // responseCallback(responseData)
171 })
172 appClient.getERCode('postERCode', function (res) {
173 // layer.open({
174 // content: JSON.stringify(res) + 'cb',
175 // time: 10
176 // });
122 }, '') 177 }, '')
178
123 } else { 179 } else {
124 layer.open({ 180 layer.open({
125 content: 'JSBridge 初始化失败', 181 content: '调起摄像头失败',
126 time:2 182 time:2
127 }); 183 });
128 } 184 }
......
...@@ -297,7 +297,15 @@ angular.module('myApp') ...@@ -297,7 +297,15 @@ angular.module('myApp')
297 // onSuccess(res) 297 // onSuccess(res)
298 // } 298 // }
299 // }); 299 // });
300
300 if(appClient){ 301 if(appClient){
302 appClient.appObj.registerHandler('postGPS', function(data, responseCallback) {
303 var res = JSON.parse(data)
304 layer.open({
305 content: data,
306 time: 2
307 });
308 })
301 appClient.getGPS('getGPS', function (res) { 309 appClient.getGPS('getGPS', function (res) {
302 // layer.open({ 310 // layer.open({
303 // content: JSON.stringify(res) + 'cb', 311 // content: JSON.stringify(res) + 'cb',
...@@ -309,9 +317,15 @@ angular.module('myApp') ...@@ -309,9 +317,15 @@ angular.module('myApp')
309 }) 317 })
310 318
311 }, '') 319 }, '')
312 }
313 320
314 // onSuccess({latitude:30.2741500000,longitude:120.1551500000}) 321 } else {
322 onSuccess({latitude:30.2741500000,longitude:120.1551500000})
323 setTimeout(function () {
324 $rootScope.isLoadFinish = true
325
326 },1000)
327
328 }
315 } 329 }
316 330
317 331
......
...@@ -3,7 +3,7 @@ angular.module('myApp.services') ...@@ -3,7 +3,7 @@ angular.module('myApp.services')
3 function($http,globalService) { 3 function($http,globalService) {
4 return { 4 return {
5 sendPhoneCode: function(phone , openId){ 5 sendPhoneCode: function(phone , openId){
6 var url = globalService.getParam('dingdaLoginAPI') + '/login/sms?mobile=' + phone + '&openId=' + openId; 6 var url = globalService.getParam('dingdaLoginAPI') + '/login/sms?mobile=' + phone + (openId?('&openId=' + (openId || '')):'');
7 var res = $http.get(url).success(function(data, status) { 7 var res = $http.get(url).success(function(data, status) {
8 }).error(function(data, status) { 8 }).error(function(data, status) {
9 alert(data.meta.message) 9 alert(data.meta.message)
...@@ -12,15 +12,21 @@ angular.module('myApp.services') ...@@ -12,15 +12,21 @@ angular.module('myApp.services')
12 }, 12 },
13 verifyPhoneCode : function(phone , code){ 13 verifyPhoneCode : function(phone , code){
14 var url = globalService.getParam('dingdaLoginAPI') + '/login/sms?mobile=' + phone + '&code=' + code; 14 var url = globalService.getParam('dingdaLoginAPI') + '/login/sms?mobile=' + phone + '&code=' + code;
15 var res = $http.post(url , { 15 var res = $http.post(url, {}, {}).success(function(data, status) {
16 } , {
17 }).success(function(data, status) {
18 16
19 }).error(function(data, status) { 17 }).error(function(data, status) {
20 alert(data.meta.message) 18 alert(data.meta.message)
21 }); 19 });
22 return res; 20 return res;
23 }, 21 },
22 verifyThirdCode : function(code){ // 通过第三方登录
23 var url = globalService.getParam('dingdaLoginAPI') + '/login/sms?code=' + code;
24 var res = $http.get(url).success(function(data, status) {
25 }).error(function(data, status) {
26 // alert(data.meta.message)
27 });
28 return res;
29 },
24 getStationList : function(longitude , latitude){ 30 getStationList : function(longitude , latitude){
25 var url = globalService.getParam('dingdaAPI') + '/service/bicycle/stations?longitude=' + longitude 31 var url = globalService.getParam('dingdaAPI') + '/service/bicycle/stations?longitude=' + longitude
26 + '&latitude=' + latitude; 32 + '&latitude=' + latitude;
......
...@@ -18,7 +18,8 @@ angular.module('myApp.services') ...@@ -18,7 +18,8 @@ angular.module('myApp.services')
18 $rootScope.inited = true; 18 $rootScope.inited = true;
19 //--------------------自行车服务-------------- 19 //--------------------自行车服务--------------
20 // 生产环境 20 // 生产环境
21 var dingdaAPI = "http://bike.dy.dingdatech.com:880"; 21 // var dingdaAPI = "http://bike.dy.dingdatech.com:880";
22 var dingdaAPI = "http://47.99.81.49:60612";
22 // 测试环境 23 // 测试环境
23 //var dingdaAPI = "http://bike.api.dingdachuxing.com"; 24 //var dingdaAPI = "http://bike.api.dingdachuxing.com";
24 globalConfig.setParam("dingdaAPI", dingdaAPI); 25 globalConfig.setParam("dingdaAPI", dingdaAPI);
...@@ -36,7 +37,8 @@ angular.module('myApp.services') ...@@ -36,7 +37,8 @@ angular.module('myApp.services')
36 globalConfig.setParam("feedbackAPI", feedbackAPI); 37 globalConfig.setParam("feedbackAPI", feedbackAPI);
37 //--------------------认证服务-------------- 38 //--------------------认证服务--------------
38 // 生产环境 39 // 生产环境
39 var dingdaLoginAPI = "http://auth.dy.dingdatech.com:880"; 40 // var dingdaLoginAPI = "http://auth.dy.dingdatech.com:880";
41 var dingdaLoginAPI = "http://47.99.81.49:40411";
40 // 测试环境 42 // 测试环境
41 //var dingdaLoginAPI = "http://auth.api.dingdachuxing.com"; 43 //var dingdaLoginAPI = "http://auth.api.dingdachuxing.com";
42 globalConfig.setParam("dingdaLoginAPI", dingdaLoginAPI); 44 globalConfig.setParam("dingdaLoginAPI", dingdaLoginAPI);
...@@ -53,7 +55,8 @@ angular.module('myApp.services') ...@@ -53,7 +55,8 @@ angular.module('myApp.services')
53 loadPersistData(); 55 loadPersistData();
54 loadCityConfig(); 56 loadCityConfig();
55 loadPathParams(); 57 loadPathParams();
56 initWeixinMenu($http); 58
59 // initWeixinMenu($http);
57 } 60 }
58 61
59 var loadPersistData = function() { 62 var loadPersistData = function() {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!