"use strict"; cc._RF.push(module, '168fbzQKWtAJJKuVGIu0CSp', 'dispatch.mod'); // Scripts/mod/home/dispatch/dispatch.mod.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2019-03-06 20:33:19 // -------------------------------------------------------------------- var BridgeController = require("bridge.controller"); var DispatchConst = require("dispatch.const"); var DispatchMod = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var DispatchModel = require("dispatch.model"); this.model = new DispatchModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册协议接受事件 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); // 第一次弹出特权提示 this.RegisterProtocal(23806, this.handle23806); // 一键领取 }, // 注册监听事件 registerEvents: function registerEvents() {}, // 从服务器初始化数据 reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; // 配置加载 var cfgs = ["shipping_data" // 家园派遣 ]; this.loadConfigs(cfgs, function (_ret, _data) { nx.dt.fnInvoke(_cb, true); _this.requestActivityStatus(); _this.reqData(); }); }, // 请求远航数据 reqData: function reqData(_cb) { this.SendProtocal(23800, {}, _cb); }, // 远航数据(订单、刷新次数等) 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(DispatchConst.FreshData); // 更新提示 this.freshViewTips(); }, // 请求接取订单 requestReceiveOrder: function requestReceiveOrder(order_id, assign_ids, _cb) { this.CB23802 = _cb; this.SendProtocal(23802, { order_id: order_id, assign_ids: assign_ids }); }, // 接取订单返回 handle23802: function handle23802(_data) { // 失败 if (nx.dt.objEmpty(_data) || nx.dt.strNEmpty(_data.msg)) { nx.dt.fnInvoke(this.CB23802, false, _data ? _data.msg : "ErrFailed"); this.CB23802 = null; return; } nx.dt.fnInvoke(this.CB23802, true); this.CB23802 = null; }, // 请求完成订单 requestFinishOrder: function requestFinishOrder(order_id, type, _cb) { this.CB23803 = _cb; this.SendProtocal(23803, { order_id: order_id, type: type }); }, // 完成订单返回 handle23803: function handle23803(_data) { // 失败 if (nx.dt.objEmpty(_data) || nx.dt.strNEmpty(_data.msg)) { nx.dt.fnInvoke(this.CB23803, false, _data ? _data.msg : "ErrFailed"); this.CB23803 = null; return; } if (_data.flag == 1 && _data.order_id) { this.model.deleteOneOrderData(_data.order_id); } nx.dt.fnInvoke(this.CB23803, true, this.stepData); this.CB23803 = null; gcore.GlobalEvent.fire(DispatchConst.DeleteOrder); // 更新提示 this.freshViewTips(); }, // 请求刷新 requestRefreshOrder: function requestRefreshOrder() { this.SendProtocal(23804, {}); }, // 刷新订单返回 handle23804: function handle23804(_data) { nx.tbox(_data.msg); }, // 请求远航活动状态 requestActivityStatus: function requestActivityStatus() { var protocal = {}; this.SendProtocal(23805, protocal); }, //远航订单数据更新 handle23801: function handle23801(_data) { this.model.updateOneOrderData(_data); // 更新提示 this.freshViewTips(); }, //远航活动状态 handle23805: function handle23805(_data) { if (_data.flag) { this.model.setActivityStatus(_data.flag); gcore.GlobalEvent.fire(DispatchConst.UpdateActivityStatusEvent); this.freshViewTips(); } }, //远航第一次点击特权记录 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); }, // 一键领取 requestQuickReceiveOrder: function requestQuickReceiveOrder(_cb) { this.CB23806 = _cb; this.SendProtocal(23806, {}); }, // 一键领取 handle23806: function handle23806(_data) { // 失败 if (nx.dt.objEmpty(_data) || nx.dt.strNEmpty(_data.msg)) { nx.dt.fnInvoke(this.CB23806, false, _data ? _data.msg : "ErrFailed"); this.CB23806 = null; return; } if (_data.flag) { this.model.deleteSomeOrderData(_data.order_list); } nx.dt.fnInvoke(this.CB23806, true); this.CB23806 = null; gcore.GlobalEvent.fire(DispatchConst.DeleteOrder); gcore.GlobalEvent.fire(DispatchConst.FreshData); // 更新提示 this.freshViewTips(); }, // 提示刷新 freshViewTips: function freshViewTips() { var tip = false; var list = this.model.getAllOrderList(); for (var i in list) { var order = list[i]; if (order && order.status == DispatchConst.Order_Status.Finish) { tip = true; break; } } nx.mTip.openTip("home.dispatch.reward", tip); } }); module.exports = DispatchMod; cc._RF.pop();