From a25d66f9d4dc839b455d8342e9d2fbac660c9d71 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 14 Feb 2020 13:04:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B4=E6=9D=A1=E5=B9=B3=E5=8F=B0=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BC=BA=E5=A4=B1=E7=9A=84=E5=87=A0=E4=B8=AA=E6=9C=89?= =?UTF-8?q?=E5=85=B3=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcfw/platform/plat.js | 1058 +++++++++++++++++++++++++++++--------- jcfw/platform/plat_tt.js | 12 + 2 files changed, 829 insertions(+), 241 deletions(-) diff --git a/jcfw/platform/plat.js b/jcfw/platform/plat.js index d675325..7904055 100644 --- a/jcfw/platform/plat.js +++ b/jcfw/platform/plat.js @@ -1,246 +1,822 @@ +var PLAT_TT = { + SHARE_FAIL: 40, + SHARE_TIME: 3000, + shareCount: {}, -var PLAT_H5 = { - isThisPT(){ - let n = Math.floor(this._ptid/1000); - return this._ptid == 6000 || n == 7; - }, + isThisPT() { + return this._ptid === jc.channel.TT; + }, - isJCPT(){ - return this._ptid == 6000; - }, - - isMQQPT(){ - return this._ptid == 7003; - }, - - getLaunchInfo(){ - if(this.isThisPT()){ - - } - return null; - }, - - getSystemInfo(){ - if(this.isThisPT()){ - - } - return null; - }, - - /** example: - * - * @param {object} btninfo : - * { - * width: 100, - * height: 100, - * name: logo.png - * } - * @param {function} cb - */ - getUserInfo(btninfo, cb){ - cb && cb(null, -1000); - }, - - setUserInfo(dstinfo, ptinfo){ - dstinfo.nickname = ptinfo.nickname; - }, - - setTokenInfo(dstinfo, tokeninfo){ - - }, - - init(owner, channelid){ - this._owner = owner; - this._ptid = channelid; - }, - - bindController(ctrl){ - this._man = ctrl; - }, - - commonShare(img, title, stype, param, successcb, failcb, exinfo){ - let sp = this._owner.makeShareParam(stype, param, exinfo); - let uuid = this._owner.currUUID(); - this.PTShare(title, img, sp, successcb, failcb, uuid); - }, - - captureShare(rc, title, stype, param, successcb, failcb, exinfo){ - let sp = this._owner.makeShareParam(stype, param, exinfo); - let uuid = this._owner.currUUID(); - this.PTShareCapture(title, rc, sp, successcb, failcb, uuid); - }, - - PTInitShare(normalinfo){ - if(!normalinfo){ - return; - } - if(this.isThisPT()){ - - } - }, - - PTShare(content, imgurl, param, successcb, failcb, tokenid){ - if(this.isThisPT()){ - failcb && failcb(-1, param, tokenid); - }else{ - failcb && failcb(-1000, param, tokenid); - } - }, - - PTShareCapture(content, rc, param, successcb, failcb, tokenid){ - if(this.isThisPT()){ - failcb && failcb(-1, param, tokenid); - }else{ - failcb && failcb(-1000, param, tokenid); - } - }, - - PTOpenKF(cb){ - if (this.isThisPT()) { - cb && cb(false); - }else{ - cb && cb(false); - } - }, - - PTShowToast(str){ - if (this.isThisPT()) { - - } - }, - - PTGotoApp(appid, apppath, exobj, cb, qdid){ - if(this.isThisPT()){ - let self = this; - let obj = { - appId: appid, - path: apppath, - extraData: exobj, - success: function(res){ - self._owner.gamelog.logJumpApp(appid, apppath, 1, qdid); - cb && cb(1, res); - }, - fail: function(res){ - self._owner.gamelog.logJumpApp(appid, apppath, -1, qdid); - cb && cb(0, res); - } - }; - - - }else{ - this._owner.gamelog.logJumpApp(appid, apppath, -1000, qdid); - cb && cb(-1000, null); - } - }, - - PTLogin(info, successcb, failcb){ - if(this.isThisPT()){ - if(!info){ - this._owner.login.login(this._owner.localUUID, (obj)=>{ - successcb && successcb(obj); - }, failcb);//调试用 - }else if(typeof info == 'string'){ - this._owner.login.login(info, (obj)=>{ - obj.token = info; - successcb && successcb(obj); - }, failcb); - }else if(this.isJCPT()){ - this._owner.login.loginJC(info, successcb, failcb); - } - }else{ - failcb && failcb(0, -1000, "not h5 platform!"); - } - }, - - //广告相关 - PTInitADService(){ - - }, - - PTCreateBannerAD(adid, st){ - return null; - }, - - PTCreateVideoAD(adid){ - return null; - }, - - PTCreateInsertAD(adid){ - return null; - }, - - PTSetVideoADCallback(adobj, adowner, cb){ - - }, - - PTVibrateShort(successcb, failcb){ - - }, - - PTVibrateLong(successcb, failcb){ - - }, - - PTOpenDataContext(){ - return null; - }, - - PTPostOpenMsg(msg){ - - }, - - // 排行榜相关 - saveRankData(nscore, nmoney, stitle){ - if(this.isThisPT()){ - - } - }, - - showRankData(){ - if(this.isThisPT()){ - - } - }, - - hideRankData(){ - if(this.isThisPT()){ - - } - }, - - prevRankPage(){ - if(this.isThisPT()){ - - } - }, - - nextRankPage(){ - if(this.isThisPT()){ - - } - }, - - setLocalStorage(key, value) { - const keyPre = 'jc_userData_' - if (typeof localStorage != "undefined") { - localStorage.setItem(keyPre + key, value); - } - }, - - getLocalStorage(key) { - const keyPre = 'jc_userData_'; - if (typeof localStorage != "undefined") { - return localStorage.getItem(keyPre + key); - } else { - return null; - } - }, - - removeStorage(key) { - if (typeof localStorage != "undefined") { - localStorage.removeItem(keyPre + key); - } + getLaunchInfo() { + if (this.isThisPT()) { + return tt.getLaunchOptionsSync(); } + return null; + }, + + getSystemInfo() { + if (this.isThisPT()) { + return tt.getSystemInfoSync(); + } + return null; + }, + + /** example: + * + * @param {object} btninfo : + * { + * width: 100, + * height: 100, + * name: logo.png + * } + * @param {function} cb + */ + getUserInfo(btninfo, cb) { + if (!this.isThisPT()) { + cb && cb(null, -1000); + return; + } + this._usercb = cb; + + let self = this; + let getInfo = function () { + console.log('[tt.getUserInfo]'); + tt.getUserInfo({ + withCredentials: true, + lang: 'zh_CN', + success: function (res) { + self._usercb && self._usercb(res, 1); + }, + fail: function (res) { + console.log(res); + self._usercb && self._usercb(res, -1); + } + }) + } + if (tt.createUserInfoButton) { + tt.getSetting({ + success: (res) => { + if (!res.authSetting['scope.userInfo']) { + var sysInfo = tt.getSystemInfoSync(); + + var sz = { + width: sysInfo.screenWidth, + height: sysInfo.screenHeight, + } + var realw = btninfo.width / 512 * sz.width; + var realh = btninfo.height / 1200 * sz.height; + //var realx = sz.width / 2 + btnPos.x / 480 * sz.width - realw / 2; + //var realy = sz.height / 2 - btnPos.y / 960 * sz.height - realh / 2; + var realx = btninfo.x / 512 * sz.width - realw / 2; + var realy = sz.height - btninfo.y / 1200 * sz.height - realh / 2; + + var windowW = sysInfo.windowWidth; + var windowH = sysInfo.windowHeight; + var btnwidth = btninfo.width;//102*1.4; + var btnheight = btninfo.height;//36*1.4; + + console.log('[tt.createUserInfoButton]'); + console.log(sysInfo); + console.log(btninfo); + + let stype = btninfo.name ? 'image' : 'text'; + + this.btnAuthorize = tt.createUserInfoButton({ + type: stype, + text: '', + image: btninfo.name, + style: { + left: realx, + top: realy, + width: realw, + height: realh + }, + withCredentials: true, + lang: 'zh_CN' + } + ); + + this.btnAuthorize.onTap((uinfo) => { + console.log('[tt.getUserInfo]:', uinfo); + if (uinfo.userInfo) { + this._usercb && this._usercb(uinfo, 1); + } else { + // tt.showToast({title:"授权失败"}); + this._usercb && this._usercb(null, -10); + } + if (this.btnAuthorize) { + this.btnAuthorize.destroy && this.btnAuthorize.destroy(); + this.btnAuthorize = null; + } + + }); + + this._usercb && this._usercb(null, 0, 1); + } else { + console.log('authSetting success'); + getInfo(); + } + }, + fail: () => { + console.error('getSetting fail'); + this._usercb && this._usercb(null, -100); + } + }); + } else { + console.log('tt.createUserInfoButton is null'); + getInfo(); + } + }, + + setUserInfo(dstinfo, ptinfo) { + dstinfo.nickname = ptinfo.nickName; + dstinfo.country = ptinfo.country; + dstinfo.province = ptinfo.province; + dstinfo.city = ptinfo.city; + dstinfo.avatar_url = ptinfo.avatarUrl; + dstinfo.sex = ptinfo.gender; + }, + + setTokenInfo(dstinfo, tokeninfo) { + if (tokeninfo && tokeninfo.rawData) { + dstinfo.rawData = tokeninfo.rawData; + dstinfo.signature = tokeninfo.signature; + dstinfo.encryptedData = tokeninfo.encryptedData; + dstinfo.iv = tokeninfo.iv; + } + }, + + init(owner, channelid) { + this._owner = owner; + this._ptid = channelid; + // this.loadInfo(); + + if (this.isThisPT()) { + window.wx = window.tt; + + tt.showShareMenu({ + withShareTicket: true + }); + tt.updateShareMenu({ + withShareTicket: true + }); + let self = this; + let _onShow = function (res) { + console.log('[tt.onShow]'); + self._owner.gameShow(); + self._man && self._man.onPlatShow && self._man.onPlatShow(res); + }; + tt.offShow(_onShow); + tt.onShow(_onShow); + + let _onHide = function () { + console.log('[tt.onHide]'); + self._owner.gameHide(); + self._man && self._man.onPlatHide && self._man.onPlatHide(); + }; + + tt.offHide(_onHide); + tt.onHide(_onHide); + + tt.onAudioInterruptionBegin((res) => { + console.log('tt.onAudioInterruptionBegin'); + self._owner.event.emit(self._owner.event.Events.AUDIO_INTERRUPT_BEGIN, res); + }); + + tt.onAudioInterruptionEnd((res) => { + console.log('tt.onAudioInterruptionEnd'); + self._owner.event.emit(self._owner.event.Events.AUDIO_INTERRUPT_END, res); + }); + } + }, + + bindController(ctrl) { + this._man = ctrl; + }, + + commonShare(img, title, stype, param, successcb, failcb, exinfo) { + var st = (new Date()).getTime(); + let sp = this._owner.makeShareParam(stype, param, exinfo); + let self = this; + if (exinfo && exinfo.videoPath) { + this.videoShare(title, img, sp, function () { + successcb && successcb(); + }, function () { + failcb && failcb(-3, param); + }, exinfo); + } else { + this.PTShare(title, img, sp, function () { + successcb && successcb(); + }, function () { + failcb && failcb(-3, param); + }, exinfo); + } + + }, + + captureShare(rc, title, stype, param, successcb, failcb, exinfo) { + var st = (new Date()).getTime(); + let sp = this._owner.makeShareParam(stype, param, exinfo); + this.PTShareCapture(title, rc, sp, function () { + successcb && successcb(); + }, function () { + failcb && failcb(-3, param); + }, exinfo); + }, + + _checkShareRes(starttime, sharetype, param, successcb, failcb) { + if (!this._man) { + try { + failcb && failcb(-100, param, tokenid); + } catch (err) { + + } + return; + } + this._man.scheduleOnce(() => { + let dt = (new Date()).getTime() - starttime; + console.log(dt); + + if (this.shareCount[sharetype] == undefined) { + this.shareCount[sharetype] = false; + } + if (this.shareCount[sharetype] == false && Math.random() * 100 > this.SHARE_FAIL) { + this.shareCount[sharetype] = true; + try { + failcb && failcb(-1, param, tokenid, dt); + } catch (err) { + + } + return; + } + + if (dt > this.SHARE_TIME) { + try { + successcb && successcb(param, tokenid, dt); + } catch (err) { + + } + } else { + try { + failcb && failcb(-2, param, tokenid, dt); + } catch (err) { + + } + } + }, 0.5); + }, + + PTStartRecord(dur, cb) { + if (!this.isThisPT()) { + return -100; + } + let maxdur = dur ? dur : 300; + if (!this.recorder) { + let self = this; + this.recorder = tt.getGameRecorderManager(); + this.recorder.onStop(res => { + console.log('[video] on record stop', res.videoPath); + self._stoprecording = false; + self.recording = false; + self._videoPath = res.videoPath; + self._endTime = Date.now(); + let obj = { + videoPath: self._videoPath, + endTime: self._endTime, + totalSec: self._endTime - self._beginTime + }; + self._owner.event.emit(self._owner.event.Events.RECORD_STOP, obj); + if (self._stoprecordcb) { + self._stoprecordcb(obj); + self._stoprecordcb = null; + } + }); + this.recorder.onStart(res => { + console.log('[video] on record start'); + self._startrecording = false; + self.recording = true; + self._beginTime = Date.now(); + let obj = { + beginTime: self._beginTime + }; + self._owner.event.emit(self._owner.event.Events.RECORD_START, obj); + if (self._startrecordcb) { + self._startrecordcb(obj); + self._startrecordcb = null; + } + }); + this.recorder.onError(res => { + console.log('[video] on record error'); + console.log(res); + self._startrecording = false; + self._stoprecording = false; + // self.recording = false; + self._owner.event.emit(self._owner.event.Events.RECORD_ERROR, res); + }); + } + + if (this.recording) { + let obj = { + beginTime: this._beginTime + }; + cb && cb(obj); + return 1; + } else { + this._startrecordcb = cb; + if (this._startrecording) { + return 100; + } + this._startrecording = true; + this.recorder.start({ + duration: maxdur + }); + this._man && this._man.scheduleOnce(this.PTStopRecord, maxdur > 10 ? maxdur - 10 : maxdur); + return 0; + } + ; + }, + + PTStopRecord(cb) { + if (!this.isThisPT()) { + return -100; + } + if (!this.recording) { + let obj = { + videoPath: self._videoPath, + endTime: self._endTime, + totalSec: self._endTime - self._beginTime + }; + cb && cb(obj); + return 1; + } + this._stoprecordcb = cb; + if (this._stoprecording) { + return 100; + } + this._stoprecording = true; + this.recorder && this.recorder.stop(); + this._man && this._man.unschedule(this.PTStopRecord); + return 0; + }, + + PTIsRecording() { + return this.recording; + }, + + PTInitShare(normalinfo) { + console.log('[tt] init share config', normalinfo); + let self = this; + if (!normalinfo) { + return; + } + if (this.isThisPT()) { + tt.showShareMenu({ + withShareTicket: true, + success: function (data) { + console.log(data); + }, + fail: function (data) { + console.log(data); + } + }); + + tt.updateShareMenu({ + withShareTicket: true, + success: function (data) { + console.log(data); + }, + fail: function (data) { + console.log(data); + } + }); + tt.onShareAppMessage(function (res) { + console.log(res.channel); + return { + title: normalinfo.title, + imageUrl: normalinfo.imgurl, + success() { + console.log('分享成功') + tt.showToast('分享成功', 'success'); + }, + fail(e) { + console.log('分享失败', e) + tt.showToast({title: '分享失败', icon: 'none'}); + } + } + }); + } + }, + /** + * 头条的视频分享 + * */ + videoShare(content, imgurl, param, successcb, failcb, extra) { + let channel = 'article'; + if (extra && extra.channel) { + channel = extra.channel; + delete extra['channel']; + } + let videoPath = extra.videoPath; + delete extra['videoPath']; + if (this.isThisPT()) { + tt.shareVideo({ + videoPath: videoPath, + title: content, + query: param, + extra: extra, + success() { + console.log(`[TT]视频分享成功!`); + successcb && successcb(); + }, + fail(e) { + console.log(`[TT]视频分享失败!`, e); + failcb && failcb(-1000); + } + }); + } + }, + + PTShare(content, imgurl, param, successcb, failcb, extra) { + let channel = 'article'; + if (extra && extra.channel) { + channel = extra.channel; + delete extra['channel']; + } + + if (this.isThisPT()) { + tt.shareAppMessage({ + title: content, + imageUrl: imgurl, + query: param, + extra: extra, + success() { + console.log('[TT]分享成功'); + successcb && successcb(); + }, + fail(e) { + console.log('[TT]分享失败'); + failcb && failcb(-1000); + } + }); + + } else { + failcb && failcb(-1000); + } + }, + + PTShareCapture(content, rc, param, successcb, failcb) { + if (this.isThisPT()) { + let surl = canvas.toTempFilePathSync({ + x: rc.x, + y: rc.y, + width: rc.width, + height: rc.height, + destWidth: 500, + destHeight: 400 + }); + + tt.shareAppMessage({ + title: content, + imageUrl: surl, + query: param, + success() { + console.log('分享成功') + tt.showToast({title: '分享成功'}); + }, + fail(e) { + console.log('分享失败', e) + tt.showToast({title: '分享失败', icon: 'none'}); + } + }); + } else { + failcb && failcb(-1000); + } + }, + + PTOpenKF(cb) { + if (this.isThisPT()) { + if (tt && tt.openCustomerServiceConversation) { + let self = this; + let obj = { + // sessionFrom: '烧味蹦蹦蹦', + showMessageCard: false, + sendMessageTitle: '', + sendMessagePath: '', + sendMessageImg: '', + success: function (res) { + console.log('[tt.openCustomerServiceConversation]success'); + console.log(res); + cb && cb(true); + if (self._man && self._man.onKFOpened) { + self._man.onKFOpened(); + } + }, + fail: function (res) { + console.log('[tt.openCustomerServiceConversation]fail'); + console.log(res); + cb && cb(false); + } + } + tt.openCustomerServiceConversation(obj); + } + } else { + cb && cb(false); + } + }, + + PTCreateGameClubButton(nleft, ntop, nwidth) { + if (this.isThisPT() && tt.createGameClubButton) { + let btn = tt.createGameClubButton({ + icon: 'light', + style: { + left: nleft, + top: ntop, + width: nwidth, + height: nwidth + } + }); + + if (btn) { + btn.onTap((res) => { + console.log(res); + }); + } + + return btn; + } + }, + + /** + * @param {string} str 显示的文字 + * @param {icon} icon 图标类型 默认'none'; + * success: 显示成功图标 + * loading: 显示加载图标 + * none: 不显示图标,此时 title 文本最多可显示两行 + * */ + PTShowToast(str, icon) { + wx.showToast({title: str, icon: icon || 'none'}); + }, + + PTGotoApp(appid, apppath, exobj, cb, qdid) { + if (this.isThisPT()) { + let self = this; + let obj = { + appId: appid, + path: apppath, + extraData: exobj, + success: function (res) { + self._owner.gamelog.logJumpApp(appid, apppath, 1, qdid); + cb && cb(1, res); + }, + fail: function (res) { + self._owner.gamelog.logJumpApp(appid, apppath, -1, qdid); + cb && cb(0, res); + } + }; + + tt.navigateToMiniProgram(obj); + } else { + this._owner.gamelog.logJumpApp(appid, apppath, -1000, qdid); + cb && cb(-1000, null); + } + }, + + PTLogin(info, successcb, failcb) { + if (this.isThisPT()) { + var self = this; + tt.login({ + success: function (res) { + console.log('[tt]login success!' + res.code); + self._owner.login.login(res.code, successcb, failcb, null, false, res.anonymousCode || ''); + }, + fail: function (res) { + console.log('[tt]login fail!' + JSON.stringify(res)); + // self._owner.login.loginAnonymous(successcb, failcb); + tt.login({ + force: false, + success: function (res) { + console.log('[tt] second login success!' + res.code); + self._owner.login.login(res.code || '', successcb, failcb, null, false, res.anonymousCode || ''); + }, + fail: function (res) { + console.log('[tt]second login fail!' + JSON.stringify(res)); + failcb && failcb(0, res ? res.errcode : -1, res ? res.errmsg : ''); + } + }) + // failcb && failcb(0, res? res.errcode: -1, res? res.errmsg:""); + } + }); + } else { + failcb && failcb(0, -1000, 'not weixin platform!'); + } + }, + + + PTSetClipboardData: function (content, successcb, failcb) { + if (this.isThisPT()) { + tt.setClipboardData({ + data: content, + successcb, + failcb + }); + } else { + failcb && failcb(-1000); + } + }, + + PTGetClipboardData: function (successcb, failcb) { + if (this.isThisPT()) { + tt.getClipboardData({ + success: function (res) { + successcb && successcb(res.data); + }, + failcb + }); + } else { + failcb && failcb(-1000); + } + }, + + PTPreviewImage(imgurl, successcb, failcb) { + if (this.isThisPT()) { + tt.previewImage({ + urls: [imgurl], + successcb, + failcb + }) + } else { + failcb && failcb(-1000); + } + }, + + //广告相关 + PTInitADService() { + + }, + + PTBannerADMaxWidth() { + return 208; + }, + + PTBannerNeedLoad() { + return true; + }, + + PTCreateBannerAD(adid, st) { + if (this.isThisPT()) { + console.log('[tt] begin create banner ad,', adid); + if (tt.createBannerAd) { + let rst = { + width: st.width, + top: st.top, + left: st.left + } + let data = { + adUnitId: adid, + style: rst + }; + return tt.createBannerAd(data); + } + } + return null; + }, + + PTCreateVideoAD(adid) { + if (this.isThisPT()) { + if (tt.createRewardedVideoAd) { + let data = { + adUnitId: adid + }; + return tt.createRewardedVideoAd(data); + } + } + return null; + }, + + PTCreateInsertAD(adid) { + return null; + }, + + PTSetVideoADCallback(adobj, adowner, cb) { + if (this.isThisPT()) { + let closeCb = function (res) { + console.log('[ad]onClose:' + JSON.stringify(res)); + // 用户点击了【关闭广告】按钮 + // 小于 2.1.0 的基础库版本,res 是一个 undefined + if (res && res.isEnded || res === undefined) { + // 正常播放结束,可以下发游戏奖励 + cb && cb(res.isEnded, adowner, res); + } else { + // 播放中途退出,不下发游戏奖励 + cb && cb(false, adowner, res); + } + // ad.offClose && ad.offClose(closeCb); + }; + adobj.onClose && adobj.onClose(closeCb); + } + }, + + PTVibrateShort(successcb, failcb) { + if (this.isThisPT()) { + tt.vibrateShort({ + success: () => { + successcb && successcb(); + }, + fail: () => { + failcb && failcb(); + } + }) + } + }, + + PTVibrateLong(successcb, failcb) { + if (this.isThisPT()) { + tt.vibrateLong({ + success: () => { + successcb && successcb(); + }, + fail: () => { + failcb && failcb(); + } + }) + } + }, + + PTOpenDataContext() { + if (this.isThisPT()) { + return tt.getOpenDataContext(); + } + return null; + }, + + PTPostOpenMsg(msg) { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage(msg); + } + }, + + // 排行榜相关 + saveRankData(nscore, nmoney, stitle) { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage({ + type: 'save_data', + score: nscore, + money: nmoney, + title: stitle + }); + } + }, + + showRankData() { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage({ + type: 'friends_all' + }); + } + }, + + hideRankData() { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage({ + type: 'friends_all_hide' + }); + } + }, + + prevRankPage() { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage({ + type: 'pagechange', + prev: 1 + }); + } + }, + + nextRankPage() { + if (this.isThisPT()) { + const openDataContext = tt.getOpenDataContext(); + openDataContext.postMessage({ + type: 'pagechange', + next: 1 + }); + } + }, + + setLocalStorage(key, value) { + tt.setStorageSync(key, value); + }, + + getLocalStorage(key) { + return tt.getStorageSync(key); + }, + + removeStorage(key) { + tt.removeStorageSync(key); + } }; -module.exports = PLAT_H5; +module.exports = PLAT_TT; diff --git a/jcfw/platform/plat_tt.js b/jcfw/platform/plat_tt.js index 38ad046..7904055 100644 --- a/jcfw/platform/plat_tt.js +++ b/jcfw/platform/plat_tt.js @@ -804,6 +804,18 @@ var PLAT_TT = { next: 1 }); } + }, + + setLocalStorage(key, value) { + tt.setStorageSync(key, value); + }, + + getLocalStorage(key) { + return tt.getStorageSync(key); + }, + + removeStorage(key) { + tt.removeStorageSync(key); } };