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
"use strict";
cc._RF.push(module, '6742dTeGy5Gf4cqukwQzfFf', 'endlesstrail_awards_tips_window');
// Scripts/mod/endless_trail/view/endlesstrail_awards_tips_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     这里是描述这个窗体的作用的
// <br/>Create: 2019-03-06 14:02:00
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Endlesstrail_awards_tipsWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("endlesstrail", "endlesstrail_awards_tips");
    this.viewTag = SCENE_TAG.ui; //该窗体所属ui层级,全屏ui需要在ui层,非全屏ui在dialogue层,这个要注意
 
    this.win_type = WinType.Tips; //是否是全屏窗体  WinType.Full, WinType.Big, WinType.Mini, WinType.Tips
 
    this.ctrl = arguments[0];
    this.model = this.ctrl.getModel();
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initConfig: function initConfig() {
    this.item_list = [];
  },
  // 预制体加载完成之后的回调,可以在这里捕获相关节点或者组件
  openCallBack: function openCallBack() {
    this.background = this.root_wnd.getChildByName("background");
    this.background.scale = FIT_SCALE;
    this.main_panel = this.root_wnd.getChildByName("main_panel");
    this.main_container = this.main_panel.getChildByName("main_container");
    this.desc_label = this.main_panel.getChildByName("desc_label").getComponent(cc.Label);
    ;
    this.close_btn = this.main_panel.getChildByName("close_btn");
    this.ok_btn = this.main_panel.getChildByName("ok_btn");
    this.ok_btn.btn = this.main_panel.getChildByName("ok_btn").getComponent(cc.Button);
    this.ok_btn.label = this.ok_btn.getChildByName("label").getComponent(cc.Label);
    this.ok_btn.label.string = Utils.TI18N("领取");
    this.ok_btn.line = this.ok_btn.getChildByName("label").getComponent(cc.LabelOutline);
    this.title_container = this.main_panel.getChildByName("title_container");
    this.title_label = this.title_container.getChildByName("title_label").getComponent(cc.Label);
    this.title_label.string = Utils.TI18N("奖励");
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {
    Utils.onTouchEnd(this.background, function () {
      this.ctrl.openEndlessRewardTips(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.close_btn, function () {
      this.ctrl.openEndlessRewardTips(false);
    }.bind(this), 2);
    Utils.onTouchEnd(this.ok_btn, function () {
      if (this.data) {
        this.ctrl.send23904(this.data.id);
      }
    }.bind(this), 1);
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调,也就是一个窗体的正式入口,可以设置一些数据了
  openRootWnd: function openRootWnd(data) {
    this.data = data;
 
    if (data) {
      if (Config.endless_data.data_first_data && Config.endless_data.data_first_data[this.data.id]) {
        var config = Config.endless_data.data_first_data[this.data.id];
        this.updateItemData(config);
      }
    }
  },
  updateItemData: function updateItemData(config) {
    if (config) {
      var str = cc.js.formatStr(Utils.TI18N("第%s关首通奖励"), config.limit_id);
      this.desc_label.string = str;
      var sum = config.items.length;
      this.space = 30;
      var total_width = sum * 120 + (sum - 1) * this.space;
      this.start_x = (this.main_container.getContentSize().width - total_width) * 0.5;
 
      for (var i in config.items) {
        if (!this.item_list[i]) {
          var item = ItemsPool.getInstance().getItem("backpack_item");
          item.setParent(this.main_container);
          item.initConfig(true);
          item.setData({
            bid: config.items[i][0],
            num: config.items[i][1]
          });
 
          var _x = this.start_x + 120 * 0.5 + parseInt(i) * (120 + this.space);
 
          item.setPosition(_x, this.main_container.getContentSize().height / 2);
          item.show();
          item.setDefaultTip();
          this.item_list[i] = item;
        }
      }
    }
 
    if (this.data) {
      if (this.data.status == 1) {
        if (this.ok_btn.label) {
          if (this.ok_btn.btn) {
            this.ok_btn.btn.interactable = true;
            this.ok_btn.btn.enableAutoGrayEffect = false;
          } // this.ok_btn.line.width = 2;
 
 
          this.ok_btn.line.enabled = true;
          this.ok_btn.label.string = Utils.TI18N("领取");
        }
      } else {
        if (this.ok_btn.label) {
          if (this.ok_btn.btn) {
            this.ok_btn.btn.interactable = false;
            this.ok_btn.btn.enableAutoGrayEffect = true;
          } // this.ok_btn.line.width = 0;
 
 
          this.ok_btn.line.enabled = false;
          this.ok_btn.label.string = Utils.TI18N("不可领取");
        }
      }
    }
  },
  // 关闭窗体回调,需要在这里调用该窗体所属controller的close方法没用于置空该窗体实例对象
  closeCallBack: function closeCallBack() {
    for (var i in this.item_list) {
      this.item_list[i].deleteMe();
    }
 
    this.item_list = [];
    this.ctrl.openEndlessRewardTips(false);
  }
});
 
cc._RF.pop();