/******************************************************************************* * * 活动: 開服冲級 * ******************************************************************************/ const ActBase = require( "act.base" ); const GrowthRush = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 21200, this.growthRushDataBack.bind( this ) ); // 升级/冲级礼包状态 this.RegisterProtocal( 21201, this.getGiftBack.bind( this ) ); // 請求子活動相關,來取相關的顯示數據 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { let cfgs = [ this.data.config,//付費活動 ] this.loadConfigs( cfgs, ( _ret, _data ) =>{ // this.reqBaseData( _cb ); nx.dt.fnInvoke( _cb, true ); } ) }, // 请求活动信息 reqBaseData: function( _cb ) { this.reqGrowthRushData( _cb ); }, // ============================================================ // 升级有礼 // ============================================================ // 请求升/冲级有礼相关 reqGrowthRushData: function( _cb ) { let protocal = {}; this.SendProtocal( 21200, protocal ); }, // 请求相關配置信息 growthRushDataBack: function( _data ) { let get = 0; let cfg = gdata( this.data.config, "data_level_welfare" ); _data.gifts.forEach( _aim => { if( _aim.status == 1 && cfg[_aim.id].num != _aim.num ){ get++; } _aim.sortid = _aim.status == 1 ? _aim.status - 1 : _aim.status + 1; } ) this.vset( "growthrush", _data ); this.openTip( "reward", get != 0 ); }, reqGetGift: function( _id ) { let protocal = {} protocal.id = _id; this.SendProtocal( 21201, protocal ); }, // 请求相關配置信息 getGiftBack: function( _data ) { let msg = _data.msg; if( !nx.dt.strEmpty( msg ) ){ nx.tbox( msg ); } }, } ); // 模块导出 module.exports = GrowthRush;