Files
fc/dev/project/assets/Scripts/mod/backpack/cmps/cmp.item.detail.source.js
T
2026-05-23 22:10:14 +08:00

195 lines
5.9 KiB
JavaScript

const PathTool = require( "pathtool" );
const GoodsVo = require( "goods_vo" );
const HeroController = require( "hero_controller" );
const TipsController = require( "tips_controller" );
cc.Class( {
extends: cc.Component,
properties: {
nodList: {
default: null,
type: cc.Node,
displayName: "列表容器"
},
},
// 载入
onLoad: function() {
},
// 置空
setEmpty: function() {
nx.gui.hideAllChildren( this.nodList, "" );
},
// 设置道具
// @ 返回true:需要显示
setData: function( _item, _config, _fromBag ) {
this.fromBag = _fromBag;
// 全隐藏
if( !_item || !_config || !_config.source ) {
this.setEmpty();
return false;
}
// 获取配置
this.item = _item;
this.config = _config;
let final_list = [];
let source_list = _config.source;
if( source_list) {
let list = [];
for( let i in source_list ) {
let 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( let i in list ) {
let data = game.configs.source_data.data_source_data[ list[ i ][ 0 ] ];
let source_info = this.getSourceInfo( data.lev_limit );
if( source_info ){
let 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" ] ) );
}
// 属性设置
const setProp = function( _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( ( a, b ) =>{
return a.index - b.index;
} )
const chds = this.nodList.children;
nx.gui.gocChildren( this.nodList, "", this.props.length, chds[ 0 ] );
for( let i = 0; i < this.props.length; ++i ) {
setProp( chds[ i ], this.props[ i ] );
}
return true;
},
// 点击前往
onTouchGoto: function( _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( data ) {
let source_info = {};
if( !data || !data[ 0 ] ){
source_info.is_lock = true;
return source_info;
}
source_info.is_lock = false;
switch( data[ 0 ] ) {
case "dungeon": { // 关卡等级
let BattleDramaController = require( "battle_drama_controller" );
let battle_drama_ctrl = BattleDramaController.getInstance();
let 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": { // 关卡等级
let BattleDramaController = require( "battle_drama_controller" );
let battle_drama_ctrl = BattleDramaController.getInstance();
let 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": { // 等级
let RoleController = require( "role_controller" )
let role_vo = RoleController.getInstance().getRoleVo()
if( role_vo && data[ 1 ] ) {
if( role_vo.lev >= data[ 1 ] ) {
source_info.is_lock = true;
}
}
}
break;
case "guild": { // 公会等级
let GuildController = require( "guild_controller" );
let RoleController = require( "role_controller" )
let role_vo = RoleController.getInstance().getRoleVo()
if( role_vo && role_vo.gid && role_vo.gsrv_id ) {
let 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
},
} );