UIPetStampListCtr.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. local UIPetStampListCtr = class("UIPetStampListCtr", require("UICtrBase"))
  2. function UIPetStampListCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIPetStampListCtr:SetData(data)
  6. self.asyncIdx = 0
  7. if data == nil then return end
  8. self.data = data
  9. end
  10. function UIPetStampListCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIPetStampListCtr:GetData()
  15. return self.data
  16. end
  17. function UIPetStampListCtr:NilStampData()
  18. self.data.curStamp = nil
  19. end
  20. function UIPetStampListCtr:GetStampData()
  21. return self.data.curStamp
  22. end
  23. function UIPetStampListCtr:GetAllTypeStampDatas()
  24. local id = self.data.curStamp and self.data.curStamp.id or nil
  25. self.typeStampDatas = ManagerContainer.DataMgr.PetDataMgr.petStampData:GetAllPetStampDatasByTypeExcludeId(self.data.slotIdx, id)
  26. if self.typeStampDatas then
  27. CommonUtil.ArraySortSelections(self.typeStampDatas, Enum.TableSortRule.Down, "quality", "lv", "cfgId")
  28. end
  29. return self.typeStampDatas
  30. end
  31. function UIPetStampListCtr:GetShowDataByIdx(idx)
  32. return self.typeStampDatas and self.typeStampDatas[idx + 1] or nil
  33. end
  34. function UIPetStampListCtr:SendDownStamp()
  35. local slotIdx = self.data.slotIdx
  36. local petId = self.data.petId
  37. ManagerContainer.DataMgr.PetDataMgr:SendStampDownReq(petId, slotIdx)
  38. end
  39. function UIPetStampListCtr:SendChangeStamp(id)
  40. local slotIdx = self.data.slotIdx
  41. local petId = self.data.petId
  42. local petData = ManagerContainer.DataMgr.PetDataMgr:GetPetDataById(petId)
  43. if not petData then
  44. return
  45. end
  46. local slots = petData.slots
  47. local list = {}
  48. list[#list + 1] = {key = slotIdx, value = id}
  49. for _,v in pairs(slots) do
  50. if v.idx ~= slotIdx then
  51. list[#list + 1] = {key = v.idx, value = v.stampId}
  52. end
  53. end
  54. ManagerContainer.DataMgr.PetDataMgr:SendStampUpReq(petId, list)
  55. end
  56. function UIPetStampListCtr:OnDispose()
  57. self.data = nil
  58. self.view = nil
  59. end
  60. return UIPetStampListCtr