105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'c8d3dZfBPNOyoWtM/kqHe8R', 'cmp.item.detail.prop.base');
|
|
// Scripts/mod/backpack/cmps/cmp.item.detail.prop.base.js
|
|
|
|
"use strict";
|
|
|
|
var PathTool = require("pathtool");
|
|
var BackPackConst = require("backpack_const");
|
|
var GoodsVo = require("goods_vo");
|
|
cc.Class({
|
|
"extends": cc.Component,
|
|
properties: {
|
|
nodList: {
|
|
"default": null,
|
|
type: cc.Node,
|
|
displayName: "列表容器"
|
|
}
|
|
},
|
|
// 载入
|
|
onLoad: function onLoad() {},
|
|
// 置空
|
|
setEmpty: function setEmpty() {
|
|
nx.gui.hideAllChildren(this.nodList, "");
|
|
},
|
|
// 设置道具
|
|
// @ 返回true:需要显示
|
|
setData: function setData(_item, _config, _fromBag) {
|
|
// 全隐藏
|
|
if (!_item || !_config) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 统计主属性信息
|
|
var props = [];
|
|
if (nx.dt.arrNEmpty(_item.main_attr)) {
|
|
// 优先服务器数据
|
|
_item.main_attr.forEach(function (_p) {
|
|
var key = game.configs.attr_data.data_id_to_key[_p.attr_id];
|
|
props.push({
|
|
key: key,
|
|
id: _p.attr_id,
|
|
val: _p.attr_val
|
|
});
|
|
});
|
|
}
|
|
// 其次静态配置属性,固定位置config.ext[0][1]为main_attr
|
|
else if (nx.dt.arrNEmpty(_config.ext) && nx.dt.arrNEmpty(_config.ext[0])) {
|
|
var tmp = _config.ext[0][1];
|
|
if (nx.dt.arrNEmpty(tmp)) {
|
|
tmp.forEach(function (_p) {
|
|
var id = game.configs.attr_data.data_key_to_id[_p[0]];
|
|
props.push({
|
|
key: _p[0],
|
|
id: id,
|
|
val: _p[1]
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
// 统计精炼属性
|
|
// *** 全体缩放1000倍后走正常流程
|
|
if (nx.dt.arrNEmpty(_item.attr)) {
|
|
_item.attr.forEach(function (_p) {
|
|
var key = game.configs.attr_data.data_id_to_key[_p.attr_id];
|
|
props.push({
|
|
key: key,
|
|
id: _p.attr_id,
|
|
val: _p.attr_val / 1000
|
|
});
|
|
});
|
|
}
|
|
|
|
// 统计附加属性
|
|
// *** 全体缩放1000倍后走正常流程
|
|
if (nx.dt.arrNEmpty(_item.extra_attr)) {
|
|
_item.extra_attr.forEach(function (_p) {
|
|
var key = game.configs.attr_data.data_id_to_key[_p.attr_id];
|
|
props.push({
|
|
key: key,
|
|
id: _p.attr_id,
|
|
val: _p.attr_val / 1000
|
|
});
|
|
});
|
|
}
|
|
|
|
// 空属性
|
|
if (nx.dt.arrEmpty(props)) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 列表创建
|
|
var chds = this.nodList.children;
|
|
nx.gui.gocChildren(this.nodList, "", props.length, chds[0]);
|
|
for (var i = 0; i < props.length; ++i) {
|
|
// setProp( chds[ i ], props[ i ] );
|
|
typeof _fromBag === 'string' ? nx.bridge.attrs.setAttribute(nx.gui.find(chds[i], "info"), [props[i].key, props[i].val]) : nx.bridge.attrs.setAttribute(nx.gui.find(chds[i], "info"), [props[i].key, props[i].val, i + 1]);
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |