"use strict"; cc._RF.push(module, '5b315hv/QRGPb0BFIPTRXim', 'act.sign15.mod'); // Scripts/mod/acts/sign15/act.sign15.mod.js "use strict"; /******************************************************************************* * * 活动: 15日签到 * * ******************************************************************************/ var ActBase = require("act.base"); var ActModSign15 = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(14110, this.onHand14110.bind(this)); // 签到数据 this.RegisterProtocal(14111, this.onHand14111.bind(this)); // 领取签到 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["holiday_checkin_data"]; this.loadConfigs(cfgs, function (_ret, _data) { nx.dt.fnInvoke(_cb, true); _this.reqSignData(); }); }, // 签到数据 reqSignData: function reqSignData(_cb) { this.SendProtocal(14110, { camp_id: this.data.camp_id }, _cb); }, // 签到数据 onHand14110: function onHand14110(_data) { if (_data.camp_id != this.data.camp_id || !this.isGoodData(_data)) { return; } nx.bridge.acts.vset("sign15", _data.gift_buy_info || []); this.freshTips(); }, // 领取签到 reqReward: function reqReward(_day, _cb) { this.SendProtocal(14111, { camp_id: this.data.camp_id, day: _day }, _cb); }, // 领取签到 onHand14111: function onHand14111(_data) { if (_data.camp_id != this.data.camp_id || !this.isGoodData(_data)) { return; } this.reqSignData(); }, // 获取配置 queryConfig: function queryConfig() { var data = game.configs.holiday_checkin_data.data_client_info; var cfgs = data ? data[this.data.camp_id] : null; if (nx.dt.objEmpty(cfgs)) { nx.error("Sign15:\u7B7E\u5230\u914D\u7F6E\u7F3A\u5931!" + this.data.camp_id); } return cfgs; }, // 获取帮助 queryRule: function queryRule() { var data = game.configs.holiday_checkin_data.data_desc; var cfgs = data ? data[this.data.camp_id] : null; return cfgs ? cfgs.desc : ""; }, // 获取签到任务配置 queryTaskList: function queryTaskList() { var data = game.configs.holiday_checkin_data.data_sign_in; var list = data ? data[this.data.camp_id] : null; if (nx.dt.objEmpty(list)) { nx.error("Sign15:\u7B7E\u5230\u4EFB\u52A1\u914D\u7F6E\u7F3A\u5931!" + this.data.camp_id); } return list; }, // ============================================================ // 活动红点提示 // ============================================================ // 红点提示更新 freshTips: function freshTips() { var can = false; var list = this.vget("sign15") || []; for (var i = 0; i < list.length; ++i) { // 0不可领取 1可领取 2已领取 var task = list[i]; if (task && task.status == 1) { can = true; break; } } this.openTip("reward", can); } }); // 模块导出 module.exports = ActModSign15; cc._RF.pop();