UIGuildLogView.lua 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. local UIGuildLogView = require("UIGuild/UIGuildLogView_Generate")
  2. local LoadStatusLoopListCtr = require('Common/LoadStatusLoopListCtr')
  3. function UIGuildLogView:OnAwake(data)
  4. self.controller = require("UIGuild/UIGuildLogCtr")
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIGuildLogView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_LOG_CHANGED, self, self.OnGuildLogChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
  13. end
  14. function UIGuildLogView:FillContent(data, uiBase)
  15. self.uiBase = uiBase
  16. local gameObject = self.uiBase:GetRoot()
  17. if gameObject ~= nil then
  18. self.gameObject = gameObject
  19. self.transform = gameObject.transform
  20. end
  21. self:InitGenerate(self.transform, data)
  22. self:Init()
  23. end
  24. function UIGuildLogView:Init()
  25. if self.loadStatusLoopListCtr then
  26. self.loadStatusLoopListCtr:Dispose()
  27. self.loadStatusLoopListCtr = nil
  28. end
  29. local logMaxNum = self.controller:GetLogMaxNum()
  30. self.loadStatusLoopListCtr = LoadStatusLoopListCtr:new(self, self.changeList.loopListView, 0, logMaxNum,
  31. false, 'LoadingItem', Enum.ListLoadingStatus.None,
  32. true, 'LoadingItem', Enum.ListLoadingStatus.WaitLoad,
  33. self.GetItemByIndex,nil, self.OnBeginLoad)
  34. self.changeList.loopListView.ScrollRect.enabled = false
  35. local errorCode = self.controller:SendGetGuildLogInfoReq(true)
  36. if errorCode ~= 0 then
  37. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  38. end
  39. end
  40. function UIGuildLogView:RemoveEventListener()
  41. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  42. end
  43. function UIGuildLogView:AddUIEventListener()
  44. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.OnClickCancelBtn)
  45. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickCancelBtn)
  46. end
  47. function UIGuildLogView:OnHide()
  48. end
  49. function UIGuildLogView:OnShow(data)
  50. self.controller:SetData(data)
  51. end
  52. function UIGuildLogView:OnClose()
  53. end
  54. function UIGuildLogView:OnDispose()
  55. if self.loadStatusLoopListCtr then
  56. self.loadStatusLoopListCtr:Dispose()
  57. self.loadStatusLoopListCtr = nil
  58. end
  59. self.controller:OnDispose()
  60. end
  61. function UIGuildLogView:OnPageInEnd()
  62. self.super.OnPageInEnd(self)
  63. self.changeList.loopListView.ScrollRect.enabled = true
  64. end
  65. function UIGuildLogView:OnGuildDisBandSuccess()
  66. self:UIClose()
  67. end
  68. function UIGuildLogView:OnGuildQuitSuccess()
  69. self:UIClose()
  70. end
  71. function UIGuildLogView:OnGuildKickoutSuccess()
  72. self:UIClose()
  73. end
  74. function UIGuildLogView:OnGuildLogChanged(changed, startChanged, endChanged)
  75. self:RefreshList(startChanged)
  76. end
  77. function UIGuildLogView:OnClickCancelBtn()
  78. self:UIClose()
  79. end
  80. function UIGuildLogView:GetItemByIndex(loopListView, idx, dataIdx)
  81. local itemData = self.controller:GetLogById(dataIdx)
  82. if not itemData then return nil end
  83. local item = loopListView:NewListViewItem('GuildLogItem')
  84. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'GuildLogItem', item.gameObject)
  85. if itemLua then
  86. local guildLogType = itemData.type
  87. local time = itemData.time
  88. itemLua.timeTxt.text.text = ManagerContainer.LuaTimerMgr:ParseTimeStamp2Format(time, '%Y-%m-%d %H:%M:%S')
  89. if guildLogType == Enum.GuildLogType.AuditEnter then
  90. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_002', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  91. elseif guildLogType == Enum.GuildLogType.Kickout then
  92. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_003', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  93. elseif guildLogType == Enum.GuildLogType.Exit then
  94. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_004', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  95. elseif guildLogType == Enum.GuildLogType.UpVicePresident then
  96. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_005', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  97. elseif guildLogType == Enum.GuildLogType.DownMember then
  98. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_009', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  99. elseif guildLogType == Enum.GuildLogType.UpPresident then
  100. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_006', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  101. elseif guildLogType == Enum.GuildLogType.Enter then
  102. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_001', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  103. elseif guildLogType == Enum.GuildLogType.EliteBoss then
  104. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_010', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  105. elseif guildLogType == Enum.GuildLogType.AutoDownPresident then
  106. itemLua.contentTxt.text.text = string.formatbykey('GuildLog_011', CommonUtil.GetGuildPostStr(itemData.opPost), tostring(itemData.opName), CommonUtil.GetGuildPostStr(itemData.beOpPost), tostring(itemData.beOpName))
  107. else
  108. itemLua.contentTxt.text.text = ''
  109. end
  110. end
  111. ManagerContainer.LuaUIMgr:ForceRebuildLayoutImmediate(item.CachedRectTransform)
  112. return item
  113. end
  114. function UIGuildLogView:OnBeginLoad(isBegin)
  115. local errorCode = self.controller:SendGetGuildLogInfoReq(isBegin)
  116. if errorCode ~= 0 then
  117. self:RefreshList(isBegin)
  118. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  119. end
  120. end
  121. function UIGuildLogView:RefreshList(isBegin)
  122. local whole = self.controller:GetLogWhole()
  123. local dataLength = self.controller:GetLogNum()
  124. self.loadStatusLoopListCtr:SetHasBegin(true)
  125. self.loadStatusLoopListCtr:OnAllLoaded()
  126. self.loadStatusLoopListCtr:RefreshMaxDataLength((whole and dataLength or (dataLength + 1)))
  127. self.loadStatusLoopListCtr:RefreshDataLength(dataLength)
  128. end
  129. return UIGuildLogView