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
"use strict";
cc._RF.push(module, '6323c6c9RBEWoj+IY7WdwxX', 'function_icon_vo');
// Scripts/mod/mainui/view/function_icon_vo.js
 
"use strict";
 
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 
/*-----------------------------------------------------+
 * 图标数据内存缓存数据,数据事件,更新自身
 * @author zys
 +-----------------------------------------------------*/
var FunctionIconVo = cc.Class({
  "extends": gcore.BaseEvent,
  ctor: function ctor() {
    this.config = arguments[0] || {};
    this.pos = this.config.type || 1;
    this.sort = this.config && this.config.index || 1;
    this.is_new = false;
    this.is_lock = arguments[1];
    this.tips_status = false;
    this.res_id = this.config.icon_res;
    this.unclick = false;
    this.status = 0;
    this.end_time = 0;
    this.action_id = 0;
    this.dynamicres_id = 0;
    this.real_name = ""; //动态调整的名字
 
    this.tips_status_list = {};
    this.real_res_id = ""; //动态调整的资源
  },
  setConfig: function setConfig(conf) {
    this.config = conf;
  },
  setLock: function setLock(status) {
    this.is_lock = status;
  },
  //刚进入主场景的时候锁定点击状态,避免引导出问题
  setUnclick: function setUnclick(status) {
    this.unclick = status;
  },
  update: function update(params) {
    if (params == null || Utils.next(params) == null) return;
 
    if (Utils.getArrLen(params) == 1) {
      var arg = params[0];
 
      if (_typeof(arg) == "object") {
        if (arg instanceof Object) {
          this.id = arg.id;
          this.status = arg.status; // 活动状态 0结束,1开始, 2准备
 
          this.int_args = arg.int_args; //整型数组: 默认第一个参数为持续时间(单位秒),第二个是图标资源
        }
 
        if (this.int_args && Utils.next(this.int_args) != null) {
          this.end_time = this.int_args[0].val || 0;
        }
 
        var ext_args = arg.ext_args;
 
        if (ext_args && Utils.next(ext_args)) {
          for (var k in ext_args) {
            var v = ext_args[k];
 
            if (v.type == 1) {
              this.dynamicres_id = v.val;
              this.real_name = v.str;
 
              if (v.val != 0) {
                this.changeDynamicResId();
              }
 
              break;
            }
          }
        }
      } else if (typeof arg == "number") {
        this.status = arg;
      } else if (typeof arg == "string") {
        var config = Config.function_data.data_convert_icon[arg];
 
        if (config) {
          this.real_name = config.icon_name;
          this.real_res_id = config.icon_res;
        }
      }
    } else if (Utils.getArrLen(params) >= 2) {
      this.status = params[0] || 0;
      this.end_time = params[1] || 0;
    }
 
    this.fire(FunctionIconVo.UPDATE_SELF_EVENT);
  },
  //设置图标红点状态, 如果是table则必须包含 bid 这个作为唯一标志去储存的
  setTipsStatus: function setTipsStatus(data) {
    if (data instanceof Object) {
      if (data.bid != null) {
        this.tips_status_list[data.bid] = data;
      } else {
        for (var k in data) {
          var v = data[k];
 
          if (data[k].bid != null) {
            this.tips_status_list[v.bid] = v;
          }
        }
      }
    } else {
      if (data != null) {
        this.tips_status = data;
      } else {
        this.tips_status = !this.tips_status;
      }
    }
 
    this.fire(FunctionIconVo.UPDATE_SELF_EVENT, "tips_status");
  },
  //获取图标红点状态
  getTipsStatus: function getTipsStatus() {
    for (var k in this.tips_status_list) {
      var v = this.tips_status_list[k];
 
      if (v.num != null && typeof v.num == "number" && v.num > 0) {
        return true;
      }
    }
 
    return this.tips_status;
  },
  //获取当前红点的总数量
  getTipsNum: function getTipsNum() {
    var num = 0;
 
    if (this.tips_status_list && Utils.next(this.tips_status_list)) {
      for (var k in this.tips_status_list) {
        var v = this.tips_status_list[k];
        num = num + (v.num || 0);
      }
    }
 
    return num;
  },
  changeDynamicResId: function changeDynamicResId() {
    if (this.dynamicres_id == 0) return;
    var res_id = "icon" + this.dynamicres_id;
    this.changeIcon(res_id);
  },
  getBattleIconRes: function getBattleIconRes() {
    return this.dynamicres_id || 1;
  },
  changeIcon: function changeIcon(id) {
    this.res_id = id;
    this.fire(FunctionIconVo.UPDATE_SELF_EVENT, "res_id");
  },
  changeTime: function changeTime(time) {
    this.end_time = time;
    this.fire(FunctionIconVo.UPDATE_SELF_EVENT, "end_time");
  },
  //获取配置表的id
  getID: function getID() {
    if (this.config != null) {
      return this.config.id;
    }
  },
  _delete: function _delete() {}
});
FunctionIconVo.UPDATE_SELF_EVENT = "FunctionIconVo.UPDATE_SELF_EVENT";
FunctionIconVo.type = {
  right_top_1: 1,
  right_top_2: 2,
  right_bottom_1: 3,
  right_bottom_2: 4
};
module.exports = FunctionIconVo;
 
cc._RF.pop();