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
"use strict";
cc._RF.push(module, '1533c7/MopOpqQGfjv/Ukj+', 'strong_main_window');
// Scripts/mod/stronger/view/strong_main_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-29 11:44:54
// --------------------------------------------------------------------
var StrongerController = require("stronger_controller");
 
var PathTool = require("pathtool");
 
var HeroController = require("hero_controller");
 
var Strong_main_window = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("stronger", "stronger_main_window"); // this.viewTag = SCENE_TAG.ui;                //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Full; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = StrongerController.getInstance();
    this.partner_id = arguments[0];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.view_list = {};
    this.getZiyuanIndex = null;
    this.zhenrongIndex = null;
    this.wentiIndex = null;
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.bianqiangScrollView = this.seekChild("bianqiangScrollView", cc.ScrollView);
    this.container = this.seekChild("container");
    this.communal_nd = this.seekChild("communal");
    this.background_nd = this.seekChild("background");
    this.background_nd.scale = FIT_SCALE;
    this.tab_container_nd = this.seekChild("tab_container");
    this.ziyuan_sv = this.seekChild("ziyuan_ScrollView", cc.ScrollView);
    this.zhenrong_sv = this.seekChild("zhenrong_ScrollView", cc.ScrollView);
    this.wenti_sv = this.seekChild("wenti_ScrollView", cc.ScrollView);
    this.back_nd = this.seekChild("close_btn");
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    var _this = this;
 
    var _loop = function _loop(i) {
      _this.tab_container_nd.getChildByName("tab_btn_" + i).on("touchend", function () {
        Utils.playButtonSound(1);
        this.createSubPanel(i);
      }, _this);
    };
 
    for (var i = 1; i <= 4; ++i) {
      _loop(i);
    }
 
    this.back_nd.on("touchend", function () {
      this.ctrl.openMainWin(false);
      Utils.playButtonSound(2);
    }, this);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(index) {
    index = index || 1;
    this.ctrl.setIsFirst(false);
    this.createSubPanel(index);
  },
  createSubPanel: function createSubPanel(index) {
    var panel = this.view_list[index];
 
    if (!panel) {
      switch (index) {
        case 1:
          var StrongerPanel = require("stronger_panel");
 
          panel = new StrongerPanel(this.partner_id);
          panel.setPosition(0, 15);
          panel.setParent(this.container);
          this.view_list[index] = panel;
          break;
 
        case 2:
          this.view_list[index] = this.ziyuan_sv.content;
          this.resourcePanel();
          break;
 
        case 3:
          this.view_list[index] = this.zhenrong_sv.content;
          this.recommandPanel();
          break;
 
        case 4:
          this.view_list[index] = this.wenti_sv.content;
          this.problemPanel();
          break;
      }
    }
 
    if (index == 1) {
      panel.show();
      this.communal_nd.active = false;
    } else {
      this.view_list[1].hide();
      this.communal_nd.active = true;
      this.ziyuan_sv.node.active = false;
      this.zhenrong_sv.node.active = false;
      this.wenti_sv.node.active = false;
 
      if (index == 2) {
        this.ziyuan_sv.node.active = true;
      } else if (index == 3) {
        this.zhenrong_sv.node.active = true;
      } else if (index == 4) {
        this.wenti_sv.node.active = true;
      }
    }
  },
  //获取资源
  resourcePanel: function resourcePanel() {
    var path = PathTool.getPrefabPath("stronger", "stronger_item");
    var self = this;
    var list = [];
 
    for (var i in Config.stronger_data.data_resource_one) {
      list.push(Config.stronger_data.data_resource_one[i]);
    }
 
    this.startUpdate(list.length, function (index) {
      var i = index; // for(let i in list){
 
      var node = new cc.Node();
      node.setAnchorPoint(0.5, 1); // Utils.delayRun(this.ziyuan_sv.content,Number(i)/30,function(){
 
      this.ziyuan_sv.content.addChild(node);
      var a = node;
      this.loadRes(path, function (prefabPath) {
        var _this2 = this;
 
        var data = list[i];
        var prefab = prefabPath;
        a.addChild(prefab);
        a.setContentSize(prefab.getContentSize());
        var node = prefab.getChildByName("top").getChildByName("main_container");
        node.getChildByName("name").getComponent(cc.Label).string = list[i].name;
        node.getChildByName("title").getComponent(cc.Label).string = list[i].desc;
        var res = PathTool.getIconPath("item", data.icon);
        var path1 = PathTool.getUIIconPath("common", "common_1078");
        this.loadRes(res, function (SpriteFrame) {
          node.getChildByName("goods_icon").getComponent(cc.Sprite).spriteFrame = SpriteFrame;
        }.bind(this));
        this.ziyuan_sv.content.getComponent(cc.Layout).updateLayout(); //创建展开列表
 
        var arr = [];
        var path2 = PathTool.getPrefabPath("stronger", "stronger_sec_item");
 
        var _loop2 = function _loop2(j) {
          var b = new cc.Node();
          prefab.getChildByName("bottom").addChild(b);
 
          _this2.loadRes(path2, function (item) {
            var pre = item;
            b.addChild(pre);
            b.setContentSize(pre.getContentSize());
            var list1 = Config.stronger_data.data_resource_two[data.sub_list[j]];
            pre.getChildByName("main_container").getChildByName("title").getComponent(cc.Label).string = list1.desc;
            pre.getChildByName("main_container").getChildByName("name").getComponent(cc.Label).string = list1.name;
            pre.getChildByName("main_container").getChildByName("btn").on('click', function () {
              Utils.playButtonSound(1);
              this.ctrl.clickCallBack(list1.evt_type);
            }.bind(this)); // arr.push(pre)
 
            this.loadRes(path1, function (res) {
              pre.getChildByName("main_container").getChildByName("background").getComponent(cc.Sprite).spriteFrame = res;
            }.bind(this));
            this.loadRes(res, function (SpriteFrame) {
              pre.getChildByName("main_container").getChildByName("goods_icon").getComponent(cc.Sprite).spriteFrame = SpriteFrame;
            }.bind(this));
          }.bind(_this2));
        };
 
        for (var j = 0; j < data.sub_list.length; ++j) {
          _loop2(j);
        }
 
        node.getChildByName("btn").on('toggle', function (event) {
          var res;
 
          if (event.isChecked) {
            node.getChildByName("btn").getChildByName("btn_name").getComponent(cc.Label).string = "收起";
            res = PathTool.getUIIconPath("common", "common_1020");
          } else {
            node.getChildByName("btn").getChildByName("btn_name").getComponent(cc.Label).string = "展开";
            res = PathTool.getUIIconPath("common", "common_1029");
          }
 
          this.loadRes(res, function (SpriteFrame) {
            node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = SpriteFrame;
          }.bind(this));
 
          if (this.getZiyuanIndex == i) {
            this.getZiyuanIndex = null;
          } else {
            if (this.getZiyuanIndex && this.getZiyuanIndex != i) {
              var toggle = this.view_list[2].children[this.getZiyuanIndex - 1].children[0].getChildByName("top").getChildByName("main_container").getChildByName("btn").getComponent(cc.Toggle);
              toggle.isChecked = false;
            }
 
            this.getZiyuanIndex = i;
          }
 
          Utils.playButtonSound(1);
 
          if (self.getZiyuanIndex) {
            // this.ziyuan_sv.content.getComponent(cc.Layout).updateLayout()
            // ScrollView里content高度没同步 所以延迟0.1秒滚动
            this.ziyuan_sv.content.getComponent(cc.Layout).scheduleOnce(function () {
              self.ziyuan_sv.scrollToOffset(cc.v2(0, Math.abs(self.view_list[2].children[self.getZiyuanIndex - 1].y)));
            }, 0.1);
          }
 
          prefab.getChildByName("bottom").getComponent(cc.Layout).updateLayout();
          prefab.getComponent(cc.Layout).updateLayout();
          a.setContentSize(prefab.getContentSize());
        }.bind(this)); // }.bind(this))
        // }.bind(this))
      }.bind(this));
    }.bind(this));
  },
  recommandPanel: function recommandPanel() {
    var path2 = PathTool.getPrefabPath("stronger", "recommand_item");
    var list = []; //Utils.deepCopy(Config.stronger_data.data_recommand) 
 
    for (var i in Config.stronger_data.data_recommand) {
      list.push(Config.stronger_data.data_recommand[i]);
    }
 
    this.startUpdate(list.length, function (index) {
      // for(let i in list){
      var i = index;
      var node = new cc.Node();
      node.setAnchorPoint(0.5, 1); // Utils.delayRun(this.zhenrong_sv.content,Number(i)/30,function(){
 
      this.zhenrong_sv.content.addChild(node);
      var a = node;
      this.loadRes(path2, function (prefabPath) {
        var _this3 = this;
 
        var prefab = prefabPath;
        a.addChild(prefab);
        a.setContentSize(prefab.getContentSize());
        var main = prefab.getChildByName("main_container");
        main.getChildByName("title").getComponent(cc.Label).string = list[i].name;
        var desc = StringUtil.parse(list[i].desc);
        prefab.getChildByName("messagePanel").getChildByName("desc").getComponent(cc.RichText).string = desc;
        main.getChildByName("btn").on('toggle', function (event) {
          var res;
 
          if (event.isChecked) {
            res = PathTool.getUIIconPath("common", "common_1020");
          } else {
            res = PathTool.getUIIconPath("common", "common_1029");
          }
 
          this.loadRes(res, function (SpriteFrame) {
            main.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = SpriteFrame;
          }.bind(this));
 
          if (i == this.zhenrongIndex) {
            this.zhenrongIndex = null;
          } else {
            if (this.zhenrongIndex && i != this.zhenrongIndex) {
              this.view_list[3].children[this.zhenrongIndex - 1].children[0].getChildByName("main_container").getChildByName("btn").getComponent(cc.Toggle).isChecked = false;
            }
 
            this.zhenrongIndex = i;
          }
 
          Utils.playButtonSound(1);
          prefab.getComponent(cc.Layout).updateLayout();
          a.setContentSize(prefab.getContentSize());
        }, this);
        prefab.getChildByName("messagePanel").on("touchend", function () {
          main.getChildByName("btn").getComponent(cc.Toggle).isChecked = false;
        }, this);
 
        var _loop3 = function _loop3(j) {
          var id = list[i].hero_list[0][j];
          var config = Utils.deepCopy(Config.partner_data.data_partner_base[id]);
 
          if (config) {
            var hero_item = ItemsPool.getInstance().getItem("hero_exhibition_item");
            hero_item.setData(config);
            hero_item.setParent(prefab.getChildByName("main_container").getChildByName("scroll_con"));
            hero_item.show();
            hero_item.setScale(0.73);
            hero_item.setPosition(60 + j * 95, 0);
            hero_item.addCallBack(function () {
              if (config.bid) {
                HeroController.getInstance().openHeroTipsPanelByBid(config.bid);
              }
            }.bind(_this3));
          }
        };
 
        for (var j = 0; j < list[i].hero_list[0].length; ++j) {
          _loop3(j);
        }
      }.bind(this)); // }.bind(this))
      // }
    }.bind(this));
  },
  problemPanel: function problemPanel() {
    var list = []; //Utils.deepCopy(Config.stronger_data.data_problem) 
 
    for (var i in Config.stronger_data.data_problem) {
      list.push(Config.stronger_data.data_problem[i]);
    }
 
    this.startUpdate(list.length, function (index) {
      var i = index; // for(let i in list){
      //     Utils.delayRun(this.wenti_sv.content,Number(i)/30,function(){
 
      var path = PathTool.getPrefabPath("stronger", "problem_item");
      this.loadRes(path, function (prefabPath) {
        var prefab = prefabPath;
        this.wenti_sv.content.addChild(prefab);
        var main = prefab.getChildByName("main_container");
        main.getChildByName("name").getComponent(cc.Label).string = list[i].name;
        prefab.getChildByName("msgBottom").getChildByName("desc").getComponent(cc.RichText).string = StringUtil.parse(list[i].desc);
        var height = prefab.getChildByName("msgBottom").getChildByName("desc").height;
        prefab.getChildByName("msgBottom").height = height + 25;
        main.getChildByName("btn").on('toggle', function (event) {
          var res, name;
 
          if (event.isChecked) {
            res = PathTool.getUIIconPath("common", "common_1020");
            name = "收起";
          } else {
            res = PathTool.getUIIconPath("common", "common_1029");
            name = "查看";
          }
 
          main.getChildByName("btn").getChildByName("Label").getComponent(cc.Label).string = name;
          this.loadRes(res, function (SpriteFrame) {
            main.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = SpriteFrame;
          }.bind(this));
 
          if (i == this.wentiIndex) {
            this.wentiIndex = null;
          } else {
            if (this.wentiIndex && this.wentiIndex != i) {
              this.view_list[4].children[this.wentiIndex - 1].getChildByName("main_container").getChildByName("btn").getComponent(cc.Toggle).isChecked = false;
            }
 
            this.wentiIndex = i;
          }
 
          Utils.playButtonSound(1);
        }, this);
      }.bind(this)); //     }.bind(this))
      // }
    }.bind(this));
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    if (this.view_list[1]) {
      this.view_list[1].deleteMe();
    }
 
    this.ctrl.openMainWin(false);
  }
});
module.exports = Strong_main_window;
 
cc._RF.pop();