103 lines
3.2 KiB
JavaScript
103 lines
3.2 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '64bb58UcFRJ6LjTOHgrM4v3', 'cmp.item.detail.header');
|
||
|
|
// Scripts/mod/backpack/cmps/cmp.item.detail.header.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var BackPackConst = require("backpack_const");
|
||
|
|
var HeroCalculate = require("hero_calculate");
|
||
|
|
var GoodsVo = require("goods_vo");
|
||
|
|
cc.Class({
|
||
|
|
"extends": cc.Component,
|
||
|
|
properties: {},
|
||
|
|
// 载入
|
||
|
|
onLoad: function onLoad() {},
|
||
|
|
// 置空
|
||
|
|
setEmpty: function setEmpty() {
|
||
|
|
nx.gui.setActive(this, "empty", true);
|
||
|
|
nx.gui.setActive(this, "content", false);
|
||
|
|
},
|
||
|
|
// 设置道具
|
||
|
|
// @ 返回true:需要显示
|
||
|
|
setData: function setData(_item, _config, _fromBag) {
|
||
|
|
// 全隐藏
|
||
|
|
if (!_item || !_config) {
|
||
|
|
this.setEmpty();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
nx.gui.setActive(this, "empty", false);
|
||
|
|
var content = nx.gui.setActive(this, "content", true);
|
||
|
|
|
||
|
|
// 名字
|
||
|
|
nx.gui.setString(content, "name", nx.text.getKey(_config.name));
|
||
|
|
|
||
|
|
// 类型
|
||
|
|
nx.gui.setString(content, "type/txt", nx.text.getKey(_config.type_desc));
|
||
|
|
|
||
|
|
// 品质
|
||
|
|
var qa = _item.quality || _config.quality;
|
||
|
|
var path = cc.path.join("coms/images", "bar_qa" + qa);
|
||
|
|
var qa_path = cc.path.join("coms/images", "bg_qa" + qa);
|
||
|
|
nx.gui.setSpriteFrame(content, "bg", path);
|
||
|
|
if (typeof _fromBag === 'string') {
|
||
|
|
if (_fromBag == "bag") {
|
||
|
|
nx.gui.setSpriteFrame(content, "qa", "");
|
||
|
|
} else {
|
||
|
|
nx.gui.setSpriteFrame(content, "qa", "");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 图标
|
||
|
|
nx.bridge.setIcon(content, "qa/icon", _config.icon);
|
||
|
|
|
||
|
|
// 星级
|
||
|
|
var star = _config.eqm_star || _config.eqm_jie;
|
||
|
|
var good = nx.dt.numPositive(star, false);
|
||
|
|
if (good) {
|
||
|
|
path = cc.path.join("coms/images", "star" + star);
|
||
|
|
nx.gui.setSpriteFrame(content, "qa/stars", path);
|
||
|
|
} else {
|
||
|
|
nx.gui.setSpriteFrame(content, "qa/stars", null);
|
||
|
|
}
|
||
|
|
|
||
|
|
// 附加说明
|
||
|
|
var vars = nx.gui.hideAllChildren(content, "vars");
|
||
|
|
if (vars) {
|
||
|
|
var new_score = 0;
|
||
|
|
if (nx.dt.arrNEmpty(_item.holy_eqm_attr) && typeof _fromBag === 'string' && _fromBag == "partner") {
|
||
|
|
var holy_eqm_attr = _item.holy_eqm_attr;
|
||
|
|
var new_holy_eqm_attr = [];
|
||
|
|
for (var i = 0; i < holy_eqm_attr.length; i++) {
|
||
|
|
var attr = holy_eqm_attr[i];
|
||
|
|
if (attr) {
|
||
|
|
var title = game.configs.attr_data.data_id_to_key[attr.attr_id];
|
||
|
|
new_holy_eqm_attr.push({
|
||
|
|
attr_key: title,
|
||
|
|
attr_val: attr.attr_val
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
new_score = HeroCalculate.getInstance().holyEquipMentPower(new_holy_eqm_attr) || 0;
|
||
|
|
}
|
||
|
|
// 评分
|
||
|
|
var score = _item.all_score + new_score || _config.all_score + new_score;
|
||
|
|
if (nx.dt.numPositive(score, false)) {
|
||
|
|
nx.gui.setActive(vars, "score", true);
|
||
|
|
nx.gui.setString(vars, "score/txt", score);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// UseType描述头区分
|
||
|
|
var tdesc = _config.use_desc;
|
||
|
|
if (nx.dt.strNEmpty(tdesc)) {
|
||
|
|
nx.gui.setActive(vars, "use", true);
|
||
|
|
var elfin = _config.type == BackPackConst.item_type.ELFIN;
|
||
|
|
nx.gui.setString(vars, "use/tip", nx.text.getKey(elfin ? "UseElfin" : "UseTo"));
|
||
|
|
nx.gui.setString(vars, "use/txt", nx.text.getKey(tdesc));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|