2fd85bd2-9545-4c6f-9505-8993896582f0.js
3.19 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
"use strict";
cc._RF.push(module, '2fd85vSlUVMb5UFiZOJZYLw', 'ActivitiesItemModelManager');
// script/game/model/ActivitiesItemModelManager.ts
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActivitiesItemModelManager = void 0;
const simba_config_manager_1 = require("simba-config-manager");
const simba_sdk_1 = require("simba-sdk");
const AVG_1 = require("../../avg/AVG");
const ActivitiesConifg_1 = require("../../config/ActivitiesConifg");
const ActivitiesTypeConfig_1 = require("../../config/ActivitiesTypeConfig");
class ActivitiesItemModelManager1 {
constructor() {
/**存档Key */
this.ActivitiesReaded = "ActivitiesReaded";
}
/**
* 获取有效的活动配置信息
* @returns 返回值为有效的活动配置信息
*/
getValidActivitiesConfigs() {
let ret = [];
let cfg = simba_config_manager_1.ConfigManager.getAllConfig(ActivitiesConifg_1.activitiesConifg);
for (let id in cfg) {
let currentTime = simba_sdk_1.TimeManager.getTime();
if (!cfg[id].isForever && (currentTime < cfg[id].startTime || currentTime > cfg[id].endTime)) {
continue;
}
let typeConfig = simba_config_manager_1.ConfigManager.getConfig(ActivitiesTypeConfig_1.activitiesTypeConfig, cfg[id].activityTypeConfig);
ret.push({
activityId: cfg[id].activityId,
index: cfg[id].index,
activityTypeConfig: {
activityType: typeConfig.activityType,
taobaoTempId: typeConfig.taobaoTempId,
pageIndex: typeConfig.pageIndex,
},
isForever: cfg[id].isForever,
startTime: cfg[id].startTime,
endTime: cfg[id].endTime,
canClick: cfg[id].canClick,
describe: cfg[id].describe,
});
}
//根据活动配置索引进行排序
ret.sort((a, b) => {
if (a.index < b.index) {
return -1;
}
else if (a.index > b.index) {
return 1;
}
return 0;
});
return ret;
}
/**
* 保存活动的已读状态
* @param activityId 活动ID
*/
setActivitiesReaded(activityId) {
let readed = AVG_1.GameRecord.globalVariables[this.ActivitiesReaded];
readed = readed ? readed : [];
if (readed.indexOf(activityId) == -1) {
readed.push(activityId);
}
let newReaded = [...readed];
AVG_1.GameRecord.globalVariables[this.ActivitiesReaded] = newReaded;
AVG_1.GameRecord.saveRecord();
}
/**
* 获取活动的已读状态
* @param activityId 活动ID
* @returns 返回值为活动是否已读
*/
getActivitiesReaded(activityId) {
let isReaded = false;
let readed = AVG_1.GameRecord.globalVariables[this.ActivitiesReaded];
readed = readed ? readed : [];
if (readed.indexOf(activityId) !== -1) {
isReaded = true;
}
return isReaded;
}
}
exports.ActivitiesItemModelManager = new ActivitiesItemModelManager1();
cc._RF.pop();