Files

206 lines
6.3 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '32f3e3uo9NBJoZ5tjYfszTl', 'cmp.act.relicexplore');
// Scripts/mod/acts/relicexploreact/cmp/cmp.act.relicexplore.js
"use strict";
/******************************************************************
*
* 快速作战
*
******************************************************************/
var BasePage = require("act.page.base");
var NxSpine = require("nx.fx.spine");
var TipsController = require("tips_controller");
cc.Class({
"extends": BasePage,
properties: {
nodContent: {
type: cc.Node,
"default": null
},
spRole: {
"default": null,
type: NxSpine
},
nodEndTime: {
"default": null,
type: cc.Node
},
nodScore: {
"default": null,
type: cc.Node
},
nodCloseIco: {
"default": null,
type: cc.Node
}
},
// 初始化
build: function build(_data) {
var _this = this;
this.spRole.load("resDB/models/H30082/show", function (_e) {
if (!_e) {
_this.spRole.action("action1", true);
} else {
_this.spRole.stop();
}
});
this._super(_data);
this.rfgs = gdata(this.data.config, "data_get_info5");
var len = Object.keys(this.rfgs).length;
nx.gui.gocChildren(this.nodContent, "", len);
// 无效
if (!this.mod) {
return;
}
nx.gui.setActive(this.nodCloseIco, "", false);
// 活动监听
this.mod.vbind(this, [["actrelicexplore", this.freshInfo.bind(this)], ["activepoints", this.freshActivePoints.bind(this)]]);
},
onEnable: function onEnable() {
// 请求信息
this.mod.reqRelicExploreActData();
this.mod.reqGetActivePoints();
},
// 销毁
onDestroy: function onDestroy() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
this._super();
},
freshInfo: function freshInfo(_data) {
var _this2 = this;
if (!_data || nx.dt.objEmpty(_data)) {
return;
}
/****
* "aim_args":[
* {"aim_args_key":4,"aim_args_val":56,"aim_args_str":""},
* {"aim_args_key":5,"aim_args_val":0,"aim_args_str":""}
* ]
*/
var aim_list = _data.aim_list;
aim_list.sort(function (a, b) {
return a.sortid - b.sortid;
});
this.aims = aim_list;
var chd = this.nodContent.children;
var _loop = function _loop() {
var nod = chd[i];
var sinfo = aim_list[i];
var info = _this2.rfgs[sinfo.aim];
nx.gui.setString(nod, "descs/desc/title", info.desc);
var cmp = nx.gui.getComponent(nod, "lst", "cmp.common.itemlayout");
if (cmp) {
cmp.rebuild(info.reward);
}
var target = 0;
var value = 0;
nx.gui.find(nod, "go").zIndex = info.source_id;
nx.gui.find(nod, "get").aim = sinfo.aim;
sinfo.aim_args.forEach(function (_aim) {
if (_aim && _aim.aim_args_key == 4) {
target = _aim.aim_args_val;
}
if (_aim && _aim.aim_args_key == 5) {
value = _aim.aim_args_val;
}
});
nx.gui.setActive(nod, "go", sinfo.status == 0);
nx.gui.setActive(nod, "get", sinfo.status == 1);
nx.gui.setActive(nod, "finish", sinfo.status == 2);
nx.gui.setString(nod, "descs/leftdesc/prog", value + "/" + target);
nx.gui.setActive(nod, "descs/leftdesc", sinfo.status != 2);
};
for (var i = 0; i < chd.length; i++) {
_loop();
}
var left = _data.remain_sec > 0 ? _data.remain_sec : 0.1;
nx.gui.setCdTxt(this.nodEndTime, "txt", left, function () {
nx.gui.setString(_this2.nodEndTime, "txt", nx.text.getKey("lab_planesafk_main_have_over"));
});
},
freshActivePoints: function freshActivePoints(_actinfo) {
var _this3 = this;
var point = _actinfo.point;
nx.gui.setString(this.nodScore, "title/points/point", point);
this.rfg = gdata(this.data.config, "data_get_reward");
var len = gdata(this.data.config, "data_get_reward_length");
var prog = nx.gui.getComponent(this.nodScore, "prog", cc.ProgressBar);
var total = this.rfg[len].need_point;
var percent = parseFloat(point / total);
if (prog) {
prog.progress = percent;
}
var rewards = _actinfo.reward_list;
var chd = nx.gui.find(this.nodScore, "rewards").children;
var _loop2 = function _loop2(i) {
var nod = chd[i];
var item = _this3.rfg[i + 1];
var showcmp = nx.gui.getComponent(nod, "show", "cmp.common.itemlayout");
if (showcmp) {
showcmp.rebuild(item.reward);
}
nx.gui.setString(nod, "point", nx.text.format("ActPoint", item.need_point));
nx.gui.find(nod, "touch").zIndex = i + 1;
nx.gui.find(nod, "get").zIndex = i + 1;
nx.gui.setActive(nod, "ico_close", true);
nx.gui.setActive(nod, "ico_open", false);
nx.gui.setActive(nod, "get", point >= item.need_point);
rewards.forEach(function (_get) {
if (_get && _get.id == i + 1) {
nx.gui.setActive(nod, "ico_open", true);
nx.gui.setActive(nod, "get", false);
}
});
nx.gui.setActive(nod, "show", false);
};
for (var i = 0; i < chd.length; i++) {
_loop2(i);
}
},
onTouchHideAllDesc: function onTouchHideAllDesc() {
var chd = nx.gui.find(this.nodScore, "rewards").children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
nx.gui.setActive(nod, "show", false);
}
nx.gui.setActive(this.nodCloseIco, "", false);
},
onTouchGetActiveReward: function onTouchGetActiveReward(_btn) {
var id = this.rfg[_btn.zIndex].id;
this.mod.reqGetActiveReward(id);
},
onTouchGet: function onTouchGet(_btn) {
var id = _btn.aim;
this.mod.reqGetTouchCoinGift(id);
},
onTouchGoto: function onTouchGoto(_btn) {
var source = _btn.zIndex;
nx.bridge.jumper.jump2Window(source);
},
onTouchShow: function onTouchShow(_btn) {
var index = parseInt(_btn.zIndex - 1);
var chd = nx.gui.find(this.nodScore, "rewards").children;
for (var i = 0; i < chd.length; i++) {
var nod = chd[i];
if (i != index) {
nx.gui.setActive(nod, "show", false);
}
}
var nodShow = nx.gui.find(chd[index], "show");
nx.gui.setActive(nodShow, "", !nodShow.active);
nx.gui.setActive(this.nodCloseIco, "", nodShow.active == true);
},
onTouchHelp: function onTouchHelp() {
var TC = TipsController.getInstance();
var explain = gdata(this.data.config, "data_explain");
TC.showDetailPanel(explain);
}
});
cc._RF.pop();