/****************************************************************** * * 限定招募 * ******************************************************************/ const ActPage = require( "act.page.base" ); const NxSpine = require( "nx.fx.spine" ); const ItemLayout = require( "cmp.item.layout" ); const BridgeItemBinder = require( "bridge.binder.item.icon.count" ); const TipsController = require( "tips_controller" ); const FID = require( "bridge.function.ids" ); cc.Class( { extends: ActPage, properties: { spLogo: { default: null, type: NxSpine }, nodDate: { default: null, type: cc.Node }, nodTip: { default: null, type: cc.Node }, nodCoin: { default: null, type: BridgeItemBinder }, nodScore: { default: null, type: BridgeItemBinder }, nodOps: { default: null, type: cc.Node }, nodClose: { default: null, type: cc.Node }, tipReward: { default: null, type: ItemLayout }, }, // 初始化 build: function( _data ) { this._super( _data ); // 置空 if( !this.mod || nx.dt.objEmpty( this.data ) ) { this.setEmpty(); return; } // 配置查询 this.configs = this.mod.queryConfigs(); if( !this.configs ) { this.setEmpty(); return; } // 活动监听 // this.mod.vbind( this, [ // ["LimitPrayFreshed", this.onFreshData.bind( this )], // ] ); // 基本信息 this.buildBasic(); this.nodOps.active = false; this.nodClose.active = false; }, // 显示 onEnable: function() { this.mod.reqState( ( _ret, _data ) => { if( !_ret || !_data ) { return; } // 0-未开启,1-开放阶段 this.nodOps.active = ( _data.status == 1 ); this.nodClose.active = ( _data.status == 0 ); } ); }, // 销毁 onDestroy: function() { this._super(); }, // 置空 setEmpty: function() { nx.gui.setActive( this, "right", false ); }, // 基本信息 buildBasic: function() { // 置空 if( !this.mod || !this.configs || nx.dt.objEmpty( this.data ) ) { this.setEmpty(); return; } // 背景刷新 let spfile = cc.path.join( "locals/{lang}/spines", this.configs.anim, "action" ); this.spLogo.play( spfile, "action", null, true ); // 道具绑定 this.nodCoin.setID( this.configs.item_id, () => { this.freshOps(); } ); // 积分绑定 if( this.nodScore ) { let txt = nx.text.format( '积分解锁', this.configs.score_vip ); nx.gui.setString( this.nodScore, "vip", txt ); let tip = nx.gui.getComponent( this.nodScore, "tip", "nx.vb.visible" ); tip.setTarget( nx.mTip, this.mod.getTipKey( "score" ) ); this.nodScore.setID( this.configs.score_id, ( _id, _count ) => { this.freshScore( _count ); } ); } // 红点绑定 let tip1 = nx.gui.getComponent( this.nodOps, "once/tip", "nx.vb.visible" ); if( tip1 ) { tip1.setTarget( nx.mTip, this.mod.getTipKey( "once" ) ); } let tip2 = nx.gui.getComponent( this.nodOps, "ten/tip", "nx.vb.visible" ); if( tip2 ) { tip2.setTarget( nx.mTip, this.mod.getTipKey( "ten" ) ); } let txt = nx.text.getKey( this.configs.open_desc ); nx.gui.setString( this.nodClose, "txt", txt ); nx.gui.setString( this.nodTip, "txt", txt ); this.tipReward.rebuild( this.configs.reward_show ); this.freshDate(); }, // 刷新活动日期 freshDate: function() { let time = nx.bridge.time.toNeedTime( this.data.end_time ); nx.gui.setString( this.nodDate, "txt", time ); }, // 刷新奖励 freshRewards: function( _list ) { let rewards = []; if( nx.dt.arrNEmpty( _list ) ) { for( let i = 0; i < _list.length; ++i ) { rewards.push( [_list[i].bid, 1] ); } } this.tipReward.rebuild( rewards ); }, // 变化信息 freshOps: function() { // 置空 if( !this.mod || !this.configs || nx.dt.objEmpty( this.data ) ) { return; } // 按钮设置 let autoOp = function( _node, _draw, _pt ) { let tinfo = gitemdata( _draw[0] ); if( tinfo ) { nx.bridge.setIcon( _node, "btn/list/icon", tinfo.icon ); nx.gui.setString( _node, "btn/list/num", _draw[1] ); } } // 操作刷新 autoOp( nx.gui.find( this.nodOps, "once" ), this.configs.item_once[0] ); autoOp( nx.gui.find( this.nodOps, "ten" ), this.configs.item_ten[0] ); }, // 点击单抽 onTouchOnce: function() { if( !this.configs || !this.mod ) { return; } this.mod.reqSummon( true, ( _ret, _msg, _code ) => { if( !_ret ) { nx.tbox( _msg ); // 道具不足 if( _code == 101 ) { this.onTouchCoin(); } } } ); }, // 点击十抽 onTouchTen: function() { if( !this.configs || !this.mod ) { return; } this.mod.reqSummon( false, ( _ret, _msg, _code ) => { if( !_ret ) { nx.tbox( _msg ); // 道具不足 if( _code == 101 ) { this.onTouchCoin(); } } } ); }, // 点击规则 onTouchRule: function() { let rule = this.configs ? this.configs.rule : ""; if( nx.dt.strNEmpty( rule ) ) { const TC = TipsController.getInstance(); TC.showTextPanel( "tip", rule ); } }, // 点击道具 onTouchCoin: function() { if( this.actRoot && this.configs ) { this.actRoot.jumpToMenu( this.configs.jump ); } }, // 点击奖池 onTouchChi: function() { nx.bridge.createPanel( "WndSummonRule", { key: "recruit_gather_data" } ); }, // ============================================================ // 积分相关 // ============================================================ // 积分更新 freshScore: function( _count ) { let limit = this.configs.score_limit; let prog = nx.gui.getComponent( this.nodScore, "prog", cc.ProgressBar ); if( prog ) { prog.progress = _count / limit; } let txt = `${_count}/${limit}`; nx.gui.setString( this.nodScore, "score/txt", txt ); this.mod.freshTips(); }, // 点击积分 onTouchScore: function() { let can = nx.gui.isActive( this.nodScore, "tip" ); if( !can ) { nx.tbox( "积分不够提示" ); return; } this.mod.reqScore( ( _ret, _msg, _code ) => { // 道具不足 if( !_ret && _code == 101 ) { nx.tbox( _msg ); this.onTouchCoin(); } } ); }, } );