--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by admin. --- DateTime: 2024/11/12 13:41 ---@class UIEveryDayGiftRechargeInfo UIEveryDayGiftRechargeInfo = class() local this = UIEveryDayGiftRechargeInfo function this:ctor() end function this:Reset() end function this:Init() self:InitData() self:RegistMessages() self.EveryDayGiftAllData = SL:GetConfigTable("cfg_everydayGift_recharge") self.EveryDayGiftData = {} self.EverDayGiftFreeDataId = {} end function this:InitData() end function this:RegistMessages() SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self) end --服务器发送礼包组消息后刷新礼包组的数据 function this:RES_RECHARGE_ACTION(_, message) if tonumber(message.type)~= 13 then --类型9 return end if message.data then self.EveryDayGiftData ={} self.EveryDayGiftData.buyDay = message.data.buyDay self.EveryDayGiftData.dayFreeGift = message.data.dayFreeGift self.EveryDayGiftData.group = message.data.group self.EveryDayGiftData.todayBuy = message.data.todayBuy self.EveryDayGiftData.needCost = 6 local rewardShowItem = {} local taskInfo = {} local taskAllDayInfo={} local taskInfoReward = {} local havereward = false local carreerId = SL:GetMetaValue(EMetaVarGetKey.JOB) for k , v in ipairs(self.EveryDayGiftAllData) do if v.round == tonumber(message.data.group) then if v.sort == 0 then for key,value in ipairs(v.showItem) do if value[1] == carreerId or value[1] == 0 then taskInfoReward = { itemId = value[2], count = value[3] } table.insert(rewardShowItem,taskInfoReward) end end self.EverDayGiftFreeDataId = v.id self.EveryDayGiftData.rewardShowItem = rewardShowItem else taskInfo = {} taskInfo.id = v.id taskInfo.day = v.sort taskInfo.task = v.task taskInfo.canGain = false taskInfo.haveGain = false taskInfo.showItem={} taskInfo.gift={} if v.sort == 1 then self.EveryDayGiftData.needCost = v.needCost end if message.data.buyDay >=v.sort then taskInfo.canGain = true end if not table.isNullOrEmpty(message.data.rewards) then for key,value in pairs(message.data.rewards) do if value == v.id then taskInfo.haveGain = true break end end end for key,value in ipairs(v.showItem) do if value[1] == carreerId or value[1] == 0 then taskInfoReward = { itemId = value[2], count = value[3] } table.insert(taskInfo.showItem,taskInfoReward) end end for key,value in ipairs(v.gift) do if value[1] == carreerId or value[1] == 0 then taskInfoReward = { itemId = value[2], count = value[3] } table.insert(taskInfo.gift,taskInfoReward) end end if taskInfo.canGain and (not taskInfo.haveGain) then --可领取 taskInfo.sort = 1 havereward = true elseif taskInfo.canGain then --已领取 taskInfo.sort = 3 elseif (not taskInfo.haveGain) then --未完成 taskInfo.sort = 2 else taskInfo.sort = 0 end if taskInfo.sort~=0 then table.insert(taskAllDayInfo,taskInfo) end end end end table.sort(taskAllDayInfo,function (a,b) if a.sort == b.sort then return a.day