var yesApp = {
|
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() {
|
if (yesApp.getPlatform() == 1)
|
yestv.login();
|
else {
|
try {
|
yestv.login();
|
} catch (e) { //wkwebview兼容
|
window.webkit.messageHandlers.login.postMessage(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;
|
}
|
}
|
},
|
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)
|
});
|
}
|
}
|
},
|
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);
|
}
|
}
|
},
|
//跳转客服
|
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
|
});
|
}
|
}
|
}
|
}
|