c22c9704 by ex

h5

1 parent 8ba9954d
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var appClient = new AppClient({}, false);;
var appClient = null;
function AppClient(appObj, isAndroid) {
layer.open({
content: JSON.stringify(appObj),
......@@ -19,7 +19,7 @@ function isJson(str) {
return true;
}
function toJson(str) {
var i = str.index('"{')
var i = str.index('{')
try {
var arr = str.split(2,str.length - 4)
console.log(arr)
......@@ -101,7 +101,7 @@ if(isAndroid || isiOS) {
setupWebViewJavascriptBridge(function(bridge) {
if(isAndroid) {
bridge.init(function (message, responseCallback) {
appClient = new AppClient(bridge, isAndroid);
appClient = new AppClient(bridge, true);
responseCallback({'Javascript Responds': 'Wee!'})
})
}
......@@ -111,9 +111,5 @@ if(isAndroid || isiOS) {
// 此处可以调用一些init的方法
});
} else {
// layer.open({
// content: '非原生',
// time: 2
// })
appClient = new AppClient({}, false);
}
......
......@@ -298,29 +298,29 @@ angular.module('myApp')
// }
// });
if(isAndroid){
// // window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
// // var res = JSON.parse(data)
// // layer.open({
// // content: data,
// // time: 2
// // });
// // onSuccess(data)
// // })
// window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
// // var data = JSON.parse(res
// // var data = eval(res)
// var res = JSON.parse(data)
// layer.open({
// content: res,
// content: data,
// time: 2
// });
// onSuccess(data)
// })
appClient.getGPS('', function (data, cb) {
layer.open({
content: data,
time: 2
})
window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
// var data = JSON.parse(res
// var data = eval(res)
layer.open({
content: res,
time: 2
});
onSuccess(data)
})
// appClient.getGPS('', function (data, cb) {
// layer.open({
// content: data,
// time: 2
// })
// })
// window.WebViewJavascriptBridge.callHandler('getGPS','1', function (res) {
// // layer.open({
// // 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!