"use strict"; cc._RF.push(module, 'cdcc1o/q79C3rQ5QVTLFu+1', 'mail_controller'); // Scripts/mod/mail/mail_controller.js "use strict"; // -------------------------------------------------------------------- // @author: xxx@syg.com(必填, 创建模块的人员) // @description: // 这里填写详细说明,主要填写该模块的功能简要 //
Create: 2018-12-08 14:17:36 // -------------------------------------------------------------------- var MailController = cc.Class({ "extends": BaseController, ctor: function ctor() {}, // 初始化配置数据 initConfig: function initConfig() { var MailModel = require("mail_model"); this.model = new MailModel(); this.model.initConfig(); }, // 返回当前的model getModel: function getModel() { return this.model; }, // 注册监听事件 registerEvents: function registerEvents() {// gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, (function () { this.send10800(); }).bind(this)); }, // 注册协议接受事件 registerProtocals: function registerProtocals() { //------邮件----- this.RegisterProtocal(10800, this.mailListHandler); //邮件列表 this.RegisterProtocal(10801, this.getGoodsHandler); //提取单个邮件的附件 this.RegisterProtocal(10802, this.getAllGoodsHandler); //一键提取附件 this.RegisterProtocal(10803, this.handle10803); //新邮件推送 this.RegisterProtocal(10804, this.delMailHandler); //删除没有附件的邮件 this.RegisterProtocal(10805, this.readMailHandler); //读取邮件 }, // 打开邮件主界面 openMailUI: function openMailUI(status) { if (status == true) { if (this.mail_ui == null) { var MailWindow = require("mail_window"); this.mail_ui = new MailWindow(); } this.mail_ui.open(); } else { if (this.mail_ui) { this.mail_ui.close(); this.mail_ui = null; } } }, //打开邮件内容 openMailInfo: function openMailInfo(bool, data) { if (bool == true) { if (this.mail_info == null) { var MailInfoWindow = require("mail_info_window"); this.mail_info = new MailInfoWindow(); } this.mail_info.open(); this.mail_info.setData(data); } else { if (this.mail_info) { this.mail_info.close(); this.mail_info = null; } } }, //获取邮件信息 send10800: function send10800() { this.SendProtocal(10800, {}); }, //初始化邮件列表 mailListHandler: function mailListHandler(data) { this.model.initMailList(data.mail); }, //新增一个邮件 handle10803: function handle10803(data) { this.model.addMailItem(data.mail); }, //请求删除一个邮件 deletMailSend: function deletMailSend(ids) { var protocal = {}; protocal.ids = ids; this.SendProtocal(10804, protocal); }, //推送删除邮件 delMailHandler: function delMailHandler(data) { message(data.msg); this.model.delMailItem(data.ids); }, //读取一个邮件 read: function read(bid, srv_id) { var protocal = {}; protocal.id = bid; protocal.srv_id = srv_id; this.SendProtocal(10805, protocal); }, //读取一个邮件状态之后 readMailHandler: function readMailHandler(data) { if (data.code == 1) { this.model.readMailItem(data); } }, //提取邮件附件 getGoods: function getGoods(id, srv_id) { var protocal = {}; protocal.id = id; protocal.srv_id = srv_id; this.SendProtocal(10801, protocal); }, //提取邮件返回 getGoodsHandler: function getGoodsHandler(data) { message(data.msg); if (data.code == 1) { this.model.getMailGood(data); } }, //一键提取邮件 getAllGoods: function getAllGoods() { this.SendProtocal(10802, {}); }, //一键提取返回 getAllGoodsHandler: function getAllGoodsHandler(data) { message(data.msg); if (data.ids == null || Utils.next(data.ids) == null) return; this.model.getAllMailGood(data.ids); }, //获取已经读取过的 且没有附件的邮件,用于一键删除 getHasReadNonRewardList: function getHasReadNonRewardList() { return this.model.getHasReadNonRewardList(); }, getMailInfoView: function getMailInfoView() { if (this.mail_info) { return this.mail_info; } return null; } }); module.exports = MailController; cc._RF.pop();