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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
"use strict";
cc._RF.push(module, 'fc753Pu5ktBOZoyuaPREqO7', 'vip_controller');
// Scripts/mod/vip/vip_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-02-26 21:07:32
// --------------------------------------------------------------------
var RoleController = require("role_controller");
 
var VipEvent = require("vip_event");
 
var VipController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var VipModel = require("vip_model");
 
    this.model = new VipModel();
    this.model.initConfig();
    this.vip_redpoint_status = {};
    this.vip_privilege_redpoint = {}; //vip特权 item 红点
 
    this.is_first = true;
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {
    if (this.login_event_success == null) {
      this.login_event_success = gcore.GlobalEvent.bind(EventId.EVT_ROLE_CREATE_SUCCESS, function () {
        gcore.GlobalEvent.unbind(this.login_event_success);
        this.login_event_success = null;
        this.role_vo = RoleController.getInstance().getRoleVo();
 
        if (this.role_vo) {
          if (this.role_assets_event == null) {
            this.role_assets_event = this.role_vo.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (key, value) {
              if (key == "vip_lev") {
                this.setIsFirst(true);
                var get_list = this.model.getGetGiftList();
                var item_status = get_list[this.role_vo.vip_lev] == null && this.getIsFirst();
                this.setTipsVIPStstus(VIPREDPOINT.VIP_TAB, item_status);
                gcore.GlobalEvent.fire(VipEvent.UPDATA_ITEM_REDPOINT);
              }
            }.bind(this));
          }
        } // this.sender16707() //月卡领取
        // this.sender16710() //VIP礼包红点用
        // this.sender16712() //累充红点
        // this.sender21006() //每日礼包
        // this.sender24502() //特权礼包
 
      }, this);
    }
 
    if (this.re_link_game_event == null) {
      this.re_link_game_event = gcore.GlobalEvent.bind(EventId.EVT_RE_LINK_GAME, function () {// this.sender21006();
      }, this);
    }
  },
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(16700, this.handle16700); //获取充值列表信息
 
    this.RegisterProtocal(16710, this.handle16710); //VIP礼包领取信息
 
    this.RegisterProtocal(16711, this.handle16711); //VIP等级奖励领取
 
    this.RegisterProtocal(16712, this.handle16712); //获取永久累充信息
 
    this.RegisterProtocal(16713, this.handle16713); //领取累充奖励
 
    this.RegisterProtocal(21005, this.handle21005); //三倍返利信息
 
    this.RegisterProtocal(21006, this.handle21006); //每日礼包数据
 
    this.RegisterProtocal(24501, this.handle24501); //购买VIP特权礼包
 
    this.RegisterProtocal(24502, this.handle24502); //VIP特权礼包数据
 
    this.RegisterProtocal(16707, this.handle16707);
    this.RegisterProtocal(16708, this.handle16708);
    this.RegisterProtocal(16730, this.handle16730);
    this.RegisterProtocal(16731, this.handle16731);
    this.RegisterProtocal(21020, this.handle21020); //每日一元红点
  },
  setPrivilegeRedpoint: function setPrivilegeRedpoint(index, status) {
    this.vip_privilege_redpoint[index] = status;
  },
  getPrivilegeRedpoint: function getPrivilegeRedpoint(index) {
    var status = this.vip_privilege_redpoint[index];
    return status;
  },
  getIsFirst: function getIsFirst() {
    return this.is_first;
  },
  setIsFirst: function setIsFirst(status) {
    this.is_first = status;
  },
  //获取充值列表信息
  sender16700: function sender16700() {
    this.SendProtocal(16700, {});
  },
  handle16700: function handle16700(data) {
    gcore.GlobalEvent.fire(VipEvent.UPDATE_CHARGE_LIST, data.list);
  },
  //三倍返利信息
  sender21005: function sender21005() {
    this.SendProtocal(21005, {});
  },
  handle21005: function handle21005(data) {
    gcore.GlobalEvent.fire(VipEvent.THREE_RECHARGE, data);
  },
  //请求每次礼包数据
  sender21006: function sender21006() {
    this.SendProtocal(21006, {});
  },
  handle21006: function handle21006(data) {
    if (data) {
      this.model.setDailyGiftData(data.first_gift);
      gcore.GlobalEvent.fire(VipEvent.DAILY_GIFT_INFO);
    }
  },
  //请求购买VIP特权礼包
  sender24501: function sender24501(id) {
    var protocal = {};
    protocal.id = id;
    this.SendProtocal(24501, protocal);
  },
  handle24501: function handle24501(data) {
    if (data.msg) {
      message(data.msg);
    }
  },
  //请求VIP特权礼包数据
  sender24502: function sender24502() {
    this.SendProtocal(24502, {});
  },
  handle24502: function handle24502(data) {
    if (data) {
      this.model.setPrivilegeList(data.list);
      var status = this.model.getPrivilegeRedStatus();
      this.setTipsVIPStstus(VIPREDPOINT.PRIVILEGE, status);
      gcore.GlobalEvent.fire(VipEvent.PRIVILEGE_INFO);
    }
  },
  //VIP界面月卡领取
  sender16707: function sender16707() {
    this.SendProtocal(16707, {});
  },
  handle16707: function handle16707(data) {
    var status = false;
 
    if (data.status == 1) {
      status = true;
    }
 
    this.model.setMonthCard(data.status);
    this.setTipsVIPStstus(VIPREDPOINT.MONTH_CARD, status);
    gcore.GlobalEvent.fire(VipEvent.SUPRE_CARD_GET, data.status);
  },
  sender16708: function sender16708() {
    this.SendProtocal(16708, {});
  },
  handle16708: function handle16708(data) {
    message(data.msg);
  },
  //VIP礼包领取信息
  sender16710: function sender16710() {
    this.SendProtocal(16710, {});
  },
  handle16710: function handle16710(data) {
    this.model.setGetGiftList(data.list);
 
    if (this.role_vo == null) {
      this.role_vo = RoleController.getInstance().getRoleVo();
    }
 
    var get_list = this.model.getGetGiftList();
    var item_status = get_list[this.role_vo.vip_lev] == null && this.getIsFirst();
    this.setTipsVIPStstus(VIPREDPOINT.VIP_TAB, item_status);
    gcore.GlobalEvent.fire(VipEvent.UPDATA_ITEM_REDPOINT);
  },
  //红点
  setTipsVIPStstus: function setTipsVIPStstus(bid, status) {
    this.vip_redpoint_status[bid] = status;
    var redpoint = false;
 
    for (var i in this.vip_redpoint_status) {
      var v = this.vip_redpoint_status[i];
 
      if (v == true) {
        redpoint = true;
        break;
      }
    }
 
    var MainuiController = require("mainui_controller");
 
    var MainuiConst = require("mainui_const");
 
    MainuiController.getInstance().setFunctionTipsStatus(MainuiConst.icon.charge, redpoint);
  },
  //VIP等级奖励领取
  sender16711: function sender16711(lev) {
    var protocal = {};
    protocal.lev = lev;
    this.SendProtocal(16711, protocal);
  },
  handle16711: function handle16711(data) {
    message(data.msg);
  },
  //累充奖励信息
  sender16712: function sender16712() {
    this.SendProtocal(16712, {});
  },
  handle16712: function handle16712(data) {
    this.charge_sum = data.charge_sum; //当前总充值数
 
    this.model.setAccList(data.list);
    gcore.GlobalEvent.fire(VipEvent.ACC_RECHARGE_INFO, data);
  },
  getChargeSum: function getChargeSum() {
    return this.charge_sum || 0;
  },
  //领取累充奖励
  sender16713: function sender16713(id) {
    var protocal = {};
    protocal.id = id;
    this.SendProtocal(16713, protocal);
  },
  handle16713: function handle16713(data) {
    message(data.msg);
  },
  //
  sender16730: function sender16730() {
    var protocal = {};
    this.SendProtocal(16730, protocal);
  },
  // time
  // state
  handle16730: function handle16730(data) {
    this.model.setGiveVipInfo(data);
    this.model.setGiveVipStatus();
    gcore.GlobalEvent.fire(VipEvent.GIVE_VIP_UPDATE);
  },
  //
  sender16731: function sender16731() {
    var protocal = {};
    this.SendProtocal(16731, protocal);
  },
  //领取vip
  handle16731: function handle16731(data) {
    message(data.msg);
 
    if (data.code == 1) {
      this.openVipAwardWindow();
      this.sender16730();
    }
  },
  //index是大标签页 VIPTABCONST
  //sub_type是vip特权界面的 要跳哪个等级就传哪个等级
  openVipMainWindow: function openVipMainWindow(status, index, sub_type, callFunc) {
    if (status) {
      if (IS_SHOW_CHARGE == false) {
        message(Utils.TI18N("功能暂未开放,敬请期待"));
        return;
      }
 
      var charge_cfg = gdata("charge_data", "data_constant", ["open_lv"]);
 
      if (charge_cfg) {
        if (this.role_vo && this.role_vo.lev < charge_cfg.val) {
          message(charge_cfg.desc);
          return;
        }
      }
 
      if (!this.vip_window) {
        this.vip_window = Utils.createClass("vip_main_window");
      }
 
      index = index || 1;
 
      if (this.vip_window) {
        this.vip_window.open(index, sub_type);
      }
 
      if (callFunc) {
        this.deleteCallFunc = callFunc;
      }
    } else {
      if (this.vip_window) {
        this.vip_window.close();
        this.vip_window = null;
 
        if (this.deleteCallFunc) {
          this.deleteCallFunc();
          this.deleteCallFunc = null;
        }
      }
    }
  },
  // 打开奖励VIP界面
  openVipAwardWindow: function openVipAwardWindow(status) {
    if (status == true) {
      if (!this.vip_award_window) {
        this.vip_award_window = Utils.createClass("vip_award_window", this);
      }
 
      if (this.vip_award_window && this.vip_award_window.isOpen() == false) {
        this.vip_award_window.open();
      }
    } else {
      if (this.vip_award_window) {
        this.vip_award_window.close();
        this.vip_award_window = null;
      }
    }
  },
  //切换vip面板的标签页
  changeMainWindowTab: function changeMainWindowTab(index) {
    if (this.vip_window) {
      this.vip_window.changeTabView(index);
    }
  },
  handle21020: function handle21020(data) {
    var status = false;
 
    if (data.code == 1) {
      status = true;
    }
 
    var MainuiController = require("mainui_controller");
 
    var MainuiConst = require("mainui_const");
 
    MainuiController.getInstance().setFunctionTipsStatus(MainuiConst.icon.one_gift, status);
  }
});
module.exports = VipController;
 
cc._RF.pop();