123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032 |
- 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 = {}));
- /// <reference path="./base/BasePlatform.ts" />
- var webGame;
- /// <reference path="./base/BasePlatform.ts" />
- (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
|