/****************************************************************** * Copyright(C) 2019 - 2020 Nx Studio * * 精英召唤禮包項 * * 2018.05.18 ******************************************************************/ const SVCItem = require( "nx.fx.sv.expand.item" ); const Payment = require( "payment.mod" ); cc.Class( { extends: SVCItem, properties: { nodRewards: { default: null, type: cc.Node }, fabItem: { default: null, type: cc.Prefab }, nodCount: { default: null, type: cc.Node }, nodOps: { default: null, type: cc.Node }, }, // 设置 setData: function( _data ) { // 重置 if( !this.data || this.data.id != _data.gift_id ) { const DATA = game.configs.recruit_holiday_lucky_data.data_privilege_data; this.data = nx.dt.objClone( DATA[ _data.gift_id ] ); this.freshBase(); } // 次数刷新 this.data.buy_num = _data.buy_num; this.freshTimes(); }, // 信息刷新 freshBase: function() { let items = this.data ? this.data.item : []; for( let i = 0; i < this.nodRewards.children.length; ++i ) { let node = this.nodRewards.children[ i ]; if( node.children.length == 0 ) { let item = cc.instantiate( this.fabItem ); item.parent = node; item.position = cc.v2( 0, 0 ); } let cmp = node.children[ 0 ].getComponent( "cmp.item.base" ); cmp.setData( items[ i ][ 0 ], items[ i ][ 1 ] ); } // 价格刷新 let price = Payment.getInstance().fmtPrice( this.data.price ); nx.gui.setString( this.nodOps, "buy/txt", price ); }, // 次数刷新 freshTimes: function() { nx.gui.setString( this.nodCount, "txt", this.data.buy_num ); nx.gui.setActive( this.nodOps, "done", this.data.buy_num <= 0 ); nx.gui.setActive( this.nodOps, "buy", this.data.buy_num > 0 ); }, // 点击购买 onTouchBuy: function() { Payment.getInstance().reqPayment( this.data.charge_id ); }, } );