245acb2d by ex

js

1 parent b2f12ccd
......@@ -3,10 +3,6 @@ var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var appClient = null;
function AppClient(appObj, isAndroid) {
// layer.open({
// content: JSON.stringify(appObj),
// time: 2
// })
this.appObj = appObj;
this.isAndroid = isAndroid;
};
......@@ -54,7 +50,6 @@ AppClient.prototype.getERCode = function (jsonStr, getCallback, postCallback) {
this.appObj.callHandler("getERCode", param, getCallback);
this.appObj.registerHandler("postERCOde", postCallback)
}
// }
};
AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) {
var dataParams = "";
......@@ -65,14 +60,18 @@ AppClient.prototype.getGPS = function (jsonStr, getCallback, postCallback) {
from: 'H5',
params: dataParams
};
// if (this.isAndroid) {
// this.appObj.callHandler('getGPS', jsonStr, function (res) {
// layer.open({
// content: res,
// time: 2
// })
// })
// } else {
if(this.isAndroid) {
window.WebViewJavascriptBridge.appObj.callHandler('getGPS', jsonStr, function (res) {
layer.open({
content: res,
time: 2
})
});
} else {
this.appObj.callHandler("getERCode", param, getCallback);
this.appObj.registerHandler("postERCOde", postCallback)
}
this.appObj.registerHandler("postGPS", postCallback)
this.appObj.callHandler("getGPS", param, getCallback);
......@@ -100,8 +99,8 @@ if(isAndroid || isiOS) {
}
setupWebViewJavascriptBridge(function(bridge) {
if(isAndroid) {
bridge.init(function (message, responseCallback) {
appClient = new AppClient(bridge, true);
bridge.init(function (message, responseCallback) {
responseCallback({'Javascript Responds': 'Wee!'})
})
}
......
......@@ -306,21 +306,21 @@ angular.module('myApp')
// });
// onSuccess(data)
// })
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) {
// window.WebViewJavascriptBridge.callHandler('getGPS', '', function(res, responseCallback) {
// // var data = JSON.parse(res
// // var data = eval(res)
// layer.open({
// content: data,
// 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!