2615f045 by unknown

提示运行环境

1 parent e8101757
...@@ -14,11 +14,22 @@ function isJson(str) { ...@@ -14,11 +14,22 @@ function isJson(str) {
14 } 14 }
15 return true; 15 return true;
16 } 16 }
17 // var str = '{latitude:30.2741500000,longitude:120.1551500000}'
18 console.log(toJson(str))
17 function toJson(str) { 19 function toJson(str) {
18 var i = str.index('{')
19 try { 20 try {
20 var arr = str.split(2,str.length - 4) 21 if(str.length > 2){
21 console.log(arr) 22 var result = /\{([\s\S]*)\}/.exec(str);
23 }
24 var arr = result[1].split(',')
25 var obj = {}
26 arr.forEach(function (value) {
27 var key = value.split(':')[0]
28 var val = value.split(':')[1]
29 obj[key] = val
30 })
31 return obj
32
22 } catch (e) { 33 } catch (e) {
23 return {} 34 return {}
24 } 35 }
...@@ -41,7 +52,7 @@ AppClient.prototype.getERCode = function (jsonStr, callback) { ...@@ -41,7 +52,7 @@ AppClient.prototype.getERCode = function (jsonStr, callback) {
41 window.WebViewJavascriptBridge.registerHandler('postERCode', callback); 52 window.WebViewJavascriptBridge.registerHandler('postERCode', callback);
42 } else { 53 } else {
43 this.appObj.registerHandler("postERCOde", callback) 54 this.appObj.registerHandler("postERCOde", callback)
44 this.appObj.callHandler("getERCode", param, function (data, resCallback) { 55 this.appObj.callHandler("getERCode", param, function (data, responseCallback) {
45 56
46 }); 57 });
47 } 58 }
...@@ -59,7 +70,7 @@ AppClient.prototype.getGPS = function (jsonStr, callback) { ...@@ -59,7 +70,7 @@ AppClient.prototype.getGPS = function (jsonStr, callback) {
59 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, callback); 70 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, callback);
60 } else { 71 } else {
61 this.appObj.registerHandler("postGPS", callback) 72 this.appObj.registerHandler("postGPS", callback)
62 this.appObj.callHandler("getGPS", param, function (data, resCallback) { 73 this.appObj.callHandler("getGPS", param, function (data, responseCallback) {
63 74
64 }); 75 });
65 } 76 }
......
...@@ -160,7 +160,13 @@ angular.module('myApp') ...@@ -160,7 +160,13 @@ angular.module('myApp')
160 $rootScope.openScan = false; 160 $rootScope.openScan = false;
161 161
162 162
163 if(isAndroid){ 163 if(!appClient){
164 layer.open({
165 content: '调起摄像头失败',
166 time:2
167 });
168
169 } else {
164 appClient.getERCode('', function (data, cb) { 170 appClient.getERCode('', function (data, cb) {
165 layer.open({ 171 layer.open({
166 content: data, 172 content: data,
...@@ -188,11 +194,6 @@ angular.module('myApp') ...@@ -188,11 +194,6 @@ angular.module('myApp')
188 // // time: 10 194 // // time: 10
189 // // }); 195 // // });
190 // }, '') 196 // }, '')
191 } else {
192 layer.open({
193 content: '调起摄像头失败',
194 time:2
195 });
196 } 197 }
197 198
198 // wx.scanQRCode({ 199 // wx.scanQRCode({
......
...@@ -303,10 +303,12 @@ angular.module('myApp') ...@@ -303,10 +303,12 @@ angular.module('myApp')
303 },1000) 303 },1000)
304 } else { 304 } else {
305 appClient.getGPS('', function (data, cb) { 305 appClient.getGPS('', function (data, cb) {
306 onSuccess({ 306 var obj = toJson(data)
307 latitude:30.2741500000, 307 onSuccess(obj)
308 longitude:120.1551500000 308 // onSuccess({
309 }) 309 // latitude:30.2741500000,
310 // longitude:120.1551500000
311 // })
310 layer.open({ 312 layer.open({
311 content: data, 313 content: data,
312 time: 2 314 time: 2
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!