"use strict"; cc._RF.push(module, 'b476dYJ/YxH7owopd9GexuL', 'act.heroupstar.mod'); // Scripts/mod/acts/heroupstar/act.heroupstar.mod.js "use strict"; /******************************************************************************* * * 活动: 升星计划 * * ******************************************************************************/ var ActBase = require("act.base"); var ActHeroUpStar = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(29211, this.handle29211.bind(this)); //获取主界面信息 this.RegisterProtocal(29212, this.handle29212.bind(this)); //领取免费奖励 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["holiday_upstars_new_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqBaseData(_this.data.camp_id, _cb); }); }, // 请求剧情信息 reqBaseData: function reqBaseData(_camp_id, _cb) { this.send29211(_camp_id, _cb); }, // ============================================================ // 升星操作 // ============================================================ //任務信息 send29211: function send29211(_camp_id, _cb) { this.SendProtocal(29211, { camp_id: _camp_id }, _cb); }, handle29211: function handle29211(_data) { if (!this.isGoodData(_data)) { this.vset("heroUpstarAwards", []); return; } this.setChooseHero(_data.partner_bid, _data.partner_star); this.setLimitTime(_data.end_time); this.vset("heroUpstarAwards", _data.award_list); //獎勵列表 // 提示刷新 this.freshTips(_data); }, //领取免费奖励 send29212: function send29212(_partner_star, _camp_id, _cb) { this.SendProtocal(29212, { partner_star: _partner_star, camp_id: _camp_id }, _cb); }, handle29212: function handle29212(_data) { nx.bridge.acts.reqActsRewards(); if (!this.isGoodData(_data)) { return; } }, // ============================================================ // 活动红点提示 // ============================================================ // // 活动用到的提示KEY // tipKeys: function() { // return ["star5","star6","star7","star8","star9","star10"]; // }, // 红点提示更新 freshTips: function freshTips(_data) { var tasks = this.vget("upstarAwards"); var count = 0; for (var i = 0; i < tasks.length; i++) { if (tasks[i].free_state == 1) { // this.openTip( this.tipKeys()[i], true ); count++; } else {} } this.openTip("reward", count > 0 || _data.islock == 0); }, setChooseHero: function setChooseHero(bid, star) { this.tag_partner = {}; this.tag_partner.bid = bid; this.tag_partner.star = star; }, getChooseHero: function getChooseHero() { return this.tag_partner; }, setLimitTime: function setLimitTime(time) { this.end_time = time; }, getLimitTime: function getLimitTime() { if (this.end_time) { return this.end_time; } return 0; } }); // 模块导出 module.exports = ActHeroUpStar; cc._RF.pop();