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
"use strict";
cc._RF.push(module, '1d513sQe8pIsYbJv9vL/l91', 'rank_main_window');
// Scripts/mod/rank/view/rank_main_window.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: shiraho@syg.com(必填, 创建模块的人员)
// @description:
//      竖版排行榜排行界面
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var RankController = require("rank_controller");
 
var RankEvent = require("rank_event");
 
var CommonScrollView = require("common_scrollview");
 
var RankMainItem = require("rank_main_item");
 
var RankMainWindow = cc.Class({
  "extends": BaseView,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("rank", "rank_main");
    this.win_type = WinType.Full; // this.view_tag = SCENE_TAG.dialogue;
 
    this.ctrl = RankController.getInstance();
    this.cur_type = 0;
    this.res_list = {};
    this.tab_info_list = {};
    this.view_list = {};
    this.tab_list = {};
    this.is_init = {};
    this.select_tyep = 1; //伙伴类型选择,默认全部为1
 
    this.is_cluster = false;
    this.rank_first_list = {}; //排行配置表
 
    this.is_send = false; //是否发送协议
  },
  openCallBack: function openCallBack() {
    this.contaienr = this.seekChild("container");
    this.main_panel = this.seekChild("main_panel");
    this.close_btn = this.seekChild("close_btn");
    this.bg_nd = this.seekChild("bg");
    this.background = this.seekChild("background");
    this.background.scale = FIT_SCALE;
    this.loadRes(PathTool.getBigBg("bigbg_2"), function (res) {
      this.background.getComponent(cc.Sprite).spriteFrame = res;
    }.bind(this));
  },
  registerEvent: function registerEvent() {
    this.addGlobalEvent(RankEvent.RankEvent_Get_First_data, function (data) {
      if (!data) return;
      var index = 1;
 
      if (data.is_cluster == 0) {
        index = 2;
      }
 
      if (this.select_type != index) return;
 
      if (data.is_cluster == 1) {
        this.rank_first_list[1] = data.rank_list;
      } else {
        this.rank_first_list[2] = data.rank_list;
      }
 
      this.updateRankList();
    }, this);
 
    if (this.is_send) {
      this.ctrl.send_12902(this.is_cluster);
    } else {
      this.is_send = true;
    }
 
    Utils.onTouchEnd(this.close_btn, function () {
      this.ctrl.openMainView(false);
    }.bind(this), 2);
  },
  openRootWnd: function openRootWnd(type) {
    type = type || 2;
    this.select_tyep = type;
    this.changeTabIndex(type);
  },
  changeTabIndex: function changeTabIndex(index) {
    this.select_type = index;
    var first_data = this.rank_first_list[index];
 
    if (first_data != null) {
      this.updateRankList();
    } else {
      this.is_cluster = this.select_type == 1;
 
      if (this.is_send == false) {
        this.is_send = true;
      } else {
        this.ctrl.send_12902(this.is_cluster);
      }
    }
  },
  updateRankList: function updateRankList() {
    if (this.select_type == null) return;
    var first_data = this.rank_first_list[this.select_tyep];
    if (first_data == null) return;
    var tab_size = cc.size(610, 848);
 
    if (this.list_view == null) {
      var setting = {
        item_class: RankMainItem,
        // 单元类
        start_x: 5,
        // 第一个单元的X起点
        space_x: 0,
        // x方向的间隔
        start_y: 0,
        // 第一个单元的Y起点
        space_y: 0,
        // y方向的间隔
        item_width: 602,
        // 单元的尺寸width
        item_height: 162,
        // 单元的尺寸height
        row: 0,
        // 行数,作用于水平滚动类型
        col: 1,
        // 列数,作用于垂直滚动类型
        need_dynamic: true
      };
      this.list_view = new CommonScrollView();
      this.list_view.createScroll(this.bg_nd, cc.v2(0, 0), ScrollViewDir.vertical, ScrollViewStartPos.top, tab_size, setting, cc.v2(0.5, 0.5));
    }
 
    var is_cluster = this.select_type == 1;
    first_data.sort(Utils.tableLowerSorter(["type"]));
 
    var callback = function (item, vo) {
      if (vo && Utils.next(vo) != null) {
        var index = item.getRankIndex() || 1;
        this.ctrl.openRankView(true, index, is_cluster);
      }
    }.bind(this);
 
    this.list_view.setData(first_data, callback, is_cluster);
  },
  closeCallBack: function closeCallBack() {
    this.ctrl.openMainView(false);
 
    if (this.list_view) {
      this.list_view.deleteMe();
      this.list_view = null;
    }
  }
});
module.exports = RankMainWindow;
 
cc._RF.pop();