var yesApp = {
|
api: function(oldCallback, newCallBack) {
|
if (yesApp.getPlatform() == 1) {
|
oldCallback;
|
} else {
|
if (yestv != undefined)
|
oldCallback;
|
else
|
newCallBack;
|
}
|
},
|
postApi: function(apiName, params) {
|
//
|
eval("window.webkit.messageHandlers." + apiName + ".postMessage(" + params + ")");
|
},
|
getPlatform: function() {
|
var u = navigator.userAgent;
|
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
|
if (isAndroid)
|
return 1;
|
else
|
return 2;
|
},
|
login: function() {
|
api(function() {
|
yestv.login();
|
}, function() {
|
postApi(login, null);
|
});
|
},
|
getUid: function() {
|
if (yesApp.getPlatform() == 1)
|
return yestv.getUid();
|
else {
|
try {
|
var uid = yestv.getUid();
|
|
} catch (e) { //wkwebview兼容
|
var payload = {
|
type: 'getUid'
|
};
|
var uid = prompt(JSON.stringify(payload));
|
return uid;
|
}
|
}
|
},
|
getVersion: function() {
|
if (yesApp.getPlatform() == 1)
|
return yestv.getVersion();
|
else {
|
try {
|
var version = yestv.getVersion();
|
return version;
|
} catch (e) { //wkwebview兼容
|
var payload = {
|
type: 'getVersion'
|
};
|
var version = prompt(JSON.stringify(payload));
|
return version;
|
}
|
}
|
},
|
getRequestBaseParams: function(params) {
|
if (yesApp.getPlatform() == 1)
|
return yestv.getRequestBaseParams(JSON.stringify(params));
|
else {
|
try {
|
return yestv.getRequestBaseParams(JSON.stringify(params));
|
} catch (e) { //wkwebview兼容
|
var payload = {
|
type: 'getRequestBaseParams',
|
params: JSON.stringify(params)
|
};
|
var result = prompt(JSON.stringify(payload));
|
return result;
|
}
|
}
|
},
|
jumpPage: function(jumpDetail, params) {
|
if (params == null || params == undefined)
|
params = {}
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpPage(jumpDetail.activity, JSON.stringify(params));
|
else {
|
try {
|
yestv.jumpPage(jumpDetail.controller, JSON.stringify(params));
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.jumpPage.postMessage({
|
controller: jumpDetail.controller,
|
params: JSON.stringify(params)
|
});
|
}
|
}
|
},
|
jumpPageWithFinishCurrentPage: function(jumpDetail, params) {
|
if (params == null || params == undefined)
|
params = {}
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpPageWithFinishCurrentPage(jumpDetail.activity, JSON.stringify(params));
|
else {
|
try {
|
yestv.jumpPageWithFinishCurrentPage(jumpDetail.controller, JSON.stringify(params));
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.jumpPageWithFinishCurrentPage.postMessage({
|
controller: jumpDetail.controller,
|
params: JSON.stringify(params)
|
});
|
}
|
}
|
},
|
showLoading: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.showLoading();
|
else {
|
try {
|
yestv.showLoading();
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.showLoading.postMessage(null);
|
}
|
}
|
},
|
hideLoading: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.hideLoading();
|
else {
|
try {
|
yestv.hideLoading();
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.hideLoading.postMessage(null);
|
}
|
}
|
},
|
toast: function(msg) {
|
if (yesApp.getPlatform() == 1)
|
yestv.toast(msg);
|
else {
|
try {
|
yestv.toast(msg);
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.toast.postMessage(msg);
|
}
|
}
|
},
|
|
finishPage: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.finishPage();
|
else {
|
try {
|
yestv.finishPage();
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.finishPage.postMessage(null);
|
}
|
}
|
},
|
//跳转客服
|
jumpKeFu: function(from) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpKeFu(from);
|
else {
|
try {
|
yestv.jumpKeFu(from);
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.jumpKeFu.postMessage(from);
|
}
|
}
|
},
|
jumpGoodsSplashWithFrom: function(goodsId, from) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpGoodsSplashWithFrom(goodsId, from);
|
else {
|
try {
|
yestv.jumpGoodsSplashWithFrom(goodsId, from);
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.jumpGoodsSplashWithFrom.postMessage({
|
id: goodsId,
|
from: from
|
});
|
}
|
}
|
},
|
jumpBaiChuan: function(tbClientInfo, url, id) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpBaiChuan(tbClientInfo != null ? JSON.stringify(tbClientInfo) : null, url, id);
|
else {
|
try {
|
yestv.jumpBaiChuan(tbClientInfo != null ? JSON.stringify(tbClientInfo) : null, url, id);
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.jumpBaiChuan.postMessage({
|
tbPid: tbClientInfo != null ? JSON.stringify(tbClientInfo) : null,
|
url: 'http://www.taobao.com',
|
id: null
|
});
|
}
|
}
|
},
|
//友盟统计
|
umEventCount: function(event, params) {
|
if (yesApp.getPlatform() == 1)
|
yestv.umEventCount(event, params != null ? JSON.stringify(params) : null);
|
else {
|
try {
|
yestv.umEventCount(event, params != null ? JSON.stringify(params) : null);
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.umEventCount.postMessage({
|
key: event,
|
params: (params != null ? JSON.stringify(params) : null)
|
});
|
}
|
}
|
},
|
|
hiddenTopMenuCloseBtn: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.hiddenTopMenuCloseBtn();
|
else {
|
try {
|
yestv.hiddenTopMenuCloseBtn();
|
} catch (e) {
|
window.webkit.messageHandlers.hiddenTopMenuCloseBtn.postMessage(null);
|
}
|
}
|
},
|
showSharePanel: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.showSharePanel();
|
else {
|
try {
|
yestv.showSharePanel();
|
} catch (e) {
|
window.webkit.messageHandlers.showSharePanel.postMessage(null);
|
}
|
}
|
},
|
showSharePanel: function(menu) {
|
if (yesApp.getPlatform() == 1)
|
yestv.addMenu(JSON.stringify(menu));
|
else {
|
try {
|
yestv.addMenu(JSON.stringify(menu));
|
} catch (e) {
|
window.webkit.messageHandlers.addMenu.postMessage(menu);
|
}
|
}
|
},
|
copyText: function(content) {
|
if (yesApp.getPlatform() == 1)
|
yestv.copyText(content);
|
else {
|
try {
|
yestv.copyText(content);
|
} catch (e) {
|
window.webkit.messageHandlers.copyText.postMessage(content);
|
}
|
}
|
},
|
jumpSearch: function(key) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpSearch(key);
|
else {
|
try {
|
yestv.jumpSearch(key);
|
} catch (e) {
|
window.webkit.messageHandlers.jumpSearch.postMessage(key);
|
}
|
}
|
},
|
jumpInvite: function() {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpInvite();
|
else {
|
try {
|
yestv.jumpInvite();
|
} catch (e) {
|
window.webkit.messageHandlers.jumpInvite.postMessage();
|
}
|
}
|
},
|
setTitle: function(title) {
|
if (yesApp.getPlatform() == 1)
|
yestv.setTitle(title);
|
else {
|
try {
|
yestv.setTitle(title);
|
} catch (e) {
|
window.webkit.messageHandlers.setTitle.postMessage(title);
|
}
|
}
|
},
|
jumpJDGoodsDetailWithFrom: function(id, from) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpJDGoodsDetailWithFrom(id, from);
|
else {
|
try {
|
yestv.jumpJDGoodsDetailWithFrom(id, from);
|
} catch (e) {
|
window.webkit.messageHandlers.jumpJDGoodsDetailWithFrom.postMessage({
|
id: id,
|
from: from
|
});
|
}
|
}
|
},
|
jumpPDDGoodsDetailWithFrom: function(id, from) {
|
if (yesApp.getPlatform() == 1)
|
yestv.jumpPDDGoodsDetailWithFrom(id, from);
|
else {
|
try {
|
yestv.jumpPDDGoodsDetailWithFrom(id, from);
|
} catch (e) {
|
window.webkit.messageHandlers.jumpPDDGoodsDetailWithFrom.postMessage({
|
id: id,
|
from: from
|
});
|
}
|
}
|
},
|
|
|
|
|
|
|
|
|
|
|
|
}
|