diff --git a/sdk/WxHelper.ts b/sdk/WxHelper.ts index bf714f1..2377091 100644 --- a/sdk/WxHelper.ts +++ b/sdk/WxHelper.ts @@ -14,7 +14,7 @@ export class WxHelper { /** 微信用户信息 */ public static userInfo: WxUserInfo; public static get isOperable() { - return (cc.sys.platform === cc.sys.WECHAT_GAME || cc.sys.platform === cc.sys.ALIPAY_GAME) + return (typeof wx !== 'undefined' || typeof my != 'undefined') } /** 获取设备信息 */ @@ -191,13 +191,13 @@ export class WxHelper { * @param time 关闭时间 */ public static showToast(msg: string, time: number = 1500) { - if (cc.sys.platform === cc.sys.WECHAT_GAME) + if (typeof wx !== 'undefined') wx.showToast({ title: msg, icon: 'none', duration: time }) - else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + else if (typeof my != 'undefined') { my.showToast({ type: 'none', content: msg, @@ -397,7 +397,7 @@ export class WxHelper { } public static setUserWxCloudStorage(data: object) { - if (cc.sys.platform != cc.sys.WECHAT_GAME || !DataService.I.Authorize) return null; + if (typeof wx == 'undefined' || !DataService.I.Authorize) return null; wx.setUserCloudStorage({ KVDataList: [{ key: 'data', value: JSON.stringify(data) }], success: res => { @@ -413,7 +413,7 @@ export class WxHelper { return WxHelper.isOperable && AlipayApi.I.canUseRank() } public static getRank(key: string) { - if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof my != 'undefined') { AlipayApi.I.getRankList(key).then(() => { console.log('success 关闭banner') // BannerManager.I.hideAll(); @@ -425,7 +425,7 @@ export class WxHelper { } public static setRankScore(key: string, score: number, updateType?: number) { - if (cc.sys.platform === cc.sys.ALIPAY_GAME) + if (typeof my != 'undefined') AlipayApi.I.setRankScoreData(key, score, updateType); } public static async loginWx(isAuthorize: boolean, failFunction?: Function, count?: number, success?: Function): Promise { @@ -452,7 +452,7 @@ export class WxHelper { public static goToGameCenter(success: Function, fail: Function) { //每个游戏跳转游戏中心的url 不一样 let url = "alipays://platformapi/startapp?appId=2021003125685383&url=https%3A%2F%2Frender.alipay.com%2Fp%2Fyuyan%2F180020010001206617%2Findex.html%3FcaprMode%3Dsync&chInfo=gamesetlattice&sms=YES&appClearTop=false"; - if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof my != 'undefined') { AlipayApi.I.navigateToMiniProgramByScheme(url, success, fail) } } diff --git a/wxsdk/alipay/AlipayApi.ts b/wxsdk/alipay/AlipayApi.ts index 7c5b7f5..dfa4b3d 100644 --- a/wxsdk/alipay/AlipayApi.ts +++ b/wxsdk/alipay/AlipayApi.ts @@ -378,7 +378,7 @@ export default class AlipayApi { navigateToMiniProgramByScheme(scheme, success, fail) { let { params, message } = this.schemeToParams(scheme); console.log('params--', { ...params }); - if (cc.sys.platform != cc.sys.ALIPAY_GAME) return + if (typeof my == 'undefined') return if (params) { my.navigateToMiniProgram({ ...params, success, fail,}); } else { @@ -585,7 +585,7 @@ export default class AlipayApi { //段位 setRankSegmentData(rankKey: string, segment: number, segmentName: string) { return new Promise((resolve, reject) => { - if (cc.sys.platform != cc.sys.ALIPAY_GAME) return reject({ errMsg: `无环境`, errCode: -1 }) + if (typeof my == 'undefined') return reject({ errMsg: `无环境`, errCode: -1 }) if (!this.canIUse('10.5.6')) return reject(this.getVersionError('10.5.6')); my.setImRankData({ rankId: rankKey, @@ -611,7 +611,7 @@ export default class AlipayApi { setRankScoreData(rankKey: string, score: number, updateType: number = 1) { return new Promise((resolve, reject) => { - if (cc.sys.platform != cc.sys.ALIPAY_GAME) return reject({ errMsg: `无环境`, errCode: -1 }) + if (typeof my == 'undefined') return reject({ errMsg: `无环境`, errCode: -1 }) if (!this.canIUse(this._requirementVersion.rank)) return reject(this.getVersionError(this._requirementVersion.rank)); my.setImRankData({ rankId: rankKey, @@ -645,7 +645,7 @@ export default class AlipayApi { */ getRankList(rankKey: string, scorePrefix?: string, scoreSuffix?: string) { return new Promise((resolve, reject) => { - if (cc.sys.platform != cc.sys.ALIPAY_GAME) return reject({ errMsg: `无环境`, errCode: -1 }) + if (typeof my == 'undefined') return reject({ errMsg: `无环境`, errCode: -1 }) if (!this.canIUse(this._requirementVersion.rank)) return reject(this.getVersionError(this._requirementVersion.rank)); my.getImRankList({ rankId: rankKey, diff --git a/wxsdk/base/wx.d.ts b/wxsdk/base/wx.d.ts index 1205cb8..cb2ff4a 100644 --- a/wxsdk/base/wx.d.ts +++ b/wxsdk/base/wx.d.ts @@ -2,3 +2,4 @@ declare const wx; declare const qq; declare const my; +declare const tt; diff --git a/wxsdk/service/AdService.ts b/wxsdk/service/AdService.ts index db1f65b..0672061 100644 --- a/wxsdk/service/AdService.ts +++ b/wxsdk/service/AdService.ts @@ -20,11 +20,11 @@ export default class AdService { */ createBanner(adUnitId: string, opts?: { type?: number; bannerWidth?: number, offsetY?: number; adIntervals?: number, isOff?: boolean }) { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { return null - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { return AlipayBanner.I.create(adUnitId) - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return WxBanner.I.create(adUnitId, opts); } } @@ -32,11 +32,11 @@ export default class AdService { * banner 显示 ps:创建默认显示 */ showBanner() { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { AlipayBanner.I.show(); - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { WxBanner.I.show(); } @@ -45,11 +45,11 @@ export default class AdService { * banner 隐藏 */ hideBanner() { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { AlipayBanner.I.hide(); - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { WxBanner.I.hide(); } } @@ -58,11 +58,11 @@ export default class AdService { */ destoryBanner() { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { AlipayBanner.I.destory(); - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { WxBanner.I.destory(); } } @@ -72,11 +72,11 @@ export default class AdService { * @param adUnitId */ initInterstitialAd(adUnitId?: string) { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { // return DouyinInterstitial.initInterstitialAd(adUnitId); - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { AlipayInterstitial.initInterstitialAd(adUnitId) - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return WxInterstitial.initInterstitialAd(adUnitId) } } @@ -87,11 +87,11 @@ export default class AdService { createInterstitialAd(adUnitId: string) { console.log('~~~~~~~~~~~插屏'); // return WxInterstitial.showInterstitialAd(adUnitId) - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { + if (typeof tt != 'undefined') { // return DouyinInterstitial.initInterstitialAd(adUnitId); - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + } else if (typeof my != 'undefined') { AlipayInterstitial.showInterstitialAd(adUnitId) - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return WxInterstitial.showInterstitialAd(adUnitId) } } @@ -130,10 +130,10 @@ export default class AdService { let { id, appid, path, game } = data; LogService.I.jumps(id, type); if (!path) path = `?channel_id=${GAMEDATA.channel_id}`; - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof tt != 'undefined') { + } else if (typeof my != 'undefined') { return AlipayApi.I.navigateToMiniProgram(appid, path, opts) - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return WxApi.I.navigateToMiniProgram(appid, path, opts) } diff --git a/wxsdk/share/SDKShare.ts b/wxsdk/share/SDKShare.ts index df44f8a..531d514 100644 --- a/wxsdk/share/SDKShare.ts +++ b/wxsdk/share/SDKShare.ts @@ -55,10 +55,10 @@ export default class SDKShare { LogService.I.share(shareKey, share_id, DOT_SHARE_TYPE.share) } // 主动拉起转发 - if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof my != 'undefined') { //模拟分享支付宝上面会失败 return AlipayApi.I.shareAppMessage(commonObj, callbackObj) - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return wx.shareAppMessage(commonObj); } else { return callbackObj.success(); @@ -83,7 +83,7 @@ export default class SDKShare { forward(params: any, opts: any = {}) { let me = this; let { title, imageUrl, query, imageUrlId } = params; - if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof my != 'undefined') { my.onShareAppMessage = function () { return { title: title, diff --git a/wxsdk/share/SDKVideo.ts b/wxsdk/share/SDKVideo.ts index ead43b6..4112eba 100644 --- a/wxsdk/share/SDKVideo.ts +++ b/wxsdk/share/SDKVideo.ts @@ -179,7 +179,7 @@ export default class SDKVideo { try { __LOG__ && console.warn("handleLoaded2"); LogService.I.adStat(this.videoKey, this.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.show) - if (cc.sys.platform === cc.sys.WECHAT_GAME && typeof qq == 'undefined') { + if (typeof wx !== 'undefined' && typeof qq == 'undefined') { if (that.videoAd.isReady()) {//抖音、qq 没有 isReady that.show_time = Date.now(); await that.videoAd.show(); diff --git a/wxsdk/wx/WxLogin.ts b/wxsdk/wx/WxLogin.ts index 112fc5c..e925c8f 100644 --- a/wxsdk/wx/WxLogin.ts +++ b/wxsdk/wx/WxLogin.ts @@ -6,7 +6,6 @@ import WxSystem from "./WxSystem"; import DateUtils from "../utils/DateUtils"; import LogService from "../service/LogService"; import { DOT_SHARE_TYPE } from "../base/SDKEnum"; -import ShareVideoService from "../service/ShareVideoService"; import OnlineService from "../service/OnlineService"; import AlipayApi from '../alipay/AlipayApi'; @@ -19,9 +18,7 @@ export default class WxLogin { */ async login(isAuthorize: boolean): Promise { - if (cc.sys.platform === cc.sys.BYTEDANCE_GAME) { - return - } else if (cc.sys.platform === cc.sys.ALIPAY_GAME) { + if (typeof my !== 'undefined') { let self = this; return new Promise(async (resolve, reject) => { if (isAuthorize) { @@ -36,7 +33,7 @@ export default class WxLogin { self.weakLogin({ errCode: 1, msg: '默认未授权登录' }, code, resolve, reject) } }); - } else if (cc.sys.platform === cc.sys.WECHAT_GAME) { + } else if (typeof wx !== 'undefined') { return new Promise(async (resolve, reject) => { let code = await WxApi.I.login(); if (isAuthorize) { -- libgit2 0.21.0