87 lines
2.7 KiB
JavaScript
87 lines
2.7 KiB
JavaScript
|
|
const ItemBase = require("nx.fx.sv.expand.item");
|
||
|
|
const Itemlay = require("cmp.common.itemlayout");
|
||
|
|
const ChalMod = require("act.limitChallenge.mod");
|
||
|
|
const MysteryExploreMod = require("act.mysteryexplore.mod");
|
||
|
|
const ChatController = require("chat_controller");
|
||
|
|
const RCT = require("role_controller");
|
||
|
|
cc.Class({
|
||
|
|
extends: ItemBase,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
awardList:{
|
||
|
|
default:null,
|
||
|
|
type:Itemlay
|
||
|
|
},
|
||
|
|
headNd:{
|
||
|
|
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;
|
||
|
|
nx.gui.setString(this,"name",data.info.name);
|
||
|
|
nx.gui.setString(this,"val",data.info.val1);
|
||
|
|
if(data.info.idx <= 3){
|
||
|
|
nx.gui.setActive(this,String(data.info.idx),true);
|
||
|
|
}else{
|
||
|
|
nx.gui.setActive(this,"4",true);
|
||
|
|
nx.gui.setString(this,"4/num",data.info.idx);
|
||
|
|
}
|
||
|
|
//頭像
|
||
|
|
if(!this.pHead){
|
||
|
|
this.pHead = cc.instantiate(this.fabHead);
|
||
|
|
this.pHead.parent = this.headNd;
|
||
|
|
}
|
||
|
|
let cmp = nx.gui.getComponent(this.pHead,"","cmp.common.header");
|
||
|
|
if(cmp){
|
||
|
|
cmp.setData(data.info);
|
||
|
|
cmp.addCallBack(this.touchHead.bind(this));
|
||
|
|
}
|
||
|
|
|
||
|
|
//獎勵
|
||
|
|
let cur_camp = null;
|
||
|
|
if(this.key == 51151){//迷窟探险活动,绑定主题活动,每次一种需要更换id
|
||
|
|
cur_camp = MysteryExploreMod.getInstance().getCurCamp();
|
||
|
|
}else{
|
||
|
|
cur_camp = ChalMod.getInstance().getCurCamp();
|
||
|
|
}
|
||
|
|
let base_data = data.cfg.data_info[cur_camp];
|
||
|
|
if(base_data.type == 1){
|
||
|
|
nx.gui.setColor(this,"val",new cc.Color(255,105,46));
|
||
|
|
}else if(base_data.type == 2){
|
||
|
|
nx.gui.setColor(this,"val",new cc.Color(37,132,6));
|
||
|
|
}
|
||
|
|
let infos = data.cfg.data_awards;
|
||
|
|
let all_rewards = [];
|
||
|
|
for(let i in infos){
|
||
|
|
if(infos[i].camp_id == cur_camp){
|
||
|
|
all_rewards.push(infos[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
for(let id in all_rewards){
|
||
|
|
let rdata = all_rewards[id];
|
||
|
|
if(data.info.idx >= rdata.min && data.info.idx <= rdata.max){
|
||
|
|
this.awardList.rebuild(rdata.items);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
touchHead:function(){
|
||
|
|
let MyroleVo = RCT.getInstance().getRoleVo();
|
||
|
|
if(this.mdata.info.rid == MyroleVo.rid)return;
|
||
|
|
ChatController.getInstance().openFriendInfo({srv_id :this.mdata.info.srv_id, rid :this.mdata.info.rid,name:this.mdata.info.name});
|
||
|
|
},
|
||
|
|
});
|