local this = class("pageRaffleResultTen", G_UIPageBase)
local IMG_QUALITY = {
  [L_Const.quality.n] = "Page/BSGacha/tex_gacha_bg_pinzhi_2_shilian",
  [L_Const.quality.r] = "Page/BSGacha/tex_gacha_bg_pinzhi_2_shilian",
  [L_Const.quality.sr] = "Page/BSGacha/tex_gacha_bg_pinzhi_2_shilian",
  [L_Const.quality.ssr] = "Page/BSGacha/tex_gacha_bg_pinzhi_1_shilian"
}
local IMG_QUALITY2 = {
  [L_Const.quality.n] = "Page/BSGacha/tex_gacha_frame_pinzhi_3_down",
  [L_Const.quality.r] = "Page/BSGacha/tex_gacha_frame_pinzhi_3_down",
  [L_Const.quality.sr] = "Page/BSGacha/tex_gacha_frame_pinzhi_2_down",
  [L_Const.quality.ssr] = "Page/BSGacha/tex_gacha_frame_pinzhi_1_down"
}
local IMG_QUALITY3 = {
  [L_Const.quality.n] = "Page/BSGacha/tex_gacha_word_pinzhi_3",
  [L_Const.quality.r] = "Page/BSGacha/tex_gacha_word_pinzhi_3",
  [L_Const.quality.sr] = "Page/BSGacha/tex_gacha_word_pinzhi_2",
  [L_Const.quality.ssr] = "Page/BSGacha/tex_gacha_word_pinzhi_1"
}

function this:ctor(...)
  this.super.ctor(self, ...)
  self.data = {}
end

function this.bind()
  return {
    scrollList_tenResult_top = {
      moduleName = "pages/Raffle/cellTenResult"
    },
    scrollList_tenResult_bottom = {
      moduleName = "pages/Raffle/cellTenResult"
    }
  }
end

function this.methods()
  return {
    onClick_continue = function(self)
      L_UI:close(self.pageName)
    end
  }
end

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

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

function this:initPage()
  self:initTenResultList()
  L_AudioUtil.playSESound("card_show")
end

function this:initTenResultList()
  local cardList = L_RaffleStore:getResultList()
  local tmp = {}
  for _, v in pairs(cardList) do
    local item = L_ItemManager:parseItem(v.mainPropType, v.mainPropId)
    table.insert(tmp, {
      go_new = v.new,
      go_img_bg_quality = item.quality >= L_Const.quality.sr,
      img_bg_quality = IMG_QUALITY[item.quality],
      img_bg_quality2 = IMG_QUALITY2[item.quality],
      img_quality = IMG_QUALITY3[item.quality],
      serverData = v
    })
  end
  local top = {}
  local bottom = {}
  for i, v in ipairs(tmp) do
    if i <= 5 then
      table.insert(top, v)
    else
      table.insert(bottom, v)
    end
  end
  self.bind.scrollList_tenResult_top:clear()
  self.bind.scrollList_tenResult_top:insert_array(top)
  self.bind.scrollList_tenResult_bottom:clear()
  self.bind.scrollList_tenResult_bottom:insert_array(bottom)
end

return this
