"use strict"; cc._RF.push(module, '4f6bfKZYWRDXpwlXMiaunHe', 'task_controller'); // Scripts/mod/task/task_controller.js "use strict"; // //////////////////////////////////////////////////////////////////// // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 任务,日常,成就 //
Create: 2019-01-09 11:26:10 // //////////////////////////////////////////////////////////////////// var BridgeController = require("bridge.controller"); // 桥接替换的界面 var TaskController = cc.Class({ "extends": BridgeController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var TaskModel = require("task_model"); this.model = new TaskModel(this); this.model.initConfig(); var cfgs = ["activity_advertisement_data"]; this.loadConfigs(cfgs); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() {}, requestBaseQuestData: function requestBaseQuestData(_cb) { this.SendProtocal(10400, {}); //请求当前所有的成就列表 this.requestActivityInfo(_cb); //请求活跃度 }, // 注册协议接受事件 registerProtocals: function registerProtocals() { this.RegisterProtocal(10400, this.on10400); //全部成就列表 this.RegisterProtocal(10406, this.on10406); //提交任务返回,客户端自己更新内存缓存数据 this.RegisterProtocal(10409, this.on10409); //更新已接任务进度 this.RegisterProtocal(20300, this.on20300); //已领取的活跃宝箱 this.RegisterProtocal(20301, this.on20301); //请求领取活跃宝箱 //新主线 this.RegisterProtocal(30001, this.on30001); //进度更新时返回 this.RegisterProtocal(30002, this.on30002); //提交任务返回 }, reqBaseFromServer: function reqBaseFromServer(_cb) { var _this = this; var cfgs = ["activity_data"]; this.loadConfigs(cfgs, function (_ret, _data) { _this.requestBaseQuestData(_cb); }); }, send10400: function send10400() { this.SendProtocal(10400, {}); //请求当前所有的成就列表 }, on10400: function on10400(data) { this.model.addTaskList(data.quest_list, false, true); }, on10406: function on10406(data) { // nx.tbox( data.msg ); if (data.flag == 1) this.model.setTaskCompleted(data.id); }, on10409: function on10409(data) { this.model.addTaskList(data.quest_list, true); }, // @desc:打开日常任务主界面 // author:{author} // time:2018-05-22 11:32:35 // //@status:打开或者关闭 // //@index:自动跳转到 // return openTaskMainWindow: function openTaskMainWindow(status, index) { if (status == false) { if (this.task_main_window != null) { this.task_main_window.close(); this.task_main_window = null; } } else { if (this.task_main_window == null) { var TaskMainWindow = require("task_main_window"); this.task_main_window = new TaskMainWindow(); } this.task_main_window.open(index); } }, // @desc:点击任务前往 // author:{author} // time:2018-05-22 21:00:26 // //@data: // //@index: // //@open_type: // return handleTaskProgress: function handleTaskProgress(data, index, open_type) { index = index || 1; if (data.config.progress == null || Utils.next(data.config.progress) == null) { if (data.id != null) cc.log("=================> 处理任务进度时出错,任务id为 " + data.id + " 的没有配置任务进度"); return; } var progressConfig = data.config.progress[index]; if (progressConfig == null) { if (data.id != null) cc.log("=================> 处理任务id为 " + data.id + " 的第 " + index + " 个进度要求时出错"); return; } //拓展参数用于跳转 var extra = data.config.extra; this.gotoTagertFun(progressConfig, extra, open_type); }, //desc:任务和成就的跳转 //time:2018-07-07 03:57:59 //@progressConfig: //@extra: //@open_type: //@return gotoTagertFun: function gotoTagertFun(progressConfig, extra, open_type) {}, //------------------------活跃度相关 start requestActivityInfo: function requestActivityInfo(_cb) { this.SendProtocal(20300, {}, _cb); nx.mTip.openTip("daily.show", true); // nx.mTip.openTip( "openServerActs.show", true ); }, on20300: function on20300(data) { this.model.updateActivityData(data.activity_box); }, requestGetActivityAwards: function requestGetActivityAwards(activity) { var proto = {}; proto.activity = activity; this.SendProtocal(20301, proto); }, on20301: function on20301(data) { nx.tbox(data.msg); if (data.code == 1) this.model.updateSingleActivityData(data.activity); }, //------------------------活跃度相关 end //-----------------------新主线 // 打开主/支线界面 openMainTaskWindow: function openMainTaskWindow(_open, _params) { if (_open == false) { nx.bridge.closePanel("WndTaskMain"); } else { nx.bridge.createPanel("WndTaskMain"); } }, send30001: function send30001() { // this.SendProtocal(30001, {}); nx.warn("消息暂时屏蔽: ", 30001); }, on30001: function on30001(data) { cc.log("30001", data); this.model.setMainTaskData(data); }, send30002: function send30002(task_id) { var proto = {}; proto.id = task_id; // this.SendProtocal(30002, proto); nx.warn("消息暂时屏蔽: ", 30002); }, on30002: function on30002(data) { cc.log("3002", data); nx.tbox(data.msg); if (data.code == 1) {} } }); module.exports = TaskController; cc._RF.pop();