const SVCItem = require( "nx.fx.sv.expand.item" ); const ItemLst = require( "cmp.common.itemlayout" ); const Payment = require( "payment.mod" ); cc.Class({ extends: SVCItem, properties: { nodRewards: { default: null, type: ItemLst }, nodName: { default: null, type: cc.Node }, nodBuy : { default: null, type: cc.Node }, nodLeft : { default: null, type: cc.Node }, }, // 数据重置 rebind: function( _idx, _data, _key ) { this._super(_idx, _data, _key); this.setData(); }, setData: function(){ if( !this.mdata ){ return; } this.cb = this.mdata.cb; nx.gui.setString( this.nodName, "", this.mdata.gift.gift_name ); this.nodRewards.rebuild( this.mdata.rewards.reward ); nx.gui.setString( this.nodBuy, "num", this.mdata.gift.val == 0 ? nx.text.getKey( "Get" ) : Payment.getInstance().fmtPrice( this.mdata.gift.val ) ); // nx.gui.setActive( this.nodBuy, "tip", this.mdata.gift.val == 0 ); this.freshLeft( this.mdata.count ); }, freshLeft: function( _num ){ this.canBuy = this.mdata.gift.limit_count - _num > 0; nx.gui.setActive( this.nodBuy, "tip", this.canBuy && this.mdata.gift.val == 0 ); nx.gui.setString( this.nodLeft, "num", this.mdata.gift.limit_count - _num ); let btn = nx.gui.getComponent( this.nodBuy, "", cc.Button ); if( btn ){ btn.interactable = this.mdata.gift.limit_count - _num > 0; if( this.mdata.gift.val == 0 ){ this.mdata.gift.limit_count - _num > 0 ? nx.gui.setString( this.nodBuy, "num", nx.text.getKey( "Get" ) ) : nx.gui.setString( this.nodBuy, "num", nx.text.getKey( "Got" ) ) ; } nx.gui.setOutlineColor( this.nodBuy, "num", this.mdata.gift.limit_count - _num > 0 ? new cc.color( "#b85833" ) : cc.Color.BLACK ) } }, onTouchBuy: function(){ if( !this.canBuy ){ nx.tbox( "tip_eleBuyNumOver" ); return; } nx.dt.fnInvoke( this.cb, true ); }, });