/******************************************************************************* * * 活动: 月卡 * * ******************************************************************************/ const ActBase = require( "act.base" ); const FID = require( "bridge.function.ids" ); const ActFirst = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 21003, this.handle21003.bind( this ) ); this.RegisterProtocal( 21032, this.handle21032.bind( this ) ); // 首充信息 this.RegisterProtocal( 21033, this.handle21033.bind( this ) ); // 領取對應天數的首充禮包 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { nx.dt.fnInvoke( _cb, true ); this.reqBaseData(); }, // 请求剧情信息 reqBaseData: function( _cb ) { this.reqFirstData(); }, // ============================================================ // 首充操作 // ============================================================ // 请求首充信息 reqFirstData: function( _cb ) { this.SendProtocal( 21032, {}, _cb ); }, // 请求首充信息返回 handle21032: function( _data ) { if( !this.isGoodData( _data ) ) { this.vset( "firstCharge", [] ); return; } this.vset( "firstCharge", _data.first_gift); // 提示刷新 this.freshTips(); }, // 领取首充禮包奖励 reqChargeReward: function( _id, _cb ) { this.SendProtocal( 21033, { id: _id, }, _cb ); }, // 领取月卡奖励返回 handle21033: function( _data ) { if( !this.isGoodData( _data ) ) { return; } // 提示刷新 // this.freshTips(); }, handle21003( _data ){ if( !this.isGoodData( _data ) ) { return; } if(_data.is_open == 1){ let data = nx.bridge.acts.searchAct( this.data.camp_id ); if( data ) { // let args = nx.dt.objClone( data ); // args.focus = 51001;//首充禮包 nx.bridge.vset( "DailyLimit", _data.is_open ); if( nx.bridge.plot && !nx.bridge.plot.isDoing() ){ nx.bridge.vset( "DailyPop", 1 ); } // nx.bridge.createPanel( "WndFirstCharge", args ); // nx.bridge.popups.push( "WndFirstCharge", args, { // push : true, // } ); } // nx.bridge.jumper.jump2Window( FID.ActFirst ); } }, // ============================================================ // 活动红点提示 // ============================================================ // 活动用到的提示KEY tipKeys: function() { return [ "reward1", "reward2" ]; }, // 红点提示更新 freshTips: function() { let gifts = this.vget( "firstCharge" ); let is_reward = false; let is_reward2 = false; for(let i in gifts){ if(gifts[i].id<=3 && gifts[i].status == 1){ is_reward = true; }else if(gifts[i].id>3 && gifts[i].status == 1){ is_reward2 = true; } } // this.openTip( "reward", is_reward ); this.openTip( "reward1", is_reward ); this.openTip( "reward2", is_reward2 ); }, } ); // 模块导出 module.exports = ActFirst;