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

function SideBarIntroductGiftCell:getModuleKey()
    return ModuleManager.MODULE_KEY.INTRODUCT_GIFT
end

function SideBarIntroductGiftCell:getIsOpen()
    return DataManager.ShopData:getIntroductGiftShowSideBar()
end

function SideBarIntroductGiftCell:getSpineName()
    return "ui_main_btn_gift_first"
end

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

function SideBarIntroductGiftCell:getIsShowRedPoint()
    return false
end

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

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

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

return SideBarIntroductGiftCell