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
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//      这里填写详细说明,主要填写该模块的功能简要
// <br/>Create: 2019-01-29 10:47:25
// --------------------------------------------------------------------
var RankEvent = require("rank_event");
var MainuiController = require("mainui_controller");
var MainuiConst = require("mainui_const");
 
var RankController = cc.Class({
    extends: BaseController,
    ctor: function () {
    },
 
    // 初始化配置数据
    initConfig: function () {
        var RankModel = require("rank_model");
 
        this.model = new RankModel();
        this.model.initConfig();
    },
 
    // 返回当前的model
    getModel: function () {
        return this.model;
    },
 
    // 注册监听事件
    registerEvents: function () {
    },
 
    // 注册协议接受事件
    registerProtocals: function () {
        this.RegisterProtocal(12900, this.handle_12900)  //排行榜数据
        this.RegisterProtocal(12901, this.handle_12901)  //指定排行榜最后更新时间
        this.RegisterProtocal(12902, this.handle_12902)  //请求各个排行榜第一数据
        this.RegisterProtocal(12903, this.handle_12903)  //请求公会排行榜数据
        this.RegisterProtocal(12904, this.handle_12904)  //请求公会排行榜数据
    },
 
    //排行榜
    send_12900: function (rank_type, start, num, is_cluster) {
        //请求排行榜
        var cluster = 0;
        if (is_cluster == true) {
            cluster = 1;
        }
        var protocal = {};
        protocal.type = rank_type;
        protocal.start = start || 1;
        protocal.num = num || 100;
        protocal.is_cluster = cluster;
        this.SendProtocal(12900, protocal);
    },
 
    handle_12900:function(data){
        gcore.GlobalEvent.fire(RankEvent.RankEvent_Get_Rank_data, data);
    },
 
    //指定排行榜最后更新时间
    send_12901: function (type, is_cluster) {
        //请求排行榜
        var cluster = 0;
        if (is_cluster == true)
            cluster = 1;
        var protocal = {};
        protocal.type = type;
        protocal.is_cluster = cluster;
        this.SendProtocal(12901, protocal);
    },
 
    handle_12901: function (data) {
        gcore.GlobalEvent.fire(RankEvent.RankEvent_Get_Time_event, data);
    },
 
    //请求各个排行榜第一数据
    send_12902: function (is_cluster) {
        //请求排行榜
        var cluster = 0;
        if (is_cluster == true)
            cluster = 1;
        var protocal = {};
        protocal.is_cluster = cluster;
        this.SendProtocal(12902, protocal);
    },
 
    handle_12902: function (data) {
        gcore.GlobalEvent.fire(RankEvent.RankEvent_Get_First_data, data);
    },
 
    //请求公会排行榜数据
    send_12903: function (start, num) {
        //请求排行榜
        var protocal = {};
        protocal.start = start || 1;
        protocal.num = num || 100;
        this.SendProtocal(12903, protocal);
    },
 
    handle_12903: function (data) {
        gcore.GlobalEvent.fire(RankEvent.RankEvent_Get_Rank_data, data);
    },
 
    //请求英雄排行榜数据
    send_12904: function (start, num) {
        var protocal = {};
        protocal.start = start || 1;
        protocal.num = num || 100;
        this.SendProtocal(12904, protocal);
    },
 
    handle_12904: function (data) {
        gcore.GlobalEvent.fire(RankEvent.RankEvent_Get_Rank_data, data);
    },
 
    //index打开对应的标签页
    openMainView: function (bool) {
        if (bool == true) {
            if (MainuiController.getInstance().checkMainFunctionOpenStatus(MainuiConst.icon.rank, MainuiConst.function_type.other) == false)
                return
            if (!this.main_view) {
                this.main_view = Utils.createClass("rank_main_window");
            }
            this.main_view.open();
 
        } else {
            if (this.main_view) {
                this.main_view.close();
                this.main_view = null;
            }
        }
    },
 
    //打开排行榜信息
    openRankView: function (bool, index, is_cluster,data) {
        if (bool == true) {
            if (!this.rank_panel) {
                var view = require("rank_window");
                this.rank_panel = new view(index, is_cluster);
            }
            this.rank_panel.open(data);
        } else {
            if (this.rank_panel) {
                this.rank_panel.close();
                this.rank_panel = null;
            }
        }
    },
 
    //打开奖励排行榜界面
    openRankRewardPanel: function (bool, rank_reward_type) {
        if (bool == true) {
            if (!this.rank_reward_panel) {
                this.rank_reward_panel = Utils.createClass("rank_reward_window");
            }
            this.rank_reward_panel.open(rank_reward_type);
        } else {
            if (this.rank_reward_panel) {
                this.rank_reward_panel.close();
                this.rank_reward_panel = null;
            }
        }
    }
});
 
module.exports = RankController;