local module = class("cellSpiritron", G_UIModuleBase)

function module:ctor(...)
  module.super.ctor(self, ...)
  self.data = {photoEntity = nil}
end

function module.bind()
  return {
    img_icon = "",
    img_quality = "",
    img_owner = "",
    txt_level = "",
    go_lock = false,
    go_disable = false,
    go_active = false,
    moduleStarRating = {
      moduleName = "modulePages/moduleStarRating"
    }
  }
end

function module.methods()
  return {
    onClick_select = function(self)
      self:emit("onClick_select", self.bind)
    end,
    onClick_remove = function(self)
      self:emit("onClick_remove", self.bind)
    end
  }
end

function module:refresh()
  self.modules.moduleStarRating:refreshStar(self.bind.num_star - 1)
  self.bindComponents.go_owner.gameObject:ActiveTrans(not string.isEmpty(self.bind.img_owner))
  if self.bind.url_defaultOwner then
    if self.data.photoEntity == nil then
      self.data.photoEntity = L_PhotoManager:bindPhotoEntity(self.bindComponents.img_owner.gameObject, self.bind.url_defaultOwner)
    else
      self.data.photoEntity:bindGameObject(self.bindComponents.img_owner.gameObject)
    end
  elseif self.data.photoEntity then
    self.data.photoEntity:dispose()
    self.data.photoEntity = nil
  end
end

return module
