local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarBeginnerGiftCell = class("SideBarBeginnerGiftCell", SideBarBaseCellComp)

function SideBarBeginnerGiftCell:getModuleKey()
    return ModuleManager.MODULE_KEY.BEGINNER_GIFT
end

function SideBarBeginnerGiftCell:getIsOpen()
    return DataManager.ShopData:getBeginnerGiftShowSideBar()
end

function SideBarBeginnerGiftCell:getSpineName()
    return "main_btn_gift_new"
end

function SideBarBeginnerGiftCell:onClick()
    ModuleManager.ShopManager:showGiftPopUI(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ShopConst.BEGINNER_GIFT_ID, true, BIReport.PAY_UI_SHOW_TYPE.CLICK_SHOW)
end

function SideBarBeginnerGiftCell:getIsShowRedPoint()
    return false
end

function SideBarBeginnerGiftCell:onRefresh()
    self.timeBg:setVisible(true)
    self:_refreshTime()
end

function SideBarBeginnerGiftCell:updateTime()
    if self:getIsOpen() then
        self:_refreshTime()
    else
        self:closeBtn()
    end
end

function SideBarBeginnerGiftCell:_refreshTime()
    local remainTime = DataManager.ShopData:getBeginnerGiftSideBarRemainTime()
    if remainTime >= 0 then
        self.timeTx:setText(GFunc.getTimeStr(remainTime))
    else
        self.timeTx:setText("00:00:00")
    end
end

return SideBarBeginnerGiftCell