/****************************************************************** * * 限時特惠 * ******************************************************************/ const ActPage = require( "act.page.base" ); const TipsController = require( "tips_controller" ); const mod = require( "act.optionalparty.mod" ); const FID = require( "bridge.function.ids" ); const themeMod = require( "acts.mod" ); cc.Class( { extends: ActPage, properties: { nodRemindTime: { type: cc.Node, default: null }, nodChoice : { type: cc.Node, default: null }, nodBottom : { type: cc.Node, default: null }, }, // 初始化 build: function( _data ) { this._super( _data ); let chd = this.nodChoice.children; let cfg = gdata( this.mod.data.config, "data_drama_reward" ); let dfg = gdata( this.mod.data.config, "data_desc" ); let desc = dfg[1].desc; nx.gui.setString( this.nodBottom, "desctip", desc ); // nx.gui.setString( this.nodBottom, "desc", nx.text.format( "ActOptionalTipt", levelt ) ); for (let i = 0; i < chd.length; i++) { let nod = chd[i]; nx.gui.setActive( nod, "op", false ); let spine = nx.gui.getComponent( nod, "role", "nx.fx.spine" ); nx.gui.setString( nod, "getTip", nx.text.format( "ActOptionalGetTipt", cfg[i+1][0].limit_lev ) ); nx.gui.setString( nod, "camp", nx.text.getKey( "AnyNameCampName" + ( i + 1 ) ) ); nx.gui.setActive( nod, "tip", false ); nx.gui.setActive( nod, "addtip", true ); nx.gui.find( nod, "op" ).zIndex = i + 1; if( spine ){ spine.stop(); } let cmp = nx.gui.getComponent( nod, "icon", "cmp.item.base" ); if( cmp ){ cmp.setData( [] ); } } // 活动监听 this.mod.vbind( this, [ [ "optionalparty", this.freshInfo.bind( this ) ], ] ); // this.mod.reqOptionalPartyData(); }, onEnable: function(){ // // 请求信息 this.mod.reqOptionalPartyData(); }, // 销毁 onDestroy: function() { // 活动监听解除 if( this.mod ) { this.mod.vunbind( this ); } delete this.mod; this._super(); }, freshInfo: function( _data ){ if( !_data || nx.dt.objEmpty( _data ) ){ return; } // {"partner_ids":[{"id":1,"partner_id":10505,"status":1}]} let ids = _data.partner_ids; this.infos = _data.partner_ids; this.remain_sec = _data.remain_sec; if( this.remain_sec > 0 ){ nx.gui.setCdTxt( this.nodRemindTime, "time", this.remain_sec, ()=>{ nx.gui.setString( this.nodRemindTime, "time", nx.text.getKey( "已结束" ) ); } ) }else{ nx.gui.setString( this.nodRemindTime, "time", nx.text.getKey( "已结束" ) ); } let cfgss = game.configs.partner_data.data_partner_base; for (let i = 0; i < ids.length; i++) { let info = ids[i]; if( info ){ let nod = this.nodChoice.children[ info.id - 1]; nx.gui.setActive( nod, "add", false ) let cmp = nx.gui.getComponent( nod, "icon", "cmp.item.base" ); let spine = nx.gui.getComponent( nod, "role", "nx.fx.spine" ); if( spine ){ let path = cc.path.join( "resDB/models/" + cfgss[info.partner_id].draw_res + "/" + cfgss[info.partner_id].draw_res ) ; spine.load( path, ( _e ) => { if( !_e ) { spine.action( "stand2", true ); } else { spine.stop(); } } ); } if( cmp ){ cmp.setData( info.partner_id ); } nx.gui.setActive( nod, "op", true ); let btn = nx.gui.getComponent( nod, "op", cc.Button ); if( btn ){ btn.interactable = info.status == 1 ? true : false; nx.gui.setActive( nod, "op/tip", info.status == 1 ); nx.gui.setString( nod, "op/txt", info.status == 2 ? nx.text.getKey( "Got" ) : nx.text.getKey( "Get" ) ) nx.gui.setOutlineColor( nod, "op/txt", info.status == 1 ? new cc.color( "#B85833" ) : cc.Color.BLACK ); } nx.gui.setActive( nod, "tip", info.status != 2 ); nx.gui.setActive( nod, "addtip", false ); } } }, onTouchAdd: function( _index ){ if( !this.infos || this.remain_sec == 0 ){ nx.tbox( "已结束" ); return; } let canAdd = true; this.infos.forEach( _info => { if( _info.id == _index && _info.status == 2 ){ canAdd = false; } } ) if( !canAdd ){ nx.tbox( "lab_planesafk_order_action_reward_tip1" ); return; } let cfg = gdata( this.mod.data.config, "data_drama_reward" ); let partners = cfg[_index]; let ids = []; for ( let i = 0; i < partners.length; i++ ) { let partner = partners[i]; ids.push( partner.partner_id ); } //打開英雄選擇界面 nx.bridge.createPanel( "WndActPartnerSelect", { camp: _index, plist: partners, mod: this.mod } ); }, onTouchGet: function( _btn ){ let camp = _btn.zIndex; this.mod.reqGetOptionalPartyAward( camp ); }, onTouchHelp: function(){ let TC = TipsController.getInstance(); let explain = gdata( this.mod.data.config, "data_desc" )[1]; TC.showTextPanel( explain.name, explain.desc ); }, onTouchRecommend: function(){ nx.bridge.createPanel( "WndPopRecommend" ); }, // onTouchClose: function(){ // if( this.show && nx.dt.strNEmpty( this.show ) ){ // this.close(); // return; // } // this.close(); // let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id ); // nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme ); // }, } );