UIGetNowPopView.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. local UIGetNowPopView = require("UIBag/UIGetNowPopView_Generate")
  2. function UIGetNowPopView:OnAwake(data)
  3. self.controller = require("UIBag/UIGetNowPopCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIGetNowPopView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  9. end
  10. function UIGetNowPopView:FillContent(data, uiBase)
  11. self.uiBase = uiBase
  12. local gameObject = self.uiBase:GetRoot()
  13. if gameObject ~= nil then
  14. self.gameObject = gameObject
  15. self.transform = gameObject.transform
  16. end
  17. self:InitGenerate(self.transform, data)
  18. self:Init()
  19. end
  20. function UIGetNowPopView:Init()
  21. local data = self.controller:GetData()
  22. local cfgId = data.cfgId
  23. local needNum = data.needNum
  24. local timeTxt = data.timeTxt
  25. local idx = data.idx
  26. local itemData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  27. if itemData then
  28. local hasNum = CommonUtil.GetOwnResCountByItemId(cfgId)
  29. self.LeftTimesLbl.text.text = timeTxt
  30. self.dscTxt.text.text = I18N.T("DscWishaccelerate1")
  31. local txt = ""
  32. if hasNum < needNum then
  33. txt = string.format(Constant.RedColorText,hasNum).."/"..needNum
  34. else
  35. txt = hasNum.."/"..needNum
  36. end
  37. self.numcost.text.text = txt
  38. CommonUtil.LoadIcon(self, itemData.Icon, function (sprite)
  39. self.icon.image.sprite = sprite
  40. end)
  41. end
  42. end
  43. function UIGetNowPopView:RemoveEventListener()
  44. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  45. end
  46. function UIGetNowPopView:AddUIEventListener()
  47. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickCloseBtn)
  48. self.uiBase:AddButtonEventListener(self.CloseBtn.button,self, self.OnClickCloseBtn)
  49. self.uiBase:AddButtonEventListener(self.btnGetNow.button, self, self.OnClickGetNowBtn)
  50. end
  51. function UIGetNowPopView:OnClickCloseBtn()
  52. ManagerContainer.LuaUIMgr:ClosePage(self.uiBase.PageId)
  53. if self.uiBase.MSourceUIID > 0 then
  54. ManagerContainer.LuaUIMgr:Open(self.uiBase.MSourceUIID)
  55. end
  56. end
  57. function UIGetNowPopView:OnClickGetNowBtn()
  58. local data = self.controller:GetData()
  59. local cfgId = data.cfgId
  60. local needNum = data.needNum
  61. local timeTxt = data.timeTxt
  62. local idx = data.idx
  63. local wishSlotData = ManagerContainer.DataMgr.BagData:GetWishSlotData()
  64. if not wishSlotData then
  65. return
  66. end
  67. local hasNum = CommonUtil.GetOwnResCountByItemId(cfgId)
  68. local wishData = wishSlotData[idx]
  69. if wishData then
  70. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(wishData.end_time * 1000)
  71. if remainTime > 0 then
  72. if hasNum < needNum then
  73. CommonUtil.ItemNotEnoughHandle(cfgId)
  74. else
  75. ManagerContainer.DataMgr.BagData:SendWishAccelerateReq(idx - 1)
  76. end
  77. else
  78. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("WishacceleratTime0")
  79. end
  80. end
  81. self:OnClickCloseBtn()
  82. end
  83. function UIGetNowPopView:OnHide()
  84. end
  85. function UIGetNowPopView:OnShow(data)
  86. self.controller:SetData(data)
  87. end
  88. function UIGetNowPopView:OnClose()
  89. end
  90. function UIGetNowPopView:OnDispose()
  91. self.controller:OnDispose()
  92. end
  93. return UIGetNowPopView