99 lines
2.5 KiB
JavaScript
99 lines
2.5 KiB
JavaScript
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* STEP-UP 排行页
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeComponent = require( "bridge.component" );
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
|
const STModel = require( "act.stepup.mod" );
|
|
const TDefine = require( "trace.define" );
|
|
const TTT = TDefine.TraceType;
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeComponent,
|
|
|
|
properties: {
|
|
|
|
autoReq: { default: true },
|
|
svcList: { default: null, type: FxSVC },
|
|
nodSelf: { default: null, type: cc.Node },
|
|
nodEmpty: { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
|
|
if( !this.autoReq ) {
|
|
return;
|
|
}
|
|
|
|
STModel.getInstance().reqRankList( ( _ret, _data ) => {
|
|
|
|
if( !_ret ) {
|
|
nx.tbox( _data );
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
this.freshRank( _data );
|
|
} );
|
|
|
|
// 埋点
|
|
if( nx.mTrace ) {
|
|
nx.mTrace.trace( TTT.actCampOpened, STModel.getInstance().data.camp_id, 1 );
|
|
}
|
|
},
|
|
|
|
// 关闭
|
|
onDisable: function() {
|
|
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
nx.gui.setActive( this.svcList, "", false );
|
|
nx.gui.setActive( this.nodSelf, "", false );
|
|
nx.gui.setActive( this.nodEmpty, "", true );
|
|
},
|
|
|
|
// 刷新排行榜
|
|
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.stepup.rank.item" );
|
|
if( cmp ) {
|
|
cmp.setData( {
|
|
idx: _data.my_idx,
|
|
face_id: _data.face_id,
|
|
name: _data.name,
|
|
val1: _data.my_val1,
|
|
} );
|
|
}
|
|
|
|
},
|
|
|
|
} );
|