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
"use strict";
cc._RF.push(module, 'c71aey4g2FN4YMVxS+TjXEn', 'limitexercise_reward_window');
// Scripts/mod/limitexercise/view/limitexercise_reward_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-09-11 15:50:59
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var LimitExerciseRewardItem = require("limit_exercise_reward_item_panel");
 
var Limitexercise_rewardWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("limitexercise", "reward_window");
    this.viewTag = SCENE_TAG.dialogue; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Mini; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = arguments[0];
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.length = Config.holiday_boss_new_data.data_lev_reward_list_length;
    this.lev_reward_list = Config.holiday_boss_new_data.data_lev_reward_list;
    this.item_list = [];
    this.item_list_panel = [];
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.background = this.root_wnd.getChildByName("background");
    var main_container = this.root_wnd.getChildByName("main_container");
    main_container.getChildByName("Image_2").getChildByName("Text_1").getComponent(cc.Label).string = Utils.TI18N("奖励详情");
    this.name = main_container.getChildByName("name").getComponent(cc.Label);
    this.name.string = "";
    this.btn_left = main_container.getChildByName("btn_left");
    this.btn_right = main_container.getChildByName("btn_right");
    var txt2 = main_container.getChildByName("Text_3").getComponent(cc.Label);
    txt2.string = Utils.TI18N("通关boss关卡即可升级结算奖励,完成所有关卡可直接获得\n当期奖励。若未完成所有关卡,奖励会在本期结束时邮件发放"); // let real_label = txt2.getVirtualRenderer()
    // if real_label then
    // real_label:setLineSpacing(10)
    // end
 
    this.item_scrollview = main_container.getChildByName("item_scrollview").getComponent(cc.ScrollView);
    this.btn_close = main_container.getChildByName("btn_close");
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    this.background.on("touchend", function () {
      this.ctrl.openLimitExerciseRewardView(false);
      Utils.playButtonSound(2);
    }, this);
    this.background.on("touchend", function () {
      this.ctrl.openLimitExerciseRewardView(false);
      Utils.playButtonSound(2);
    }, this);
    this.btn_close.on("click", function () {
      this.ctrl.openLimitExerciseRewardView(false);
      Utils.playButtonSound(2);
    }, this);
    this.btn_left.on('click', function () {
      this.show_minus();
      Utils.playButtonSound(3);
    }, this);
    this.btn_right.on('click', function () {
      this.show_add();
      Utils.playButtonSound(3);
    }, this);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(params) {
    this.cur_index = this.ctrl.getModel().getCurrentDiff();
    this.dropItem(this.cur_index);
  },
  dropItem: function dropItem(id) {
    id = id || 0;
 
    if (id >= this.length + 1) {
      this.cur_index = this.length;
      message(Utils.TI18N("已经是最大等级啦~~~~"));
      return;
    }
 
    if (id <= 0) {
      this.cur_index = 1;
      message(Utils.TI18N("已经是最小等级啦~~~~"));
      return;
    }
 
    this.name.string = Utils.TI18N("难度 ") + id;
 
    if (id >= this.length) {
      id = this.length;
    }
 
    if (id <= 0) {
      id = 1;
    }
 
    if (!this.lev_reward_list[id]) return;
    var arr = [];
 
    for (var i in this.lev_reward_list[id]) {
      arr.push(this.lev_reward_list[id][i]);
    }
 
    arr.sort(function (a, b) {
      return a.order_id - b.order_id;
    });
 
    if (this.item_list.length == 0) {
      this.item_list = arr;
      this.timer = this.startUpdate(this.item_list.length, function (index) {
        var cell = this.createAreaChangeCell();
        cell.setPosition(0, -144 * index);
        cell.setData(this.item_list[index]);
        this.item_list_panel.push(cell);
      }.bind(this), 100);
    } else {
      this.item_list = arr;
 
      for (var _i = 0; _i < this.item_list.length; ++_i) {
        var cell = this.item_list_panel[_i];
 
        if (!cell) {
          cell = this.createAreaChangeCell();
          this.item_list_panel[_i] = cell;
        }
 
        this.item_list_panel[_i].setData(this.item_list[_i]);
      }
    }
 
    this.item_scrollview.content.height = 144 * this.item_list.length;
  },
  createAreaChangeCell: function createAreaChangeCell() {
    var item = new LimitExerciseRewardItem();
    item.setParent(this.item_scrollview.content);
    item.show();
    return item;
  },
  show_minus: function show_minus() {
    this.cur_index = this.cur_index - 1;
    this.dropItem(this.cur_index);
  },
  show_add: function show_add() {
    this.cur_index = this.cur_index + 1;
    this.dropItem(this.cur_index);
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    if (this.item_list_panel) {
      for (var i = 0; i < this.item_list_panel.length; ++i) {
        if (this.item_list_panel[i]) {
          this.item_list_panel[i].deleteMe();
          this.item_list_panel[i] = null;
        }
      }
 
      this.item_list_panel = null;
    }
 
    if (this.timer) {
      this.stopUpdate(this.timer);
      this.timer = null;
    }
 
    this.ctrl.openLimitExerciseRewardView(false);
  }
});
 
cc._RF.pop();