Files

179 lines
5.7 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, 'cca3dFubglMKJmw43rduHlG', 'cmp.act.timedust.wnd');
// Scripts/mod/acts/timedust/cmp/cmp.act.timedust.wnd.js
"use strict";
/******************************************************************
*
* 新服专享
*
******************************************************************/
var BasePage = require("act.page.base");
var NxSpine = require("nx.fx.spine");
var Payment = require("payment.mod");
var max = 4;
cc.Class({
"extends": BasePage,
properties: {
nodGift: {
type: cc.Node,
"default": null
},
spRole: {
"default": null,
type: NxSpine
},
nodEndTime: {
"default": null,
type: cc.Node
}
},
// 初始化
build: function build(_data) {
var _this = this;
this.spRole.load("resDB/models/H30048/show", function (_e) {
if (!_e) {
_this.spRole.action("action1", true);
} else {
_this.spRole.stop();
}
});
this._super(_data);
// 无效
if (!this.mod) {
return;
}
// 活动监听
this.mod.vbind(this, [["timedust", this.freshGift.bind(this)]]);
},
onEnable: function onEnable() {
// 请求信息
this.mod.reqTimeDustData();
},
// 销毁
onDestroy: function onDestroy() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
this._super();
},
freshGift: function freshGift(_data) {
var _this2 = this;
this.timedust = _data;
if (!this.timedust) {
return;
}
var left = this.timedust.remain_sec > 0 ? this.timedust.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"));
});
this.gifts = this.timedust.aim_list;
var _loop = function _loop() {
var gift = _this2.gifts[g];
var giftCost = gift.aim_args;
giftCost.forEach(function (_arg) {
if (_arg.aim_args_key == 39) {
gift.sortid = _arg.aim_args_val;
}
});
};
for (var g = 0; g < this.gifts.length; g++) {
_loop();
}
this.gifts.sort(Utils.tableLowerSorter(["sortid"]));
this.cost = [];
nx.gui.gocChildren(this.nodGift, "view/content", this.gifts.length);
var chd = nx.gui.find(this.nodGift, "view/content").children;
var _loop2 = function _loop2() {
var nod = chd[i];
var giftInfo = _this2.gifts[i];
if (giftInfo) {
var ui = i >= chd.length / 2 + 2 ? i + 1 - (chd.length / 2 + 2) + 3 : i + 4;
nx.gui.setString(nod, "cnt/title", giftInfo.aim_str);
var path = "prefab/acts/timedust/ui/time_0" + ui;
nx.gui.setSpriteFrame(nod, "cnt/icon", path);
var cmp = nx.gui.getComponent(nod, "cnt/list", "cmp.common.itemlayout");
if (cmp) {
cmp.rebuild(giftInfo.item_list);
}
nx.gui.setActive(nod, "cnt/op/costinfo/tip", giftInfo.status == 1 && giftInfo.aim == 0);
nod.zIndex = i;
var giftCost = giftInfo.aim_args;
var num = 0;
var limit = 0;
var price = 0;
var disPrice = 0;
giftCost.forEach(function (_arg) {
if (_arg.aim_args_key == 2 && _arg.aim_args_val != 0) {
// let showNum = num == 0 ? num : ( num <= _arg.aim_args_val && num != 0 ) ? num : _arg.aim_args_val;
limit = _arg.aim_args_val;
}
if (_arg.aim_args_key == 6 && _arg.aim_args_val != 0) {
// let showNum = num == 0 ? num : ( num <= _arg.aim_args_val && num != 0 ) ? num : _arg.aim_args_val;
num = _arg.aim_args_val;
}
if (_arg.aim_args_key == 26) {
price = _arg.aim_args_val;
}
if (_arg.aim_args_key == 27) {
disPrice = _arg.aim_args_val;
}
});
_this2.cost.push(disPrice);
if (disPrice > 0) {
nx.gui.setString(nod, "cnt/op/costinfo/cost/num", Payment.getInstance().fmtPrice(price));
nx.gui.setString(nod, "cnt/op/costinfo/now/num", disPrice > 0 ? Payment.getInstance().fmtPrice(disPrice) : Payment.getInstance().fmtPrice(price));
nx.gui.setActive(nod, "cnt/op/costinfo/now", true);
nx.gui.setActive(nod, "cnt/op/costinfo/cost", true);
} else {
nx.gui.setString(nod, "cnt/op/costinfo/cost/num", Payment.getInstance().fmtPrice(price));
if (giftInfo.status == 2 && giftInfo.aim == 0) {
nx.gui.setString(nod, "cnt/op/costinfo/now/num", disPrice != 0 ? Payment.getInstance().fmtPrice(price) : nx.text.getKey("Got"));
} else {
nx.gui.setString(nod, "cnt/op/costinfo/now/num", disPrice != 0 ? Payment.getInstance().fmtPrice(price) : nx.text.getKey("Free"));
}
nx.gui.setActive(nod, "cnt/op/costinfo/cost", price > 0);
nx.gui.setActive(nod, "cnt/op/costinfo/now", true);
}
nx.gui.setString(nod, "cnt/limit", nx.text.format("BuyLimit", num, limit));
nx.gui.setActive(nod, "cnt/limit", limit != 0);
}
};
for (var i = 0; i < chd.length; i++) {
_loop2();
}
},
onTouchBuy: function onTouchBuy(_btn) {
if (this.timedust.remain_sec == 0) {
nx.tbox("lab_recruit_hero_window_tip_6");
return;
}
var number = _btn.parent.parent.zIndex;
var aim = this.gifts[number].aim;
if (this.gifts[number].status != 0 && this.cost[number] != 0) {
nx.tbox("lab_ladder_main_window_tip4");
return;
}
if (this.gifts[number].status == 2 && this.cost[number] == 0) {
nx.tbox("已领取");
return;
}
if (this.cost[number] == 0) {
this.mod.reqGetTimeDustFree(aim);
return;
}
Payment.getInstance().reqPayment(aim);
// this.mod.reqExclusiveGift( this.exclusive.bid, aim );
}
});
/******************
*
*/
cc._RF.pop();