59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
const ItemBase = require("nx.fx.sv.expand.item");
|
|
const ItemLay = require("cmp.common.itemlayout");
|
|
const HEACT = require("heaven_controller");
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
items:{
|
|
default:null,
|
|
type:ItemLay
|
|
},
|
|
desc:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
btnGet:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
ndGot:{
|
|
default:null,
|
|
type:cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
rebind(_index,_data,_key){
|
|
this._super(_index,_data,_key);
|
|
this.setData(_data);
|
|
},
|
|
|
|
setData(data){
|
|
if(nx.dt.objEmpty(data)){
|
|
this.items.rebuild([]);
|
|
return;
|
|
}
|
|
this.items.rebuild(data.award);
|
|
let chapter_data = HEACT.getInstance().getModel().getChapterDataById(data.id);
|
|
let award_info = chapter_data.award_info;
|
|
if(award_info){
|
|
for(let i in award_info){
|
|
if(award_info[i].id == data.award_id){
|
|
nx.gui.setActive(this.btnGet,"",award_info[i].flag == 1);
|
|
nx.gui.setActive(this.ndGot,"",award_info[i].flag == 2);
|
|
}
|
|
}
|
|
}
|
|
nx.gui.setString(this.desc,"",cc.js.formatStr(nx.text.getKey("HeaChapStars"),data.limit_star,chapter_data.all_star,data.limit_star));
|
|
},
|
|
|
|
clickAward(){
|
|
if(!this.mdata)return;
|
|
|
|
HEACT.getInstance().sender25215(this.mdata.id,this.mdata.award_id);
|
|
},
|
|
|
|
// update (dt) {},
|
|
});
|