"use strict"; cc._RF.push(module, '1fc3b6GYqNIE6uRyDM3wIDY', 'act.poweraim.wnd'); // Scripts/mod/acts/poweraim/act.poweraim.wnd.js "use strict"; var BasePage = require("act.page.base"); var RoleEvent = require("role_event"); var NxSpine = require("nx.fx.spine"); var TipsController = require("tips_controller"); var RoleController = require("role_controller"); cc.Class({ "extends": BasePage, properties: { nodReward: { "default": null, type: cc.Node }, nodEndTime: { "default": null, type: cc.Node }, nodRole: { "default": null, type: cc.Node }, nodGotos: { "default": null, type: cc.Node }, nodPower: { "default": null, type: cc.Node } }, // 初始化 build: function build(_data) { var _this = this; this._super(_data); this.cfg = gdata(this.data.config, "data_get_info"); var ccfg = gdata(this.data.config, "data_source"); var list = []; var jumps = []; for (var i in this.cfg) { var item = this.cfg[i]; var ccf = ccfg[i]; if (ccf) { jumps.push(ccf); } list.push(item); } nx.gui.gocChildren(this.nodGotos, "", jumps.length); var jhd = this.nodGotos.children; nx.gui.gocChildren(this.nodReward, "", list.length); var icopath = "prefab/acts/poweraim/ui/ico"; var chd = this.nodReward.children; for (var c = 0; c < jhd.length; c++) { var jnod = jhd[c]; if (jnod) { jnod["goto"] = jumps[c].source_id; nx.gui.setString(jnod, "txt", jumps[c].desc); nx.gui.setSpriteFrame(jnod, "ico", c == 4 || c == 5 ? icopath + (c - 3) : icopath + (c + 1)); } } var role = RoleController.getInstance().getRoleVo(); var lfg = game.configs.looks_data.data_data[role.look_id]; var server = role.srv_id; var desc = server.split("_"); nx.gui.setString(this.nodRole, "info/vip/lev", role.vip_lev); nx.gui.setString(this.nodPower, "txt", role.power); nx.gui.setString(this.nodRole, "info/name", nx.text.format("ActPowerSelfTip", desc[1], role.name)); var cd = _data.end_time - Math.floor(cc.sys.now() / 1000) > 0 ? _data.end_time - Math.floor(cc.sys.now() / 1000) : 0.1; nx.gui.setCdTxt(this.nodEndTime, "txt", cd, function () { nx.gui.setString(_this.nodEndTime, "txt", nx.text.getKey("lab_planesafk_main_have_over")); }); // 获取指定主题信息 var path = cc.path.join("resDB/models/", lfg.model + "/" + lfg.model); var nodrole = nx.gui.getComponent(this.nodRole, "nodrole", NxSpine); if (nodrole) { nodrole.load(path, function (_e) { if (!_e) { nodrole.action("stand2", true); } else { nodrole.stop(); } }); } // 视图监听 this.mod.vbind(this, [["ActsPowerAimProve", this.freshInfo.bind(this)]]); this.bindGEvent(RoleEvent.UpdateModel, this.freshRoleFigure.bind(this)); }, // 开启 onEnable: function onEnable() { this.mod.reqBaseData(); // console.log( "當前的首次充值信息" + JSON.stringify( this.mod.reqChargeData() ) ); }, freshRoleFigure: function freshRoleFigure(_data) { var rolefigure = _data.code == 1 ? _data.id : 0; if (rolefigure > 0) { var lfg = game.configs.looks_data.data_data[rolefigure]; var path = cc.path.join("resDB/models/", lfg.model + "/" + lfg.model); var nodrole = nx.gui.getComponent(this.nodRole, "nodrole", NxSpine); if (nodrole) { nodrole.load(path, function (_e) { if (!_e) { nodrole.action("stand2", true); } else { nodrole.stop(); } }); } } }, // 销毁 onDestroy: function onDestroy() { // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } this.unbindGEvents(); this._super(); }, freshInfo: function freshInfo(_data) { /*** * [23400]:{"power_gift_list": * [{"id":1,"status":1}, * {"id":2,"status":1}, * {"id":3,"status":1}, * {"id":4,"status":1}, * {"id":5,"status":1}, * {"id":6,"status":1}, * {"id":7,"status":1}, * {"id":8,"status":1}, * {"id":9,"status":1}, * {"id":10,"status":1}, * {"id":11,"status":1}, * {"id":12,"status":1}, * {"id":13,"status":1}]} * */ if (!_data || nx.dt.objEmpty(_data)) { return; } _data.power_gift_list.sort(function (a, b) { return a.sortid - b.sortid; }); var chd = this.nodReward.children; var list = _data.power_gift_list; for (var i = 0; i < list.length; i++) { var info = list[i]; var rfg = this.cfg[info.id]; var nod = chd[i]; if (info) { nx.gui.setString(nod, "desc/aim", rfg.val); var ccmp = nx.gui.getComponent(nod, "rewards", "cmp.common.itemlayout"); if (ccmp) { ccmp.rebuild(rfg.rewards); } nx.gui.find(nod, "get").getid = rfg.id; nx.gui.setActive(nod, "get", info.status == 1); nx.gui.setActive(nod, "cannot", info.status == 0); nx.gui.setActive(nod, "got", info.status == 2); } } }, onTouchGoto: function onTouchGoto(_nod) { var fid = _nod["goto"]; nx.bridge.jumper.jump2Window(fid); }, onTouchGet: function onTouchGet(_nod) { var fid = _nod.getid; this.mod.reqGet(fid); }, onTouchChange: function onTouchChange() { var RC = RoleController.getInstance(); RC.fetchFigureData(function (_ret, _data) { if (!_ret) { nx.tbox(_data); return; } nx.bridge.createPanel("WndPersonalFigure", _data); }); }, onTouchHelp: function onTouchHelp() { var TC = TipsController.getInstance(); var explain = gdata(this.mod.data.config, "data_explain")[1]; TC.showTextPanel(explain.title, explain.desc); } }); cc._RF.pop();