local this = class("pageSpiritStarUpSuccess", G_UIPageBase)
local _spiritronTpl = L_GameTpl:getSpiritronTpl()

function this.bind()
  return {
    list_star = {
      moduleName = "pages/heroPanel/spirit/cellSpiritStar"
    },
    txtDescribe = "",
    icon = nil
  }
end

function this.methods()
  return {
    onClick_closeUpStarSucceed = function(self)
      if self.callback then
        self.callback()
      end
      L_UI:close(self.pageName)
    end
  }
end

function this:open(...)
end

function this:close()
end

function this:preOpen(options)
  self.spiritGuid = options.spiritGuid
  self.curStar = options.curStar
  self.afterStar = options.afterStar - 1
  self:upStarSucceed()
end

function this:upStarSucceed()
  if not math.isEmpty(self.spiritGuid) then
    local currData = L_SpiritronStore:getSpiritronItem(self.spiritGuid)
    local tpl = _spiritronTpl:getTplById(currData.spiritronId)
    self.bind.icon = _spiritronTpl:getAvatarTexture(tpl, 1)
    printf("curStar", self.afterStar)
    local tmp = {}
    for i = 1, 4 do
      local activeStar = i <= self.afterStar
      local greyStarActive = i > self.afterStar
      table.insert(tmp, {starActive = activeStar, greyStarActive = greyStarActive})
    end
    self.bind.list_star:clear()
    self.bind.list_star:insert_array(tmp)
    self.bind.txtDescribe = L_SpiritronManager:getConfigSkillDesc(currData.spiritronId, self.afterStar)
  end
end

return this
