miduo_client/Assets/ManagedResources/~Lua/Modules/FuXingGaoZhao/FuXingGaoZhaoPanel.lua

157 lines
5.3 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
local FuXingGaoZhao = Inherit(BasePanel)
local this = FuXingGaoZhao
local sortingOrder = 0
local rewardList = {}
local itemPreList={} --item预设容器
local data
local timeData = string.split(ConfigManager.GetConfigDataByKey(ConfigName.SpecialConfig,"Id",109).Value,"#")
--初始化组件(用于子类重写)
function FuXingGaoZhao:InitComponent()
self.backBtn = Util.GetGameObject(self.gameObject,"btnBack")
self.effect = Util.GetGameObject(self.gameObject,"UI_effect_LuckyCatPanel_normal")
self.time = Util.GetGameObject(self.gameObject,"Time"):GetComponent("Text")
self.getBtn = Util.GetGameObject(self.gameObject,"getBtn")
FuXingGaoZhaoManager.InitRewardData()
self.mid = Util.GetGameObject(self.gameObject,"mid")
if #rewardList == 0 then
for i = 1, self.mid.transform.childCount do
table.insert(rewardList,self.mid.transform:GetChild(i-1))
end
end
self.gift = ConfigManager.GetConfigDataByKey(ConfigName.StoreConfig,"Id",11001)
end
--绑定事件(用于子类重写)
function FuXingGaoZhao:BindEvent()
Util.AddClick(self.backBtn,function ()
self:ClosePanel()
end)
Util.AddClick(self.getBtn,function ()
if data.ActState == 0 then
local costId, abcd = self.gift.Cost[1][1], self.gift.Cost[2]
local costNum = CalculateCostCount(0, abcd)
if costNum > BagManager.GetTotalItemNum(costId) then
JumpManager.GoJump(36003)
else
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
MsgPanel.ShowTwo(string.format( "是否花费%s%s进行储值",costNum,GetLanguageStrById(itemName)), nil, function()
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUXING_SHOP,11001,1,function()
PopupTipPanel.ShowTip("您已成功进行储值!")
FuXingGaoZhao:Refresh()
end,0)
end)
end
elseif data.ActState == 1 then
NetManager.GetActivityRewardRequest(-1,data.activityId,function (drop)
UIManager.OpenPanel(UIName.RewardItemPopup, drop, 1,function()
FuXingGaoZhao:Refresh()
end)
end)
end
end)
end
--添加事件监听(用于子类重写)
function FuXingGaoZhao:AddListener()
end
--移除事件监听(用于子类重写)
function FuXingGaoZhao:RemoveListener()
end
function FuXingGaoZhao:OnSortingOrderChange()
Util.AddParticleSortLayer(self.effect, self.sortingOrder - sortingOrder)
sortingOrder = self.sortingOrder
end
--界面打开时调用(用于子类重写)
function FuXingGaoZhao:OnOpen()
end
-- 打开,重新打开时回调
function FuXingGaoZhao:OnShow()
FuXingGaoZhao:Refresh()
end
function FuXingGaoZhao:Refresh()
data = FuXingGaoZhaoManager.GetData()
FuXingGaoZhao:SetBtn()
if data.ActState == 0 then
FuXingGaoZhao:SetTime()
self.time.gameObject:SetActive(true)
else
self.time.gameObject:SetActive(false)
end
for i = 1, #rewardList do
FuXingGaoZhao:SetSingleReward(rewardList[i],data.rewards[i],i)
end
end
function FuXingGaoZhao:SetBtn()
local text = Util.GetGameObject(self.getBtn,"Text"):GetComponent("Text")
local redPoint = Util.GetGameObject(self.getBtn,"redPoint")
if data.ActState == 0 then
text.text = "储 值"
self.getBtn:SetActive(true)
redPoint:SetActive(false)
elseif data.ActState == 1 then
text.text = Language[11948]
local bool = FuXingGaoZhaoManager.CheckRedPoint()
self.getBtn:SetActive(bool)
redPoint:SetActive(bool)
elseif data.ActState == 2 then
self.getBtn:SetActive(false)
end
end
function FuXingGaoZhao:SetTime()
if self.timer then
self.timer:Stop()
self.timer = nil
end
local time = data.startTime + tonumber(timeData[1])*86400 - GetTimeStamp()
self.time.text = string.format("剩余接受时间:%s",TimeToFelaxible(time))
self.timer = Timer.New(function()
time = time - 1
if time < 1 then
self.timer:Stop()
self.timer = nil
self:ClosePanel()
end
self.time.text = string.format("剩余接受时间:%s",TimeToFelaxible(time))
end, 1, -1, true)
self.timer:Start()
end
function FuXingGaoZhao:SetSingleReward(go,data,index)
local reward = Util.GetGameObject(go,"GameObject")
local mask = Util.GetGameObject(go,"mask")
-- LogBlue("index:"..index.." go:"..tostring(go.name).." 天数:"..tostring(NumToSimplenessFont[index]))
Util.GetGameObject(go,"Text"):GetComponent("Text").text = string.format("第%s天",NumToSimplenessFont[index])
if not itemPreList[index] then
itemPreList[index] = SubUIManager.Open(SubUIConfig.ItemView,reward.transform)
end
itemPreList[index]:OnOpen(false, data.Reward, 0.85,false, false, false, sortingOrder)
mask:SetActive(data.State == 1)
end
--界面关闭时调用(用于子类重写)
function FuXingGaoZhao:OnClose()
if self.timer then
self.timer:Stop()
self.timer = nil
end
end
--界面销毁时调用(用于子类重写)
function FuXingGaoZhao:OnDestroy()
if self.timer then
self.timer:Stop()
self.timer = nil
end
itemPreList={}
end
return FuXingGaoZhao