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

138 lines
4.5 KiB
JavaScript

/******************************************************************
*
* 新服纍充
*
******************************************************************/
const ActPage = require( "act.page.base" );
const NxSpine = require( "nx.fx.spine" );
const Mod = require( "act.accumulative.mod" );
const themeMod = require( "acts.mod" );
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/H30097/show", ( _e ) => {
if( !_e ) {
this.spRole.action( "action1", true );
} else {
this.spRole.stop();
}
} );
// 活动监听
this.mod.vbind( this, [
[ "accumulative", this.freshGift.bind( this ) ],
] );
},
onEnable: function(){
// 请求信息
this.mod.reqAccumulativeData();
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
delete this.mod;
this._super();
},
freshGift: function( _data ){
this.accumulative = _data;
if( !this.accumulative ){
return;
}
let left = this.accumulative.remain_sec != 0 ? this.accumulative.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.accumulative.aim_list;
this.gifts.sort( ( a, b ) => {
return a.aim - b.aim;
} )
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 ){
nx.gui.setStringRich( nod, "cnt/title", giftInfo.aim_str );
let cmp = nx.gui.getComponent( nod, "cnt/list", "cmp.common.itemlayout" );
if( cmp ){
cmp.rebuild( giftInfo.item_list );
}
nod.zIndex = i;
/**{"aim":21,"aim_str":"累充21圓",
* "status":1,"item_list":[{"bid":3,"num":50},{"bid":10403,"num":1},{"bid":10002,"num":5}],
* "aim_args":[]}* */
nx.gui.setStringRich( nod, "cnt/show", nx.text.format( "ChargeShow", this.accumulative.finish, giftInfo.aim ) );
nx.gui.setActive( nod, "cnt/charge", giftInfo.status == 0 );
nx.gui.setActive( nod, "cnt/get", giftInfo.status != 0 );
let btn = nx.gui.getComponent( nod, "cnt/get", cc.Button );
if( btn ){
btn.interactable = giftInfo.status == 1;
nx.gui.setActive( nod, "cnt/get/tip", giftInfo.status == 1 );
giftInfo.status == 1 ? nx.gui.setOutlineColor( nod, "cnt/get/num", new cc.color( "#b85833" ) ) : nx.gui.setOutlineColor( nod, "cnt/get/num", cc.Color.BLACK );
giftInfo.status == 1 ? nx.gui.setString( nod, "cnt/get/num", nx.text.getKey( "Get" ) ) : nx.gui.setString( nod, "cnt/get/num", nx.text.getKey( "Got" ) );
}
}
}
},
onTouchBuy: function( _btn ){
if( this.accumulative.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 == 2 ){
let show = nx.text.getKey( "ReWards" ) + nx.text.getKey( "Got" );
nx.tbox( show );
return;
}
this.mod.reqAccumulativeGift( this.accumulative.bid, aim );
},
onTouchCharge: function(){
nx.bridge.createPanel( "WndPayment", { key: "recharge" } );
},
// close: function(){
// let theme = themeMod.getInstance().queryTheme( this.mod.data.theme_id );
// nx.bridge.jumper.jump2Window( FID.ActOpenServer, theme );
// this._super();
// },
} );