e660d58f-8b2b-4ef9-a537-c92cebe7d874.js
5.47 KB
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
"use strict";
cc._RF.push(module, 'e660dWPiytO+aU3ySzr59h0', 'CooperationDataCenter');
// script/cooperation/script/CooperationDataCenter.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubGameLocation = void 0;
const HttpClient_1 = require("../../network/HttpClient");
const EventCenter_1 = require("../event/EventCenter");
const CooperationClassBase_1 = require("./CooperationClassBase");
var SubGameLocation;
(function (SubGameLocation) {
SubGameLocation["MainUI"] = "mainUI";
SubGameLocation["GameCenter"] = "gameCenter";
SubGameLocation["MomentCenter"] = "momentCenter";
})(SubGameLocation = exports.SubGameLocation || (exports.SubGameLocation = {}));
/**
* 数据中心
*/
let CooperationDataCenter = /** @class */ (() => {
class CooperationDataCenter {
constructor() {
/**网络请求对象 */
this._httpObj = new HttpClient_1.HttpClient("");
/**oss配置文件缓存 */
this._cooperationDataModels = [];
/**当前游戏的appid */
this._appID = "";
/**当前游戏的gameId */
this._gameID = "";
/**当前游戏的渠道 */
this._gameChannel = "";
/**当前游戏中MainUI中需要展示的游戏 */
this._mainUISubGameModels = [];
}
/**获取数据中心单例对象 */
static getInstance() {
return CooperationDataCenter._instance;
}
/**设置当前游戏的渠道 */
setCurGameChannel(channel) {
this._gameChannel = channel;
}
/**设置当前游戏的gameId */
setCurGameID(gameId) {
this._gameID = gameId;
}
/**获取当前游戏的渠道 */
getCurGameChannel() {
return this._gameChannel;
}
/**获取当前游戏的gameId */
getCurGameID() {
return this._gameID;
}
/**设置当前游戏的appid */
setCurGameAppID(appId) {
this._appID = appId;
}
/**获取当前游戏的appid */
getCurGameAppID() {
return this._appID;
}
/**获取oss配置列表 */
getCooperationItemDataModelList() {
return this._cooperationDataModels;
}
/**获取在主UI中需要展示的游戏列表 */
getMainUISubGameDataModelList() {
return this._mainUISubGameModels;
}
/**从oss上拉取配置文件 */
async requestCooperationDataFromOSS(release) {
try {
this._cooperationDataModels = [];
this._mainUISubGameModels = [];
let ossPath = release ? CooperationClassBase_1.CooperationClassBase.COO_OSS_PATH_RELEASE : CooperationClassBase_1.CooperationClassBase.COO_OSS_PATH_DEV;
let configPath = ossPath + CooperationDataCenter.getInstance().getCurGameID() + CooperationClassBase_1.CooperationClassBase.CONFIG_PATH;
let resStr = await this._httpObj.get(configPath);
let res = JSON.parse(resStr);
if (res) {
let items = res.items;
if (items) {
let serialNum = 1;
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (item && item.appId && "" !== item.appId && item.img && "" !== item.img && this._appID !== item.appId) {
this._cooperationDataModels.push({
appId: item.appId,
appName: item.name,
icon: item.img,
showAppName: item.showName === 1,
showPlayingUser: item.showPlayingUser === 1,
userMin: item.userMin ? item.userMin : 0,
userMax: item.userMax ? item.userMax : 100,
labelColor: item.labelColor,
index: serialNum
});
if (item.independentDisplay === 1) {
this._mainUISubGameModels.push({
appId: item.appId,
appName: item.name,
icon: item.img,
showAppName: item.showName === 1,
showPlayingUser: item.showPlayingUser === 1,
userMin: item.userMin ? item.userMin : 0,
userMax: item.userMax ? item.userMax : 100,
labelColor: item.labelColor,
index: serialNum
});
}
serialNum += 1;
}
}
EventCenter_1.EventCenter.COOPERATION_DATA_DOWNLOAD_SUCCEED.emit();
}
}
}
catch (e) {
console.error(e);
}
}
}
/**单例对象 */
CooperationDataCenter._instance = new CooperationDataCenter();
return CooperationDataCenter;
})();
exports.default = CooperationDataCenter;
cc._RF.pop();