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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
"use strict";
cc._RF.push(module, '941a7QZuwtDCbqK0qoAhlio', 'redbag_controller');
// Scripts/mod/redbag/redbag_controller.js
 
"use strict";
 
// ------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      公会红包
// <br/>Create: 2019-02-13 11:19:47
// --------------------------------------------------------------------
var RoleController = require("role_controller");
 
var MainuiEvent = require("mainui_event");
 
var RedbagEvent = require("redbag_event");
 
var RedbagController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var RedbagModel = require("redbag_model");
 
    this.model = new RedbagModel();
    this.model.initConfig();
    this.red_bag_vo = null; //临时存储当前领的
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    if (!this.role_create_success) {
      this.role_create_success = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
        gcore.GlobalEvent.unbind(this.role_create_success);
        this.role_create_success = null;
 
        if (this.role_vo) {
          if (this.role_update_event == null) {
            this.role_update_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) {
              if (key == "gid" && value == 0) {
                this.model.resetData();
              }
            }.bind(this));
          }
        }
      }.bind(this));
    }
 
    if (!this.red_bg_event) {
      this.red_bg_event = gcore.GlobalEvent.bind(MainuiEvent.CLOSE_ITEM_VIEW, function (data) {
        if (data && data.is_red_bag && data.is_red_bag == true) {
          var info_data = this.model.getRedBagListById(data.info_data.id);
 
          if (info_data != null) {
            this.openLookWindow(true, info_data);
          }
        }
      }.bind(this));
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(13534, this.handle13534);
    this.RegisterProtocal(13535, this.handle13535);
    this.RegisterProtocal(13536, this.handle13536); //领取成员红包
 
    this.RegisterProtocal(13546, this.handle13546); // 当前发放红包情况
 
    this.RegisterProtocal(13540, this.handle13540); //公会红包领取情况
 
    this.RegisterProtocal(13545, this.handle13545); //发红包排名
  },
  openMainView: function openMainView(bool, extend_id) {
    if (bool == false) {
      if (this.main_window) {
        this.main_window.close();
        this.main_window = null;
      }
    } else {
      if (this.main_window == null) {
        this.main_window = Utils.createClass("redbag_window", extend_id);
      }
 
      this.main_window.open();
    }
  },
  openLookWindow: function openLookWindow(bool, data) {
    if (bool == false) {
      if (this.look_window) {
        this.look_window.close();
        this.look_window = null;
      }
    } else {
      if (this.look_window == null) {
        this.look_window = Utils.createClass("redbag_look_window", data);
      }
 
      this.look_window.open(data);
    }
  },
  //成员红包列表信息
  sender13534: function sender13534() {
    var protocal = {};
    this.SendProtocal(13534, protocal);
  },
  handle13534: function handle13534(data) {
    this.model.updateData(data);
  },
  //请求使用道具发放公会红包
  sender13535: function sender13535(type, loss_type) {
    var protocal = {};
    protocal.type = type;
    protocal.num = 1;
    protocal.msg_id = 0;
    protocal.loss_type = loss_type;
    this.SendProtocal(13535, protocal);
  },
  handle13535: function handle13535(data) {
    if (data) {
      message(data.msg);
    }
  },
  //领取成员红包
  sender13536: function sender13536(id) {
    var protocal = {};
    protocal.id = id;
    this.SendProtocal(13536, protocal);
  },
  handle13536: function handle13536(data) {
    message(data.msg);
    if (data.code == 1) this.openRegBagWindow(true, data);
  },
  //公会红包领取情况
  sender13540: function sender13540(id) {
    var protocal = {};
    protocal.id = id;
    this.SendProtocal(13540, protocal);
  },
  handle13540: function handle13540(data) {
    gcore.GlobalEvent.fire(RedbagEvent.Get_List_Event, data);
  },
  //发红包排名
  sender13545: function sender13545() {
    this.SendProtocal(13545, {});
  },
  handle13545: function handle13545(data) {
    gcore.GlobalEvent.fire(RedbagEvent.Rank_List_Event, data);
  },
  setRedBagVo: function setRedBagVo(vo) {
    this.red_bag_vo = vo;
  },
  //打开红包特效界面
  openRegBagWindow: function openRegBagWindow(bool, data) {
    if (bool == false) {
      if (this.open_window) {
        this.open_window.close();
        this.open_window = null;
      }
    } else {
      if (this.open_window == null) {
        this.open_window = Utils.createClass("redbag_open_window", data);
      }
 
      this.open_window.open(data);
    }
  },
  //请求红包数据
  send13546: function send13546() {
    this.SendProtocal(13546, {});
  },
  handle13546: function handle13546(data) {
    gcore.GlobalEvent.fire(RedbagEvent.Update_Red_Bag_Event, data.list);
  }
});
module.exports = RedbagController;
 
cc._RF.pop();