"use strict"; cc._RF.push(module, '18251Ac1r9EbpvGaDMuLd5G', 'cmp.act.assembly'); // Scripts/mod/acts/assembly/cmp/cmp.act.assembly.js "use strict"; /****************************************************************** * * 集結令 開服活动 * ******************************************************************/ var ActPage = require("act.page.base"); var NxSpine = require("nx.fx.spine"); var Payment = require("payment.mod"); var Mod = require("act.assembly.mod"); var themeMod = require("acts.mod"); var FID = require("bridge.function.ids"); cc.Class({ "extends": ActPage, properties: { nodItems: { type: cc.Node, "default": null }, spRole: { "default": null, type: NxSpine }, nodEndTime: { "default": null, type: cc.Node }, nodOp: { type: cc.Node, "default": null }, nodSpecial: { type: cc.Node, "default": null } }, // 初始化 build: function build(_data) { var _this = this; this._super(_data); this.spRole.load("resDB/models/H30082/show", function (_e) { if (!_e) { _this.spRole.action("action1", true); } else { _this.spRole.stop(); } }); this.tweens = []; this.canbuy = true; // 活动监听 this.mod.vbind(this, [["assembly", this.freshAssemblyInfo.bind(this)]]); }, onEnable: function onEnable() { // 请求信息 this.mod.reqAssemblyData(); }, // 销毁 onDestroy: function onDestroy() { // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } delete this.mod; this._super(); }, freshAssemblyInfo: function freshAssemblyInfo(_data) { var _this2 = this; if (!_data || nx.dt.objEmpty(_data) || !this.nodItems) { return; } /**** {"is_buy":0,"end_time":1695830399,"charge_id":912, "award_list":[ {"id":7,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]}, {"id":6,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]}, {"id":5,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]}, {"id":4,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]}, {"id":3,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]}, {"id":2,"acv_id":0,"finish":0,"award_time":0,"award":[{"bid":11403,"num":2}]}, {"id":1,"acv_id":263,"finish":0,"award_time":0,"award":[{"bid":29905,"num":50}]} ] } */ this.award_id = 0; nx.gui.setActive(this.nodEndTime, "", false); nx.gui.setActive(this.nodEndTime, "title", true); var descTime = _data.is_buy == 0 ? nx.text.getKey("StepUpDone") : nx.text.getKey("act_common_tips"); 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.setActive(_this2.nodEndTime, "title", false); _this2.canbuy = _data.is_buy != 0; nx.gui.setString(_this2.nodEndTime, "txt", descTime); }); var awardss = nx.dt.objClone(_data.award_list); var free = awardss.shift(); var awards = awardss; var cmp = nx.gui.getComponent(this.nodSpecial, "item", "cmp.item.base"); if (cmp) { cmp.setData(free.award[0]); } nx.gui.setActive(this.nodSpecial, "got", free.finish == 2); nx.gui.setActive(this.nodSpecial, "free", free.finish == 1 || free.finish == 0); this.buy_info = _data; if (awards.length > 0) { var path = "prefab/acts/assembly/ui/assembly_0"; var price = game.configs.charge_data.data_charge_data[_data.charge_id].val; nx.gui.gocChildren(this.nodItems, "", awards.length); var chd = this.nodItems.children; for (var i = 0; i < chd.length; i++) { var nod = chd[i]; var award = awards[i]; nx.gui.setActive(nod, "bg", award.acv_id == 0); nx.gui.setActive(nod, "bg_special", award.acv_id != 0); nx.gui.setSpriteFrame(nod, "number", path + (award.id + 2)); var _cmp = nx.gui.getComponent(nod, "item", "cmp.item.base"); if (_cmp) { _cmp.setData(award.award[0]); } nx.gui.setActive(nod, "focus", award.finish == 1 && this.buy_info.is_buy == 1); nx.gui.setActive(nod, "icolog", award.finish == 1); nx.gui.setActive(nod, "got", award.finish == 2); if (award.finish == 1) { this.award_id = award.id; } var tween = nx.gui.find(nod, "focus"); var tweenAct = cc.tween(tween).to(0.6, { scale: 0.96 }).to(0.6, { scale: 1 }).union().repeatForever().start(); this.tweens.push(tweenAct); } // nx.gui.setActive( this.nodEndTime, "", _data.is_buy == 0 ); var desc = _data.is_buy != 0 ? nx.text.getKey("Get") : nx.text.format("ChargeCost", Payment.getInstance().fmtPrice(price)); nx.gui.setString(this.nodOp, "txt", desc); var btn = nx.gui.getComponent(this.nodOp, "", cc.Button); if (btn) { if (_data.is_buy != 0) { if (this.award_id == 0) { btn.interactable = false; nx.gui.setOutlineColor(this.nodOp, "txt", cc.Color.BLACK); } else { btn.interactable = true; nx.gui.setOutlineColor(this.nodOp, "txt", new cc.color("#B85833")); } } else { btn.interactable = true; nx.gui.setOutlineColor(this.nodOp, "txt", new cc.color("#B85833")); } } } else { nx.gui.hideAllChildren(this.nodItems, ""); nx.gui.setString(this.nodOp, "txt", nx.text.getKey("lab_planesafk_main_have_over")); } }, // 领取奖励 与 购买礼包 onTouchGet: function onTouchGet() { if (!this.canbuy) { nx.tbox("StepUpDone"); return; } if (this.buy_info.is_buy != 0) { this.mod.reqGetAssemblyAward(this.award_id); return; } Payment.getInstance().reqPayment(this.buy_info.charge_id); }, onTouchGetFree: function onTouchGetFree() { this.mod.reqGetAssemblyAward(0); } }); cc._RF.pop();