/******************************************************************************* * * 活动: 殘骸收集 * * ******************************************************************************/ const ActBase = require( "act.base" ); const ActTreasure = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); this.task = 0; }, // 注册协议接受事件 registerProtocals: function() { // // 前端准备完毕 this.RegisterProtocal( 29700, this.getWreckageColBase.bind( this ) ); this.RegisterProtocal( 29701, this.wreckageColTaskInfo.bind( this ) ); this.RegisterProtocal( 29702, this.exChangeInfoBack.bind( this ) ); this.RegisterProtocal( 29703, this.taskBack.bind( this ) ); this.RegisterProtocal( 29704, this.exchangeStatus.bind( this ) ); }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { let cfgs = [ this.data.config, //殘骸收集 ] this.loadConfigs( cfgs, ( _ret, _data ) =>{ nx.dt.fnInvoke( _cb, true ); this.reqWreckageColData(); } ) }, // 请求探宝活动数据 reqWreckageColData: function( _cb ) { this.SendProtocal( 29700, {}, _cb ); }, // 请求探宝活动数据 reqWreckageColTaskData: function( ) { this.SendProtocal( 29701, {}); }, getWreckageColBase: function( _data ){ let canshow = 0; let lst = _data.list; this.taskInfo = lst; if( lst ){ lst.forEach( task => { if( task ){ if( task.finish == 1 ){ canshow ++; task.sortid = 2; } if( task.finish == 2 ){ task.sortid = 0; } if( task.finish == 0 ){ task.sortid = 1; } } }); } this.openTip( "reward", canshow != 0 ); this.vset( "wreckagecol", _data ); }, wreckageColTaskInfo: function( _data ){ this.vset( "wreckagecolTask", _data ); this.reqWreckageColData(); }, reqFinishTask: function( _id, _cb ){ let protocal = {}; protocal.id = _id; this.task = _id; this.SendProtocal( 29703, protocal, _cb ); }, reqExchange: function( _id ){ let protocal = {}; protocal.id = _id; this.SendProtocal( 29704, protocal ); }, // 探宝轮次变化 exChangeInfoBack : function( _data ){ this.vset( "wreckagecolExchange", _data ); }, // 探宝轮次变化 taskBack : function( _data ){ if( _data.code == 1 ){ let tip = nx.text.getKey( "lab_get" ) + nx.text.getKey( "ActCol" ); let show = { tip : tip, cfg : gdata( this.data.config, "data_quest_list" )[this.task] } // nx.tbox( tip ); this.vset( "wreckagecolInfo", show ); } }, exchangeStatus : function( _data ){ }, } ); // 模块导出 module.exports = ActTreasure;