"use strict"; cc._RF.push(module, 'a17fa//TMNJVJrK/JXZiGGo', 'act.month.mod'); // Scripts/mod/acts/month/act.month.mod.js "use strict"; /******************************************************************************* * * 活动: 月卡 * * ******************************************************************************/ var ActBase = require("act.base"); var ActMonth = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(16705, this.handle16705.bind(this)); // 月卡信息 this.RegisterProtocal(16706, this.handle16706.bind(this)); // 领取月卡 this.RegisterProtocal(16707, this.handle16707.bind(this)); // 月卡额外奖励情况 this.RegisterProtocal(16708, this.handle16708.bind(this)); // 领取月卡额外奖励 this.RegisterProtocal(16701, this.handle16701.bind(this)); // 月卡激活 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { nx.dt.fnInvoke(_cb, true); this.reqBaseData(); }, // 请求剧情信息 reqBaseData: function reqBaseData(_cb) { this.reqMonthData(); this.reqExtraData(_cb); }, // ============================================================ // 月卡操作 // ============================================================ // 请求月卡信息 reqMonthData: function reqMonthData(_cb) { this.SendProtocal(16705, {}, _cb); }, // 请求月卡信息返回 handle16705: function handle16705(_data) { if (!this.isGoodData(_data)) { this.vset("monthCard1", null); this.vset("monthCard2", null); return; } this.vset("monthCard1", { is_reward: _data.card1_is_reward, // 状态 0:未激活 1:可领取 2:已领取 3:可激活 start_time: _data.card1_start_time, // 开始时间(unixtime) end_time: _data.card1_end_time, // 到期时间(unixtime) days: _data.card1_days, // 累计天数 acc: _data.card1_acc // 累计进度 }); this.vset("monthCard2", { is_reward: _data.card2_is_reward, // 状态 0:未激活 1:可领取 2:已领取 3:可激活 start_time: _data.card2_start_time, // 开始时间(unixtime) end_time: _data.card2_end_time, // 到期时间(unixtime) days: _data.card2_days, // 累计天数 acc: _data.card2_acc // 累计进度 }); if (this.data) { // 提示刷新 this.freshTips(); } }, // 领取月卡奖励 reqMonthReward: function reqMonthReward(_type, _cb) { this.SendProtocal(16706, { card_type: _type }, _cb); }, // 领取月卡奖励返回 handle16706: function handle16706(_data) { if (!this.isGoodData(_data)) { return; } var key = "monthCard" + _data.card_type; var ifo = this.vget(key); if (ifo) { ifo.is_reward = 2; ifo.days += 1; this.vset(key, ifo); } // 提示刷新 this.freshTips(); }, // ============================================================ // 额外操作 // ============================================================ // 请求月卡激活 reqActiveCard: function reqActiveCard(_type, _cb) { this.SendProtocal(16701, { card_type: _type }, _cb); }, // 激活月卡返回 handle16701: function handle16701(_data) { if (!this.isGoodData(_data)) { return; } }, // 请求月卡额外奖励信息 reqExtraData: function reqExtraData(_cb) { this.SendProtocal(16707, {}, _cb); }, // 请求月卡额外奖励信息返回 handle16707: function handle16707(_data) { var stat = _data ? _data.status : 0; this.vset("monthExtraStatus", stat || 0); }, // 领取月卡额外奖励 reqExtraReward: function reqExtraReward(_type, _cb) { this.SendProtocal(16708, {}, _cb); }, // 领取月卡额外奖励返回 handle16708: function handle16708(_data) { if (!this.isGoodData(_data)) { return; } this.vset("monthExtraStatus", 2); }, // ============================================================ // 活动红点提示 // ============================================================ // 活动用到的提示KEY tipKeys: function tipKeys() { return ["active1", "active2", "reward1", "reward2"]; }, // 红点提示更新 freshTips: function freshTips() { this.openTip("reward", false); var c1 = this.vget("monthCard1"); if (c1) { this.openTip("reward1", c1.is_reward == 1); this.openTip("active1", c1.is_reward == 3); } var c2 = this.vget("monthCard2"); if (c2) { this.openTip("reward2", c2.is_reward == 1); this.openTip("active2", c2.is_reward == 3); } } }); // 模块导出 module.exports = ActMonth; cc._RF.pop();