45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
|
|
const ItemBase = require("nx.fx.sv.expand.item");
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
extends: ItemBase,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
tagHead:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
fabHead:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Prefab
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
rebind(_index,_data,_key){
|
||
|
|
this._super(_index,_data,_key);
|
||
|
|
this.setData(_data);
|
||
|
|
},
|
||
|
|
|
||
|
|
setData(data){
|
||
|
|
if(nx.dt.objEmpty(data)){
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let selfhead = cc.instantiate(this.fabHead);
|
||
|
|
selfhead.parent = this.tagHead;
|
||
|
|
let cmp = nx.gui.getComponent(selfhead,"","cmp.common.header");
|
||
|
|
if(cmp){
|
||
|
|
cmp.setData(data);
|
||
|
|
}
|
||
|
|
nx.gui.setString(this.node,"name",data.name);
|
||
|
|
nx.gui.setString(this.node,"stars",data.star);
|
||
|
|
nx.gui.setString(this.node,"achi",data.war_score);
|
||
|
|
if(data.rank < 4){
|
||
|
|
nx.gui.setActive(this.node,String(data.rank),true);
|
||
|
|
}else{
|
||
|
|
let nod = nx.gui.find( this.node, "4" );
|
||
|
|
nx.gui.setActive(nod,"",true);
|
||
|
|
nx.gui.setString(nod,"num",data.rank);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
});
|