local this = class("cellSpiritronCardItem", G_UIModuleBase)
local _spTpl = L_GameTpl:getSpiritronTpl()

function this.bind()
  return {
    quality = "",
    infoBtn = false,
    paintingScalerPath = ""
  }
end

function this.methods()
  return {
    onClick_infoBtn = function(self)
      local tpl = _spTpl:getTplById(self._confId)
      local cgPath = _spTpl:getCgPath(tpl)
      if string.isEmpty(cgPath) then
        L_UI:open("pageSpiritronInfoLow", {
          id = self._confId
        })
      else
        L_UI:open("pageSpiritronInfo", {
          id = self._confId
        })
      end
    end
  }
end

function this:setId(confId)
  if math.isEmpty(confId) then
    self.bind.quality = string.format("PageSpiritron/tex_herospiritron_frame_%s", L_Const.qualityToKey[3])
    self.bind.paintingScalerPath = ""
  else
    local conf = _spTpl:getTplById(confId)
    self.bind.quality = string.format("PageSpiritron/tex_herospiritron_frame_%s", L_Const.qualityToKey[_spTpl:getRarity(conf)])
    self.bind.paintingScalerPath = _spTpl:getSpinePath(conf)
  end
  self._confId = confId
end

return this
