Files
fc/dev/project/library/imports/82/824a551d-f9d7-453e-ae26-f2c8c2d780a6.js
2026-05-24 10:21:26 +08:00

201 lines
5.5 KiB
JavaScript

"use strict";
cc._RF.push(module, '824a5Ud+ddFPq4m8sjC14Cm', 'cmp.act.wreckagecol');
// Scripts/mod/acts/wreckagecol/cmp/cmp.act.wreckagecol.js
"use strict";
var ActPopup = require("act.popup.base");
var FxSVC = require("nx.fx.sv.expand");
var Mod = require("act.wreckagecol.mod");
var themeMod = require("acts.mod");
var FID = require("bridge.function.ids");
/***
*
* 探宝活动
*/
cc.Class({
"extends": ActPopup,
properties: {
nodItems: {
"default": null,
type: FxSVC
},
nodTasklst: {
"default": null,
type: cc.Node
},
nodMat: {
"default": null,
type: cc.Node
},
nodEndtime: {
"default": null,
type: cc.Node
},
nodShow: {
"default": null,
type: cc.Node
}
},
// 初始化
onOpenConfigs: function onOpenConfigs(_params) {
this._super(_params);
this.mod = Mod.getInstance();
if (!this.mod) {
this.delayClose();
return;
}
var cfgs = gdata(this.mod.data.config, "data_item_exchange");
this.cfgs = nx.dt.objClone(cfgs);
var qfgs = gdata(this.mod.data.config, "data_quest_list");
this.qfgs = nx.dt.objClone(qfgs);
var qls = [];
var items = [];
for (var i in cfgs) {
var item = cfgs[i];
items.push(item);
}
items.sort(function (a, b) {
return a.point - b.point;
});
for (var j in qfgs) {
var qitem = qfgs[j];
qls.push(qitem);
}
nx.gui.gocChildren(this.nodTasklst, "", qls.length);
this.nodItems.rebuild(items);
this.mod.vbind(this, [["wreckagecol", this.freshWreckagecolInfo.bind(this)], ["wreckagecolTask", this.freshWreckagecolTask.bind(this)], ["wreckagecolExchange", this.freshColExchange.bind(this)], ["wreckagecolInfo", this.onShowInfo.bind(this)]]);
this.mod.reqWreckageColData();
},
onEnable: function onEnable() {},
onDisable: function onDisable() {
this.mod.vset("wreckagecolInfo", null);
},
// 销毁
onDestroy: function onDestroy() {
// this.mod.vset( "wreckagecolInfo", null );
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
delete this.mod;
this._super();
},
freshWreckagecolInfo: function freshWreckagecolInfo(_data) {
var _this = this;
if (!_data || nx.dt.objEmpty(_data)) {
return;
}
// 材料顯示
nx.gui.setString(this.nodMat, "count", _data.num);
var time = _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", time, function () {
nx.gui.setString(_this.nodEndtime, "txt", nx.text.getKey("lab_planesafk_main_have_over"));
});
var taskLst = _data.list;
var exchange = _data.reward_list;
this.have = _data.num;
this.freshExchangeInfo(exchange);
var chd = this.nodTasklst.children;
// 刷新任務信息顯示
if (nx.dt.arrEmpty(taskLst)) {
chd.forEach(function (_nod) {
var cmp = _nod.getComponent("cmp.act.wreckagecol.titem");
if (cmp) {
var exInfo = {
finish: -1,
target_val: 0,
value: 0
};
cmp.setExInfo(exInfo);
}
});
} else {
taskLst.sort(function (a, b) {
return b.sortid - a.sortid;
});
var _loop = function _loop() {
var task = taskLst[i];
var nod = chd[i];
var baseinfo = _this.qfgs[task.id];
baseinfo.cb = function () {
_this.mod.reqFinishTask(baseinfo.id);
};
if (nod) {
var cmp = nod.getComponent("cmp.act.wreckagecol.titem");
if (cmp) {
cmp.rebind(i, baseinfo);
var exInfo = {
finish: task.finish,
target_val: task.target_val,
value: task.value
};
cmp.setExInfo(exInfo);
}
}
};
for (var i = 0; i < taskLst.length; i++) {
_loop();
}
}
// {"end_time":1695139199,"num":0,"list":[],"reward_list":[]}
},
freshExchangeInfo: function freshExchangeInfo(_info) {
var rhd = nx.gui.find(this.nodItems.bindSCV, "view/content").children;
for (var r = 0; r < rhd.length; r++) {
var rnod = rhd[r];
var rinfo = _info[r];
if (rinfo) {
var cmp = rnod.svItem;
if (cmp) {
var exinfo = {
buy_num: rinfo.buy_num,
max_num: rinfo.max_num
};
cmp.setExData(exinfo);
}
}
}
},
freshWreckagecolTask: function freshWreckagecolTask(_data) {},
freshColExchange: function freshColExchange(_exchange) {
if (!_exchange) {
return;
}
this.freshExchangeInfo(_exchange.reward_list);
this.have = _exchange.num;
nx.gui.setString(this.nodMat, "count", _exchange.num);
},
onTouchExChange: function onTouchExChange(_item) {
if (this.have < _item.mdata.point) {
nx.tbox("SummonItemNotEnough");
return;
}
this.mod.reqExchange(_item.mdata.id);
},
onShowInfo: function onShowInfo(_info) {
if (_info) {
var info = _info;
nx.gui.setString(this.nodShow, "num", "x " + info.cfg.point);
nx.gui.setString(this.nodShow, "tip", info.tip);
nx.gui.setActive(this.nodShow, "", true);
} else {
this.hideInfo();
}
},
hideInfo: function hideInfo() {
nx.gui.setActive(this.nodShow, "", false);
},
onTouchClose: function onTouchClose() {
var theme = themeMod.getInstance().queryTheme(this.mod.data.theme_id);
nx.bridge.jumper.jump2Window(FID.ActOpenServer, theme);
this.close();
}
});
cc._RF.pop();