"use strict"; cc._RF.push(module, 'c5dd30lo+JA/Jc9LVSn7AuB', 'cmp.stronger.item.panel'); // Scripts/mod/stronger/cmp/cmp.stronger.item.panel.js "use strict"; var SvcItem = require("nx.fx.sv.expand.item"); var BaseLayout = require("cmp.common.itemlayout"); var 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 rebind(_idx, _data, _key) { this._super(_idx, _data, _key); // 刷新 this.setData(this.mdata); }, setEmpty: function setEmpty() { this.is_open = true; this.bottom.rebuild([]); nx.gui.setActive(this.node, "bottom", false); }, setData: function setData(data) { this.setEmpty(); if (nx.dt.objEmpty(data)) { return false; } // // 引导辅助 if (nx.bridge.plot && nx.bridge.plot.isDoing() && data.evt_type == 12) { var cmp = this.btnGo.getComponent("cmp.plot.trigger"); if (cmp) { cmp.pID = "strongLev"; cmp.regist(); } } var self = this; self.data = data; self.goods_icon.spriteFrame = null; if (data.type == 1) { self.title.string = data.name; self.desc.string = data.desc; var res = cc.js.formatStr("prefab/battle/battledrama/strongericon/%s", data.icon); cc.loader.loadRes(res, cc.SpriteFrame, function (err, spr) { if (err) { return; } self.goods_icon.spriteFrame = spr; }); } else { self.title.string = data.data.name; self.desc.string = data.data.desc; var _res = PathTool.queryIconPath(data.data.icon); cc.loader.loadRes(_res, cc.SpriteFrame, function (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: function onClickGoBtn() { StrongerController.getInstance().clickCallBack(this.data.evt_type); }, onClickDetail: function onClickDetail() { var list = []; if (this.is_open) { this.is_open = false; for (var i in this.data.data.sub_list) { var 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")); } } }); cc._RF.pop();