c1_lua/lua/app/ui/fund/fund_reward_ui.lua
2025-09-24 16:21:47 +08:00

83 lines
2.8 KiB
Lua
Executable File

local BaseTips = require "app/ui/tips/base_tips"
local FundRewardUI = class("FundRewardUI", BaseTips)
--fund_reward_ui FundRewardUI
local REWARD_BOX_CELL = "app/ui/tips/cell/reward_box_cell"
function FundRewardUI:ctor(params)
self.params = params or {}
self.params.txTitle = self.params.txTitle
self.params.giftIds = self.params.giftIds
self.params.rewards = params.rewards or {}
self.params.func = params.func
end
function FundRewardUI:getPrefabPath()
return "assets/prefabs/ui/fund/fund_reward_ui.prefab"
end
function FundRewardUI:setRootUI(ui)
self.parentUI = ui
end
function FundRewardUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.btnCloseMask = uiMap["fund_reward_ui.btn_close_mask"]
self.content = uiMap["fund_reward_ui.content"]
self.txTitle = uiMap["fund_reward_ui.content.tx_title"]
self.btnClose = uiMap["fund_reward_ui.content.btn_close"]
self.imgArt = uiMap["fund_reward_ui.content.img_art"]
self.imgProg = uiMap["fund_reward_ui.content.img_art.img_prog"]
self.txPro = uiMap["fund_reward_ui.content.img_art.img_prog.tx_pro"]
self.scrollrect = uiMap["fund_reward_ui.content.img_art.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.btnBuy = uiMap["fund_reward_ui.content.btn_buy"]
self.txDescBuy = uiMap["fund_reward_ui.content.btn_buy.tx_desc_buy"]
if self.params.giftIds ~= nil then
local gift = ConfigManager:getConfig("act_gift")[self.params.giftIds]
if gift ~= nil then
self.txDescBuy:setText(GFunc.getFormatPrice(gift.recharge_id))
self.txPro:setText(gift.value .. "%")
end
self.btnBuy:setVisible(true)
self.imgProg:setVisible(true)
else
self.imgProg:setVisible(false)
self.btnBuy:setVisible(false)
end
self.txTitle:setText(self.params.txTitle)
self.btnBuy:addClickListener(function()
if self.params.func ~= nil then
self.params.func()
end
self:closeUI()
end)
self.btnCloseMask:addClickListener(function()
self:closeUI()
end)
self.btnClose:addClickListener(function()
self:closeUI()
end)
local count = #self.params.rewards
if count <= 5 then
uiMap["fund_reward_ui.content.img_art.scrollrect"]:setAnchoredPositionY(-191)
else
uiMap["fund_reward_ui.content.img_art.scrollrect"]:setAnchoredPositionY(-128)
end
self.scrollrect:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
end)
self.scrollrect:addRefreshCallback(function(index, cell)
cell:refreshByConfig(self.params.rewards[index])
end)
if self.scrollrect:getTotalCount() == #self.params.rewards then
self.scrollrect:updateAllCell()
else
self.scrollrect:refillCells(#self.params.rewards)
end
end
return FundRewardUI