"use strict"; cc._RF.push(module, '44649Ksw8VH64Uzw8aXfkZw', 'cmp.personal.push.page.1'); // Scripts/mod/acts/push/cmp.personal.push.page.1.js "use strict"; /****************************************************************** * * 个人推送页 * ******************************************************************/ var PPPage = require("cmp.personal.push.page"); var ItemLayout = require("cmp.common.itemlayout"); var Payment = require("payment.mod"); var NxSpine = require("nx.fx.spine"); cc.Class({ "extends": PPPage, properties: { spBG: { "default": null, type: cc.Node }, spRole: { "default": null, type: NxSpine }, spHoverd: { "default": null, type: cc.Node }, nodTip: { "default": null, type: cc.Node }, nodDesc: { "default": null, type: cc.Node }, nodDate: { "default": null, type: cc.Node }, nodPrice: { "default": null, type: cc.Node }, lstReward: { "default": null, type: cc.Node }, lstSL: { "default": null, type: ItemLayout }, lstML: { "default": null, type: ItemLayout } }, // 重构 rebuild: function rebuild(_gift) { var _this = this; this.gift = _gift; if (!this.gift) { return; } var path = cc.path.join("resDB/acts/images", this.gift.bg); nx.gui.setSpriteFrame(this.spBG, "", path); // 角色动画 path = PathTool.getSpinePath(this.gift.model, "show", false); this.spRole.load(path, function (_e) { if (!_e) { _this.spRole.action(_this.gift.action, true); } else { _this.spRole.stop(); } }); path = cc.path.join("locals", nx.getLocLanguage(), "images/push", this.gift.hover); nx.gui.setSpriteFrame(this.spHoverd, "", path); if (nx.dt.strEmpty(this.gift.desc1)) { nx.gui.setActive(this.nodTip, "", false); } else { nx.gui.setActive(this.nodTip, "", true); nx.gui.setString(this.nodTip, "txt", nx.text.getKey(this.gift.desc1)); } nx.gui.setString(this.nodDesc, "txt", nx.text.getKey(this.gift.desc2)); // 价格 var price = Payment.getInstance().fmtPrice(this.gift.price); nx.gui.setString(this.nodPrice, "", price); // 奖励 var rewards = []; this.gift.award.forEach(function (_t) { rewards.push([_t.id, _t.num]); }); if (rewards.length <= 3) { nx.gui.setActive(this.lstReward, "mt", false); nx.gui.setActive(this.lstReward, "st", true); this.lstSL.rebuild(rewards); } else { nx.gui.setActive(this.lstReward, "mt", true); nx.gui.setActive(this.lstReward, "st", false); this.lstML.rebuild(rewards); } // 倒計時 this.updateDate(); this.schedule(function () { _this.updateDate(); }, 1, cc.macro.repeatForever); }, // 关闭 onDisable: function onDisable() { this.unscheduleAllCallbacks(); }, // 倒计时 updateDate: function updateDate() { var txt = nx.bridge.time.cdSimple(this.gift ? this.gift.over_time : 0); txt = nx.text.getKey(txt || "已结束"); nx.gui.setString(this.nodDate, "txt", txt); }, // 购买 onTouchBuy: function onTouchBuy() { if (!this.gift) { return; } // let msg = `pay ${this.gift.charge_id}`; Payment.getInstance().reqPayment(this.gift.charge_id); // client.socket.send( 10399, { msg: msg } ); nx.bridge.closePanel("WndPersonalPush"); } }); cc._RF.pop();