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
"use strict";
cc._RF.push(module, 'e14bfKymw5Oo6R2jE29f611', 'redbag_window');
// Scripts/mod/redbag/view/redbag_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      公会boss主窗体
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var RedbagController = require("redbag_controller");
 
var GuildEvent = require("guild_event");
 
var RedbagWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("redbag", "redbag_btn_panel");
    this.win_type = WinType.Big;
    this.viewTag = SCENE_TAG.dialogue;
    this.ctrl = RedbagController.getInstance();
    this.model = this.ctrl.getModel();
    this.extend_id = arguments[0];
    this.btn_list = {};
    this.view_list = {};
    this.select_btn = null;
  },
  openCallBack: function openCallBack() {
    var main_panel = this.seekChild("main_panel");
    this.container = this.seekChild(main_panel, "container");
    this.background = this.seekChild("background");
 
    for (var i = 1; i <= 3; i++) {
      var btn = main_panel.getChildByName("tab_btn_" + i);
 
      if (btn) {
        var tab = {};
        tab.btn = btn;
        tab.select_bg = btn.getChildByName("select_bg");
        tab.select_bg.active = false;
        tab.title = btn.getChildByName("title").getComponent(cc.Label);
        tab.red_point = btn.getChildByName("red_point");
        tab.red_point.active = false;
 
        if (i == 2) {
          var is_red = this.model.getIsHaveRedBag();
          tab.red_point.active = is_red;
        } else if (i == 1) {
          var is_red = this.model.getSendRedBagStatue();
          tab.red_point.active = is_red;
        }
 
        tab.index = i;
        this.btn_list[i] = tab;
        this.setBtnClick(btn, i);
      }
    }
  },
  setBtnClick: function setBtnClick(btn, index) {
    btn.on(cc.Node.EventType.TOUCH_END, function () {
      this.changeTabIndex(index);
    }.bind(this));
  },
  registerEvent: function registerEvent() {
    this.background.on(cc.Node.EventType.TOUCH_END, function () {
      this.ctrl.openMainView(false);
    }.bind(this));
    this.addGlobalEvent(GuildEvent.UpdateGuildRedStatus, function () {
      var is_red = this.model.getIsHaveRedBag();
      this.updateSomeRedStatus(is_red);
      is_red = this.model.getSendRedBagStatue();
      this.updateOneRedStatus(is_red);
    });
  },
  updateSomeRedStatus: function updateSomeRedStatus(status) {
    if (this.btn_list && this.btn_list[2]) {
      var btn = this.btn_list[2];
      btn.red_point.active = status;
    }
  },
  updateOneRedStatus: function updateOneRedStatus(status) {
    if (this.btn_list && this.btn_list[1]) {
      var btn = this.btn_list[1];
      btn.red_point.active = status;
    }
  },
  changeTabIndex: function changeTabIndex(index) {
    if (this.select_btn && this.select_btn.index == index) return;
 
    if (this.select_btn) {
      this.select_btn.select_bg.active = false;
      this.select_btn.title.color = new cc.Color(0xcf, 0xb5, 0x93, 0xff);
    }
 
    if (this.pre_panel) this.pre_panel.setVisibleStatus(false);
    this.pre_panel = this.createSubPanel(index);
    this.select_btn = this.btn_list[index];
 
    if (this.select_btn) {
      this.select_btn.select_bg.active = true;
      this.select_btn.title.color = new cc.Color(0xff, 0xed, 0xd6, 0xff);
    }
 
    if (this.pre_panel) {
      this.pre_panel.setVisibleStatus(true); // this.pre_panel.setData(this.data);
    }
 
    if (this.select_btn && this.select_btn.index == 3) {
      this.ctrl.sender13545();
    }
  },
  createSubPanel: function createSubPanel(index) {
    index = Number(index);
    var panel = this.view_list[index];
    var size = this.container.getContentSize();
 
    if (panel == null) {
      if (index == 1) {
        panel = Utils.createClass("redbag_send_panel", this.extend_id);
        panel.setPosition(cc.v2(size.width / 2, 355));
      } else if (index == 2) {
        panel = Utils.createClass("redbag_get_panel");
        panel.setPosition(cc.v2(size.width / 2, 375));
      } else if (index == 3) {
        panel = Utils.createClass("redbag_rank_panel");
        panel.setPosition(cc.v2(size.width / 2, 375));
      }
 
      panel.show();
      panel.setParent(this.container);
      this.view_list[index] = panel;
    }
 
    return panel;
  },
  openRootWnd: function openRootWnd(index, data) {
    this.data = data;
    index = index || 1;
    var is_have_red = this.model.getIsHaveRedBag() || false;
 
    if (is_have_red == true && index == 1 && !this.extend_id) {
      index = 2;
    }
 
    this.changeTabIndex(index);
  },
  closeCallBack: function closeCallBack() {
    this.ctrl.openMainView(false);
 
    for (var i in this.view_list) {
      var v = this.view_list[i];
      v.deleteMe();
      v = null;
    }
 
    this.view_list = null;
  }
});
module.exports = RedbagWindow;
 
cc._RF.pop();