/****************************************************************** * * 限時特惠 * ******************************************************************/ const ActPopup = require( "act.popup.base" ); const NxSpine = require( "nx.fx.spine" ); const Payment = require( "payment.mod" ); const Mod = require( "act.limitedtimeoffer.mod" ); const themeMod = require( "acts.mod" ); const FID = require( "bridge.function.ids" ); // const ActPage = require( "act.page.base" ); cc.Class( { extends: ActPopup, properties: { nodGift : { type: cc.Node, default: null }, spRole: { default: null, type: NxSpine }, nodInfo : { default: null, type: cc.Node }, nodOp : { default: null, type: cc.Node }, }, // 初始化 onOpenConfigs: function( _params ) { this._super( _params ); this.mod = Mod.getInstance(); // 无效 if( !this.mod || !this.mod.data ) { this.delayClose(); return; } this.spRole.load( "resDB/models/H30002/show", ( _e ) => { if( !_e ) { this.spRole.action( "action1", true ); } else { this.spRole.stop(); } } ); // 活动监听 this.mod.vbind( this, [ [ "limitedtimeoffer", this.freshInfo.bind( this ) ], ] ); // // 请求信息 this.mod.reqLimitedTimeOfferData(); }, // 初始化 // build: function( _data ) { // this._super( _data ); // this.spRole.load( "resDB/models/H30002/show", ( _e ) => { // if( !_e ) { // this.spRole.action( "action1", true ); // } else { // this.spRole.stop(); // } // } ); // // 活动监听 // this.mod.vbind( this, [ // [ "limitedtimeoffer", this.freshInfo.bind( this ) ], // ] ); // // // 请求信息 // this.mod.reqLimitedTimeOfferData(); // }, onEnable(){ }, onDisable(){ }, // 销毁 onDestroy: function() { // 活动监听解除 if( this.mod ) { this.mod.vunbind( this ); } this._super(); }, freshInfo: function( _data ){ if( !_data ){ return; } let aim_list = _data.aim_list; this.limitoffer = _data; this.aims = aim_list; let gift = aim_list[0]; // 当前为1个礼包的布局,若要增加则需要加scrollview this.gift = gift; if( gift ){ nx.gui.gocChildren( this.nodGift, "", gift.item_list.length ); let chd = this.nodGift.children; for (let i = 0; i < chd.length; i++) { let nod = chd[i]; let info = gift.item_list[i]; let cmp = nod.getComponent( "cmp.item.base" ); if( cmp ){ cmp.setData( info ); } } let limit = 0; let nowbuy = 0; this.paycode = 0; let needpay = 0; let discount = 0; let pay = 0; gift.aim_args.forEach( _arg => { switch( _arg.aim_args_key ){ case 27: { pay = _arg.aim_args_val } break; case 26: { needpay = _arg.aim_args_val } break; case 4: { limit = _arg.aim_args_val } break; case 5: { nowbuy = _arg.aim_args_val } break; case 25: { discount = _arg.aim_args_val } break; case 33: { this.paycode = _arg.aim_args_val } break; } } ); let showNum = 0; if( nowbuy == 0 ){ showNum = limit; } nx.gui.setString( this.nodOp, "limit/count", ( showNum + "/" + limit ) ); nx.gui.setString( this.nodOp, "cost", Payment.getInstance().fmtPrice( needpay ) ); nx.gui.setString( this.nodOp, "buy/txt", Payment.getInstance().fmtPrice( pay ) ); let btn = nx.gui.getComponent( this.nodOp, "buy", cc.Button ); if( btn ){ btn.interactable = limit != nowbuy; nx.gui.setOutlineColor( this.nodOp, "buy/txt", limit != nowbuy ? new cc.color( "#b85833" ) : cc.Color.BLACK ); } nx.gui.setActive( this.nodOp, "limit", false ); } let left = _data.remain_sec > 0 ? _data.remain_sec : 0.1; nx.gui.setCdTxt( this.nodInfo, "time", left, () => { nx.gui.setString( this.nodInfo, "time", nx.text.getKey( "lab_planesafk_main_have_over" ) ); } ); }, onTouchBuy: function( _btn ){ if( this.limitoffer.remain_sec == 0 ){ nx.tbox( "lab_recruit_hero_window_tip_6" ); return; } if( this.gift.status != 0 ){ nx.tbox( "lab_ladder_main_window_tip4" ); return; } Payment.getInstance().reqPayment( this.paycode ); }, } );