/****************************************************************** * * 新服专享 * ******************************************************************/ const BasePage = require( "act.page.base" ); const NxSpine = require( "nx.fx.spine" ); const Payment = require( "payment.mod" ); const max = 4; cc.Class( { extends: BasePage, properties: { nodGift : { type: cc.Node, default: null }, spRole: { default: null, type: NxSpine }, nodEndTime : { default: null, type: cc.Node }, }, // 初始化 build: function( _data ) { this.spRole.load( "resDB/models/H30048/show", ( _e ) => { if( !_e ) { this.spRole.action( "action1", true ); } else { this.spRole.stop(); } } ); this._super( _data ); // 无效 if( !this.mod ) { return; } // 活动监听 this.mod.vbind( this, [ [ "timedust", this.freshGift.bind( this ) ], ] ); }, onEnable: function(){ // 请求信息 this.mod.reqTimeDustData(); }, // 销毁 onDestroy: function() { // 活动监听解除 if( this.mod ) { this.mod.vunbind( this ); } this._super(); }, freshGift: function( _data ){ this.timedust = _data; if( !this.timedust ){ return; } let left = this.timedust.remain_sec > 0 ? this.timedust.remain_sec : 0.1; nx.gui.setCdTxt( this.nodEndTime, "txt", ( left ), () => { nx.gui.setString( this.nodEndTime, "txt", nx.text.getKey( "lab_planesafk_main_have_over" ) ); } ); this.gifts = this.timedust.aim_list; for (let g = 0; g < this.gifts.length; g++) { let gift = this.gifts[g]; let giftCost = gift.aim_args giftCost.forEach( _arg => { if( _arg.aim_args_key == 39 ){ gift.sortid = _arg.aim_args_val; } }); } this.gifts.sort( Utils.tableLowerSorter([ "sortid"] ) ); this.cost = []; nx.gui.gocChildren( this.nodGift, "view/content", this.gifts.length ); let chd = nx.gui.find( this.nodGift, "view/content" ).children; for ( let i = 0; i < chd.length; i++ ) { let nod = chd[i]; let giftInfo = this.gifts[i]; if( giftInfo ){ let ui = i >= ( chd.length / 2 + 2 ) ? ( i + 1 - ( chd.length / 2 + 2 ) ) + 3 : i + 4 ; nx.gui.setString( nod, "cnt/title", giftInfo.aim_str ); let path = "prefab/acts/timedust/ui/time_0" + ( ui ) ; nx.gui.setSpriteFrame( nod, "cnt/icon", path ); let cmp = nx.gui.getComponent( nod, "cnt/list", "cmp.common.itemlayout" ); if( cmp ){ cmp.rebuild( giftInfo.item_list ); } nx.gui.setActive( nod, "cnt/op/costinfo/tip", giftInfo.status == 1 && giftInfo.aim == 0 ); nod.zIndex = i; let giftCost = giftInfo.aim_args; let num = 0; let limit = 0; let price = 0; let disPrice = 0; giftCost.forEach( _arg => { if( _arg.aim_args_key == 2 && _arg.aim_args_val != 0 ){ // let showNum = num == 0 ? num : ( num <= _arg.aim_args_val && num != 0 ) ? num : _arg.aim_args_val; limit = _arg.aim_args_val; } if( _arg.aim_args_key == 6 && _arg.aim_args_val != 0 ){ // let showNum = num == 0 ? num : ( num <= _arg.aim_args_val && num != 0 ) ? num : _arg.aim_args_val; num = _arg.aim_args_val; } if( _arg.aim_args_key == 26 ){ price = _arg.aim_args_val; } if( _arg.aim_args_key == 27 ){ disPrice = _arg.aim_args_val; } }); this.cost.push( disPrice ); if( disPrice > 0 ){ nx.gui.setString( nod, "cnt/op/costinfo/cost/num", Payment.getInstance().fmtPrice( price ) ); nx.gui.setString( nod, "cnt/op/costinfo/now/num", disPrice > 0 ? Payment.getInstance().fmtPrice( disPrice ) : Payment.getInstance().fmtPrice( price ) ); nx.gui.setActive( nod, "cnt/op/costinfo/now", true ); nx.gui.setActive( nod, "cnt/op/costinfo/cost", true ); }else{ nx.gui.setString( nod, "cnt/op/costinfo/cost/num", Payment.getInstance().fmtPrice( price ) ); if( giftInfo.status == 2 && giftInfo.aim == 0 ){ nx.gui.setString( nod, "cnt/op/costinfo/now/num", disPrice != 0 ? Payment.getInstance().fmtPrice( price ) : nx.text.getKey( "Got" ) ); }else{ nx.gui.setString( nod, "cnt/op/costinfo/now/num", disPrice != 0 ? Payment.getInstance().fmtPrice( price ) : nx.text.getKey( "Free" ) ); } nx.gui.setActive( nod, "cnt/op/costinfo/cost", price > 0 ); nx.gui.setActive( nod, "cnt/op/costinfo/now", true ); } nx.gui.setString( nod, "cnt/limit", nx.text.format( "BuyLimit", num, limit ) ); nx.gui.setActive( nod, "cnt/limit" , limit != 0 ); } } }, onTouchBuy: function( _btn ){ if( this.timedust.remain_sec == 0 ){ nx.tbox( "lab_recruit_hero_window_tip_6" ); return; } let number = _btn.parent.parent.zIndex; let aim = this.gifts[number].aim; if( ( this.gifts[number].status != 0 && this.cost[number] != 0 ) ){ nx.tbox( "lab_ladder_main_window_tip4" ); return; } if( ( this.gifts[number].status == 2 && this.cost[number] == 0 ) ) { nx.tbox( "已领取" ); return; } if( this.cost[number] == 0 ){ this.mod.reqGetTimeDustFree( aim ); return; } Payment.getInstance().reqPayment( aim ); // this.mod.reqExclusiveGift( this.exclusive.bid, aim ); } } ); /****************** * */