"use strict"; cc._RF.push(module, '4ca8c9uvlpF75WC1jCp/hb4', 'act.heroneworder.mod'); // Scripts/mod/acts/heroneworder/act.heroneworder.mod.js "use strict"; /******************************************************************************* * * 活动:星辉密令(新英雄活动) * * ******************************************************************************/ var ActBase = require("act.base"); var HeroNewOrder = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); this.cards = []; }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(31210, this.handle31210.bind(this)); //任務信息 this.RegisterProtocal(31211, this.handle31211.bind(this)); //任務狀態更新 this.RegisterProtocal(31212, this.handle31212.bind(this)); //提交任務 this.RegisterProtocal(31213, this.handle31213.bind(this)); //等級獎勵展示 this.RegisterProtocal(31214, this.handle31214.bind(this)); //領取等級禮包 this.RegisterProtocal(31215, this.handle31215.bind(this)); //等級變更(只主動推送) this.RegisterProtocal(31216, this.handle31216.bind(this)); //進階卡情況 this.RegisterProtocal(31217, this.handle31217.bind(this)); //是否彈窗 this.RegisterProtocal(31218, this.handle31218.bind(this)); //周期重置紅點 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["holiday_newhero_order_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqBaseData(_cb); _this.send31213(); }); }, // 请求剧情信息 reqBaseData: function reqBaseData(_cb) { this.send31210(_cb); }, // ============================================================ // 星辉密令(新英雄活动) // ============================================================ //任務完成情況 send31210: function send31210(_cb) { this.SendProtocal(31210, {}, _cb); }, handle31210: function handle31210(_data) { if (!this.isGoodData(_data)) { this.vset("HeroNewOrderTasks", []); return; } this.setPeriod(_data.period); this.setRmdStatus(_data.rmb_status); if (_data.rmb_status == 1) { nx.bridge.closePanel("WndStarorderBuys"); } this.setEndTime(_data.end_time); this.vset("HeroNewOrderInfos", { lev: _data.lev, exp: _data.exp }); _data.list.forEach(function (_task) { if (_task.finish == 0) { _task.sortid = 1; } else if (_task.finish == 1) { _task.sortid = 0; } else if (_task.finish == 2) { _task.sortid = 2; } }); this.vset("HeroNewOrderTasks", _data.list); // 提示刷新 this.freshTaskTips(_data.list); }, handle31211: function handle31211(_data) { if (!this.isGoodData(_data)) { return; } var temp_list = _data.list; var task_list = this.vget("HeroNewOrderTasks"); var count = 0; for (var i = 0; i < task_list.length; i++) { var task = task_list[i]; if (task) { task.sortid = 1; for (var t = 0; t < temp_list.length; t++) { if (temp_list[t].id == task.id && temp_list[t].type == task.type) { if (temp_list[t].finish == 1) { count++; task_list[t].sortid = 0; } else if (temp_list[t].finish == 0) { task_list[t].sortid = 1; } else if (task.finish == 2) { task_list[t].sortid = 2; } task_list[i] = temp_list[t]; break; } } } } this.vset("HeroNewOrderTasks", task_list); this.openTip("reward", count > 0); this.openTip(this.tipKeys()[0], count > 0); }, //提交任務 send31212: function send31212(_id, _cb) { this.SendProtocal(31212, { id: _id }, _cb); }, handle31212: function handle31212(_data) { if (!this.isGoodData(_data)) { return; } }, //任務完成情況 send31213: function send31213(_cb) { this.SendProtocal(31213, {}, _cb); }, handle31213: function handle31213(_data) { if (!this.isGoodData(_data)) { this.vset("HeroNewOrderRewards", []); return; } /***8 * {"lev":7,"reward_list":[ * {"id":1,"status":1,"rmb_status":1}, * {"id":2,"status":1,"rmb_status":1}, * {"id":3,"status":1,"rmb_status":1}, * {"id":4,"status":1,"rmb_status":1}, * {"id":5,"status":1,"rmb_status":1}, * {"id":6,"status":1,"rmb_status":1} * ] */ var max_lv = game.configs.holiday_star_hero_order_data.data_constant.star_order_levmax.val; var is_buy = this.getRmbStatus(); if (_data.reward_list.length < _data.lev && _data.lev != max_lv) { var count = _data.lev - _data.reward_list.length; _data.reward_list.forEach(function (_reward) { _reward.rmb_status = is_buy == 1 && _reward.rmb_status != 1 ? 2 : _reward.rmb_status; }); for (var r = 0; r < count; r++) { var showdata = { id: _data.lev - r, status: 0, rmb_status: is_buy == 1 ? 2 : 0 }; _data.reward_list.push(showdata); } } this.vset("HeroNewOrderRewards", _data.reward_list); // 提示刷新 this.freshAwardTips(_data.reward_list); }, //領取等級獎勵 send31214: function send31214(_id, _cb) { this.SendProtocal(31214, { id: _id }, _cb); }, handle31214: function handle31214(_data) { if (!this.isGoodData(_data)) { return; } }, //等級變更 handle31215: function handle31215(_data) { if (!this.isGoodData(_data)) { return; } this.vset("HeroNewOrderInfos", { lev: _data.lev, exp: _data.exp }); }, //進階卡情況 send31216: function send31216(_cb) { this.SendProtocal(31216, {}, _cb); }, handle31216: function handle31216(_data) { if (!this.isGoodData(_data)) { return; } this.setRmdStatus(_data.rmb_status); this.setOrderCards(_data.list); }, handle31217: function handle31217(_data) { if (!this.isGoodData(_data)) { return; } }, handle31218: function handle31218(_data) { if (!this.isGoodData(_data)) { return; } }, // ============================================================ // 活动红点提示 // ============================================================ // 活动用到的提示KEY tipKeys: function tipKeys() { return ["tasks", "orders", "awards"]; }, // 红点提示更新 freshTaskTips: function freshTaskTips(list) { var count = 0; //是否有任務完成 for (var i = 0; i < list.length; i++) { var task = list[i]; if (task.finish == 1) { //已完成 count++; } else { // this.openTip( this.tipKeys()[0], false ); } } this.openTip("reward", count > 0); this.openTip(this.tipKeys()[0], count > 0); }, freshAwardTips: function freshAwardTips(list) { var count = 0; //是否有任務完成 for (var i = 0; i < list.length; i++) { var award = list[i]; if (award.status == 0) { //已完成 count++; } else { // this.openTip( this.tipKeys()[1], false ); // this.openTip( this.tipKeys()[2], false ); } } this.openTip("reward", count > 0); this.openTip(this.tipKeys()[2], count > 0); }, //當前活動周期 setPeriod: function setPeriod(period) { this.curPeriod = period; }, getPeriod: function getPeriod() { return this.curPeriod || 51178; }, setRmdStatus: function setRmdStatus(status) { this.is_rmb = status; }, getRmbStatus: function getRmbStatus() { return this.is_rmb || 0; }, setOrderCards: function setOrderCards(cards) { this.cards = cards; }, getOrderCards: function getOrderCards() { return this.cards; }, setEndTime: function setEndTime(end_time) { this.cdTime = end_time; }, getEndTime: function getEndTime() { return this.cdTime || 0; } }); // 模块导出 module.exports = HeroNewOrder; cc._RF.pop();