h5
Showing
1 changed file
with
19 additions
and
17 deletions
| 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 | function AppClient(appObj, isAndroid) { | 5 | function AppClient(appObj, isAndroid) { |
| 5 | layer.open({ | 6 | layer.open({ |
| 6 | content: appObj, | 7 | content: JSON.stringify(appObj), |
| 7 | time: 2 | 8 | time: 2 |
| 8 | }) | 9 | }) |
| 9 | this.appObj = appObj; | 10 | this.appObj = appObj; |
| ... | @@ -42,16 +43,17 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) { | ... | @@ -42,16 +43,17 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) { |
| 42 | from: 'H5', | 43 | from: 'H5', |
| 43 | params: dataParams | 44 | params: dataParams |
| 44 | }; | 45 | }; |
| 45 | // if(this.isAndroid) { | 46 | if(this.isAndroid) { |
| 46 | // this.appObj.callHandler('getERCode', jsonStr, function (res) { | 47 | window.WebViewJavascriptBridge.appObj.callHandler('getERCode', jsonStr, function (res) { |
| 47 | // layer.open({ | 48 | layer.open({ |
| 48 | // content: res, | 49 | content: res, |
| 49 | // time: 2 | 50 | time: 2 |
| 50 | // }) | 51 | }) |
| 51 | // }); | 52 | }); |
| 52 | // } else { | 53 | } else { |
| 53 | this.appObj.registerHandler("postERCOde", postCallback) | 54 | this.appObj.callHandler("getERCode", param, getCallback); |
| 54 | this.appObj.callHandler("getERCode", param, getCallback); | 55 | this.appObj.registerHandler("postERCOde", postCallback) |
| 56 | } | ||
| 55 | // } | 57 | // } |
| 56 | }; | 58 | }; |
| 57 | AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) { | 59 | AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) { |
| ... | @@ -103,15 +105,15 @@ if(isAndroid || isiOS) { | ... | @@ -103,15 +105,15 @@ if(isAndroid || isiOS) { |
| 103 | responseCallback({'Javascript Responds': 'Wee!'}) | 105 | responseCallback({'Javascript Responds': 'Wee!'}) |
| 104 | }) | 106 | }) |
| 105 | } | 107 | } |
| 106 | if (isiOS) { | 108 | if(isiOS) { |
| 107 | appClient = new AppClient(bridge, false); | 109 | appClient = new AppClient(bridge, false); |
| 108 | } | 110 | } |
| 109 | // 此处可以调用一些init的方法 | 111 | // 此处可以调用一些init的方法 |
| 110 | }); | 112 | }); |
| 111 | } else { | 113 | } else { |
| 112 | appClient = new AppClient({}, false); | 114 | |
| 113 | layer.open({ | 115 | // layer.open({ |
| 114 | content: '环境判断失败', | 116 | // content: '非原生', |
| 115 | time: 2 | 117 | // time: 2 |
| 116 | }) | 118 | // }) |
| 117 | } | 119 | } | ... | ... |
-
Please register or sign in to post a comment