c22c9704 by ex

h5

1 parent 8ba9954d
1 var u = navigator.userAgent; 1 var u = navigator.userAgent;
2 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 2 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 = new AppClient({}, false);; 4 var appClient = null;
5 function AppClient(appObj, isAndroid) { 5 function AppClient(appObj, isAndroid) {
6 layer.open({ 6 layer.open({
7 content: JSON.stringify(appObj), 7 content: JSON.stringify(appObj),
...@@ -19,7 +19,7 @@ function isJson(str) { ...@@ -19,7 +19,7 @@ function isJson(str) {
19 return true; 19 return true;
20 } 20 }
21 function toJson(str) { 21 function toJson(str) {
22 var i = str.index('"{') 22 var i = str.index('{')
23 try { 23 try {
24 var arr = str.split(2,str.length - 4) 24 var arr = str.split(2,str.length - 4)
25 console.log(arr) 25 console.log(arr)
...@@ -101,7 +101,7 @@ if(isAndroid || isiOS) { ...@@ -101,7 +101,7 @@ if(isAndroid || isiOS) {
101 setupWebViewJavascriptBridge(function(bridge) { 101 setupWebViewJavascriptBridge(function(bridge) {
102 if(isAndroid) { 102 if(isAndroid) {
103 bridge.init(function (message, responseCallback) { 103 bridge.init(function (message, responseCallback) {
104 appClient = new AppClient(bridge, isAndroid); 104 appClient = new AppClient(bridge, true);
105 responseCallback({'Javascript Responds': 'Wee!'}) 105 responseCallback({'Javascript Responds': 'Wee!'})
106 }) 106 })
107 } 107 }
...@@ -111,9 +111,5 @@ if(isAndroid || isiOS) { ...@@ -111,9 +111,5 @@ if(isAndroid || isiOS) {
111 // 此处可以调用一些init的方法 111 // 此处可以调用一些init的方法
112 }); 112 });
113 } else { 113 } else {
114 114 appClient = new AppClient({}, false);
115 // layer.open({
116 // content: '非原生',
117 // time: 2
118 // })
119 } 115 }
......
...@@ -298,29 +298,29 @@ angular.module('myApp') ...@@ -298,29 +298,29 @@ angular.module('myApp')
298 // } 298 // }
299 // }); 299 // });
300 if(isAndroid){ 300 if(isAndroid){
301 // // window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
302 // // var res = JSON.parse(data)
303 // // layer.open({
304 // // content: data,
305 // // time: 2
306 // // });
307 // // onSuccess(data)
308 // // })
309 // window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) { 301 // window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
310 // // var data = JSON.parse(res 302 // var res = JSON.parse(data)
311 // // var data = eval(res)
312 // layer.open({ 303 // layer.open({
313 // content: res, 304 // content: data,
314 // time: 2 305 // time: 2
315 // }); 306 // });
316 // onSuccess(data) 307 // onSuccess(data)
317 // }) 308 // })
318 appClient.getGPS('', function (data, cb) { 309 window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
319 layer.open({ 310 // var data = JSON.parse(res
320 content: data, 311 // var data = eval(res)
321 time: 2 312 layer.open({
322 }) 313 content: res,
314 time: 2
315 });
316 onSuccess(data)
323 }) 317 })
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!