Files
fc/dev/project/assets/Scripts/mod/acts/exchange/cmp.act.exchange.wnd.js
T

119 lines
3.1 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const FxSVC = require( "nx.fx.sv.expand" );
const BasePage = require( "act.page.base" );
const NxSpine = require( "nx.fx.spine" );
cc.Class({
extends: BasePage,
properties: {
svcshopLst : { default: null, type : FxSVC, displayName: "商城列表",},
nodEndTime: { default: null, type : cc.Node, displayName: "結束時間",},
nodRole: { default: null, type : NxSpine, displayName: "結束時間",},
},
build: function( _data ) {
this._super( _data );
// console.log( "當前的相關數據顯示" + JSON.stringify( _data ) );
// 获取指定主题信息
if( !this.mod ){
return;
}
// let list = this.mod.getExchangeInfo();
let extra = this.mod.getExtraInfo();
let free = this.mod.getFreeInfo();
let rolepath = nx.dt.objEmpty( extra ) ? "H30117": extra.model;
let finalpath = "resDB/models/" + rolepath + "/show";
let action = nx.dt.objEmpty( extra ) ? "action1": extra.act;
let fidd = nx.gui.getComponent( this, "panel/mat", "bridge.binder.item.icon.count" );
let fiddc = nx.gui.getComponent( this, "panel/matc", "bridge.binder.item.icon.count" );
if( fidd ){
fidd.setID( extra.item1 );
}
if( fiddc ){
fiddc.setID( extra.item2 );
}
this.nodRole.load( finalpath, ( _e ) => {
if( !_e ) {
this.nodRole.action( action, true );
} else {
this.nodRole.stop();
}
} );
let cmp = nx.gui.getComponent( this, "panel/free/item", "cmp.item.base" );
if( cmp && free ){
cmp.setData( free[0] );
}
nx.gui.setString( this.nodEndTime, "txt", nx.bridge.time.toNeedTime( this.mod.data.end_time ) );
nx.gui.setActive( this, "panel/warn", ( this.mod.data.end_time - Math.floor( cc.sys.now() / 1000 ) ) <= 86400 )
this.mod.vbind( this, [
[ "exchangeInfo", this.freshInfo.bind( this ) ],
] )
},
onEnable: function(){
this.mod.reqBaseInfo( this.mod.data.camp_id );
},
// 销毁
onDestroy: function() {
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
this._super();
},
freshInfo: function( _data ){
if( !_data ){
return;
}
// 刷新顯示
let list = nx.dt.arrEmpty( _data.gift_buy_info ) ? this.mod.getExchangeInfo() : _data.gift_buy_info;
nx.dt.arrEmpty( _data.gift_buy_info ) ? list.sort( Utils.tableLowerSorter( ["order"] ) ) : list.sort( Utils.tableLowerSorter( ["id"] ) );
this.svcshopLst.rebuild( list );
nx.gui.setActive( this, "panel/empty", nx.dt.arrEmpty( list ) );
nx.gui.setActive( this, "panel/free", _data.is_free == 0 );
},
// 兌換
onTouchExChange: function( _nod ){
let info = _nod;
this.mod.reqExchange( info.mdata.order || info.mdata.id )
},
// 兌換
onTouchGetFree: function(){
this.mod.reqGetFree();
},
});