"use strict"; cc._RF.push(module, '168fbzQKWtAJJKuVGIu0CSp', 'voyage_controller'); // Scripts/mod/voyage/voyage_controller.js "use strict"; var _cc$Class; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2019-03-06 20:33:19 // -------------------------------------------------------------------- var RoleController = require("role_controller"); var VoyageEvent = require("voyage_event"); var VoyageController = cc.Class((_cc$Class = { "extends": BaseController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var VoyageModel = require("voyage_model"); this.model = new VoyageModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() { if (this.init_role_event == null) { this.init_role_event = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () { gcore.GlobalEvent.unbind(this.init_role_event); this.init_role_event = null; }, this); } //断线重连的时候 if (this.re_link_game_event == null) { this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {}, this); } }, //请求远航数据 requestVoyageInfo: function requestVoyageInfo() { this.SendProtocal(23800, {}); }, //请求接取订单 requestReceiveOrder: function requestReceiveOrder(order_id, assign_ids) { var protocal = {}; protocal.order_id = order_id; protocal.assign_ids = assign_ids; this.SendProtocal(23802, protocal); }, //请求完成订单 requestFinishOrder: function requestFinishOrder(order_id, type) { var protocal = {}; protocal.order_id = order_id; protocal.type = type; this.SendProtocal(23803, protocal); }, //请求刷新 requestRefreshOrder: function requestRefreshOrder() { this.SendProtocal(23804, {}); }, //请求远航活动状态 requestActivityStatus: function requestActivityStatus() { var protocal = {}; this.SendProtocal(23805, protocal); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(23800, this.handle23800); // 远航数据(订单、刷新次数等) this.RegisterProtocal(23801, this.handle23801); // 远航订单数据 this.RegisterProtocal(23802, this.handle23802); // 远航接取订单 this.RegisterProtocal(23803, this.handle23803); // 远航完成订单 this.RegisterProtocal(23804, this.handle23804); // 远航刷新订单 this.RegisterProtocal(23805, this.handle23805); // 远航活动状态 this.RegisterProtocal(23820, this.handle23820); // 远航记录返回 this.RegisterProtocal(23821, this.handle23821); // 第一次弹出特权提示 }, //远航数据(订单、刷新次数等) handle23800: function handle23800(data) { if (data.order_list) { this.model.setOrderList(data.order_list); } if (data.free_times) { this.model.setFreeTimes(data.free_times); } if (data.coin_times) { this.model.setCoinTimes(data.coin_times); } gcore.GlobalEvent.fire(VoyageEvent.UpdateVoyageDataEvent); gcore.GlobalEvent.fire(VoyageEvent.UpdateVoyageRedEvent); }, //远航订单数据更新 handle23801: function handle23801(data) { if (data) { this.model.updateOneOrderData(data); gcore.GlobalEvent.fire(VoyageEvent.UpdateVoyageRedEvent); } }, //接取订单返回 handle23802: function handle23802(data) { message(data.msg); if (data.flag == 1) { this.openVoyageDispatchWindow(false); } }, //完成订单返回 handle23803: function handle23803(data) { message(data.msg); if (data.flag == 1 && data.order_id) { this.model.deleteOneOrderData(data.order_id); gcore.GlobalEvent.fire(VoyageEvent.DeleteOrderDataEvent); gcore.GlobalEvent.fire(VoyageEvent.UpdateVoyageRedEvent); } }, //刷新订单返回 handle23804: function handle23804(data) { message(data.msg); }, //远航活动状态 handle23805: function handle23805(data) { if (data.flag) { this.model.setActivityStatus(data.flag); gcore.GlobalEvent.fire(VoyageEvent.UpdateActivityStatusEvent); } }, //远航第一次点击特权记录 send23820: function send23820() { this.SendProtocal(23820, {}); }, handle23820: function handle23820(data) {}, //请求特权记录情况 send23821: function send23821() { this.SendProtocal(23821, {}); }, handle23821: function handle23821(data) { this.model.setFirstFresh(data.flag != 1); }, //--------------------------@ 界面相关 openVoyageMainWindow: function openVoyageMainWindow(status, not_tips) { if (status == true) { if (!this.checkVoyageIsOpen(not_tips)) { return; } if (!this.voyage_main_window) { this.voyage_main_window = Utils.createClass("voyage_main_window"); this.voyage_main_window.open(); } } else { if (this.voyage_main_window) { this.voyage_main_window.close(); this.voyage_main_window = null; } } }, //引导需要 getVoyageMainRoot: function getVoyageMainRoot() { if (this.voyage_main_window) { return this.voyage_main_window.root_wnd; } }, //打开远航派遣界面 openVoyageDispatchWindow: function openVoyageDispatchWindow(status, data) { if (status == true) { if (!this.voyage_dispatch_window) { this.voyage_dispatch_window = Utils.createClass("voyage_dispatch_window"); this.voyage_dispatch_window.open(data); } } else { if (this.voyage_dispatch_window) { this.voyage_dispatch_window.close(); this.voyage_dispatch_window = null; } } }, //远航是否开启 checkVoyageIsOpen: function checkVoyageIsOpen(no_tips) { var is_open = false; var lev_config = Config.shipping_data.data_const["guild_lev"]; var role_vo = RoleController.getInstance().getRoleVo(); if (lev_config && lev_config.val <= role_vo.lev) { is_open = true; } else if (!no_tips) { message(lev_config.desc); } return is_open; } }, _defineProperty(_cc$Class, "getVoyageMainRoot", function getVoyageMainRoot() { if (this.voyage_main_window) return this.voyage_main_window.root_wnd; }), _defineProperty(_cc$Class, "getVoyageDispatchRoot", function getVoyageDispatchRoot() { if (this.voyage_dispatch_window) return this.voyage_dispatch_window.root_wnd; }), _cc$Class)); module.exports = VoyageController; cc._RF.pop();