2021-04-16 14:58:40 +08:00
|
|
|
CommonActPageManager = {}
|
|
|
|
local this = CommonActPageManager
|
2021-04-16 16:21:34 +08:00
|
|
|
local dataList = {}
|
2021-04-16 14:58:40 +08:00
|
|
|
|
|
|
|
function this.Initialize()
|
|
|
|
end
|
|
|
|
|
2021-04-20 11:17:50 +08:00
|
|
|
--初始化活动的特殊数据
|
|
|
|
local TypeInitFunc = {
|
|
|
|
[ActivityTypeDef.YunYouShangRen] = function ()
|
|
|
|
local curData = dataList[ActivityTypeDef.YunYouShangRen]
|
|
|
|
local configData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ComposeActivity,"ActivityId",curData.activityId)
|
|
|
|
for i = 1, #curData.rewards do
|
|
|
|
for j = 1, #configData do
|
|
|
|
if curData.rewards[i].missionId == configData[j].Id then
|
|
|
|
curData.rewards[i].otherData.needItems = configData[j].NeedItems
|
|
|
|
curData.rewards[i].otherData.count = configData[j].Count
|
|
|
|
curData.rewards[i].otherData.composeType = configData[j].ComposeType
|
|
|
|
curData.rewards[i].otherData.selectId = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
--数据刷新时是否需要前端自己刷新,如果有就写里面
|
|
|
|
local TypeUpdateFunc = {
|
|
|
|
[ActivityTypeDef.YunYouShangRen] = function ()
|
|
|
|
local curData = dataList[ActivityTypeDef.YunYouShangRen]
|
|
|
|
for i = 1, #curData.rewards do
|
|
|
|
curData.rewards[i].otherData.selectId = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2021-04-16 14:58:40 +08:00
|
|
|
function this.GetData(actType)
|
2021-04-16 16:21:34 +08:00
|
|
|
if not dataList[actType] then
|
|
|
|
dataList[actType] = this.InitSingleTypeData(actType)
|
2021-04-20 11:17:50 +08:00
|
|
|
TypeInitFunc[actType]()
|
2021-04-16 14:58:40 +08:00
|
|
|
end
|
2021-04-16 16:21:34 +08:00
|
|
|
this.UpdateSingleTypeData(actType)
|
2021-04-20 11:17:50 +08:00
|
|
|
TypeUpdateFunc[actType]()
|
2021-04-17 14:01:12 +08:00
|
|
|
return dataList[actType]
|
2021-04-16 14:58:40 +08:00
|
|
|
end
|
|
|
|
|
2021-04-16 16:21:34 +08:00
|
|
|
function this.InitSingleTypeData(actType)
|
|
|
|
local singleTypeData = {}
|
2021-04-17 14:01:12 +08:00
|
|
|
local data = ActivityGiftManager.GetActivityTypeInfo(actType)
|
2021-04-20 11:17:50 +08:00
|
|
|
-- LogYellow("InitData activityId:"..tostring(data.activityId).." value:"..tostring(data.value).." startTime:"..tostring(data.startTime).." endTime:"..tostring(data.endTime))
|
2021-04-16 16:21:34 +08:00
|
|
|
singleTypeData.activityId = data.activityId
|
|
|
|
singleTypeData.value = data.value
|
|
|
|
singleTypeData.startTime = data.startTime
|
|
|
|
singleTypeData.endTime = data.endTime
|
|
|
|
singleTypeData.rewards = {}
|
2021-04-20 11:17:50 +08:00
|
|
|
for i = 1, #data.mission do
|
2021-04-16 16:21:34 +08:00
|
|
|
local reward = {}
|
2021-04-20 11:17:50 +08:00
|
|
|
reward.missionId = data.mission[i].missionId or 0
|
|
|
|
reward.progress = data.mission[i].progress or 0
|
|
|
|
reward.state = data.mission[i].state or 0
|
|
|
|
reward.otherData = {}
|
|
|
|
table.insert(singleTypeData.rewards,reward)
|
2021-04-16 16:21:34 +08:00
|
|
|
end
|
|
|
|
return singleTypeData
|
|
|
|
end
|
|
|
|
|
|
|
|
function this.UpdateSingleTypeData(actType)
|
2021-04-17 14:01:12 +08:00
|
|
|
local data = ActivityGiftManager.GetActivityTypeInfo(actType)
|
2021-04-19 19:44:54 +08:00
|
|
|
-- LogPink("Update".." activityId:"..tostring(data.activityId).." value:"..tostring(data.value).." startTime:"..tostring(data.startTime).." endTime:"..tostring(data.endTime))
|
2021-04-16 16:21:34 +08:00
|
|
|
dataList[actType].activityId = data.activityId--应该无变化
|
|
|
|
dataList[actType].value = data.value
|
|
|
|
dataList[actType].startTime = data.startTime--应该无变化
|
|
|
|
dataList[actType].endTime = data.endTime--应该无变化
|
|
|
|
for i = 1, #data.mission do
|
2021-04-19 19:44:54 +08:00
|
|
|
for j = 1, #dataList[actType].rewards do
|
|
|
|
if data.mission[i].missionId == dataList[actType].rewards[j].missionId then
|
|
|
|
dataList[actType].rewards[j].missionId = data.mission[i].missionId or 0--应该无变化
|
|
|
|
dataList[actType].rewards[j].progress = data.mission[i].progress or 0
|
|
|
|
dataList[actType].rewards[j].state = data.mission[i].state or 0
|
|
|
|
end
|
2021-04-17 14:01:12 +08:00
|
|
|
end
|
2021-04-16 16:21:34 +08:00
|
|
|
end
|
2021-04-19 19:44:54 +08:00
|
|
|
table.sort(dataList[actType].rewards,function (a,b)
|
|
|
|
if a.progress == b.progress then
|
|
|
|
return a.missionId < b.missionId
|
|
|
|
else
|
|
|
|
return a.progress > b.progress
|
|
|
|
end
|
|
|
|
end)
|
2021-04-16 14:58:40 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return CommonActPageManager
|