123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- --- Generated by EmmyLua(https://github.com/EmmyLua)
- --- Created by admin.
- --- DateTime: 2024/11/7 10:08
- ---@class UIWeekPackRechargeInfo
- UIWeekPackRechargeInfo = class()
- local this = UIWeekPackRechargeInfo
- function this:ctor()
- end
- function this:Reset()
- end
- function this:Init()
- self:InitData()
- self:RegistMessages()
- self.WeekPackAllData = SL:GetConfigTable("cfg_WeeklyGiftPack")
- self.WeekPackData = {}
- end
- function this:InitData()
- end
- function this:RegistMessages()
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self)
- SL:RegisterLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE, this.LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE, self)
- end
- --服务器发送礼包组消息后刷新礼包组的数据
- function this:RES_RECHARGE_ACTION(_, message)
- if tonumber(message.type)~=6 then --类型6
- return
- end
- self.WeekPackData = {}
- if message then
- local itemInfo = {}
- local itemCountInfo = {}
- local buycount = 0 --剩余次数
- local totalcount = 0
- for k , v in ipairs(self.WeekPackAllData) do
- if v.Packagetype == tonumber(message.data.group) and this:IsOpenJudge(v.conditionid)then
- itemInfo = {}
- itemInfo.id = v.id
- itemInfo.Price = v.Price
- itemInfo.Packagename= v.Packagename
- itemInfo.Packagetype = v.Packagetype
- itemInfo.conditionid = v.conditionid
- itemInfo.Limited =tonumber(v.Limited)
- itemInfo.Rewards = v.Rewards
- itemInfo.rebate = v.rebate
- itemInfo.canBuy = true
- itemInfo.RechargeId = 0
- itemInfo.Countkey = 0
- buycount = 0
- totalcount = 0
- for key,value in pairs(message.data.recharge_ids) do
- itemCountInfo = SL:GetConfig('cfg_recharge',tonumber(value))
- if itemCountInfo.parameter == v.id then
- itemInfo.RechargeId = tonumber(value)
- itemInfo.Countkey = itemCountInfo.Countkey
- buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(itemCountInfo.Countkey)
- if buycount < 1 then
- itemInfo.canBuy = false
- end
- break
- end
- end
- table.insert(self.WeekPackData,itemInfo)
- end
- end
- end
- local isDailyPackRedPoint = false
- for k,v in pairs(self.WeekPackData) do
- if v.Price== 0 and v.canBuy then
- isDailyPackRedPoint = true
- end
- end
- InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_WeekDailyPack",isDailyPackRedPoint)
- SL:onLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_CHANGE)
- end
- --Count刷新
- function this:LUA_EVENT_WEEKPACK_RECHARGE_COUNT_CHANGE()
- local isDailyPackRedPoint = false
- local buycount = 0 --剩余次数
- local totalcount = 0
- for k,v in pairs(self.WeekPackData) do
- buycount = 0
- totalcount = 0
- v.canBuy = true
- buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(v.Countkey)
- if buycount < 1 then
- v.canBuy = false
- end
- if v.Price== 0 and v.canBuy then
- isDailyPackRedPoint = true
- end
- end
- InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_WeekDailyPack",isDailyPackRedPoint)
- SL:onLUAEvent(LUA_EVENT_WEEKPACK_RECHARGE_CHANGE)
- end
- function this:IsOpenJudge(condition)
- local isShow = condition == "" or ConditionManager.Check4D(condition)
- ---if else 可特殊处理页签显示隐藏
- return isShow
- end
|