245acb2d by ex

js

1 parent b2f12ccd
...@@ -3,10 +3,6 @@ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终 ...@@ -3,10 +3,6 @@ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终
3 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 3 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
4 var appClient = null; 4 var appClient = null;
5 function AppClient(appObj, isAndroid) { 5 function AppClient(appObj, isAndroid) {
6 // layer.open({
7 // content: JSON.stringify(appObj),
8 // time: 2
9 // })
10 this.appObj = appObj; 6 this.appObj = appObj;
11 this.isAndroid = isAndroid; 7 this.isAndroid = isAndroid;
12 }; 8 };
...@@ -54,7 +50,6 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) { ...@@ -54,7 +50,6 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) {
54 this.appObj.callHandler("getERCode", param, getCallback); 50 this.appObj.callHandler("getERCode", param, getCallback);
55 this.appObj.registerHandler("postERCOde", postCallback) 51 this.appObj.registerHandler("postERCOde", postCallback)
56 } 52 }
57 // }
58 }; 53 };
59 AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) { 54 AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) {
60 var dataParams = ""; 55 var dataParams = "";
...@@ -65,14 +60,18 @@ AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) { ...@@ -65,14 +60,18 @@ AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) {
65 from: 'H5', 60 from: 'H5',
66 params: dataParams 61 params: dataParams
67 }; 62 };
68 // if (this.isAndroid) { 63
69 // this.appObj.callHandler('getGPS', jsonStr, function (res) { 64 if(this.isAndroid) {
70 // layer.open({ 65 window.WebViewJavascriptBridge.appObj.callHandler('getGPS', jsonStr, function (res) {
71 // content: res, 66 layer.open({
72 // time: 2 67 content: res,
73 // }) 68 time: 2
74 // }) 69 })
75 // } else { 70 });
71 } else {
72 this.appObj.callHandler("getERCode", param, getCallback);
73 this.appObj.registerHandler("postERCOde", postCallback)
74 }
76 this.appObj.registerHandler("postGPS", postCallback) 75 this.appObj.registerHandler("postGPS", postCallback)
77 this.appObj.callHandler("getGPS", param, getCallback); 76 this.appObj.callHandler("getGPS", param, getCallback);
78 77
...@@ -100,8 +99,8 @@ if(isAndroid || isiOS) { ...@@ -100,8 +99,8 @@ if(isAndroid || isiOS) {
100 } 99 }
101 setupWebViewJavascriptBridge(function(bridge) { 100 setupWebViewJavascriptBridge(function(bridge) {
102 if(isAndroid) { 101 if(isAndroid) {
103 bridge.init(function (message, responseCallback) {
104 appClient = new AppClient(bridge, true); 102 appClient = new AppClient(bridge, true);
103 bridge.init(function (message, responseCallback) {
105 responseCallback({'Javascript Responds': 'Wee!'}) 104 responseCallback({'Javascript Responds': 'Wee!'})
106 }) 105 })
107 } 106 }
......
...@@ -306,21 +306,21 @@ angular.module('myApp') ...@@ -306,21 +306,21 @@ angular.module('myApp')
306 // }); 306 // });
307 // onSuccess(data) 307 // onSuccess(data)
308 // }) 308 // })
309 window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) { 309 // window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
310 // var data = JSON.parse(res 310 // // var data = JSON.parse(res
311 // var data = eval(res) 311 // // var data = eval(res)
312 layer.open({
313 content: res,
314 time: 2
315 });
316 onSuccess(data)
317 })
318 // appClient.getGPS('', function (data, cb) {
319 // layer.open({ 312 // layer.open({
320 // content: data, 313 // content: res,
321 // time: 2 314 // time: 2
315 // });
316 // onSuccess(data)
322 // }) 317 // })
323 // }) 318 appClient.getGPS('', function (data, cb) {
319 layer.open({
320 content: data,
321 time: 2
322 })
323 })
324 // window.WebViewJavascriptBridge.callHandler('getGPS','1', function (res) { 324 // window.WebViewJavascriptBridge.callHandler('getGPS','1', function (res) {
325 // // layer.open({ 325 // // layer.open({
326 // // content: JSON.stringify(res) + 'cb', 326 // // content: JSON.stringify(res) + 'cb',
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!