From 51dfbf15282fcdb7edbf8c089d92c21a69c8a84d Mon Sep 17 00:00:00 2001 From: CloudJ Date: Tue, 30 May 2023 14:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E5=8C=85=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/shop/cell/coin_sell_cell.lua | 23 ++++++++++++++++++----- lua/app/ui/shop/cell/grow_sell_cell.lua | 7 +++++-- lua/app/ui/shop/gift_pop_ui.lua | 2 ++ lua/app/ui/shop/shop_comp.lua | 12 ++++++++++++ 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lua/app/ui/shop/cell/coin_sell_cell.lua b/lua/app/ui/shop/cell/coin_sell_cell.lua index 5989b888..e7267845 100644 --- a/lua/app/ui/shop/cell/coin_sell_cell.lua +++ b/lua/app/ui/shop/cell/coin_sell_cell.lua @@ -43,7 +43,8 @@ end function CoinSellCell:refresh() local actGiftId = DataManager.ShopData:getValidCoinGiftId() if actGiftId and actGiftId > 0 then - local cfgInfo = ConfigManager:getConfig("act_gift")[actGiftId] + self.actGiftId = actGiftId -- 记录当前金币礼包ID + local cfgInfo = ConfigManager:getConfig("act_gift")[self.actGiftId] -- 超值 self.offText:setText(tostring(cfgInfo.value) .. "%") -- 限购 @@ -77,8 +78,13 @@ function CoinSellCell:refresh() self:refreshTime() self.clickArea:addClickListener(function() - self:onClickGift(actGiftId) + self:onClickGift(self.actGiftId) end) + else -- 倒计时结束的情况 + if self.actGiftId then + DataManager.ShopData:setDirty() + self.actGiftId = nil + end end end @@ -100,9 +106,8 @@ end function CoinSellCell:refreshTime() local remainTime = 0 - local actId = DataManager.ShopData:getValidCoinGiftId() - if actId > 0 then - local cfgInfo = DataManager.ShopData:getActGiftConfig()[actId] + if self.actGiftId and self.actGiftId > 0 then + local cfgInfo = DataManager.ShopData:getActGiftConfig()[self.actGiftId] local triggerTime = DataManager.ShopData:getCoinGiftTriggerTime() remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime() if remainTime <= 0 then @@ -112,4 +117,12 @@ function CoinSellCell:refreshTime() self.timeText:setText(Time:formatNumTimeStr(remainTime)) end +function CoinSellCell:getCellCount() + if self.actGiftId and self.actGiftId > 0 then + return 1 + else + return 0 + end +end + return CoinSellCell \ No newline at end of file diff --git a/lua/app/ui/shop/cell/grow_sell_cell.lua b/lua/app/ui/shop/cell/grow_sell_cell.lua index 6c461618..8e8977c1 100644 --- a/lua/app/ui/shop/cell/grow_sell_cell.lua +++ b/lua/app/ui/shop/cell/grow_sell_cell.lua @@ -39,9 +39,12 @@ function GrowSellCell:refreshTime() end end +function GrowSellCell:getCellCount() + return self.actGifts and #self.actGifts or 0 +end + function GrowSellCell:getCellHeight() - local cellCount = self.actGifts and #self.actGifts or 0 - return BASE_CELL_HEIGHT * cellCount + return BASE_CELL_HEIGHT * self:getCellCount() end function GrowSellCell:getIsOpen() diff --git a/lua/app/ui/shop/gift_pop_ui.lua b/lua/app/ui/shop/gift_pop_ui.lua index 381fdc14..c839be2c 100644 --- a/lua/app/ui/shop/gift_pop_ui.lua +++ b/lua/app/ui/shop/gift_pop_ui.lua @@ -181,6 +181,7 @@ function GiftPopUI:updateTime() remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime() if remainTime <= 0 then remainTime = 0 + self:checkNextPopGiftOrClose() end self.timeText:setText(GFunc.getTimeStr(remainTime)) end @@ -194,6 +195,7 @@ function GiftPopUI:updateTime() remainTime = triggerTime + (cfgInfo.limit_time or 0) * 3600 - Time:getServerTime() if remainTime <= 0 then remainTime = 0 + self:checkNextPopGiftOrClose() end self.timeText:setText(GFunc.getTimeStr(remainTime)) end diff --git a/lua/app/ui/shop/shop_comp.lua b/lua/app/ui/shop/shop_comp.lua index e031b27d..433a9a74 100644 --- a/lua/app/ui/shop/shop_comp.lua +++ b/lua/app/ui/shop/shop_comp.lua @@ -135,12 +135,24 @@ function ShopComp:refreshTime() if self.hotSellCell and self.hotSellCell:getIsOpen() then self.hotSellCell:refreshTime() end + local coinCellCount = 0 if self.coinSellCell and self.coinSellCell:getIsOpen() then + coinCellCount = self.coinSellCell:getCellCount() self.coinSellCell:refreshTime() end + if self.coinCellCount ~= coinCellCount then + self.coinCellCount = coinCellCount + DataManager.ShopData:setDirty() + end + local growCellCount = 0 if self.growSellCell and self.growSellCell:getIsOpen() then + growCellCount = self.growSellCell:getCellCount() self.growSellCell:refreshTime() end + if self.growCellCount ~= growCellCount then + self.growCellCount = growCellCount + DataManager.ShopData:setDirty() + end end function ShopComp:refreshDiscountPage()