Files
fc/dev/project/assets/Scripts/mod/acts/exclusive/cmp/cmp.act.exclusive.wnd.js
T
2026-05-23 22:10:14 +08:00

182 lines
5.7 KiB
JavaScript

/******************************************************************
*
* 新服专享
*
******************************************************************/
const ActPage = require( "act.page.base" );
const Mod = require( "act.exclusive.mod" );
const NxSpine = require( "nx.fx.spine" );
const Payment = require( "payment.mod" );
const themeMod = require( "acts.mod" );
const max = 4;
const FID = require( "bridge.function.ids" );
cc.Class( {
extends: ActPage,
properties: {
nodGift : { type: cc.Node, default: null },
spRole: { default: null, type: NxSpine },
nodEndTime : { default: null, type: cc.Node },
},
// 初始化
build: function( _data ) {
this._super( _data );
// 无效
this.spRole.load( "resDB/models/H30021/show", ( _e ) => {
if( !_e ) {
this.spRole.action( "drama1", true );
} else {
this.spRole.stop();
}
} );
// 活动监听
this.mod.vbind( this, [
[ "exclusive", this.freshGift.bind( this ) ],
] );
},
onEnable: function(){
// 请求信息
this.mod.reqExclusiveData();
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
this._super();
},
freshGift: function( _data ){
this.exclusive = _data;
if( !this.exclusive ){
return;
}
this.cost = [];
let left = this.exclusive.remain_sec != 0 ? this.exclusive.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.exclusive.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"] ) );
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 giftCost = giftInfo.aim_args;
let num = giftInfo.status;
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;
nx.gui.setString( nod, "limit", nx.text.format( "BuyLimit", showNum, _arg.aim_args_val ) );
}
if( _arg.aim_args_key == 26 ){
price = _arg.aim_args_val;
}
if( _arg.aim_args_key == 27 && _arg.aim_args_val != price && price != 0 ){
disPrice = _arg.aim_args_val;
}
});
nx.gui.setActive( nod, "op/tip", false );
this.cost.push( price );
nx.gui.setString( nod, "title", giftInfo.aim_str );
let btn = nx.gui.getComponent( nod, "op", cc.Button );
if( btn ){
btn.interactable = price != 0 ? giftInfo.status == 0 : giftInfo.status == 1 ;
if( price != 0 ){
nx.gui.setOutlineColor( nod, "op/num", giftInfo.status == 0 ? new cc.color( "#B85833" ) : cc.Color.BLACK );
}else{
nx.gui.setActive( nod, "op/tip", disPrice == 0 && giftInfo.status == 1 );
nx.gui.setOutlineColor( nod, "op/num", giftInfo.status == 1 ? new cc.color( "#B85833" ) : cc.Color.BLACK );
}
}
let path = i < max ? "prefab/acts/exclusive/ui/zhuanxiang_0" + ( 4 + i ) : "prefab/acts/exclusive/ui/zhuanxiang_08";
nx.gui.setSpriteFrame( nod, "icon", path );
let cmp = nx.gui.getComponent( nod, "list", "cmp.common.itemlayout" );
if( cmp ){
cmp.rebuild( giftInfo.item_list );
}
nod.zIndex = i;
nx.gui.setString( nod, "op/num", price == 0 ? nx.text.getKey( "Free" ) : Payment.getInstance().fmtPrice( price ) );
}
}
},
onTouchBuy: function( _btn ){
if( this.exclusive.remain_sec == 0 ){
nx.tbox( "lab_recruit_hero_window_tip_6" );
return;
}
let number = _btn.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.cost[number] == 0 ){
this.mod.reqExclusiveGift( aim );
return;
}
Payment.getInstance().reqPayment( aim );
// this.mod.reqExclusiveGift( this.exclusive.bid, aim );
},
// close: function(){
// let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
// nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
// this._super();
// },
} );