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

function SideBarDiscountCell:getModuleKey()
    return nil
end

function SideBarDiscountCell:getHasPurchase()
    return true
end

function SideBarDiscountCell:getIsOpen()
    -- 同ShopComp:refreshDiscountPage() 一起修改
    if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MALL, true) then
        return false
    end

    -- 章节礼包
    if #DataManager.ShopData:getActChapterStoreCanBuyActIds() > 0 then
        return true
    end

    -- 新手礼包
    if not DataManager.ShopData:getBeginnerGiftHasBuy() then
        return true
    end

    -- 竞技场
    if DataManager.ArenaData:getGiftId() ~= nil then
        return true
    end

    -- 助力礼包
    if #DataManager.ShopData:getLevelUpGiftActIds() > 0 then
        return true
    end

    -- 成长礼包
    if DataManager.ShopData:hasGrowUpGift() then
        return true
    end

    -- 金币
    if DataManager.ShopData:getValidCoinGiftId() ~= nil  then
        return true
    end

    return false
end

function SideBarDiscountCell:getSpineName()
    return "ui_main_btn_indulgencegift"
end

function SideBarDiscountCell:onClick()
    DataManager.ShopData:markEntranceDiscountRedPoint()
    EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_SHOP, {page = GConst.ShopConst.PAGE_TYPE.DISCOUNT})
end

function SideBarDiscountCell:getIsShowRedPoint()
    return DataManager.ShopData:getEntranceDiscountRedPoint()
end

return SideBarDiscountCell