94 lines
2.7 KiB
JavaScript
94 lines
2.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '26c4ccw3wpHsrXNq3627hmv', 'cmp.act.limitchallenge.rank.item');
|
|
// Scripts/mod/acts/limitChallenge/cmp/cmp.act.limitchallenge.rank.item.js
|
|
|
|
"use strict";
|
|
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
|
var Itemlay = require("cmp.common.itemlayout");
|
|
var ChalMod = require("act.limitChallenge.mod");
|
|
var MysteryExploreMod = require("act.mysteryexplore.mod");
|
|
var ChatController = require("chat_controller");
|
|
var 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: function rebind(_index, _data, _key) {
|
|
this._super(_index, _data, _key);
|
|
this.setData(_data);
|
|
},
|
|
setData: function 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;
|
|
}
|
|
var cmp = nx.gui.getComponent(this.pHead, "", "cmp.common.header");
|
|
if (cmp) {
|
|
cmp.setData(data.info);
|
|
cmp.addCallBack(this.touchHead.bind(this));
|
|
}
|
|
|
|
//獎勵
|
|
var cur_camp = null;
|
|
if (this.key == 51151) {
|
|
//迷窟探险活动,绑定主题活动,每次一种需要更换id
|
|
cur_camp = MysteryExploreMod.getInstance().getCurCamp();
|
|
} else {
|
|
cur_camp = ChalMod.getInstance().getCurCamp();
|
|
}
|
|
var 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));
|
|
}
|
|
var infos = data.cfg.data_awards;
|
|
var all_rewards = [];
|
|
for (var i in infos) {
|
|
if (infos[i].camp_id == cur_camp) {
|
|
all_rewards.push(infos[i]);
|
|
}
|
|
}
|
|
for (var id in all_rewards) {
|
|
var rdata = all_rewards[id];
|
|
if (data.info.idx >= rdata.min && data.info.idx <= rdata.max) {
|
|
this.awardList.rebuild(rdata.items);
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
touchHead: function touchHead() {
|
|
var 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
|
|
});
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |