3430d388 by ex

GPS

1 parent cda75a27
...@@ -15,31 +15,31 @@ function isJson(str) { ...@@ -15,31 +15,31 @@ function isJson(str) {
15 return true; 15 return true;
16 } 16 }
17 // console.log(obj.latitude) 17 // console.log(obj.latitude)
18 function toJson(str) { 18 // function toJson(str) {
19 try { 19 // try {
20 if(str.length > 2){ 20 // if(str.length > 2){
21 var result = /\{([\s\S]*)\}/.exec(str); 21 // var result = /\{([\s\S]*)\}/.exec(str);
22 } 22 // }
23 var arr = result[1].split(',') 23 // var arr = result[1].split(',')
24 var obj = {} 24 // var obj = {}
25 arr.forEach(function (value) { 25 // arr.forEach(function (value) {
26 var key, val 26 // var key, val
27 if(isAndroid){ 27 // if(isAndroid){
28 key = value.split('=')[0] 28 // key = value.split('=')[0]
29 val = value.split('=')[1] 29 // val = value.split('=')[1]
30 } else { 30 // } else {
31 key = value.split(':')[0] 31 // key = value.split(':')[0]
32 val = value.split(':')[1] 32 // val = value.split(':')[1]
33 } 33 // }
34 34 //
35 obj[key] = val*1 35 // obj[key] = val*1
36 }) 36 // })
37 return obj 37 // return obj
38 38 //
39 } catch (e) { 39 // } catch (e) {
40 return {} 40 // return {}
41 } 41 // }
42 } 42 // }
43 // layer.open({ 43 // layer.open({
44 // content: "isAndroid:"+ isAndroid+ ",isiOS:" + isiOS, 44 // content: "isAndroid:"+ isAndroid+ ",isiOS:" + isiOS,
45 // time: 2 45 // time: 2
......
...@@ -303,9 +303,19 @@ angular.module('myApp') ...@@ -303,9 +303,19 @@ angular.module('myApp')
303 },1000) 303 },1000)
304 } else { 304 } else {
305 appClient.getGPS('', function (data, cb) { 305 appClient.getGPS('', function (data, cb) {
306 var latitude = ''
307 var longitude = ''
306 308
307 var obj = toJson(data) 309 var result = /\{([\s\S]*)\}/.exec(str);
308 310 // var obj = toJson(data)
311 var arr = result[1].split(',')
312 if(isAndroid){
313 latitude = result[0].split('=')[1]
314 longitude = result[1].split('=')[1]
315 } else {
316 latitude = result[0].split(':')[1]
317 longitude = result[1].split(':')[1]
318 }
309 // layer.open({ 319 // layer.open({
310 // content: obj.latitude, 320 // content: obj.latitude,
311 // time: 5 321 // time: 5
...@@ -318,11 +328,11 @@ angular.module('myApp') ...@@ -318,11 +328,11 @@ angular.module('myApp')
318 // content: JSON.stringify(obj), 328 // content: JSON.stringify(obj),
319 // time: 5 329 // time: 5
320 // }) 330 // })
321 onSuccess(JSON.parse(JSON.stringify(obj))) 331 // onSuccess(JSON.parse(JSON.stringify(obj)))
322 // onSuccess({ 332 onSuccess({
323 // latitude: obj.latitude, 333 latitude: latitude,
324 // longitude: obj.longitude 334 longitude: longitude
325 // }) 335 })
326 336
327 }) 337 })
328 // if(isAndroid){ 338 // if(isAndroid){
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!