c81b05de-adb4-44f1-a5ad-15b9193cf1cf.js
3.42 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
"use strict";
cc._RF.push(module, 'c81b0XerbRE8aWtFbkZPPHP', 'CustomerServiceDataCenter');
// script/customerService/script/CustomerServiceDataCenter.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const GameConfig_1 = require("../../GameConfig");
const HttpClient_1 = require("../../network/HttpClient");
let CustomerServiceDataCenter = /** @class */ (() => {
class CustomerServiceDataCenter {
constructor() {
/**网络请求对象 */
this._httpObj = new HttpClient_1.HttpClient("");
this._showCustomerServiceBtn = true;
this._tipLabel = "";
this._qrCodePath = "";
}
init() {
this.requestCooperationDataFromOSS();
}
/**获取数据中心单例对象 */
static getInstance() {
return CustomerServiceDataCenter._instance;
}
/**从oss上拉取配置文件 */
async requestCooperationDataFromOSS() {
try {
let configPath = `https://weixingame.icesimba.com/weixingame/icesimba/${GameConfig_1.GameConfig.debug ? "dev" : "release"}/customerService/${GameConfig_1.channel}/${GameConfig_1.GameConfig.gameId}/config.json`;
let resStr = await this._httpObj.get(configPath);
let res = JSON.parse(resStr);
if (res) {
let items = res.items;
if (items) {
for (let i = 0; i < items.length; i++) {
let item = items[i];
if (item && item.qrCodeImg && "" !== item.qrCodeImg) {
if (item.showCustomerServiceBtn) {
this._showCustomerServiceBtn = item.showCustomerServiceBtn;
}
if (item.tipLabel) {
this._tipLabel = item.tipLabel;
}
if (item.qrCodeImg) {
this._qrCodePath = item.qrCodeImg;
}
}
}
}
}
}
catch (e) {
console.error(e);
}
}
/**刷新QRCode */
refreshQRCode(imgPath, spr) {
return new Promise((resolve, reject) => {
let path = `https://weixingame.icesimba.com/weixingame/icesimba/${GameConfig_1.GameConfig.debug ? "dev" : "release"}/customerService/${GameConfig_1.channel}/${GameConfig_1.GameConfig.gameId}/${imgPath}`;
cc.assetManager.loadRemote(path, (err, sprite) => {
if (err) {
reject(err);
}
else {
spr.spriteFrame = new cc.SpriteFrame(sprite);
resolve(true);
}
});
});
}
getShowCustomerServiceBtn() {
return this._showCustomerServiceBtn;
}
getTipLabel() {
return this._tipLabel;
}
getQRCodePath() {
return this._qrCodePath;
}
}
/**单例对象 */
CustomerServiceDataCenter._instance = new CustomerServiceDataCenter();
return CustomerServiceDataCenter;
})();
exports.default = CustomerServiceDataCenter;
cc._RF.pop();