982bafbd by ex

无法获取定位提示

1 parent 1cffe74c
...@@ -53,10 +53,29 @@ AppClient.prototype.getERCode = function (jsonStr, callback) { ...@@ -53,10 +53,29 @@ AppClient.prototype.getERCode = function (jsonStr, callback) {
53 from: 'H5', 53 from: 'H5',
54 params: dataParams 54 params: dataParams
55 }; 55 };
56 var isRes = false
57 if(this.isAndroid) { 56 if(this.isAndroid) {
58 window.WebViewJavascriptBridge.callHandler('getERCode', jsonStr); 57 window.WebViewJavascriptBridge.callHandler('getERCode', jsonStr);
59 window.WebViewJavascriptBridge.registerHandler('postERCode', function (data, responseCallback) { 58 window.WebViewJavascriptBridge.registerHandler('postERCode', callback)
59 } else {
60 this.appObj.registerHandler("postERCOde", callback)
61 this.appObj.callHandler("getERCode", param, function (data, responseCallback) {
62
63 });
64 }
65
66 };
67 AppClient.prototype.getGPS = function (jsonStr, callback) {
68 var dataParams = "";
69 if(isJson(jsonStr)) {
70 dataParams = JSON.parse(jsonStr);
71 }
72 var param = {
73 from: 'H5',
74 params: dataParams
75 };
76 var isRes = false
77 if(this.isAndroid) {
78 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, function (data, responseCallback) {
60 isRes = true 79 isRes = true
61 var latitude = '' 80 var latitude = ''
62 var longitude = '' 81 var longitude = ''
...@@ -67,18 +86,18 @@ AppClient.prototype.getERCode = function (jsonStr, callback) { ...@@ -67,18 +86,18 @@ AppClient.prototype.getERCode = function (jsonStr, callback) {
67 callback(latitude, longitude, responseCallback) 86 callback(latitude, longitude, responseCallback)
68 }) 87 })
69 } else { 88 } else {
70 this.appObj.registerHandler("postERCOde", function (data, responseCallback) { 89 this.appObj.registerHandler("postGPS", function (data, responseCallback) {
71 isRes = true 90 isRes = true
72 var latitude = '' 91 var latitude = ''
73 var longitude = '' 92 var longitude = ''
74 var result = /\{([\s\S]*)\}/.exec(data); 93 var result = /\{([\s\S]*)\}/.exec(data);
75 var arr = result[1].split(',') 94 var arr = result[1].split(',')
76 latitude = arr[0].split(':')[1] 95 latitude = arr[0].split(':')[1]
77 longitude = arr[1].split(':')[1] 96 longitude = arr[1].split(':')[1]
78 callback(latitude, longitude, responseCallback) 97 callback(latitude, longitude, responseCallback)
79 }) 98 })
80 this.appObj.callHandler("getERCode", param, function (data, responseCallback) { 99 this.appObj.callHandler("getGPS", param, function (data, responseCallback) {
81 100
82 }); 101 });
83 } 102 }
84 setTimeout(function () { 103 setTimeout(function () {
...@@ -90,24 +109,6 @@ AppClient.prototype.getERCode = function (jsonStr, callback) { ...@@ -90,24 +109,6 @@ AppClient.prototype.getERCode = function (jsonStr, callback) {
90 } 109 }
91 }, 3000) 110 }, 3000)
92 }; 111 };
93 AppClient.prototype.getGPS = function (jsonStr, callback) {
94 var dataParams = "";
95 if(isJson(jsonStr)) {
96 dataParams = JSON.parse(jsonStr);
97 }
98 var param = {
99 from: 'H5',
100 params: dataParams
101 };
102 if(this.isAndroid) {
103 window.WebViewJavascriptBridge.callHandler('getGPS', jsonStr, callback);
104 } else {
105 this.appObj.registerHandler("postGPS", callback)
106 this.appObj.callHandler("getGPS", param, function (data, responseCallback) {
107
108 });
109 }
110 };
111 112
112 if(isAndroid || isiOS) { 113 if(isAndroid || isiOS) {
113 114
......
...@@ -302,6 +302,7 @@ angular.module('myApp') ...@@ -302,6 +302,7 @@ angular.module('myApp')
302 $rootScope.isLoadFinish = true 302 $rootScope.isLoadFinish = true
303 },1000) 303 },1000)
304 } else { 304 } else {
305
305 appClient.getGPS('', function (latitude, longitude, cb) { 306 appClient.getGPS('', function (latitude, longitude, cb) {
306 307
307 onSuccess({ 308 onSuccess({
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!