difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"use strict";
cc._RF.push(module, 'cdcc1o/q79C3rQ5QVTLFu+1', 'mail_controller');
// Scripts/mod/mail/mail_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>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();