Files
fc/dev/project/assets/Scripts/mod/stronger/cmp/cmp.stronger.item.panel.js
T

142 lines
3.6 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
const SvcItem = require("nx.fx.sv.expand.item")
const BaseLayout = require( "cmp.common.itemlayout" );
const PathTool = require("pathtool")
var StrongerController = require("stronger_controller")
cc.Class( {
extends: SvcItem,
properties: {
title:{
default:null,
type:cc.Label
},
desc:{
default:null,
type:cc.Label
},
btn_lb:{
default:null,
type:cc.Label
},
detailTxt:{
default:null,
type:cc.Node
},
goods_icon:{
default:null,
type:cc.Sprite
},
bottom:{
default:null,
type:BaseLayout
},
btnGo:{
default:null,
type:cc.Node
},
btnDetal:{
default:null,
type:cc.Node
},
is_open:true
},
// 数据重置
rebind: function( _idx, _data, _key ) {
this._super( _idx, _data, _key );
// 刷新
this.setData(this.mdata)
},
setEmpty(){
this.is_open = true;
this.bottom.rebuild([]);
nx.gui.setActive(this.node,"bottom",false);
},
setData(data){
this.setEmpty();
if(nx.dt.objEmpty(data)){
return false;
}
// // 引导辅助
if( nx.bridge.plot && nx.bridge.plot.isDoing() && data.evt_type == 12 ) {
let cmp = this.btnGo.getComponent( "cmp.plot.trigger" );
if( cmp ){
cmp.pID = "strongLev";
cmp.regist();
}
}
let self = this;
self.data = data;
self.goods_icon.spriteFrame = null;
if(data.type == 1){
self.title.string = data.name;
self.desc.string = data.desc;
let res = cc.js.formatStr("prefab/battle/battledrama/strongericon/%s",data.icon);
cc.loader.loadRes(res,cc.SpriteFrame,(err,spr)=>{
if(err){
return;
}
self.goods_icon.spriteFrame = spr;
});
}else{
self.title.string = data.data.name;
self.desc.string = data.data.desc;
let res = PathTool.queryIconPath(data.data.icon);
cc.loader.loadRes(res,cc.SpriteFrame,(err,spr)=>{
if(err){
return;
}
self.goods_icon.spriteFrame = spr;
});
}
if(this.data.type == 1 && this.data.evt_type){
this.btnGo.active = true;
this.btnDetal.active = false;
}else{
this.btnGo.active = false;
this.btnDetal.active = true;
nx.gui.setString(this.detailTxt,"",nx.text.getKey("ListOpen"));
}
},
onClickGoBtn(){
StrongerController.getInstance().clickCallBack(this.data.evt_type)
},
onClickDetail(){
let list = [];
if(this.is_open){
this.is_open = false;
for(let i in this.data.data.sub_list){
let v = gdata("stronger_data","data_resource_two",this.data.data.sub_list[i])
list.push(v);
}
this.bottom.rebuild(list);
nx.gui.setActive(this.node,"bottom",true);
nx.gui.setString(this.detailTxt,"",nx.text.getKey("ListClose"));
}else{
this.is_open = true;
this.bottom.rebuild(list);
nx.gui.setActive(this.node,"bottom",false);
nx.gui.setString(this.detailTxt,"",nx.text.getKey("ListOpen"));
}
}
} );