"use strict"; cc._RF.push(module, '7b1adUXVTBI+IyP04X3YqkV', 'cmp.act.month'); // Scripts/mod/acts/month/cmp.act.month.js "use strict"; /****************************************************************** * * 月卡 * ******************************************************************/ var BasePage = require("act.page.base"); var Payment = require("payment.mod"); cc.Class({ "extends": BasePage, properties: { card1: { "default": null, type: cc.Node }, card2: { "default": null, type: cc.Node } }, // 初始化 build: function build(_data) { this._super(_data); // 无效 if (!this.mod) { this.card1.active = false; this.card2.active = false; return; } // 活动监听 this.mod.vbind(this, [["monthCard1", this.freshCard1.bind(this)], ["monthCard2", this.freshCard2.bind(this)]]); // 请求月卡信息 this.mod.reqMonthData(); }, // 销毁 onDestroy: function onDestroy() { // 活动监听解除 if (this.mod) { this.mod.vunbind(this); } this._super(); }, // 卡更新 freshCard1: function freshCard1(_info) { this.freshCard(1, _info); }, // 卡更新 freshCard2: function freshCard2(_info) { this.freshCard(2, _info); }, // 卡更新 freshCard: function freshCard(_type, _info) { var card = _type == 1 ? this.card1 : this.card2; if (!card || nx.dt.objEmpty(_info)) { return; } // 配置缺失 var data = game.configs.charge_data.data_constant; if (!data) { nx.error("月卡配置缺失!"); return; } // 未激活 if (_info.is_reward == 0) { nx.gui.setActive(card, "reward", false); nx.gui.setActive(card, "active", false); var _node = nx.gui.setActive(card, "goto", true); var key = _type == 1 ? "month_card1_sun" : "month_card2_sun"; var val = data[key].val; nx.gui.setString(_node, "tip/arr/total", Payment.getInstance().fmtPrice(val)); nx.gui.setString(_node, "acc/total", Payment.getInstance().transPrice(val)); nx.gui.setString(_node, "acc/cur", Payment.getInstance().transPrice(_info.acc)); return; } // 待激活 if (_info.is_reward == 3) { nx.gui.setActive(card, "reward", false); nx.gui.setActive(card, "goto", false); nx.gui.setActive(card, "active", true); return; } nx.gui.setActive(card, "goto", false); nx.gui.setActive(card, "active", false); var node = nx.gui.setActive(card, "reward", true); // 生效时间段 var start = nx.bridge.time.toLocalMD(_info.start_time); var end = nx.bridge.time.toLocalMD(_info.end_time); nx.gui.setString(node, "tip/arr/date", start + " - " + end); // 领取天数 nx.gui.setString(node, "acc/cur", _info.days); var have = _info.is_reward == 1; nx.gui.setActive(node, "get", have); nx.gui.setActive(node, "got", !have); }, // 点击激活 onTouchActive: function onTouchActive(_type) { console.log("Active:" + parseInt(_type)); nx.bridge.createPanel("WndPayment", { key: "recharge" }); this.scheduleOnce(function () { nx.bridge.closePanel("WndActs"); }, 0.5); }, // 激活祝福 onTouchActiveReward: function onTouchActiveReward(_type) { var type = parseInt(_type); this.mod.reqActiveCard(type, function (_ret, _data) {}); }, // 点击领取 onTouchGet: function onTouchGet(_type) { var type = parseInt(_type); this.mod.reqMonthReward(type, function (_ret, _data) {}); }, // 点击特权 onTouchVipRight: function onTouchVipRight() { nx.bridge.createPanel("WndPayment", { key: "vip" }); } }); cc._RF.pop();