83 lines
2.3 KiB
JavaScript
83 lines
2.3 KiB
JavaScript
|
|
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* 精英召唤排行项
|
|
*
|
|
* 2018.05.18
|
|
******************************************************************/
|
|
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
|
const ItemLayout = require( "cmp.item.layout" );
|
|
const EliteRank = require( "cmp.act.elite.rank.wnd" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: SVCItem,
|
|
|
|
properties: {
|
|
rankWnd: { default: null, type: EliteRank },
|
|
nodRank: { default: null, type: cc.Node },
|
|
nodTimes: { default: null, type: cc.Node },
|
|
nodAvatar: { default: null, type: cc.Node },
|
|
nodName: { default: null, type: cc.Node },
|
|
nodRewards: { default: null, type: ItemLayout },
|
|
},
|
|
|
|
// 数据重置
|
|
rebind: function( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
|
|
if( nx.dt.objEmpty( _data ) ) {
|
|
return;
|
|
}
|
|
|
|
// 设置
|
|
this.setData( _data );
|
|
},
|
|
|
|
// 设置
|
|
setData: function( _data ) {
|
|
|
|
// 排行
|
|
if( _data.idx < 4 ){
|
|
nx.gui.setActive( this, "rank_" + _data.idx , true );
|
|
}
|
|
|
|
this.nodRank = nx.gui.find( this, "rank_4" );
|
|
nx.gui.setString( this.nodRank, "txt", ( _data.idx > 3 ) ? _data.idx : "" );
|
|
nx.gui.setActive( this.nodRank, "" , _data.idx >= 4 );
|
|
|
|
// 头像
|
|
if( nx.dt.numPositive( _data.face_id, false ) ) {
|
|
this.nodAvatar.active = true;
|
|
nx.bridge.setAvatarByFaceId( this.nodAvatar, "mask/img", _data.face_id );
|
|
} else {
|
|
this.nodAvatar.active = false;
|
|
}
|
|
|
|
// 名字
|
|
nx.gui.setString( this.nodName, "", _data.name || "" );
|
|
|
|
// 次数
|
|
nx.gui.setString( this.nodTimes, "", _data.val1 || "" );
|
|
|
|
// 奖励
|
|
let rewards = [];
|
|
let list = this.rankWnd ? this.rankWnd.getRewards() : [];
|
|
if( nx.dt.arrNEmpty( list ) ) {
|
|
let idx = _data.idx;
|
|
for( let i = 0; i < list.length; ++i ) {
|
|
if( idx >= list[i].min && idx <= list[i].max ) {
|
|
rewards = list[i].items;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
this.nodRewards.rebuild( rewards );
|
|
|
|
},
|
|
|
|
} );
|