177 lines
5.1 KiB
JavaScript
177 lines
5.1 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'd900fkxWExPqKLTqq87UIvc', 'cmp.item.detail.source');
|
|
// Scripts/mod/backpack/cmps/cmp.item.detail.source.js
|
|
|
|
"use strict";
|
|
|
|
var PathTool = require("pathtool");
|
|
var GoodsVo = require("goods_vo");
|
|
var HeroController = require("hero_controller");
|
|
var TipsController = require("tips_controller");
|
|
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) {
|
|
this.fromBag = _fromBag;
|
|
// 全隐藏
|
|
if (!_item || !_config || !_config.source) {
|
|
this.setEmpty();
|
|
return false;
|
|
}
|
|
|
|
// 获取配置
|
|
this.item = _item;
|
|
this.config = _config;
|
|
var final_list = [];
|
|
var source_list = _config.source;
|
|
if (source_list) {
|
|
var list = [];
|
|
for (var i in source_list) {
|
|
var data = game.configs.source_data.data_source_data[source_list[i][0]];
|
|
if (data && data.evt_type != "evt_league_help") {
|
|
//帮内求助特殊处理下 只出现在特定场合
|
|
list.push(source_list[i]);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
for (var _i in list) {
|
|
var _data = game.configs.source_data.data_source_data[list[_i][0]];
|
|
var source_info = this.getSourceInfo(_data.lev_limit);
|
|
if (source_info) {
|
|
var val = {};
|
|
val.infon_data = _data;
|
|
val.is_lock = source_info.is_lock;
|
|
val.index = _i;
|
|
final_list.push(val);
|
|
}
|
|
}
|
|
final_list.sort(Utils.tableLowerSorter(["is_lock"]));
|
|
}
|
|
|
|
// 属性设置
|
|
var setProp = function setProp(_node, _prop) {
|
|
if (!_node || nx.dt.objEmpty(_prop)) {
|
|
return;
|
|
}
|
|
nx.gui.setString(_node, "name", _prop.infon_data.name);
|
|
_node.zIndex = _prop.index;
|
|
nx.gui.setActive(_node, "on", _prop.is_lock);
|
|
nx.gui.setActive(_node, "off", !_prop.is_lock);
|
|
};
|
|
|
|
// 判空
|
|
if (nx.dt.arrEmpty(final_list)) {
|
|
return false;
|
|
}
|
|
|
|
// 列表创建
|
|
this.props = final_list;
|
|
this.props.sort(function (a, b) {
|
|
return a.index - b.index;
|
|
});
|
|
var chds = this.nodList.children;
|
|
nx.gui.gocChildren(this.nodList, "", this.props.length, chds[0]);
|
|
for (var _i2 = 0; _i2 < this.props.length; ++_i2) {
|
|
setProp(chds[_i2], this.props[_i2]);
|
|
}
|
|
return true;
|
|
},
|
|
// 点击前往
|
|
onTouchGoto: function onTouchGoto(_btn) {
|
|
if (this.fromBag == "partner") {
|
|
HeroController.getInstance().openEquipChangePanel(false);
|
|
}
|
|
if (this.props && !this.props[_btn.parent.zIndex]) return;
|
|
if (this.fromBag == "tips") {
|
|
TipsController.getInstance().showItemTips();
|
|
}
|
|
// nx.bridge.cleanPanels();
|
|
nx.bridge.jumper.jump2Window(this.props[_btn.parent.zIndex].infon_data.id);
|
|
},
|
|
getSourceInfo: function getSourceInfo(data) {
|
|
var source_info = {};
|
|
if (!data || !data[0]) {
|
|
source_info.is_lock = true;
|
|
return source_info;
|
|
}
|
|
source_info.is_lock = false;
|
|
switch (data[0]) {
|
|
case "dungeon":
|
|
{
|
|
// 关卡等级
|
|
var BattleDramaController = require("battle_drama_controller");
|
|
var battle_drama_ctrl = BattleDramaController.getInstance();
|
|
var drama_data = battle_drama_ctrl.getModel().getDramaData();
|
|
if (drama_data && data[1]) {
|
|
if (drama_data.max_dun_id >= data[1]) {
|
|
source_info.is_lock = true;
|
|
}
|
|
}
|
|
}
|
|
case "dun":
|
|
{
|
|
// 关卡等级
|
|
var _BattleDramaController = require("battle_drama_controller");
|
|
var _battle_drama_ctrl = _BattleDramaController.getInstance();
|
|
var _drama_data = _battle_drama_ctrl.getModel().getDramaData();
|
|
if (_drama_data && data[1]) {
|
|
if (_drama_data.max_dun_id >= data[1]) {
|
|
source_info.is_lock = true;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "lev":
|
|
{
|
|
// 等级
|
|
var RoleController = require("role_controller");
|
|
var role_vo = RoleController.getInstance().getRoleVo();
|
|
if (role_vo && data[1]) {
|
|
if (role_vo.lev >= data[1]) {
|
|
source_info.is_lock = true;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "guild":
|
|
{
|
|
// 公会等级
|
|
var GuildController = require("guild_controller");
|
|
var _RoleController = require("role_controller");
|
|
var _role_vo = _RoleController.getInstance().getRoleVo();
|
|
if (_role_vo && _role_vo.gid && _role_vo.gsrv_id) {
|
|
var guild_info = GuildController.getInstance().getModel().getMyGuildInfo();
|
|
if (guild_info && data[1]) {
|
|
if (guild_info.lev >= data[1]) {
|
|
source_info.is_lock = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
source_info.is_lock = false;
|
|
}
|
|
break;
|
|
}
|
|
return source_info;
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |