123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- ---@class KLRechargeLinkPanel:UIKmlLuaPanelBase
- ---@field view KLRechargeLinkPanelView
- local KLRechargeLinkPanel = class(UIKmlLuaPanelBase)
- local this = KLRechargeLinkPanel
- function this:AsyncLoadUI()
- end
- ---创建时调用一次
- function this:Init()
- self.careerId = SL:GetMetaValue(EMetaVarGetKey.JOB)
- self.ItemList = {}
- self.giftTbl = SL:GetConfigTable("cfg_newServerGIft")
- self.bigAwardTbl = self.giftTbl[table.count(self.giftTbl)]
- self.dataList = {}
- GUI:DataListInitData(self.view.ItemDataList, function()
- return table.count(self.giftTbl) - 1
- end, function()
- end, function()
- end, function(realIndex)
- return self:UpDataList(realIndex)
- end)
- --[[ GUI:DataListUpdateData(self.view.ItemDataList)
-
- self:UpDataBigAward()]]
- end
- function this:UpDataList(realIndex)
- local index = realIndex + 1
- local strengthInfo = self.giftTbl[index]
- local ItemBg = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemBg')
- local ItemBg_BtnMask = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemBg_BtnMask')
- local ItemGet = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'ItemGet')
- local Txt = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'Txt')
- local TextTitle = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'TextTitle')
- local model = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'model')
- local GetBtn = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'GetBtn')
- local RedDot = GUI:GetChildControl(self.view.ItemDataList, realIndex, 'RedDot')
- GUI:Text_setString(TextTitle, "连续达成目标" .. index .. "天")
- for ItemIndex, v in pairs(strengthInfo.reward) do
- if v[1] == self.careerId or v[1] == 0 then
- local itemId = v[2]
- local count = v[3]
- self:SetItem(itemId, count, index, ItemIndex, model)
- ---@type cfg_item_column
- local ItemTbl = SL:GetConfig("cfg_item", itemId)
- GUI:Text_setString(Txt, ItemTbl.name)
- end
- end
- GUI:SetActive(RedDot, false)
- if self.dataList[strengthInfo.id] then
- if self.dataList[strengthInfo.id].state == 2 then
- GUI:SetActive(ItemGet, false)
- GUI:SetActive(ItemBg_BtnMask, false)
- GUI:SetActive(GetBtn, false)
- elseif self.dataList[strengthInfo.id].state == 1 then
- GUI:SetActive(ItemGet, false)
- GUI:SetActive(ItemBg_BtnMask, true)
- GUI:SetActive(GetBtn, true)
- GUI:SetActive(RedDot, true)
- GUI:AddOnClickEvent(GetBtn, self, function()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = ERechargeType.RechargeLink, action = "reward", id = strengthInfo.id })
- end)
- elseif self.dataList[strengthInfo.id].state == 3 then
- GUI:SetActive(ItemGet, true)
- GUI:SetActive(ItemBg_BtnMask, false)
- GUI:SetActive(GetBtn, false)
- end
- end
- end
- function this:SetItem(itemId, count, index, ItemIndex, model)
- ---列表index和道具index
- local data = {
- width = "70",
- height = "70",
- itemid = itemId,
- mfixsize = "70,70",
- tips = "1",
- itemcustomcount = count
- }
- if not self.ItemList[index] then
- self.ItemList[index] = {}
- end
- if self.ItemList[index][ItemIndex] then
- GUI:Item_UpdataData(self.ItemList[index][ItemIndex], data)
- else
- local item = GUI:Item_Create(model, data)
- self.ItemList[index][ItemIndex] = item
- end
- GUI:AddOnClickEvent(self.ItemList[index][ItemIndex], self, function()
- SL:OpenTips(nil, itemId)
- end)
- end
- function this:UpDataBigAward()
- local index = table.count(self.giftTbl)
- local data = self.dataList[self.bigAwardTbl.id]
- GUI:Text_setString(self.view.BigTitle, "连续达成目标" .. index .. "天")
- for ItemIndex, v in pairs(self.bigAwardTbl.reward) do
- if v[1] == self.careerId or v[1] == 0 then
- local itemId = v[2]
- ---@type cfg_item_column
- local ItemTbl = SL:GetConfig("cfg_item", itemId)
- GUI:Text_setString(self.view.ItemTex, ItemTbl.name)
- GUI:AddOnClickEvent(self.view.BigGetBtn, self, function()
- if not data then return end
- if data.state == 2 then
- SL:OpenTips(nil, itemId)
- elseif data.state == 1 then
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = ERechargeType.RechargeLink, action = "reward", id = self.bigAwardTbl.id })
- elseif data.state == 3 then
- return
- end
- end)
- end
- end
- self:ShowBigModel(self.bigAwardTbl)
- GUI:SetActive(self.view.BigRedDot, false)
- if not data then return end
- if data.state == 2 then
- GUI:SetActive(self.view.Get, false)
- GUI:SetActive(self.view.bg_BtnMask, false)
- elseif data.state == 1 then
- GUI:SetActive(self.view.Get, false)
- GUI:SetActive(self.view.bg_BtnMask, true)
- GUI:SetActive(self.view.BigRedDot, true)
- elseif data.state == 3 then
- GUI:SetActive(self.view.Get, true)
- GUI:SetActive(self.view.bg_BtnMask, false)
- end
- if self.bigAwardTbl.previewVedio ~= "" and not table.isNullOrEmpty(self.bigAwardTbl.previewVedio) then
- for _, v in pairs(self.bigAwardTbl.previewVedio) do
- if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
- GUI:SetActive(self.view.button_watchVideo,true)
- GUI:Text_setString(self.view.text19, v[2])
- end
- end
- else
- GUI:SetActive(self.view.button_watchVideo,false)
- end
- end
- function this:ShowBigModel(Tbl)
- if not Tbl then
- return
- end
- local scale = 40
- local mrotate = "-70,-70,0"
- local x = "0"
- local y = "-50"
- local z = "-200"
- local path = ""
- local ani = ""
- local rX = 1
- local rY = 0
- local rZ = 0
- for _, model1 in pairs(Tbl.showModel) do
- if tonumber(model1[1]) == self.careerId or tonumber(model1[1]) == 0 then
- path = model1[2]
- end
- end
- for _, model2 in pairs(Tbl.modelCondition) do
- if tonumber(model2[5]) == self.careerId or tonumber(model2[1]) == 0 then
- x=model2[1]
- y =model2[2]
- z = model2[3]
- scale = tonumber(model2[4])
- end
- end
- for _, model3 in pairs(Tbl.modelRevolve) do
- if tonumber(model3[4]) == self.careerId or tonumber(model3[1]) == 0 then
- --mrotate = model3[1].. "," .. model3[2] .. "," .. model3[3]
- rX = tonumber(model3[1])
- rY = tonumber(model3[2])
- rZ = tonumber(model3[3])
- end
- end
- for _, model4 in pairs(Tbl.modelBehavior) do
- if tonumber(model4[2]) == self.careerId or tonumber(model4[1]) == 0 then
- ani=model4[1]
- end
- end
- local data = {
- mscale = 1 .. "," .. 1 .. "," .. 1,
- mrotate = mrotate,
- x = x,
- y = y,
- z = z,
- a = "00",
- src = path,
- ani = ani,
- }
- if self.model then
- GUI:Item_UpdataData(self.model, data)
- else
- self.model = GUI:Model_Create(self.view.ItemModel, data)
- end
- GUI:setScale(self.model, scale)
- GUI:setRotationSkewX(self.model,rX)
- GUI:setRotationSkewY(self.model,rY)
- GUI:setRotation(self.model,rZ)
- end
- function this:SetFillAmount(value)
- GUI:SetLoadingbar_startper(self.view.scheduleImg, math.floor(value*100))
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.button_watchVideo, self, self.VideoOnClick)
- SL:RegisterLUAEvent(LUA_EVENT_RECHARGE_LINK_CHANGE, self.LUA_EVENT_RECHARGE_LINK_CHANGE, self)
- GUI:AddOnClickEvent(self.view.btnUp, self, self.btnUpOnClick)
- end
- function this:btnUpOnClick()
- if self.bigAwardTbl then
- GUI:UIPanel_Close("dev/outui/MainRecharge/Panel/KLMainRecharge/KLMainRechargePanel")
- shortcutOutMgr.DO(self.bigAwardTbl.Jump)
- SL:HideMainPanel()
- end
- end
- function this:LUA_EVENT_RECHARGE_LINK_CHANGE()
- self.RechargeLinkData = InfoManager.rechargeLinkInfo.RechargeLinkData
- self:SetFillAmount(self.RechargeLinkData.totalMoney / 100)
- GUI:Text_setString(self.view.RechargeTargetTextBName, "今日充值达标:<color=#5DE367>" .. "100" .. "</color>元")
- GUI:Text_setString(self.view.schedule_Text, self.RechargeLinkData.totalMoney .. "/" .. 100)
- for _, v in pairs(self.RechargeLinkData.data) do
- self.dataList[tonumber(v.id)] = v
- end
- GUI:DataListUpdateData(self.view.ItemDataList)
- self:UpDataBigAward()
- end
- function this:VideoOnClick()
- if self.bigAwardTbl.previewVedio ~= "" then
- for _, v in pairs(self.bigAwardTbl.previewVedio) do
- if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
- GUI:UIPanel_Open("dev/outui/Recharge/Panel/KLPlayVideo/KLPlayVideoPanel", nil, nil, { path = v[3] })
- GUI:Text_setString(self.view.text19, v[2])
- end
- end
- end
- end
- ---界面显示时调用一次
- function this:Show()
- local mainTbl = SL:GetConfig("sub_mainRecharge",9)
- local showCondition = mainTbl.showCondition
- local conditionTbl=ConditionManager.GetConditionParams(showCondition)
- local reTime=SL:GetEndTimeStamp(tonumber(conditionTbl[1]),0)
- self:ShowTime(reTime)
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION, { type = tostring(ERechargeType.RechargeLink), action = "panel" })
- --SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECHARGE_ACTION,{type=tostring(ERechargeType.RechargeLink),action="reward",id = "10001"})
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- end
- function this:ShowTime(endTime)
- self.Timer = SL:Schedule(self.Timer, 0, 1, endTime + 1, function()
- local timeText = endTime - Time.GetServerTime()
- GUI:Text_setString(self.view.Timer,"活动剩余时间:<color=#5DE367>".. GUIUtil.FormatTimeDHM(timeText // 1000).."</color>")
- if timeText <= 0 then
- GUI:Text_setString(self.view.Timer,"")
- for _,v in pairs(self.dataList) do
- if v.state == 1 then
- v.state = 3
- end
- end
- self:SetFillAmount(0/ 100)
- GUI:Text_setString(self.view.schedule_Text, 0 .. "/" .. 100)
- GUI:DataListUpdateData(self.view.ItemDataList)
- self:UpDataBigAward()
- if self.bigAwardTbl and self.bigAwardTbl.previewVedio ~= "" and not table.isNullOrEmpty(self.bigAwardTbl.previewVedio) then
- for _, v in pairs(self.bigAwardTbl.previewVedio) do
- if tonumber(v[1]) == self.careerId or tonumber(v[1]) == 0 then
- GUI:SetActive(self.view.button_watchVideo,true)
- GUI:Text_setString(self.view.text19, v[2])
- end
- end
- else
- GUI:SetActive(self.view.button_watchVideo,false)
- end
- InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NewServerRecharge",false)
- if self.Timer then
- SL:UnSchedule(self.Timer)
- end
- end
- end)
- end
- function this:Close()
- if self.Timer then
- SL:UnSchedule(self.Timer)
- end
- self.Timer = nil
- end
- return this
|