UIPOPGotView.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. local UIPOPGotView = require("UIPOPGot/UIPOPGotView_Generate")
  2. function UIPOPGotView:OnAwake(data)
  3. self.controller = require("UIPOPGot/UIPOPGotCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIPOPGotView:AddEventListener()
  8. end
  9. function UIPOPGotView:FillContent(data, uiBase)
  10. self.uiBase = uiBase
  11. local gameObject = self.uiBase:GetRoot()
  12. if gameObject ~= nil then
  13. self.gameObject = gameObject
  14. self.transform = gameObject.transform
  15. end
  16. self:InitGenerate(self.transform, data)
  17. if self.controller:GetTitle() ~= nil then
  18. self.titleNode.uILocalizeScript:SetContent(self.controller:GetTitle())
  19. else
  20. self.titleNode.uILocalizeScript:SetContent("Congratulation")
  21. end
  22. self:Init()
  23. end
  24. function UIPOPGotView:Init()
  25. local datas = self.controller:GetRewards()
  26. self.scrollView.loopVerticalScrollRect:ClearCells()
  27. self.scrollView.loopVerticalScrollRect:StopMovement()
  28. self.scrollView.loopVerticalScrollRect.content.anchoredPosition = Vector2.zero
  29. CommonUtil.LoopGridViewEleCreateNew(self, self.scrollView.loopVerticalScrollRect, nil, datas, 0, self, self.RefreshPopGotItem, nil, nil, 0)
  30. end
  31. function UIPOPGotView:RefreshPopGotItem(itemlua, idx, data)
  32. CommonUtil.UpdateItemPrefab(self, itemlua, data, Enum.ItemIEnterType.Bag, self, self.ShowItemTips)
  33. end
  34. function UIPOPGotView:ShowItemTips(button, params)
  35. --ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIItemTips, params[0])
  36. ManagerContainer.LuaUIMgr:OpenTips(params[0])
  37. end
  38. function UIPOPGotView:RemoveEventListener()
  39. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  40. end
  41. function UIPOPGotView:AddUIEventListener()
  42. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  43. self.uiBase:AddButtonEventListener(self.AnyBtn.button, function()
  44. local page = ManagerContainer.LuaUIMgr:GetPage(Enum.UIPageName.UIMain)
  45. if page then --有UIMain界面就可以飞item到背包,没有UIMain就没有背包,你飞哪去?
  46. local datas = self.controller:GetRewards()
  47. local list = {}
  48. local startPoses = {}
  49. local content = self.scrollView.loopVerticalScrollRect.content
  50. local idx
  51. for i = 0, content.childCount - 1 do
  52. local transform = content:GetChild(i)
  53. if transform.gameObject.activeSelf then
  54. local dataIdx = tonumber(transform.gameObject.name)
  55. local data = datas[dataIdx + 1]
  56. if data then
  57. idx = i + 1
  58. list[idx] = data
  59. startPoses[idx] = transform.position
  60. end
  61. end
  62. end
  63. local data1 = {list = list, startPoses = startPoses, endterType = Enum.ItemIEnterType.PopGot}
  64. ManagerContainer.LuaUIMgr:POPGotAnimNotice(data1)
  65. end
  66. self:UIClose()
  67. end)
  68. end
  69. function UIPOPGotView:OnHide()
  70. end
  71. function UIPOPGotView:OnShow(data)
  72. self.controller:SetData(data)
  73. self:Init()
  74. end
  75. function UIPOPGotView:OnClose()
  76. ManagerContainer.PopGotMgr:PageViewKeep(false)
  77. end
  78. function UIPOPGotView:OnDispose()
  79. self.scrollView.loopVerticalScrollRect:ClearCells()
  80. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_CLOSE_POPGOT_PAGE)
  81. end
  82. return UIPOPGotView