e4cf8852 by unknown

提示运行环境

1 parent 253ed433
...@@ -14,24 +14,25 @@ function isJson(str) { ...@@ -14,24 +14,25 @@ function isJson(str) {
14 } 14 }
15 return true; 15 return true;
16 } 16 }
17 // var str = '{latitude:30.2741500000,longitude:120.1551500000}' 17 var str = '{latitude:30.2741500000,longitude:120.1551500000}'
18 // console.log(toJson(str)) 18 var obj = toJson(str)
19 console.log(obj.latitude)
19 function toJson(str) { 20 function toJson(str) {
20 try { 21 try {
21 if(str.length > 2){ 22 if(str.length > 2){
22 var result = /\{([\s\S]*)\}/.exec(str); 23 var result = /\{([\s\S]*)\}/.exec(str);
23 } 24 }
24 25 debugger
25 var arr = result[1].split(',') 26 var arr = result[1].split(',')
26 var obj = {} 27 var obj = {}
27 arr.forEach(function (value) { 28 arr.forEach(function (value) {
29 var key, val
28 if(isAndroid){ 30 if(isAndroid){
29 var key = value.split('=')[0] 31 key = value.split('=')[0]
30 var val = value.split('=')[1] 32 val = value.split('=')[1]
31 } 33 } else {
32 if(isiOS) { 34 key = value.split(':')[0]
33 var key = value.split(':')[0] 35 val = value.split(':')[1]
34 var val = value.split(':')[1]
35 } 36 }
36 37
37 obj[key] = val 38 obj[key] = val
......
...@@ -306,7 +306,7 @@ angular.module('myApp') ...@@ -306,7 +306,7 @@ angular.module('myApp')
306 306
307 var obj = toJson(data) 307 var obj = toJson(data)
308 layer.open({ 308 layer.open({
309 content: data, 309 content: JSON.stringify(obj),
310 time: 5 310 time: 5
311 }) 311 })
312 // layer.open({ 312 // layer.open({
...@@ -323,8 +323,8 @@ angular.module('myApp') ...@@ -323,8 +323,8 @@ angular.module('myApp')
323 // }) 323 // })
324 // onSuccess(obj) 324 // onSuccess(obj)
325 onSuccess({ 325 onSuccess({
326 latitude: obj['latitude'], 326 latitude: obj.latitude,
327 longitude: obj['longitude'] 327 longitude: obj.longitude
328 }) 328 })
329 329
330 }) 330 })
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!