147 lines
3.9 KiB
JavaScript
147 lines
3.9 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 精英召唤排行榜界面
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeWindow = require( "bridge.window" );
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
|
const EliteMod = require( "act.elite.mod" );
|
|
const FxTogs = require( "nx.fx.togs" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
togMenu: { default: null, type: FxTogs },
|
|
svcList: { default: null, type: FxSVC },
|
|
nodSelf: { default: null, type: cc.Node },
|
|
nodEmpty: { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function( _params ) {
|
|
|
|
// 缓存数据
|
|
this.cache1 = null;
|
|
this.cache2 = null;
|
|
|
|
this.setEmpty();
|
|
|
|
// Tog监听
|
|
this.togMenu.posTog = this.onTogMenu.bind( this );
|
|
this.togMenu.togTo( 0 );
|
|
this.onTogMenu( 0 );
|
|
},
|
|
|
|
// 获取当前配置
|
|
getRewards: function() {
|
|
const DATA = game.configs.recruit_holiday_lucky_data;
|
|
return this.today ? DATA.data_day_rank_reward : DATA.data_rank_reward;
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
|
|
// 制作演示数据
|
|
let rewards = this.getRewards();
|
|
if( nx.dt.arrEmpty( rewards ) ) {
|
|
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 < rewards.length; ++i ) {
|
|
if( _idx >= rewards[ i ].min && _idx <= rewards[ i ].max ) {
|
|
t.rewards = rewards[ i ].items;
|
|
break;
|
|
}
|
|
}
|
|
args.push( t );
|
|
};
|
|
for( let i = 1; i <= 10; ++i ) {
|
|
push( i );
|
|
}
|
|
|
|
nx.gui.setActive( this.nodSelf, "", false );
|
|
this.freshRank( { my_idx: 0, rank_list: args } );
|
|
|
|
},
|
|
|
|
// 刷新排行榜
|
|
freshRank: function( _data ) {
|
|
|
|
if( nx.dt.objEmpty( _data ) ||
|
|
nx.dt.arrEmpty( _data.rank_list ) ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
nx.gui.setActive( this.nodEmpty, "", false );
|
|
|
|
// 列表
|
|
nx.gui.setActive( this.svcList, "", true );
|
|
this.svcList.rebuild( _data.rank_list );
|
|
|
|
let node = nx.gui.setActive( this.nodSelf, "", true );
|
|
if( _data.my_idx == 0 ) {
|
|
nx.gui.setActive( node, "empty", true );
|
|
nx.gui.setActive( node, "normal", false );
|
|
nx.gui.setString( node, "empty/tip", nx.text.getKey( _data.tip || "StepUpNoRank" ) );
|
|
return;
|
|
}
|
|
|
|
nx.gui.setActive( node, "empty", false );
|
|
nx.gui.setActive( node, "normal", true );
|
|
let cmp = nx.gui.getComponent( node, "normal", "cmp.act.elite.rank.item" );
|
|
if( cmp ) {
|
|
cmp.setData( {
|
|
idx: _data.my_idx,
|
|
face_id: _data.face_id,
|
|
name: _data.name,
|
|
val1: _data.my_val1,
|
|
} );
|
|
}
|
|
|
|
},
|
|
|
|
// 等级切换
|
|
onTogMenu: function( _index ) {
|
|
|
|
this.today = ( _index == 0 );
|
|
|
|
let model = EliteMod.getInstance();
|
|
if( !model ) {
|
|
return;
|
|
}
|
|
|
|
let cache = this.today ? this.cache1 : this.cache2;
|
|
if( nx.dt.objNEmpty( cache ) ) {
|
|
this.freshRank( cache );
|
|
return;
|
|
}
|
|
|
|
model.reqRankList( this.today, ( _ret, _data ) => {
|
|
|
|
if( !_ret ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
if( this.today ) {
|
|
this.cache1 = _data;
|
|
} else {
|
|
this.cache2 = _data;
|
|
}
|
|
|
|
this.freshRank( _data );
|
|
} );
|
|
},
|
|
|
|
} );
|