/******************************************************************************* * * 活动: 15日签到 * * ******************************************************************************/ const ActBase = require( "act.base" ); const ActModSign15 = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, [ "view" ] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 14110, this.onHand14110.bind( this ) ); // 签到数据 this.RegisterProtocal( 14111, this.onHand14111.bind( this ) ); // 领取签到 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { let cfgs = [ "holiday_checkin_data", ]; this.loadConfigs( cfgs, ( _ret, _data ) => { nx.dt.fnInvoke( _cb, true ); this.reqSignData(); } ); }, // 签到数据 reqSignData: function( _cb ) { this.SendProtocal( 14110, { camp_id: this.data.camp_id, }, _cb ); }, // 签到数据 onHand14110: function( _data ) { if( _data.camp_id != this.data.camp_id || !this.isGoodData( _data ) ) { return; } nx.bridge.acts.vset( "sign15", _data.gift_buy_info || [] ); this.freshTips(); }, // 领取签到 reqReward: function( _day, _cb ) { this.SendProtocal( 14111, { camp_id: this.data.camp_id, day: _day, }, _cb ); }, // 领取签到 onHand14111: function( _data ) { if( _data.camp_id != this.data.camp_id || !this.isGoodData( _data ) ) { return; } this.reqSignData(); }, // 获取配置 queryConfig: function() { let data = game.configs.holiday_checkin_data.data_client_info; let cfgs = data ? data[this.data.camp_id] : null; if( nx.dt.objEmpty( cfgs ) ) { nx.error( `Sign15:签到配置缺失!${this.data.camp_id}` ); } return cfgs; }, // 获取帮助 queryRule: function() { let data = game.configs.holiday_checkin_data.data_desc; let cfgs = data ? data[this.data.camp_id] : null; return cfgs ? cfgs.desc : ""; }, // 获取签到任务配置 queryTaskList: function() { let data = game.configs.holiday_checkin_data.data_sign_in; let list = data ? data[this.data.camp_id] : null; if( nx.dt.objEmpty( list ) ) { nx.error( `Sign15:签到任务配置缺失!${this.data.camp_id}` ); } return list; }, // ============================================================ // 活动红点提示 // ============================================================ // 红点提示更新 freshTips: function() { let can = false; let list = this.vget( "sign15" ) || []; for( let i = 0; i < list.length; ++i ) { // 0不可领取 1可领取 2已领取 let task = list[i]; if( task && task.status == 1 ) { can = true; break; } } this.openTip( "reward", can ); }, } ); // 模块导出 module.exports = ActModSign15;