local this = class("pageRaffleInfo", G_UIPageBase)
local _gachaTpl = L_GameTpl:getGachaTpl()
local menuOption = {detail = 1, list = 2}

function this.bind()
  return {
    list_menu = {
      moduleName = "pages/Raffle/cellTextMenu"
    },
    selectId_menuTab = 1,
    module_commonTipLarge = L_Const.ModuleInfo.CommonTipLarge,
    txt_content = nil
  }
end

function this.methods()
  return {
    onTabIdSelected_menu = function(self, id)
      if self.bind.selectId_menuTab == id then
        return
      end
      self.bind.selectId_menuTab = id
      self:initShowInfo()
    end,
    module_commonTipLarge = {
      onClick_close = function(self)
        L_UI:close(self.pageName)
      end,
      onClick_bg = function(self)
        L_UI:close(self.pageName)
      end
    }
  }
end

function this:preOpen(options)
  this.super.preOpen(self, options)
  self._curPoolId = options.poolId
  self:initPage()
end

function this:close(options)
  this.super.close(self, options)
end

function this:initPage()
  self:initCommonTipModule()
  self:initMenuList()
  self:initShowInfo()
end

function this:initCommonTipModule()
  local tpl = _gachaTpl:getTplById(self._curPoolId)
  local moduleTip = self.modules.module_commonTipLarge
  moduleTip:initModule({
    hideConfirm = true,
    hideCancel = true,
    txtTitle = _gachaTpl:getGachaName(tpl)
  })
end

function this:initMenuList()
  local txtList = {
    [menuOption.detail] = L_WordsTpl:getValue("ui_pageRaffleInfo_01"),
    [menuOption.list] = L_WordsTpl:getValue("ui_pageRaffleInfo_02")
  }
  local tmp = {}
  for i, v in ipairs(txtList) do
    table.insert(tmp, {
      tabId = i,
      txt_normal = v,
      txt_active = v
    })
  end
  self.bind.selectId_menuTab = self.bind.selectId_menuTab or tmp[1].type
  self.bind.list_menu:clear()
  self.bind.list_menu:insert_array(tmp)
end

function this:initShowInfo()
  self.bind.txt_content = ""
  if self.bind.selectId_menuTab == menuOption.detail then
    local key = string.format("gacha_notice_text%s", self._curPoolId)
    self.bind.txt_content = L_WordsTpl:getValue(key)
  end
end

return this
