金猪倒计时

This commit is contained in:
chenxi 2023-06-13 11:59:35 +08:00
parent 95fd46ed94
commit 823dac78f8

View File

@ -55,24 +55,19 @@ function GoldPigUI:onLoadRootComplete()
end
end)
self:bind(DataManager.GoldPigData, "dirty", function()
if not DataManager.GoldPigData:getIsOpen() then
--如果是到时间关闭的则弹出提示
local id = DataManager.GoldPigData:getId()
if self.goldPigId > id then -- 降级说明是时间到了关闭的
local params = {
content = I18N:getGlobalText(I18N.GlobalConst.GOLD_PIG_CLOSE_DESC),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
okFunc = function()
self:closeUI()
end
}
GFunc.showMessageBox(params)
end
end
end)
BIReport:postPayUIShow(BIReport.GIFT_TYPE.GOLD_PIG)
self.timeTx = uiMap["gold_pig_ui.bg.time_bg.time_tx"]
local isFull = DataManager.GoldPigData:getIsFull()
if isFull then
uiMap["gold_pig_ui.bg.time_bg"]:setVisible(true)
self.cdSid = self:scheduleGlobal(function()
self:updateTime()
end, 1)
self:updateTime()
else
uiMap["gold_pig_ui.bg.time_bg"]:setVisible(false)
end
end
function GoldPigUI:initSpine()
@ -84,4 +79,26 @@ function GoldPigUI:initSpine()
end, time)
end
function GoldPigUI:updateTime()
local endTime = DataManager.GoldPigData:getEndTime()
local remainTime = endTime - Time:getServerTime()
if remainTime > 0 then
self.timeTx:setText(GFunc.getTimeStrWithHMS(remainTime))
else
self.timeTx:setText("00:00:00")
if self.cdSid then
self:unscheduleGlobal(self.cdSid)
self.cdSid = nil
end
local params = {
content = I18N:getGlobalText(I18N.GlobalConst.GOLD_PIG_CLOSE_DESC),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
okFunc = function()
self:closeUI()
end
}
GFunc.showMessageBox(params)
end
end
return GoldPigUI