/******************************************************************************* * * 活动: 七日定制相关 * * ******************************************************************************/ const ActBase = require( "act.base" ); const ActSevenCustom = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 29900, this.getSevenCustomData.bind( this ) ); // 請求子活動相關,來取相關的顯示數據 this.RegisterProtocal( 29901, this.setSevenCustomBack.bind( this ) ); // 請求領取子活動獎勵相關,來取相關的顯示數據 this.RegisterProtocal( 29902, this.setSevenCustomSureBack.bind( this ) ); // 請求領取子活動獎勵相關,來取相關的顯示數據 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { let cfgs = [ this.data.config,//付費活動 ] this.loadConfigs( cfgs, ( _ret, _data ) =>{ this.reqBaseData( _cb ); } ) }, // 请求活动信息 reqBaseData: function( _cb ) { this.reqOptionalGiftData( _cb ); }, // ============================================================ // 自選陣容 // ============================================================ // 请求 自選陣容信息 reqOptionalGiftData: function( _cb ) { this.SendProtocal( 29900, {}, _cb ); }, // 请求保存相關 禮包配置 reqSetGift: function( _cate, _reward, _day, _status ) { this.SendProtocal( 29901, { cate : _cate, reward : _reward, day : _day, status : _status } ); }, // 请求領取 自選陣容 夥伴--- camp_id reqMakeSureGift: function( _cate, _day ) { this.SendProtocal( 29902, { cate : _cate, day : _day }); }, // 七日定制 返回 getSevenCustomData: function( _data ) { this.vset( "sevenCustom", _data ); let count = 0; let day = _data.day; let list = _data.data_list; list.forEach( _item =>{ if( _item.cate == 1 ){ if( !_item.reward_list[ day - 1 ] ){ count++; } } } ) this.openTip( "reward", count > 0 ); /** * {"day":2,"data_list":[ * {"cate":1,"is_activate":1,"reward_list":[{"day":1,"status":3,"item_list":[]},{"day":2,"status":2,"item_list":[{"item_id":11403,"num":1}]}]}, * {"cate":2,"is_activate":1,"reward_list":[{"day":1,"status":1,"item_list":[{"item_id":11403,"num":5},{"item_id":22,"num":500000}]}]}, * {"cate":3,"is_activate":0,"reward_list":[]}, * {"cate":4,"is_activate":0,"reward_list":[]}]} */ }, // 请求 保存设置相關礼包数据 返回 setSevenCustomBack: function( _data ) { if( _data.code == 1 ){ nx.bridge.closePanel( "WndActSevenCustomSelect" ); } if( nx.dt.strNEmpty( _data.msg ) ){ nx.tbox( _data.msg ); } }, // 请求 确认设置相關礼包数据 返回 setSevenCustomSureBack: function( _data ) { if( _data.code == 1 ){ nx.bridge.closePanel( "WndActSevenCustomSelect" ); } if( nx.dt.strNEmpty( _data.msg ) ){ nx.tbox( _data.msg ); } }, } ); // 模块导出 module.exports = ActSevenCustom;