UIExpiditionHelpLogView.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. local UIExpiditionHelpLogView = require("UIExpedition/UIExpiditionHelpLogView_Generate")
  2. function UIExpiditionHelpLogView:OnAwake(data)
  3. self.controller = require("UIExpedition/UIExpiditionHelpLogCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIExpiditionHelpLogView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_Expedition_REFRESH_HELP_LOG,self,self.ShowLogList)
  9. end
  10. function UIExpiditionHelpLogView: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 UIExpiditionHelpLogView:Init()
  21. self.lastReqTime = 0
  22. self.logScrollList.loopVerticalScrollRect:SetDragLuaCallback(self.OnDragScrollView)
  23. self:ShowLogList()
  24. self:OnDragScrollView()
  25. end
  26. function UIExpiditionHelpLogView:RemoveEventListener()
  27. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  28. end
  29. function UIExpiditionHelpLogView:AddUIEventListener()
  30. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickClose)
  31. self.uiBase:AddButtonEventListener(self.closeBtn.button,self, self.OnClickClose)
  32. end
  33. function UIExpiditionHelpLogView:OnHide()
  34. end
  35. function UIExpiditionHelpLogView:OnShow(data)
  36. self.controller:SetData(data)
  37. end
  38. function UIExpiditionHelpLogView:OnClose()
  39. self.logScrollList.loopVerticalScrollRect:ClearCells()
  40. end
  41. function UIExpiditionHelpLogView:OnDispose()
  42. self.controller:OnDispose()
  43. end
  44. function UIExpiditionHelpLogView:OnClickClose()
  45. self:UIClose()
  46. end
  47. function UIExpiditionHelpLogView:ShowLogList()
  48. local leftRescuedNum = ManagerContainer.DataMgr.ExpeditionDataMgr.maxRescuedNum - ManagerContainer.DataMgr.ExpeditionDataMgr.usedRescuedNum
  49. local leftAssistNum = ManagerContainer.DataMgr.ExpeditionDataMgr.maxAssistNum - ManagerContainer.DataMgr.ExpeditionDataMgr.usedAssistNum
  50. self.leftRescuedNumTxt.text.text = tostring(leftRescuedNum)
  51. self.leftAssistNumTxt.text.text = tostring(leftAssistNum)
  52. local logList = ManagerContainer.DataMgr.ExpeditionDataMgr:GetRescuers()
  53. if logList ~= nil and #logList > 0 then
  54. self.emptyNode:SetActive(false)
  55. CommonUtil.LoopGridViewEleCreateNew(self,
  56. self.logScrollList.loopVerticalScrollRect,
  57. self.logScrollList.content.verticalLayoutGroup,
  58. logList,
  59. 0,
  60. self, self.SetLogData);
  61. else
  62. self.emptyNode:SetActive(true)
  63. self.logScrollList.loopVerticalScrollRect:ClearCells()
  64. end
  65. end
  66. function UIExpiditionHelpLogView:SetLogData(node,idx,friendData)
  67. if node == nil or friendData == nil then
  68. return
  69. end
  70. local _jbIcon = nil;
  71. local jobCfg = ManagerContainer.CfgMgr:GetJobDataById(friendData.job)
  72. if jobCfg ~= nil then
  73. _jbIcon = jobCfg.JobIcon;
  74. end
  75. local _headIcon = nil;
  76. if friendData.head ~= nil then
  77. _headIcon = friendData.head;
  78. end
  79. local _fakerData = {Level = friendData.level, ProfessionIcon = _jbIcon, HeadIcon = _headIcon, IsHero = true};
  80. CommonUtil.SetPlayerHeadAndFrame(self, node.headItem, _fakerData,false, friendData.headFrameId, self, self.OnClickPlayerHead, friendData.uid);
  81. node.playerName.text.text = friendData.name
  82. node.timeTxt.text.text = DateTimeUtil.convertTime2Str(friendData.param,"yyyy-MM-dd")
  83. end
  84. function UIExpiditionHelpLogView:OnClickPlayerHead(btn,params)
  85. local uid = params[0]
  86. ManagerContainer.LuaUIMgr:OpenRoleMessagePanel(uid)
  87. end
  88. function UIExpiditionHelpLogView:OnDragScrollView()
  89. local leftCnt = ManagerContainer.DataMgr.ExpeditionDataMgr:GetRescuerCnt()
  90. if leftCnt > 0 then
  91. local curTime = Time.realtimeSinceStartup
  92. if (curTime - self.lastReqTime) >= 0.1 then
  93. ManagerContainer.DataMgr.ExpeditionDataMgr:ReqestRescuerBriefData()
  94. self.lastReqTime = curTime
  95. end
  96. end
  97. end
  98. return UIExpiditionHelpLogView