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

75 lines
1.7 KiB
JavaScript

/******************************************************************
*
* 精英召唤助力禮包
*
******************************************************************/
const ActPage = require( "act.page.base" );
const EliteShop = require( "act.elite.shop.mod" );
cc.Class( {
extends: ActPage,
properties: {
lstProd: { default: null, type: cc.Node },
nodDate: { default: null, type: cc.Node },
},
// 初始化
build: function( _data ) {
this._super( _data );
let model = EliteShop.getInstance();
if( !model ) {
this.delayClose();
return;
}
// 视图监听
model.vbind( this, [
[ "eliteGifts", this.onGiftsFresh.bind( this ) ],
] );
nx.gui.setActive( this.nodDate, "", false );
model.reqGiftList();
},
// 关闭
onDestroy: function() {
// 视图监听
let model = EliteShop.getInstance();
if( model ) {
model.vunbind( this );
}
},
// 礼包刷新
onGiftsFresh: function( _lst, _old, _init ) {
if( _init ) return;
// 空
if( nx.dt.arrEmpty( _lst ) ) {
nx.gui.setActive( this.lstProd, "", false );
return;
}
// 重建
nx.gui.setActive( this.lstProd, "", true );
let root = nx.gui.find( this.lstProd, "view/content" );
nx.gui.gocChildren( root, "", _lst.length, root.children[ 0 ] );
for( let i = 0; i < _lst.length; ++i ) {
let cmp = nx.gui.getComponent( root.children[ i ], "", "cmp.act.elite.gift.item" );
cmp.setData( _lst[ i ] );
}
}
} );