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
"use strict";
cc._RF.push(module, '6541bIuL31FMKqBIio91fSt', 'orderaction_controller');
// Scripts/mod/orderaction/orderaction_controller.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      战令控制模块
// <br/>Create: 2019-08-10 16:19:12
// --------------------------------------------------------------------
var OrderActionEvent = require("orderaction_event");
 
var OrderactionController = cc.Class({
  "extends": BaseController,
  ctor: function ctor() {},
  // 初始化配置数据
  initConfig: function initConfig() {
    var OrderactionModel = require("orderaction_model");
 
    this.model = new OrderactionModel();
    this.model.initConfig();
  },
  // 返回当前的model
  getModel: function getModel() {
    return this.model;
  },
  // 注册监听事件
  registerEvents: function registerEvents() {},
  // 注册协议接受事件
  registerProtocals: function registerProtocals() {
    this.RegisterProtocal(25300, this.handle25300);
    this.RegisterProtocal(25301, this.handle25301);
    this.RegisterProtocal(25303, this.handle25303);
    this.RegisterProtocal(25304, this.handle25304);
    this.RegisterProtocal(25305, this.handle25305);
    this.RegisterProtocal(25306, this.handle25306);
    this.RegisterProtocal(25307, this.handle25307);
    this.RegisterProtocal(25308, this.handle25308);
    this.RegisterProtocal(25309, this.handle25309);
  },
  // 任务信息
  send25300: function send25300() {
    this.SendProtocal(25300, {});
  },
  // [[
  // 由于第三期的界面改动比较大,所以相对应的有些界面就特殊去处理
  // ]]
  handle25300: function handle25300(data) {
    this.model.setCurPeriod(data.period); //周期数
 
    this.model.setCurDay(data.cur_day); //天数
 
    this.model.setRMBStatus(data.rmb_status); //是否激活特权
 
    this.model.setExtraStatus(data.exp_status); //是否领取额外礼包
 
    this.model.setCurLev(data.lev); //当前等级
 
    this.model.setCurExp(data.exp); //当前经验
 
    this.model.setInitTaskData(data.list); //任务列表
 
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_Init_Event, data);
  },
  // 任务更新
  handle25301: function handle25301(data) {
    this.model.updataTeskData(data);
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_TaskGet_Event);
  },
  // 提交任务
  send25302: function send25302(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(25302, proto);
  },
  // 等级奖励
  send25303: function send25303() {
    this.SendProtocal(25303, {});
  },
  handle25303: function handle25303(data) {
    this.model.setLevShowData(data.reward_list);
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_LevReward_Event, data.lev);
  },
  // 领取等级奖励
  send25304: function send25304(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(25304, proto);
  },
  handle25304: function handle25304(data) {
    message(data.msg);
  },
  //  等级变更(只会主动推)
  handle25305: function handle25305(data) {
    this.model.setCurExp(data.exp);
    this.model.setCurLev(data.lev);
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_Updata_LevExp_Event, data);
  },
  // 进阶卡情况
  send25306: function send25306() {
    this.SendProtocal(25306, {});
  },
  handle25306: function handle25306(data) {
    this.model.setRMBStatus(data.rmb_status);
    this.model.setExtraStatus(data.exp_status);
    this.model.setGiftStatus(data.list);
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_BuyGiftCard_Event);
  },
  // 购买等级(成功推送25305)
  send25307: function send25307(id) {
    var proto = {};
    proto.id = id;
    this.SendProtocal(25307, proto);
  },
  handle25307: function handle25307(data) {
    message(data.msg);
 
    if (data.flag == 1) {
      this.openBuyLevView(false);
    }
  },
  // 领取额外奖励(成功推25306)
  send25308: function send25308() {
    this.SendProtocal(25308, {});
  },
  handle25308: function handle25308(data) {
    message(data.msg);
  },
  // 是否要弹窗
  send25309: function send25309() {
    this.SendProtocal(25309, {});
  },
  handle25309: function handle25309(data) {
    gcore.GlobalEvent.fire(OrderActionEvent.OrderAction_IsPopWarn_Event, data);
  },
  // 打开主界面
  openOrderActionMainView: function openOrderActionMainView(status) {
    if (status == true) {
      if (!this.order_action_view) {
        this.order_action_view = Utils.createClass("orderaction_main_window", this);
      }
 
      if (this.order_action_view && this.order_action_view.isOpen() == false) {
        this.order_action_view.open();
      }
    } else {
      if (this.order_action_view) {
        this.order_action_view.close();
        this.order_action_view = null;
      }
    }
  },
  getOrderActionMainRoot: function getOrderActionMainRoot() {
    if (this.order_action_view) {
      return this.order_action_view;
    }
 
    return null;
  },
  // 打开购买等级
  openBuyLevView: function openBuyLevView(status) {
    if (status == true) {
      if (!this.buy_lev_view) {
        this.buy_lev_view = Utils.createClass("buy_lev_window", this);
      }
 
      if (this.buy_lev_view && this.buy_lev_view.isOpen() == false) {
        this.buy_lev_view.open();
      }
    } else {
      if (this.buy_lev_view) {
        this.buy_lev_view.close();
        this.buy_lev_view = null;
      }
    }
  },
  // 奖励总览
  openUntieRewardView: function openUntieRewardView(status) {
    if (status == true) {
      if (!this.untie_reward_view) {
        this.untie_reward_view = Utils.createClass("untie_reward_1_window", this);
      }
 
      if (this.untie_reward_view && this.untie_reward_view.isOpen() == false) {
        this.untie_reward_view.open();
      }
    } else {
      if (this.untie_reward_view) {
        this.untie_reward_view.close();
        this.untie_reward_view = null;
      }
    }
  },
  // 打开活动结束警告界面
  openEndWarnView: function openEndWarnView(status, day) {
    if (status == true) {
      if (!this.end_warn_view) {
        this.end_warn_view = Utils.createClass("orderaction_end_warn_window", this);
      }
 
      if (this.end_warn_view && this.end_warn_view.isOpen() == false) {
        this.end_warn_view.open(day);
      }
    } else {
      if (this.end_warn_view) {
        this.end_warn_view.close();
        this.end_warn_view = null;
      }
    }
  },
  // 购买进阶卡
  openBuyCardView: function openBuyCardView(status) {
    if (status == true) {
      if (!this.buy_card_view) {
        this.buy_card_view = Utils.createClass("untie_reward_window", this);
      }
 
      if (this.buy_card_view && this.buy_card_view.isOpen() == false) {
        this.buy_card_view.open();
      }
    } else {
      if (this.buy_card_view) {
        this.buy_card_view.close();
        this.buy_card_view = null;
      }
    }
  }
});
module.exports = OrderactionController;
 
cc._RF.pop();