New file |
| | |
| | | var yesApp = { |
| | | api: function(oldCallback, newCallBack) { |
| | | var platform = yesApp.getPlatform(); |
| | | if (platform == 1) { |
| | | oldCallback(); |
| | | } else if (platform == 2) { |
| | | try { |
| | | var i = yestv == undefined; |
| | | } catch (e) { |
| | | newCallBack(); |
| | | return; |
| | | } |
| | | oldCallback(); |
| | | } |
| | | }, |
| | | postApi: function(apiName, params) { |
| | | 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 if (u.indexOf('iPhone') > -1 || u.indexOf('iPad') > -1) |
| | | return 2; |
| | | else return 0; |
| | | }, |
| | | login: function() { |
| | | yesApp.api(function() { |
| | | yestv.login(); |
| | | }, function() { |
| | | yesApp.postApi('login', null); |
| | | }); |
| | | }, |
| | | getUid: function() { |
| | | var platform = yesApp.getPlatform(); |
| | | if (platform == 1) |
| | | return yestv.getUid(); |
| | | else if (platform == 2) { |
| | | try { |
| | | var uid = yestv.getUid(); |
| | | return uid; |
| | | } catch (e) { //wkwebview兼容 |
| | | var payload = { |
| | | type: 'getUid' |
| | | }; |
| | | var uid = prompt(JSON.stringify(payload)); |
| | | return uid; |
| | | } |
| | | } |
| | | }, |
| | | getVersion: function() { |
| | | var platform = yesApp.getPlatform(); |
| | | if (platform == 1) |
| | | return yestv.getVersion(); |
| | | else if (platform == 2) { |
| | | try { |
| | | var version = yestv.getVersion(); |
| | | return version; |
| | | } catch (e) { //wkwebview兼容 |
| | | var payload = { |
| | | type: 'getVersion' |
| | | }; |
| | | var version = prompt(JSON.stringify(payload)); |
| | | return version; |
| | | } |
| | | } |
| | | }, |
| | | getSign: function(str) { |
| | | var platform = yesApp.getPlatform(); |
| | | if (platform == 1) |
| | | return yestv.getSign(str); |
| | | else if (platform == 2) { |
| | | try { |
| | | var sign = yestv.getSign(str); |
| | | return sign; |
| | | } catch (e) { //wkwebview兼容 |
| | | var payload = { |
| | | type: 'getSign', |
| | | params: str |
| | | }; |
| | | var sign = prompt(JSON.stringify(payload)); |
| | | return sign; |
| | | } |
| | | } |
| | | }, |
| | | getRequestBaseParams: function(params) { |
| | | var platform = yesApp.getPlatform(); |
| | | if (platform == 1) |
| | | return yestv.getRequestBaseParams(JSON.stringify(params)); |
| | | else if (platform == 2) { |
| | | 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; |
| | | } |
| | | } |
| | | }, |
| | | jumpWeb: function(url, title) { |
| | | var params = { |
| | | "url": url |
| | | }; |
| | | if (title != null && title.length > 0) |
| | | params.title = title; |
| | | yesApp.jumpPage({ |
| | | activity: 'com.yeshi.ec.rebate.myapplication.ui.invite.ShareBrowserActivity', |
| | | controller: 'ShonpingShareViewController', |
| | | type: 'web' |
| | | }, params); |
| | | }, |
| | | jumpPage: function(jumpDetail, params) { |
| | | if (params == null || params == undefined) |
| | | params = {} |
| | | if (jumpDetail != null && jumpDetail.type == 'baichuan') { |
| | | yesApp.jumpBaiChuan(null, params.url, null); |
| | | return; |
| | | } |
| | | yesApp.api(function() { |
| | | yestv.jumpPage(jumpDetail.activity, JSON.stringify(params)); |
| | | }, function() { |
| | | yesApp.postApi('jumpPage', { |
| | | controller: jumpDetail.controller, |
| | | params: JSON.stringify(params) |
| | | }); |
| | | }); |
| | | }, |
| | | jumpPageWithFinishCurrentPage: function(jumpDetail, params) { |
| | | if (params == null || params == undefined) |
| | | params = {} |
| | | |
| | | yesApp.api(function() { |
| | | yestv.jumpPageWithFinishCurrentPage(jumpDetail.activity, JSON.stringify(params)); |
| | | }, function() { |
| | | yesApp.postApi('jumpPageWithFinishCurrentPage', { |
| | | controller: jumpDetail.controller, |
| | | params: JSON.stringify(params) |
| | | }); |
| | | }); |
| | | }, |
| | | showLoading: function() { |
| | | yesApp.api(function() { |
| | | yestv.showLoading(); |
| | | }, function() { |
| | | yesApp.postApi('showLoading', null); |
| | | }); |
| | | }, |
| | | hideLoading: function() { |
| | | yesApp.api(function() { |
| | | yestv.hideLoading(); |
| | | }, function() { |
| | | yesApp.postApi('hideLoading', null); |
| | | }); |
| | | }, |
| | | toast: function(msg) { |
| | | yesApp.api(function() { |
| | | yestv.toast(msg); |
| | | }, function() { |
| | | yesApp.postApi('toast', msg); |
| | | }); |
| | | }, |
| | | |
| | | finishPage: function() { |
| | | yesApp.api(function() { |
| | | yestv.finishPage(); |
| | | }, function() { |
| | | yesApp.postApi('finishPage', null); |
| | | }); |
| | | }, |
| | | //跳转客服 |
| | | jumpKeFu: function(from) { |
| | | yesApp.api(function() { |
| | | yestv.jumpKeFu(from); |
| | | }, function() { |
| | | yesApp.postApi('jumpKeFu', from); |
| | | }); |
| | | }, |
| | | jumpGoodsSplashWithFrom: function(goodsId, from) { |
| | | yesApp.api(function() { |
| | | yestv.jumpGoodsSplashWithFrom(goodsId, from); |
| | | }, function() { |
| | | yesApp.postApi('jumpGoodsSplashWithFrom', { |
| | | id: goodsId, |
| | | from: from |
| | | }); |
| | | }); |
| | | }, |
| | | jumpBaiChuan: function(tbClientInfo, url, id) { |
| | | yesApp.api(function() { |
| | | yestv.jumpBaiChuan(tbClientInfo != null ? JSON.stringify(tbClientInfo) : null, url, id); |
| | | }, function() { |
| | | yesApp.postApi('jumpBaiChuan', { |
| | | tbPid: tbClientInfo != null ? JSON.stringify(tbClientInfo) : null, |
| | | url: url, |
| | | id: id |
| | | }); |
| | | }); |
| | | }, |
| | | //友盟统计 |
| | | umEventCount: function(event, params) { |
| | | yesApp.api(function() { |
| | | yestv.umEventCount(event, params != null ? JSON.stringify(params) : null); |
| | | }, function() { |
| | | yesApp.postApi('umEventCount', { |
| | | key: event, |
| | | params: (params != null ? JSON.stringify(params) : null) |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | hiddenTopMenuCloseBtn: function() { |
| | | yesApp.api(function() { |
| | | yestv.hiddenTopMenuCloseBtn(); |
| | | }, function() { |
| | | yesApp.postApi('hiddenTopMenuCloseBtn', null); |
| | | }); |
| | | }, |
| | | showSharePanel: function() { |
| | | yesApp.api(function() { |
| | | yestv.showSharePanel(); |
| | | }, function() { |
| | | yesApp.postApi('showSharePanel', null); |
| | | }); |
| | | }, |
| | | addMenu: function(menu) { |
| | | yesApp.api(function() { |
| | | yestv.addMenu(JSON.stringify(menu)); |
| | | }, function() { |
| | | yesApp.postApi('addMenu', menu); |
| | | }); |
| | | }, |
| | | copyText: function(content) { |
| | | yesApp.api(function() { |
| | | yestv.copyText(content); |
| | | }, function() { |
| | | yesApp.postApi('copyText', content); |
| | | }); |
| | | }, |
| | | jumpSearch: function(key) { |
| | | yesApp.api(function() { |
| | | yestv.jumpSearch(key); |
| | | }, function() { |
| | | yesApp.postApi('jumpSearch', key); |
| | | }); |
| | | }, |
| | | jumpInvite: function() { |
| | | yesApp.api(function() { |
| | | yestv.jumpInvite(); |
| | | }, function() { |
| | | yesApp.postApi('jumpInvite', null); |
| | | }); |
| | | }, |
| | | setTitle: function(title) { |
| | | yesApp.api(function() { |
| | | yestv.setTitle(title); |
| | | }, function() { |
| | | yesApp.postApi('setTitle', title); |
| | | }); |
| | | }, |
| | | jumpJDGoodsDetailWithFrom: function(id, from) { |
| | | |
| | | yesApp.api(function() { |
| | | yestv.jumpJDGoodsDetailWithFrom(id, from); |
| | | }, function() { |
| | | yesApp.postApi('jumpJDGoodsDetailWithFrom', { |
| | | id: id, |
| | | from: from |
| | | }); |
| | | }); |
| | | }, |
| | | jumpPDDGoodsDetailWithFrom: function(id, from) { |
| | | yesApp.api(function() { |
| | | yestv.jumpPDDGoodsDetailWithFrom(id, from); |
| | | }, function() { |
| | | yesApp.postApi('jumpPDDGoodsDetailWithFrom', { |
| | | id: id, |
| | | from: from |
| | | }); |
| | | }); |
| | | }, |
| | | //分享链接 |
| | | shareLink: function(type, title, content, img, url) { |
| | | var params = { |
| | | title: title, |
| | | content: content, |
| | | img: img, |
| | | url: url |
| | | }; |
| | | yesApp.api(function() { |
| | | yestv.shareLink(type, JSON.stringify(params)); |
| | | }, function() { |
| | | params.type = type; |
| | | yesApp.postApi('shareLink', params); |
| | | }); |
| | | }, |
| | | //分享图片 |
| | | shareImg: function(type, url) { |
| | | var params = { |
| | | url: url |
| | | }; |
| | | yesApp.api(function() { |
| | | yestv.shareImg(type, url); |
| | | }, function() { |
| | | params.type = type; |
| | | yesApp.postApi('shareImg', params); |
| | | }); |
| | | }, |
| | | //分享图片 |
| | | shareImgs: function(type, urls) { |
| | | var params = { |
| | | imgUrls: urls |
| | | }; |
| | | yesApp.api(function() { |
| | | yestv.shareImgs(type, urls); |
| | | }, function() { |
| | | params.type = type; |
| | | yesApp.postApi('shareImgs', params); |
| | | }); |
| | | }, |
| | | |
| | | savePicture: function(url) { |
| | | var params = { |
| | | url: url, |
| | | name: '' |
| | | }; |
| | | yesApp.api(function() { |
| | | yestv.savePicture(params.url, params.name); |
| | | }, function() { |
| | | yesApp.postApi('savePicture', url); |
| | | }); |
| | | }, |
| | | |
| | | savePictures: function(urls) { |
| | | var params = { |
| | | type: 1, |
| | | imgUrls: JSON.stringify(urls) |
| | | } |
| | | |
| | | yesApp.api(function() { |
| | | yestv.savePictures(params.imgUrls); |
| | | }, function() { |
| | | yesApp.postApi('savePictures', params); |
| | | }); |
| | | }, |
| | | |
| | | //分享文本 |
| | | shareText: function(type, text) { |
| | | var params = { |
| | | type: type, |
| | | text: text |
| | | }; |
| | | yesApp.api(function() { |
| | | yestv.shareText(type, text); |
| | | }, function() { |
| | | params.type = type; |
| | | yesApp.postApi('shareText', params); |
| | | }); |
| | | }, |
| | | //清除粘贴板 |
| | | clearClipboard: function() { |
| | | yesApp.api(function() { |
| | | yestv.clearClipboard(); |
| | | }, function() { |
| | | yesApp.postApi('clearClipboard', null); |
| | | }); |
| | | }, |
| | | //跳转京东 |
| | | jumpJD: function(url) { |
| | | yesApp.api(function() { |
| | | yestv.jumpJD(url); |
| | | }, function() { |
| | | yesApp.postApi('jumpJD', { |
| | | url: url |
| | | }); |
| | | }); |
| | | }, |
| | | //显示大图 |
| | | showImgs: function(urls, position) { |
| | | var array = new Array(); |
| | | for (var i = 0; i < urls.length; i++) { |
| | | array.push({ |
| | | url: urls[i] |
| | | }); |
| | | } |
| | | var jumpDetail = { |
| | | activity: 'com.yeshi.ec.rebate.myapplication.ui.trends.BigImageActivity', |
| | | type: 'showimgs' |
| | | }; |
| | | |
| | | yesApp.postApi('showimgs', { |
| | | imgList: JSON.stringify(array), |
| | | position: position |
| | | }); |
| | | }, |
| | | |
| | | playVideo: function(url) { |
| | | yesApp.jumpPage({ |
| | | activity: 'com.yeshi.ec.rebate.myapplication.ui.trends.VideoPlayActivity', |
| | | controller: 'PlayerVideoController', |
| | | type: 'playvideo' |
| | | }, { |
| | | url: url |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |