/******************************************************************************* * * 活动: 探宝活动 * * ******************************************************************************/ const ActBase = require( "act.base" ); const ActTreasure = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { // // 前端准备完毕 this.RegisterProtocal( 29600, this.getTreasureStatus.bind( this ) ); this.RegisterProtocal( 29601, this.reqTreasureBack.bind( this ) ); this.RegisterProtocal( 29602, this.periodChange.bind( this ) ); }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { let cfgs = [ this.data.config,//付費活動 ] this.loadConfigs( cfgs, ( _ret, _data ) =>{ this.reqTreasureData( _cb ); } ) }, // 请求探宝活动数据 reqTreasureData: function( _cb ) { this.SendProtocal( 29600, {}, _cb ); }, getTreasureStatus: function( _data ){ nx.bridge.acts.vset( "treasureInfo", _data ); if( _data.num > 0 ){ this.openTip( "rewarddd", true ); }else{ this.openTip( "rewarddd", false ); } }, reqTreasureBack: function( _data ){ // {"code":1,"msg":"","day":1,"status":1} if( _data.code == 1 ){ // let data = nx.bridge.acts.vget( "sign30" ); // data.day = _data.day; // data.status = _data.status; // nx.bridge.acts.vset( "sign30", data ); } // this.reqBaseData(); }, // 活动用到的提示KEY tipKeys: function() { return ["rewarddd"]; }, reqGetTreasure: function( _act, _cb ){ let protocal = {}; protocal.action = _act; this.SendProtocal( 29601, protocal, _cb ); }, // 探宝轮次变化 periodChange : function( _data ){ nx.bridge.acts.vset( "treasurePeriodChange", _data ); }, } ); // 模块导出 module.exports = ActTreasure;