var webGame; (function (webGame) { class BasePlatform extends core.BasePlatform { constructor() { super(); } /**web版本直接用Laya自带的方法获取保存数据本地缓存*/ getStorageSync(key) { return Laya.LocalStorage.getJSON(key + core.Manager.baseInfo.game_id); } setStorageSync(key, data) { Laya.LocalStorage.setJSON(key + core.Manager.baseInfo.game_id, data); } /** 初始化监听事件 */ initEvent() { Laya.stage.on(Laya.Event.VISIBILITY_CHANGE, this, this.stageVisibleChange); // core.Manager.eDispatcher.on(core.Event.ACTIVITYCLOSE, this, this.activityViewClose); if (!core.Manager.wtsdk.isReady) core.Manager.eDispatcher.on(core.Event.WTSDK_INIT_COMPLETE, this, this.login); //wtskd加载好并初始化完成后,登陆 else this.login(); //登陆 } stageVisibleChange() { if (Laya.stage.isVisibility) { this.onShow(); } else { this.onHide(); } } /** * 回到前台的事件处理函数 */ onShow(data) { // Laya.timer.resume(); // Laya.stage.renderingEnabled=true//恢复渲染 // Laya.updateTimer.resume() //恢复onUpdate // Laya.physicsTimer.resume() //恢复物理 // Laya.systemTimer.resume(); core.SoundManager.muted = this._muted; //还原onHide前的静音状态 // core.Manager.wtsdk.sendStart({ scene: this.startScene }); core.Manager.wtsdk.dotEvent(core.WtsdkEvent.ID_GAME_START); core.Manager.eDispatcher.event(core.Event.ON_SHOW, data); } /** * 小游戏隐藏到后台事件处理函数。 */ onHide(data) { // Laya.timer.pause(); // Laya.stage.renderingEnabled=false//停止渲染 // Laya.updateTimer.pause() //停止onUpdate // Laya.physicsTimer.pause() //停止物理 // Laya.systemTimer.pause(); this._muted = core.SoundManager.muted; //记录onHide前的静音状态 core.SoundManager.muted = false; // core.Manager.wtsdk.sendExit({ scene: this.startScene }); core.Manager.wtsdk.dotEvent(core.WtsdkEvent.ID_GAME_EXIT); core.Manager.eDispatcher.event(core.Event.ON_HIDE, data); } /** * 初始化(登陆、获取用户信息、设置默认分享) */ init() { this.systemInfo = new webGame.SystemInfo(); core.Manager.baseInfo.app_name = this.systemInfo.appName; //设置应用名 core.Manager.baseInfo.device = this.systemInfo.device; //设置设备 core.Manager.baseInfo.platform_id = core.PlatformType.ID_WEBGAME; //设置平台id(3-web) this.moneyActivity = new webGame.MoneyActivity(); this.initEvent(); //初始化监听事件 } /** * 登陆 - 获取Code */ login() { this.gameStarted(); if (core.Manager.wtsdk.isReady) ////wtskd初始化完成才能登陆 { let locationSearch = decodeURIComponent(window.location.search); if (locationSearch) //从url取 { let code = this.jsGetHttpParam("code", locationSearch); this.loginComplete(code); } else { //======================本地测试用的web版本token======================= this.loginComplete("bcd182bffa0af49c4fe90b69affca5e4"); } this.ad = new webGame.BaseADManager(); //初始化广告 } } jsGetHttpParam(paras, locationSearch) { let reg = new RegExp("(^|&)" + paras + "=([^&]*)(&|$)", "i"); let r = locationSearch.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配 let context = ""; if (r != null) context = r[2]; reg = null; r = null; return context == null || context == "" || context == "undefined" ? "" : context; } /** * 登陆完成回调 */ loginComplete(code) { // {errMsg: "login:ok", anonymousCode: "535ed5c9f15679e2", code: "6a4bfc20dc513b4e", isLogin: true} // 登陆失败时,后台要求anonymousCode、code发个空值 let data = {}; data.code = code; data.app_name = core.Manager.baseInfo.app_name; data.game_id = core.Manager.baseInfo.game_id; data.platform_id = core.Manager.baseInfo.platform_id; data.device = this.systemInfo.device; data.scene = "0"; data.version = BaseConfig.version; core.Manager.wtsdk.getUserInfo(data, Laya.Handler.create(this, this.httpUserInfoCallback)); //向后台请求用户信息 } //向后台请求用户信息 httpUserInfoCallback(data) { if (data && data.code == 200) { core.Manager.baseInfo.token = data.result.token; //data.result.id; core.Manager.selfInfo.updateAll(data.result); // this.setUserInfo(null); core.Manager.isLogined = true; } else log(data); } // //向后台发送平台用户信息 // private setUserInfo(userInfo: any) { // //如果能获取到字节个人信息,则发送更新用户信息 // if (userInfo) core.Manager.wtsdk.modifyUserInfo({ userInfo: userInfo, member_id: core.Manager.selfInfo.id }, Laya.Handler.create(this, this.httpModifyUserInfoCallback)); // else { // core.Manager.selfInfo.isAuthorized = true;//web默认已授权 // this.sendUserInfo(core.Manager.selfInfo);//无需更新信息,则直接发送用户信息到开放域 // } // } // private httpModifyUserInfoCallback(data: any) { // // log(data); // if (data && data.code == 200) { // core.Manager.selfInfo.update(data.result); // core.Manager.selfInfo.isAuthorized = true;//已授权 // this.sendUserInfo(core.Manager.selfInfo);//发送用户信息到开放域 // } // else log(data); // } // /** 传递UserInfo */ // private sendUserInfo(userInfo: any) { // core.Manager.isLogined = true; // } /**震动 */ vibrate(pattern) { if (core.Manager.wtsdk.isReady) wtsdk.onVibrator(pattern); } /** 创建桌面图标 */ addToDeskIcon(isShow, x = 0, y = 0, parent) { if (isShow) { if (core.Manager.config.isOpen(core.FunctionKey.ADD_TO_DESK)) { return webGame.AddToDeskIcon.show(x, y, parent); } } else webGame.AddToDeskIcon.hide(); } /** 保存最高分 */ saveScore(score) { core.Manager.wtsdk.saveScore({ score: score }, Laya.Handler.create(this, (data) => { if (data && data.code == 200) { core.Manager.selfInfo.score = data.result.score; } })); } /**游戏开始接口 */ gameStarted() { if (core.Manager.wtsdk.isReady) { wtsdk.gameStarted({ gameId: core.Manager.baseInfo.game_id, version: BaseConfig.version }); } else { log('wtsdk is not ready, gameStarted fail'); } } //↓↓ 广告类 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ /** 显示或隐藏Banner广告 */ adBanner(isShow, position_id) { if (core.Manager.wtsdk.isReady) { try { if (isShow) this.ad.showBanner(position_id); else this.ad.hideBanner(position_id); } catch (e) { log("adBanner error:", e); } } else { log('wtsdk is not ready, adBanner fail'); } } /** 显示激励式广告 */ // adrewardCding = false adRewardedVideo(position_id) { new webGame.LoadADTipsView(); if (core.Manager.wtsdk.isReady) { try { this.ad.showRewardedVideoAd(position_id); } catch (e) { log("adBanner error:", e); } } else { log('wtsdk is not ready, adRewardedVideo fail'); } } /** 显示插屏广告 */ adInterstitial(position_id) { if (core.Manager.wtsdk.isReady) { try { this.ad.showInterstitialAd(position_id); } catch (e) { log("adBanner error:", e); } } else { log('wtsdk is not ready, adInterstitial fail'); } } /** 显示全屏广告流广告 */ adFullVideo(position_id) { if (core.Manager.wtsdk.isReady) { try { this.ad.showFullVideoAd(position_id); } catch (e) { log("adBanner error:", e); } } else { log('wtsdk is not ready, fullVideo fail'); } } /** 信息流(可以理解为Banner一样的东西) */ adFeed(isShow, position_id, gravity) { if (core.Manager.wtsdk.isReady) { if (isShow) { try { if (isShow) this.ad.showFreeAd(position_id); else this.ad.hideFreeAd(position_id); } catch (e) { log("adBanner error:", e); } } else { wtsdk.closeFeed(); } } else { log('wtsdk is not ready, adInterstitial fail'); } } /** * 更多游戏图标 * @parame isShow 是否显示 */ moreGameBtn(isShow) { // if (isShow) { // if (!core.Manager.gameList || core.Manager.gameList.length == 0) return null; // if (!this._moreGameBtn) this._moreGameBtn = new MoreGameIcon(this.moreGameParams); // } // else if (this._moreGameBtn) { // this._moreGameBtn.destroy(); // this._moreGameBtn = null; // } // return this._moreGameBtn; return; } /** 更多游戏按钮参数 */ get moreGameParams() { return { x: 0, y: 0, w: 60, h: 60, appLaunchOptions: [] }; } //↓↓ 网赚 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ openMoneyActiviyView(type, data) { if (core.Manager.wtsdk.isReady) { this.moneyActivity.ActivityView(type, data); } else { log('wtsdk is not ready, openMoneyActiviyView fail'); } } /**账户的金币信息接口 */ operateCoin(callback) { if (core.Manager.wtsdk.isReady) { this.moneyActivity.operateCoin(callback); } else { log('wtsdk is not ready, operateCoin fail'); } } /**账户的积分信息接口 */ getUserCoinInfo(Type, callback) { if (core.Manager.wtsdk.isReady) { this.moneyActivity.getUserCoinInfo(Type, callback); } else { log('wtsdk is not ready, getUserCoinInfo fail'); } } /**小迈--神策 --自定义事件上报 */ // event: "game_pass", // game_pass 是事件的标识,策划定的 // data: { // data 里面需要的数据,策划定的 // game_level: 8, // 通关的关卡 // game_state: 'succeed' // 是否通过 // }, // public Event_track(eventName: string, eventdata: any) { // if (core.Manager.wtsdk.isReady) { // wtsdk.track({ // event: eventName, // data: eventdata, // }); // } else { // // alert('wtsdk is not ready'); // } // } //↓↓ 网赚view客户端接口 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ // 领取奖励 wzFinishReward(sceneType, Level, moneyType = 2) { if (core.Manager.wtsdk.isReady) { wtsdk.wzFinishReward({ params: { type: moneyType, scene: sceneType, level: Level }, onSuccess: function (res) { core.Manager.eDispatcher.event(core.Event.GET_ACTIVITY_REWARD, { type: sceneType, value: res.data.coin_add }); }, onFail: function (res) { // core.FloatTips.addTips(res.msg) } }); } else { // alert('wtsdk is not ready'); } } // 如果需要预加载,先提前调用loadRewardVideo去加载广告 loadRewardVideo(postionID) { if (core.Manager.wtsdk.isReady) { this.ad.LoadRewardedVideoAd(postionID); } else { // alert('wtsdk is not ready'); } } /**签到初始化 */ loginSignInit(SuccessCallBack) { if (core.Manager.wtsdk.isReady) { wtsdk.loginSignInit({ onSuccess: function (res) { if (SuccessCallBack) SuccessCallBack.runWith(res.data); }, onFail: function (res) { // core.FloatTips.addTips("初始化失败,请稍后重试") } }); } else { // alert('wtsdk is not ready'); } } /**签到一次,保存用户当天签到记录 */ loginSignLog(onSuccess) { if (core.Manager.wtsdk.isReady) { wtsdk.loginSignLog({ onSuccess: function (res) { if (res && res.code == 1) { onSuccess.run(); } }, onFail: function (res) { // core.FloatTips.addTips(res.msg) } }); } else { // alert('wtsdk is not ready'); } } /**签到提现 */ loginSignWithdraw(day, amount, Rank, SuccessCallBack) { if (core.Manager.wtsdk.isReady) { wtsdk.loginSignWithdraw({ params: { days: day, amount: amount, rank: Rank // 提现的档位 }, onSuccess: function (res) { if (SuccessCallBack) SuccessCallBack.runWith(1); }, onFail: function (res) { if (SuccessCallBack) SuccessCallBack.runWith(0); } }); } else { // alert('wtsdk is not ready'); } } /** * 进度值 * @param data percent进度值,1-100 */ progress(data) { // log("to sdk progress",data.percent) if (core.Manager.wtsdk.isReady) { return wtsdk.progress(data); } } } webGame.BasePlatform = BasePlatform; })(webGame || (webGame = {})); /// var webGame; /// (function (webGame) { class Platform extends webGame.BasePlatform { constructor() { super(); // if(BaseConfig.needResServer) Laya.URL.basePath = core.Manager.baseResPath + "game/gameResName/tt/v1.0.0";//"/gameResName/tt/v" + BaseConfig.version; } showTitle(score) { throw new Error("Method not implemented."); } sendLoginCheck() { throw new Error("Method not implemented."); } // public showSurpass(score:number):void{} /** 更多游戏按钮参数 */ get moreGameParams() { return { x: 0, y: 0, w: 60, h: 60, appLaunchOptions: [ { appId: "ttXXXXXX", query: "", extraData: {}, } ] }; } } webGame.Platform = Platform; })(webGame || (webGame = {})); window.webGame = webGame; //首次加载时,初始化 window.platform = new webGame.Platform(); /** * 广告 */ var webGame; /** * 广告 */ (function (webGame) { class BaseADManager { constructor() { this.createAD(); } createAD() { this.createBannerAd(); this.createInterstitialAd(); this.createRewardedVideoAd(); this.createFreeAd(); this.createFullVideoAd(); } //↓↓ Banner广告 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ /** 创建Banner广告 */ createBannerAd() { if (!core.Manager.wtsdk.isReady || this._bannerAd) return; // 创建 Banner 广告实例,提前初始化 let ad = wtsdk.createBannerAd(); if (!ad) return; ad.onError(this.onBannerError.bind(this)); this._bannerAd = ad; } /** banner报错 */ onBannerError(err) { } /** 显示 banner 广告 */ showBanner(posid) { if (this._bannerAd) this._bannerAd.show(posid); } /** 隐藏 banner 广告 */ hideBanner(posid) { if (this._bannerAd) this._bannerAd.close(posid); } //↑↑ Banner广告 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //↓↓ 插屏广告 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ /** 创建插屏广告 */ createInterstitialAd() { // 创建插屏广告实例,提前初始化 if (!core.Manager.wtsdk.isReady || this._interstitialAd) return; this._interstitialAd = wtsdk.createInterstitialAd(); if (!this._interstitialAd) return; this._interstitialAd.onError(this.onInterstitialAdError.bind(this)); this._interstitialAd.onClose(this.onInterstitialAdClosed.bind(this)); this._interstitialAd.onLoad(this.onInterstitialAdLoaded.bind(this)); //默认load一个视频出来 this.LoadInterstitialAd(40000); } /** 插屏广告报错 */ onInterstitialAdError(err) { core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_ERROR, err); } /** 插屏广告关闭 */ onInterstitialAdClosed(res) { core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_CLOSE, res); } /** 插屏广告加载完成 */ onInterstitialAdLoaded(res) { if (!this._interstitialAd) return; core.Manager.eDispatcher.event(core.Event.INTERSTITIAL_AD_ONLOAD, res); } /** 插屏广告预加载 */ LoadInterstitialAd(posId) { if (!this._interstitialAd) return; this._interstitialAd.load(posId); } /** * 显示插屏广告 */ showInterstitialAd(posid) { // 在适合的场景显示插屏广告 if (!this._interstitialAd) return; this._interstitialAd.show(posid); //skd在show里加了load,不再需要load // this._interstitialAd.load(posid); // this._interstitialAd.onLoad((function(result){ // this._interstitialAd.show(posid); // }).bind(this)); } //↑↑ 插屏广告 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //↓↓ 激励视频广告 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ /** 创建激励视频广告 */ createRewardedVideoAd() { if (!core.Manager.wtsdk.isReady || this._rewardedVideoAd) return; this._rewardedVideoAd = wtsdk.createRewardVideoAd(); if (!this._rewardedVideoAd) return; this._rewardedVideoAd.onError(this.onRewardedVideoAdError.bind(this)); this._rewardedVideoAd.onClose(this.onRewardedVideoAdClosed.bind(this)); this._rewardedVideoAd.onLoad(this.onRewardedVideoAdLoaded.bind(this)); //默认load一个视频出来 this.LoadRewardedVideoAd(30000); //this._rewardedVideoAd.onReward(this.onRewardedVideoAdReward.bind(this)); } /** 激励视频广告报错 */ onRewardedVideoAdError(err) { core.Manager.eDispatcher.event(core.Event.REWARDED_AD_ERROR, false); } /** 激励视频广告关闭 */ onRewardedVideoAdClosed(res) { let result = res && res.data ? res.data.isReward : false; core.Manager.eDispatcher.event(core.Event.REWARDED_AD_CLOSE, result); } /** 激励视频广告加载完成 */ onRewardedVideoAdLoaded(res) { core.Manager.eDispatcher.event(core.Event.REWARDED_AD_ONLOAD, res); } // /**激励播放成功 */ // protected onRewardedVideoAdReward(){ // } /** 激励视频广告预加载 */ LoadRewardedVideoAd(posId) { if (!this._rewardedVideoAd) return; this._rewardedVideoAd.load(posId); } /** 显示激励广告 */ showRewardedVideoAd(posId) { if (!this._rewardedVideoAd) return; this._rewardedVideoAd.show(posId); } //↑↑ 激励视频广告 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //↓↓ 信息流广告 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ createFreeAd() { if (!core.Manager.wtsdk.isReady || this._FreeAD) return; // 创建 FreeAd 广告实例,提前初始化 let ad = wtsdk.createFeedAd(); if (!ad) return; ad.onError(this.onFreeAdError.bind(this)); this._FreeAD = ad; } /** FreeAd报错 */ onFreeAdError(err) { } /** 显示 FreeAd 广告 */ showFreeAd(posid) { if (this._FreeAD) this._FreeAD.show(posid); } /** 隐藏 FreeAd 广告 */ hideFreeAd(posid) { if (this._FreeAD) this._FreeAD.close(posid); } //↑↑ 信息流广告 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //↓↓ 全屏视频广告 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ createFullVideoAd() { if (!core.Manager.wtsdk.isReady || this._FullVideoAd) return; this._FullVideoAd = wtsdk.createFullVideoAd(); if (!this._FullVideoAd) return; this._FullVideoAd.onError(this.onFullVideoAdError.bind(this)); this._FullVideoAd.onClose(this.onFullVideoAdClosed.bind(this)); this._FullVideoAd.onLoad(this.onFullVideoAdLoaded.bind(this)); } /** 全屏广告广告报错 */ onFullVideoAdError(err) { core.Manager.eDispatcher.event(core.Event.FULL_AD_ERROR, false); } /** 全屏广告广告关闭 */ onFullVideoAdClosed(res) { core.Manager.eDispatcher.event(core.Event.FULL_AD_CLOSE, res); } /** 全屏广告广告加载完成 */ onFullVideoAdLoaded(res) { core.Manager.eDispatcher.event(core.Event.FULL_AD_ONLOAD, res); } /** 全屏广告广告预加载 */ LoadFullVideoAd(posId) { if (!this._FullVideoAd) return; this._FullVideoAd.load(posId); } /** 显示激励广告 */ showFullVideoAd(posId) { if (!this._FullVideoAd) return; this._FullVideoAd.show(posId); } } webGame.BaseADManager = BaseADManager; })(webGame || (webGame = {})); var webGame; (function (webGame) { class MoneyActivity { constructor() { } /**账户的金币信息接口 */ operateCoin(callback) { if (core.Manager.wtsdk.isReady) { wtsdk.operateCoin({ userState: function (result) { log(result); if (callback) callback.runWith(result.data); } }); } } /** * 账户的积分信息接口 * @param Type 货币类型 * @param callback */ getUserCoinInfo(Type, callback) { if (core.Manager.wtsdk.isReady) { wtsdk.getUserCoinInfo({ params: { type: Type }, success: function (result) { log("getUserCoinInfo success..."); if (callback) callback.runWith(result.data); }, error: function (result) { log("getUserCoinInfo error", result); if (callback) callback.runWith({}); }, }); } else { log('wtsdk is not ready'); } } /******************以下维特部分网赚接口是独立工程调起网赚页接口************************************************************************ */ ActivityView(type, data) { if (!core.Manager.wtsdk.isReady) return; switch (type) { case core.MoneyActivityType.withdraw: /** 提现页 */ log("提现"); // wtsdk.withdraw(data) break; case core.MoneyActivityType.wheel: /** 大转盘 */ wtsdk.wheel(data); break; case core.MoneyActivityType.fruitMachine: /** 水果机 */ wtsdk.fruitMachine(data); break; case core.MoneyActivityType.idiom: /** 成语游戏 */ wtsdk.idiom(data); break; case core.MoneyActivityType.newIdiom: /**成语答题 */ wtsdk.newIdiom(data); break; case core.MoneyActivityType.scratchCard: /**刮刮卡 */ wtsdk.scratchCard(data); break; case core.MoneyActivityType.userFeedBack: /**用户反馈 */ wtsdk.userFeedBack(data); break; case core.MoneyActivityType.policyPage: /**隐私政策 */ wtsdk.policyPage(data); break; case core.MoneyActivityType.agreementPage: /**用户协议 */ wtsdk.agreementPage(data); break; case core.MoneyActivityType.withdrawIntegral: /**积分提现页 */ wtsdk.withdrawIntegral(data); break; // case core.MoneyActivityType.loginSignWithdraw:/**签到提现页 */ // wtsdk.loginSignWithdraw(data) // break case core.MoneyActivityType.loginOut: /** 小迈 注销页 */ wtsdk.logout(data); break; // case core.MoneyActivityType.triggerBehavior: /** 小迈 自定义激活回传 */ // wtsdk.triggerBehavior({ // level: data // }) // break // case core.MoneyActivityType.keyBehavior: /** 小迈 关键行为回传 */ // wtsdk.keyBehavior(data) // break case core.MoneyActivityType.debugPage: wtsdk.debugPage(data); break; case core.MoneyActivityType.loadWZRewardAd: wtsdk.loadWZRewardAd({ type: 'level_pass' // 过关红包 }); break; /**维特接口 */ case core.MoneyActivityType.SevenLogin: /**七日登录 */ wtsdk.showSevenLogin(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.LoginSign: /**登录签到 */ wtsdk.showLoginSign(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.Achievement: /**成就红包 */ wtsdk.showAchievement(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.AchievementBig: /**成就红包 */ wtsdk.showAchievementBig(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.Bubbles: /**泡泡红包 */ wtsdk.showBubbles(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.LevelPass: /**过关红包 */ wtsdk.showLevelPass(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.NewPlayer: /**新人红包 */ wtsdk.showNewUser(this.WeiTeSdkParame(type, data)); break; case core.MoneyActivityType.AchievementNewC: /**新成就红包(积分C) */ wtsdk.showAchievementNewC(this.WeiTeSdkParame(type, data)); break; } } WeiTeSdkParame(type, data) { let wtActivityParame = { params: { xx: data ? data : 'guide=0' }, open: function (res) { log("开启通知"); // core.Manager.eDispatcher.event(core.Event.ACTIVITYOPEN, { // activityType: type, // res: res.data // }); }, close: function (res) { log("关闭通知", res); // core.Manager.eDispatcher.event(core.Event.ACTIVITYCLOSE, { // activityType: type, // res: res.data // }); } }; log("请求网赚:", type, " 参数:", data, wtActivityParame); return wtActivityParame; } } webGame.MoneyActivity = MoneyActivity; })(webGame || (webGame = {})); var webGame; (function (webGame) { class SystemInfo { constructor() { this.info = { appName: "wtyx", platform: "" }; this.info.platform = Laya.Browser.onIOS ? "ios" : (Laya.Browser.onAndroid ? "android" : "computer"); } /** 设备:android,ios */ get device() { return this.info.platform; } /** app名字 */ get appName() { return this.info.appName; } } webGame.SystemInfo = SystemInfo; })(webGame || (webGame = {})); var webGame; (function (webGame) { class AddToDeskIcon extends Laya.Image { //↑↑ static ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ constructor() { super(core.Manager.commonResPath + "atTodesk/icon.png"); } static show(x = 0, y = 0, parent) { if (!this._instance) this._instance = new AddToDeskIcon(); this._instance.pos(x, y); if (!parent) parent = Laya.stage; parent.addChild(this._instance); return this._instance; } static hide() { if (this._instance) { this._instance.destroy(); this._instance = null; } } onEnable() { super.onEnable(); this.on(Laya.Event.CLICK, this, this.onClick); } onDisable() { super.onDisable(); this.off(Laya.Event.CLICK, this, this.onClick); } onClick(e) { if (core.Manager.wtsdk.isReady) wtsdk.onShortcut(); } destroy() { Laya.timer.clearAll(this); super.destroy(); } } webGame.AddToDeskIcon = AddToDeskIcon; })(webGame || (webGame = {})); var webGame; (function (webGame) { class LoadADTipsView extends Laya.Box { constructor() { super(); this.zOrder = 1000; this.mouseEnabled = true; this.blackBg = new Laya.Sprite(); this.blackBg.alpha = 0.5; this.addChild(this.blackBg); Laya.stage.addChild(this); } onAwake() { this.timeNum = 3; this.str = "等待广告中..."; let size = Laya.stage.width > 600 ? 38 : (Laya.stage.width <= 400 ? 24 : 30); this.lable = core.FloatTips.createLable(`${this.str}`, 0, (78 - size) / 2, size, Laya.stage.width, '#ffffff', "center"); this.lable.text = this.str + "\n" + this.timeNum; this.lable.leading = 10; this.lable.centerX = 0; this.lable.centerY = 0; this.addChild(this.lable); } onEnable() { super.onEnable(); core.Manager.eDispatcher.on(core.Event.REWARDED_AD_CLOSE, this, this.destroy); core.Manager.eDispatcher.on(core.Event.REWARDED_AD_ERROR, this, this.destroy); Laya.stage.on(Laya.Event.RESIZE, this, this.onResize); this.onResize(); Laya.timer.loop(1000, this, this.timeCount, null, false); } onResize(e) { this.blackBg.graphics.clear(); this.blackBg.graphics.drawRect(0, 0, Laya.stage.width, Laya.stage.height, '#000000'); this.blackBg.size(Laya.stage.width, Laya.stage.height); } timeCount() { this.timeNum--; this.lable.text = this.str + "\n" + this.timeNum; if (this.timeNum <= 0) { // core.FloatTips.addTips("激励视频加载失败"); Laya.timer.clearAll(this); this.destroy(); } } onDisable() { core.Manager.eDispatcher.off(core.Event.REWARDED_AD_CLOSE, this, this.destroy); core.Manager.eDispatcher.off(core.Event.REWARDED_AD_ERROR, this, this.destroy); Laya.stage.off(Laya.Event.RESIZE, this, this.onResize); } destroy() { Laya.timer.clearAll(this); super.destroy(); } } webGame.LoadADTipsView = LoadADTipsView; })(webGame || (webGame = {})); var webGame; (function (webGame) { class MoreGameIcon extends Laya.Box { constructor(params) { super(); this.ICON_SIZE = 120; //游戏图标的始尺寸 this.zOrder = core.ZOrder.POPUP; this._appLaunchOptions = params.appLaunchOptions; this.pos(params.x, params.y); // this.size(params.w, params.h); this.scale(params.w / this.ICON_SIZE, params.h / this.ICON_SIZE); Laya.stage.addChild(this); } onAwake() { this._index = 0; this._icon = new Laya.Image(); this._icon.anchorX = 0.5; this._icon.anchorY = 0.5; this.addChild(this._icon); this._label = new Laya.Image(this.getRes("gdhw")); // this._label.anchorX = 0.5; this._label.anchorY = 0.5; this._label.y = 86; this.addChild(this._label); this._iconUrls = []; let gameList = core.Manager.gameList; for (let i = gameList.length - 1; i >= 0; i--) { if (gameList[i].rec_degree == 1) this._iconUrls.push(gameList[i].icon); //取热门游戏 } if (this._iconUrls.length == 0) this._iconUrls.push(gameList[0].icon); //无热门游戏,推第一个进去,保证起码有一个游戏 this._tweentimeLite = new core.TweenTimeLine(0); this._tweentimeLite.addToTween(this, { scaleX: this.scaleX * 0.8, scaleY: this.scaleX * 0.8 }, 600, Laya.Ease.backOut); this._tweentimeLite.addToTween(this, { scaleX: this.scaleX, scaleY: this.scaleX }, 600, Laya.Ease.backIn); } getRes(name) { return core.Manager.commonResPath + "gameIcon/" + name + ".png"; //指定取资源图片 } onEnable() { super.onEnable(); this.timerLoop(5000, this, this.changeSkin); this.changeSkin(); this._tweentimeLite.start(); this.on(Laya.Event.CLICK, this, this.onClick); this._icon.on(Laya.Event.LOADED, this, this.iconLoaded); } changeSkin() { if (this._index >= this._iconUrls.length) this._index = 0; this._icon.skin = this._iconUrls[this._index]; this._index++; } iconLoaded() { this._icon.size(this.ICON_SIZE, this.ICON_SIZE); //每个图片大小可能不一样,加载完成重新设置一下 } onClick(e) { // // // 监听弹窗关闭 // // tt.onMoreGamesModalClose(function (res) { // // log("modal closed", res); // // }); // // // 监听小游戏盒子跳转 // // tt.onNavigateToMiniGameBox(function (res) { // // log(res.errCode); // // log(res.errMsg); // // }); // const systemInfo = tt.getSystemInfoSync(); // // iOS 不支持,建议先检测再使用 // if (systemInfo.platform !== "ios") { // // 打开小游戏盒子 // tt.showMoreGamesModal({ // appLaunchOptions: this._appLaunchOptions, // // success(res) { log("success", res.errMsg); }, // // fail(res) { log("fail", res.errMsg); }, // }); // } } onDisable() { super.onDisable(); this.clearTimer(this, this.changeSkin); this._tweentimeLite.pause(); this.off(Laya.Event.CLICK, this, this.onClick); this._icon.off(Laya.Event.LOADED, this, this.iconLoaded); } destroy() { super.destroy(); this._tweentimeLite.destroy(); this._tweentimeLite = null; this._appLaunchOptions = null; this._iconUrls = null; } } webGame.MoreGameIcon = MoreGameIcon; })(webGame || (webGame = {})); //# sourceMappingURL=webGame.js.map