93 lines
2.7 KiB
JavaScript
93 lines
2.7 KiB
JavaScript
|
|
|
||
|
|
/******************************************************************
|
||
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
||
|
|
*
|
||
|
|
* StepUp排行项
|
||
|
|
*
|
||
|
|
* 2018.05.18
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const SVCItem = require( "nx.fx.sv.expand.item" );
|
||
|
|
const ItemLayout = require( "cmp.item.layout" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: SVCItem,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
nodRank: { default: null, type: cc.Node },
|
||
|
|
nodBP: { 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 ) {
|
||
|
|
|
||
|
|
// 排行
|
||
|
|
let bg = "rank_26";
|
||
|
|
let img = "rank_12";
|
||
|
|
if( _data.idx < 4 ){
|
||
|
|
nx.gui.setActive( this, "rank_" + _data.idx , true );
|
||
|
|
}
|
||
|
|
|
||
|
|
this.nodRank = nx.gui.find( this, "rank_4" );
|
||
|
|
// switch( _data.idx ) {
|
||
|
|
// case 1: { } break;
|
||
|
|
// case 2: { nx.gui.setActive( this, "rank_" + _data.idx , true ); } break;
|
||
|
|
// case 3: { nx.gui.setActive( this, "rank_" + _data.idx , true ); } break;
|
||
|
|
// default: break;
|
||
|
|
// }
|
||
|
|
// bg = cc.path.join( "prefab/rank/ui", bg );
|
||
|
|
// img = cc.path.join( "prefab/rank/ui", img );
|
||
|
|
// nx.gui.setSpriteFrame( this.nodRank, "", bg );
|
||
|
|
// nx.gui.setSpriteFrame( this.nodRank, "img", img );
|
||
|
|
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 || "" );
|
||
|
|
|
||
|
|
// BP
|
||
|
|
nx.gui.setString( this.nodBP, "", _data.val1 || "" );
|
||
|
|
|
||
|
|
// 奖励
|
||
|
|
let rewards = [];
|
||
|
|
const DATA = game.configs.step_up_recruit_data.data_awards;
|
||
|
|
if( nx.dt.arrNEmpty( DATA ) ) {
|
||
|
|
let idx = _data.idx;
|
||
|
|
for( let i = 0; i < DATA.length; ++i ) {
|
||
|
|
if( idx >= DATA[i].min && idx <= DATA[i].max ) {
|
||
|
|
rewards = DATA[i].items;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
this.nodRewards.rebuild( rewards );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|