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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
"use strict";
cc._RF.push(module, '51f41q7mKlA4YX7Yk3ZSXLC', 'function_icon_panel');
// Scripts/mod/mainui/view/function_icon_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-04 17:03:31
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var FunctionIconVo = require("function_icon_vo");
 
var MainuiConst = require("mainui_const");
 
var MainuiController = require("mainui_controller");
 
var ActionEvent = require("action_event");
 
var ActionController = require("action_controller");
 
var RoleController = require("role_controller");
 
var TimeTool = require("timetool");
 
var Function_iconPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.time_ticket_desc = "";
    this.data = arguments[0];
    this.width = 0;
    this.height = 0;
 
    if (this.data.config.type == FunctionIconVo.type.right_top_1 || this.data.config.type == FunctionIconVo.type.right_top_2) {
      this.prefabPath = PathTool.getPrefabPath("mainui", "function_icon_left");
      this.width = 74;
      this.height = 90;
    } else if (this.data.config.type == FunctionIconVo.type.right_bottom_1 || this.data.config.type == FunctionIconVo.type.right_bottom_2) {
      this.prefabPath = PathTool.getPrefabPath("mainui", "function_icon_right");
      this.width = 74;
      this.height = 74;
    }
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.node_list = [];
    this.need_load = false;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.container_nd = this.seekChild("main_container");
    this.button_sp = this.seekChild("button", cc.Sprite);
    this.tishi_nd = this.seekChild("tips");
    this.tishi_sp = this.seekChild("tips", cc.Sprite);
    this.skeleton = this.seekChild("skeleton", sp.Skeleton);
    this.container_nd.name = this.data.config.name;
    this.tishi_nd.active = false;
 
    if (this.data.config.type == FunctionIconVo.type.right_bottom_1 || this.data.config.type == FunctionIconVo.type.right_bottom_2) {
      this.num_lb = this.seekChild(this.container_nd, "num", cc.Label);
      this.num_lb.node.active = false;
 
      if (this.data.config.id == MainuiConst.icon.mail || this.data.config.id == MainuiConst.icon.friend) {
        this.loadRes(PathTool.getUIIconPath("mainui", "mainui_1034"), function (sp) {
          this.tishi_sp.spriteFrame = sp;
        }.bind(this));
      }
    } else {
      this.name_lb = this.seekChild(this.container_nd, "name", cc.Label);
      this.setIconName();
    }
 
    this.updateInfo(); //7天登录特殊处理
 
    if (this.data && this.data.config) {
      if (this.data.config.id == MainuiConst.icon.seven_login) {
        this.updateSevenLoginInfo();
      } else if (this.data.config.id == MainuiConst.icon.icon_charge1 || this.data.config.id == MainuiConst.icon.icon_charge2) {
        this.updateFirstChargeInfo();
      }
    }
 
    if (this.need_load) {
      this.updateIconRes();
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.container_nd.on(cc.Node.EventType.TOUCH_END, function () {
      if (this.data != null || this.data.config != null) {
        Utils.playButtonSound(1);
        MainuiController.getInstance().iconClickHandle(this.data.config.id, this.data.action_id);
      }
    }, this);
 
    if (this.data != null) {
      if (this.update_by_self_event == null) {
        this.update_by_self_event = this.data.bind(FunctionIconVo.UPDATE_SELF_EVENT, function (key) {
          if (key == null) {
            this.updateInfo();
          } else {
            if (key == "res_id") {
              this.updateIconRes();
            } else if (key == "tips_status") {
              this.updateTishiState();
            }
          }
        }, this);
      }
 
      if (this.data.id == MainuiConst.icon.seven_login) {
        this.addGlobalEvent(ActionEvent.UPDATE_SEVEN_LOGIN_STATUS, function () {
          this.updateSevenLoginInfo();
        }, this);
      }
    } //     self:registerScriptHandler(function(event)
    //     if "exit" == event then    
    //         if self.data then
    //             if self.update_by_self_event ~= nil then
    //                 self.data:UnBind(self.update_by_self_event)
    //                 self.update_by_self_event = nil
    //             end
    //             self.data = nil
    //         end
    //     end 
    // end)
 
  },
  //更新自身,现在只处理显示tips与否
  updateInfo: function updateInfo() {
    this.updateTishiState();
    this.updateIconRes();
    this.setIconName(); //首充的特殊处理
 
    if (this.data && this.data.config) {
      if (this.data.config.id == MainuiConst.icon.icon_charge1 || this.data.config.id == MainuiConst.icon.icon_charge2) {
        this.updateFirstChargeInfo();
      }
    } //推送礼包的处理
    // if(this.data && this.data.config){
    //     if(this.data.config.id == MainuiConst.icon.personal_gift){
    //         FestivalActionController:getInstance():sender26301()
    //     }
    // }
 
  },
  setIconName: function setIconName() {
    if (!this.name_lb || this.data == null || this.data.config == null) return;
 
    if (this.data.real_name && this.data.real_name != "" && this.data.real_name != "null") {
      this.name_lb.string = this.data.real_name;
    } else {
      this.name_lb.string = this.data.config.icon_name;
    }
  },
  //针对七天登录的
  updateSevenLoginInfo: function updateSevenLoginInfo() {
    var login_data = ActionController.getInstance().getModel().getMaxSevenDay();
    if (login_data == null || login_data.day == null) return;
    var day_config = gdata("login_days_data", "data_day", [login_data.day]);
 
    if (day_config) {
      var str = "";
 
      if (login_data.status == 3) {
        str = day_config.next_desc;
      } else {
        str = day_config.day_desc;
      }
 
      if (this.extend_label == null) {
        this.extend_label = Utils.createLabel(20, new cc.Color(0xff, 0xff, 0xff, 0xff), new cc.Color(0x34, 0x0d, 0x00, 0xff), 0, -this.container_nd.getContentSize().height / 2 - 12, '', this.container_nd, 2, cc.v2(0.5, 0.5));
        this.node_list.push(this.extend_label);
      }
 
      this.extend_label.string = str;
    }
  },
  updateFirstChargeInfo: function updateFirstChargeInfo() {
    if (this.data == null) return;
    var status = this.data.status;
 
    if (this.extend_label == null) {
      this.extend_label = Utils.createLabel(20, 1, 163, this.container_nd.getContentSize().width / 2, -12, '', this.container_nd, 2, cc.v2(0.5, 0.5));
    }
 
    if (status == 0) {
      this.extend_label.string = Utils.TI18N("明日可领");
    } else {
      this.extend_label.string = Utils.TI18N("可领取");
    }
  },
  updateIconRes: function updateIconRes() {
    if (this.root_wnd == null && this.button_sp == null) {
      this.need_load = true;
      return;
    }
 
    if (this.data != null && this.data.config != null) {
      if (this.data.config.res_type == 1) {
        var res_id = this.data.real_res_id;
 
        if (res_id == "") {
          res_id = this.data.res_id;
        }
 
        var target_res = PathTool.getFunctionRes(res_id);
 
        if (target_res != this.res_id) {
          this.res_id = target_res; // if( this.button_sp && this.button_sp.spriteFrame ){
 
          this.loadRes(target_res, function (sf_obj) {
            this.button_sp.spriteFrame = sf_obj;
          }.bind(this)); // }else{
          //     this.need_load = true;
          // }
        }
      } else {
        if (MainuiController.getInstance().getHideContainerStatus()) {
          if (this.data.id == MainuiConst.icon.first_charge) {
            var target_res = PathTool.getFunctionRes(this.data.res_id);
 
            if (target_res != this.res_id) {
              this.res_id = target_res; // if( this.button_sp && this.button_sp.spriteFrame ){
 
              this.loadRes(target_res, function (sf_obj) {
                this.button_sp.spriteFrame = sf_obj;
              }.bind(this)); // }else{
              //     this.need_load = true;
              // }
            }
 
            this.button_sp.node.active = false;
 
            if (this.icon_first_effect == null) {
              this.icon_first_effect = PathTool.getSpinePath(this.data.config.icon_effect);
              this.loadRes(this.icon_first_effect, function (res_object) {
                this.skeleton.skeletonData = res_object;
                this.skeleton.setAnimation(0, PlayerAction.action, true);
              }.bind(this));
            }
 
            var get_status = false;
 
            for (var i = 1; i <= 6; i++) {
              var get_data = ActionController.getInstance().getModel().getFirstBtnStatus(i);
 
              if (get_data == 1) {
                get_status = true;
                break;
              }
            }
 
            this.tishi_nd.active = get_status;
            var role_vo = RoleController.getInstance().getRoleVo();
            var num_vip_exp = role_vo.vip_exp / 10;
 
            if (num_vip_exp >= 100) {
              if (get_status == true) {
                this.skeleton.node.active = true;
                this.button_sp.node.active = false;
              } else {
                this.skeleton.node.active = false;
                this.button_sp.node.active = true;
              }
            } else {
              this.skeleton.node.active = true;
            }
          } else {
            if (this.icon_effect == null) {
              this.icon_effect = PathTool.getSpinePath(this.data.config.icon_effect);
              this.loadRes(this.icon_effect, function (res_object) {
                this.skeleton.skeletonData = res_object;
                this.skeleton.setAnimation(0, PlayerAction.action, true);
              }.bind(this));
            }
          }
        }
      }
    }
  },
  //开始准备倒计时
  updateTime: function updateTime() {
    if (this.data == null || this.data.config == null) return;
 
    if (this.data.end_time > 0) {
      this.setLessTime();
    } else {
      this.removeTimeLabel();
    }
  },
  //设置倒计时
  setLessTime: function setLessTime() {
    var self = this;
    var time = this.data.end_time - gcore.SmartSocket.getTime();
 
    if (time <= 0) {
      this.removeTimeLabel();
    } else {
      if (self.time_label == null) {
        self.time_label = Utils.createLabel(17, new cc.Color(20, 255, 50, 255), new cc.Color(0, 0, 0, 255), 0, -55, '', self.container_nd, 1, cc.v2(0.5, 0.5));
      }
 
      var time_desc = "";
 
      if (self.data.config.id == MainuiConst.icon.champion) {
        if (self.data.status == 1) {
          time_desc = TimeTool.getTimeForFunction(time) + "后开启";
        } else if (self.data.status == 2) {
          time_desc = "进行中:" + TimeTool.getTimeForFunction(time);
        }
      } else if (self.data.config.id == MainuiConst.icon.godbattle) {
        if (self.data.status == 1) {
          time_desc = "报名中:" + TimeTool.getTimeForFunction(time);
        } else if (self.data.status == 2) {
          time_desc = "进行中:" + TimeTool.getTimeForFunction(time);
        }
      } else if (self.data.config.id == MainuiConst.icon.guildwar) {
        if (self.data.status == 1) {
          time_desc = TimeTool.getTimeForFunction(time) + "后开启";
        } else if (self.data.status == 2) {
          time_desc = TimeTool.getTimeForFunction(time) + "后结束";
        }
      } else {
        time_desc = TimeTool.getTimeForFunction(time);
      }
 
      self.setBaseTimeInfo(time_desc);
    }
  },
  removeTimeLabel: function removeTimeLabel() {
    var self = this;
 
    if (self.time_label) {
      self.time_label.node.destroy();
      self.time_label = null;
    }
  },
  updateTishiState: function updateTishiState() {
    if (this.tishi_nd == null || this.data == null) return;
    var status = this.data.getTipsStatus();
    this.tishi_nd.active = status;
 
    if (this.data.config.id == MainuiConst.icon.friend || this.data.config.id == MainuiConst.icon.mail) {
      var num = this.data.getTipsNum();
 
      if (num > 0 && this.num_lb != null) {
        this.num_lb.string = num;
        this.num_lb.node.active = true;
      } else {
        this.num_lb.node.active = false;
      }
    }
  },
  //设置通用类的倒计时显示
  setBaseTimeInfo: function setBaseTimeInfo(time_desc) {
    var self = this;
 
    if (self.time_ticket_desc != time_desc) {
      self.time_ticket_desc = time_desc;
      self.time_label.string = time_desc;
    }
  },
  getData: function getData() {
    return this.data;
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {
    for (var i in this.node_list) {
      var v = this.node_list[i];
 
      if (v instanceof cc.Node) {
        v.destroy();
        v = null;
      } else {
        v.node.destroy();
        v = null;
      }
    }
 
    this.node_list = null;
 
    if (this.data) {
      if (this.update_by_self_event != null) {
        this.data.unbind(this.update_by_self_event);
        this.update_by_self_event = null;
      }
 
      this.data = null;
    }
  }
});
 
cc._RF.pop();