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

85 lines
2.1 KiB
JavaScript

/******************************************************************
*
* STEPUP 排行榜界面
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const CmpRank = require( "cmp.act.stepup.rank" );
const STModel = require( "act.stepup.mod" );
cc.Class( {
extends: BridgeWindow,
properties: {
cmpRank: { default: null, type: CmpRank },
},
// 展示
onEnable: function( ) {
nx.gui.setActive( this.nodEmpty, "", false );
nx.gui.setActive( this.svcList, "", true );
nx.gui.setActive( this.nodSelf, "", true );
STModel.getInstance().reqRankList( ( _ret, _data ) => {
if( !_ret ) {
this.setEmpty();
return;
}
this.freshRank( _data );
} );
},
// 置空
setEmpty: function() {
// 制作演示数据
const DATA = game.configs.step_up_recruit_data.data_awards;
if( nx.dt.arrEmpty( DATA ) ) {
nx.gui.setActive( this.nodEmpty, "", true );
nx.gui.setActive( this.svcList, "", false );
nx.gui.setActive( this.nodSelf, "", false );
return;
}
let args = [];
let push = function( _idx ) {
let t = { idx: _idx, face_id: 0, rewards: [] };
for( let i = 0; i < DATA.length; ++i ) {
if( _idx >= DATA[i].min && _idx <= DATA[i].max ) {
t.rewards = DATA[i].items;
break;
}
}
args.push( t );
};
for( let i = 1; i <= 10; ++i ) {
push( i );
}
this.cmpRank.freshRank( {
my_idx: 0,
fact_id: 0,
rank_list: args,
tip: "StepUpRankWait",
} );
},
// 刷新排行榜
freshRank: function( _data ) {
if( nx.dt.objEmpty( _data ) || nx.dt.arrEmpty( _data.rank_list ) ) {
this.setEmpty();
return;
}
this.cmpRank.freshRank( _data );
},
} );