"use strict"; cc._RF.push(module, 'b42a7DnI65KZLf+GHGuSkOd', 'cmp.act.diamondcard.wnd'); // Scripts/mod/acts/diamondcard/cmp/cmp.act.diamondcard.wnd.js "use strict"; /****************************************************************** * * 日常福利 钻石周卡 * ******************************************************************/ var ActPage = require("act.page.base"); var NxSpine = require("nx.fx.spine"); var Payment = require("payment.mod"); var Mod = require("act.diamondcard.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 }, nodGetCount: { type: cc.Node, "default": null }, nodFree: { type: cc.Node, "default": null } }, // 初始化 build: function build(_data) { var _this = this; this._super(_data); this.spRole.load("resDB/models/H30040/show", function (_e) { if (!_e) { _this.spRole.action("action1", true); } else { _this.spRole.stop(); } }); this.tweens = []; this.canbuy = true; this.cfg = gdata(this.data.config, "data_week_card_data_new")[this.data.camp_id]; var items = this.cfg.reward; nx.gui.gocChildren(this.nodSpecial, "", items.length); for (var c = 0; c < this.nodSpecial.children.length; c++) { var nod = this.nodSpecial.children[c]; var info = items[c]; var item = nx.gui.getComponent(nod, "", "cmp.item.base"); if (item) { item.setData(info); } nx.gui.setActive(nod, "got", false); } var cmp = nx.gui.getComponent(this.nodFree, "item", "cmp.item.base"); if (cmp) { cmp.setData(this.cfg.daily_reward[0]); } // nx.gui.setActive( this.nodFree, "get", false ); var count = this.cfg.mail_day; var datat = this.cfg.mail_reward; nx.gui.gocChildren(this.nodItems, "", count); var chd = this.nodItems.children; for (var i = 0; i < chd.length; i++) { var _nod = chd[i]; var _item = nx.gui.getComponent(_nod, "item", "cmp.item.base"); if (_item) { _item.setData(datat[0]); } nx.gui.setActive(_nod, "got", false); nx.gui.setActive(_nod, "focus", false); nx.gui.setActive(_nod, "gotbg", false); nx.gui.setString(_nod, "day", "0" + (i + 1)); } var costfg = game.configs.charge_data.data_charge_data[this.cfg.id]; if (costfg) { nx.gui.setString(this.nodOp, "txt", nx.text.format("NeedPayUnlock", Payment.getInstance().fmtPrice(costfg.val))); } nx.gui.setString(this.nodGetCount, "num/num", this.cfg.all_num[1]); nx.bridge.setIconS(this.nodGetCount, "num/icon", this.cfg.all_num[0]); nx.gui.setActive(this.nodEndTime, "", false); // 活动监听 this.mod.vbind(this, [["DiamondCard", this.freshAssemblyInfo.bind(this)]]); // this.mod.reqDiamondCardData(); }, onEnable: function onEnable() { // 请求信息 this.mod.reqDiamondCardData(); }, freshAssemblyInfo: function freshAssemblyInfo(_data) { this.mod = !this.mod ? Mod.getInstance() : this.mod; // console.log( "當前的周卡相關" + JSON.stringify( _data ) ); var cfg = gdata(this.mod.getConfig(), "data_week_card_data_new")[this.mod.data.camp_id]; if (!_data || nx.dt.objEmpty(_data) || !cfg || !this.nodItems) { return; } // [17:11:13:023][recv] <<<[16720]:{"list":[],"list1":[{"week_id":11016,"status":0}]} var free = _data.list1; this.freeid = free[0] ? free[0].week_id : 0; nx.gui.setActive(this.nodFree, "get", free[0].status == 0); nx.gui.setActive(this.nodFree, "", free[0].status == 0); var list = _data.list; if (nx.dt.arrEmpty(list)) { this.canbuy = true; return; } this.canbuy = false; var now = {}; for (var i = 0; i < list.length; i++) { var info = list[i]; if (info.week_id == cfg.id) { now = info; } } this.now = now; var nowDay = now.gain_num; var chd = this.nodItems.children; var status = now.status; for (var _i = 0; _i < chd.length; _i++) { var _nod2 = chd[_i]; if (status == 2) { nx.gui.setActive(_nod2, "got", _i < nowDay); nx.gui.setActive(_nod2, "gotbg", _i < nowDay); if (nowDay > _i) { nx.gui.setActive(_nod2, "focus", false); } } else { nx.gui.setActive(_nod2, "focus", nowDay == _i); } } // [{"week_id":11016,"status":1,"gain_num":0,"endtime":1707667200}] for (var c = 0; c < this.nodSpecial.children.length; c++) { var _nod3 = this.nodSpecial.children[c]; nx.gui.setActive(_nod3, "got", true); } var nod = this.nodItems.children[nowDay]; var time = new Date(); var showtime = now.endtime - time / 1000; nx.gui.setCdTxt(this.nodEndTime, "txt", showtime); nx.gui.setActive(this.nodEndTime, "", true); var color = new cc.color("#592E06"); var colord = new cc.color("#784611"); nx.gui.setColor(nod, "desc", colord); nx.gui.setColor(nod, "day", color); var cmp = nx.gui.getComponent(this.nodOp, "", cc.Button); if (cmp) { nx.gui.setString(this.nodOp, "txt", nx.text.getKey("Charged")); cmp.interactable = false; } // free.forEach( _item =>{ // if( _item.status == 0 ){ // nx.gui.setActive( ) // } // } ) }, // 领取奖励 与 购买礼包 onTouchGet: function onTouchGet() { Payment.getInstance().reqPayment(this.cfg.id); }, onTouchGetFree: function onTouchGetFree() { this.mod.reqGetAward(this.now.week_id); }, onTouchGetRealFree: function onTouchGetRealFree() { this.mod.reqGetFreeAward(this.freeid); } }); cc._RF.pop();