"use strict"; cc._RF.push(module, 'dc3a3GDfldHvbGcWFNvpK0g', 'act.starorder.mod'); // Scripts/mod/acts/starorder/act.starorder.mod.js "use strict"; /******************************************************************************* * * 活动:星界密令 * * ******************************************************************************/ var ActBase = require("act.base"); var StarOrder = cc.Class({ "extends": ActBase, // 初始化配置数据 initConfig: function initConfig() { // 视图附着 nx.plugin.add(this, ["view"]); this.vattach("Acts"); this.cards = []; }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(31200, this.handle31200.bind(this)); //任務信息 this.RegisterProtocal(31201, this.handle31201.bind(this)); //任務狀態更新 this.RegisterProtocal(31202, this.handle31202.bind(this)); //提交任務 this.RegisterProtocal(31203, this.handle31203.bind(this)); //等級獎勵展示 this.RegisterProtocal(31204, this.handle31204.bind(this)); //領取等級禮包 this.RegisterProtocal(31205, this.handle31205.bind(this)); //等級變更(只主動推送) this.RegisterProtocal(31206, this.handle31206.bind(this)); //進階卡情況 this.RegisterProtocal(31207, this.handle31207.bind(this)); //是否彈窗 this.RegisterProtocal(31208, this.handle31208.bind(this)); //周期重置紅點 }, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["holiday_star_hero_order_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.reqBaseData(_cb); _this.send31203(); }); }, // 请求剧情信息 reqBaseData: function reqBaseData(_cb) { this.send31200(_cb); }, // ============================================================ // 星界密令 // ============================================================ //任務完成情況 send31200: function send31200(_cb) { this.SendProtocal(31200, {}, _cb); }, handle31200: function handle31200(_data) { if (!this.isGoodData(_data)) { this.vset("OrderTasks", []); 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("OrderInfos", { 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("OrderTasks", _data.list); // 提示刷新 this.freshTaskTips(_data.list); }, handle31201: function handle31201(_data) { if (!this.isGoodData(_data)) { return; } var temp_list = _data.list; var task_list = this.vget("OrderTasks"); 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("OrderTasks", task_list); this.openTip("reward", count > 0); this.openTip(this.tipKeys()[0], count > 0); }, //提交任務 send31202: function send31202(_id, _cb) { this.SendProtocal(31202, { id: _id }, _cb); }, handle31202: function handle31202(_data) { if (!this.isGoodData(_data)) { return; } }, //任務完成情況 send31203: function send31203(_cb) { this.SendProtocal(31203, {}, _cb); }, handle31203: function handle31203(_data) { if (!this.isGoodData(_data)) { this.vset("OrderRewards", []); 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("OrderRewards", _data.reward_list); // 提示刷新 this.freshAwardTips(_data.reward_list); }, //領取等級獎勵 send31204: function send31204(_id, _cb) { this.SendProtocal(31204, { id: _id }, _cb); }, handle31204: function handle31204(_data) { if (!this.isGoodData(_data)) { return; } }, //等級變更 handle31205: function handle31205(_data) { if (!this.isGoodData(_data)) { return; } this.vset("OrderInfos", { lev: _data.lev, exp: _data.exp }); }, //進階卡情況 send31206: function send31206(_cb) { this.SendProtocal(31206, {}, _cb); }, handle31206: function handle31206(_data) { if (!this.isGoodData(_data)) { return; } this.setRmdStatus(_data.rmb_status); this.setOrderCards(_data.list); }, handle31207: function handle31207(_data) { if (!this.isGoodData(_data)) { return; } }, handle31208: function handle31208(_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 || 0; }, 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 = StarOrder; cc._RF.pop();