/******************************************************************************* * * 活动: VIP升级 * * ******************************************************************************/ const ActBase = require( "act.base" ); const ActVipLevelup = cc.Class( { extends: ActBase, // 初始化配置数据 initConfig: function() { // 视图附着 nx.plugin.add( this, ["view"] ); this.vattach( "Acts" ); }, // 注册协议接受事件 registerProtocals: function() { this.RegisterProtocal( 16750, this.handle16750.bind( this ) ); // 等级礼包信息 this.RegisterProtocal( 16751, this.handle16751.bind( this ) ); // 领取礼包 }, // 从服务器初始化数据 reqBaseFromServer: function( _cb ) { // nx.dt.fnInvoke( _cb, true ); this.reqBaseData( _cb ); }, // ============================================================ // 操作 // ============================================================ // 等级礼包信息 reqBaseData: function( _cb ) { this.SendProtocal( 16750, {}, _cb ); }, // 等级礼包信息 handle16750: function( _data ) { if( !this.isGoodData( _data ) ) { return; } this.vset( "VipTasks", _data.lev_gift_list || [] ); this.freshTips(); }, // 领取礼包 reqGetRewardsOnce: function( _cb ) { this.SendProtocal( 16751, {}, _cb ); }, // 领取礼包 handle16751: function( _data ) { if( !this.isGoodData( _data ) ) { return; } }, // ============================================================ // 活动红点提示 // ============================================================ // 红点提示更新 freshTips: function() { let can = false; let list = this.vget( "VipTasks" ) || []; 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 = ActVipLevelup;