var PLAT_H5 = { isThisPT() { let n = Math.floor(this._ptid / 1000); return this._ptid == 6000 || n == 7; }, 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({token: this._owner.localUUID, successcb: (obj) => { successcb && successcb(obj); }, failcb});//调试用 } else if (typeof info == 'string') { this._owner.login.login({token: info, successcb: (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); } } }; module.exports = PLAT_H5;