local this = class("modulePhotoGroup_petFace", require("ui.pages.photo.group.modulePhotoGroup_base"))

function this.bind()
  return {
    selectedId = 0,
    goSlider = false,
    list = {
      moduleName = "pages/photo/cell/cellPhotoImage"
    }
  }
end

function this.methods()
  return {
    list = {
      onClick_handle = function(self, id)
        self:playAction(id)
      end
    }
  }
end

function this:open()
  self:initDefaultId()
  self:updateTargetEntity()
  self:initGroupList(L_Const.photoGroup.petFace)
end

function this:initDefaultId()
  self.defaultId = L_Const.photoParam.petDefFace
end

function this:playAction(id)
  self:setActionId(id)
  if self.parent.curSelectEntityInfo then
    self.parent.curSelectEntityInfo.actionId = id
    local tpl = self.paramTpl:getTplById(id)
    local faceIndex = self.paramTpl:getParam(tpl)
    self.parent.curSelectEntityInfo.entity:playExpression(faceIndex)
  end
end

function this:setActionId(id)
  self.actionId = id
end

function this:updateTargetEntity()
  local actionId = self.parent.curSelectEntityInfo and self.parent.curSelectEntityInfo.actionId or self.defaultId
  self:setActionId(actionId)
  self.bind.selectedId = self.defaultId
end

return this
