UIIdolRankView.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. local UIIdolRankView = require("UISeason/UIIdolRankView_Generate")
  2. local RankList = {}
  3. local LoadStatusLoopListCtr = require('Common/LoadStatusLoopListCtr')
  4. local UIIdolRankItemCtr = require('Common/UIIdolRankItemCtr')
  5. function UIIdolRankView:OnAwake(data)
  6. self.controller = require("UISeason/UIIdolRankCtr"):new()
  7. self.controller:Init(self)
  8. self.controller:SetData(data)
  9. end
  10. function UIIdolRankView:InitGrid()
  11. if self.loadStatusLoopListCtr then
  12. self.loadStatusLoopListCtr:Dispose()
  13. self.loadStatusLoopListCtr = nil
  14. end
  15. self.loadStatusLoopListCtr = LoadStatusLoopListCtr:new(self, self.rankScroll.loopListView, 0, 50,
  16. false, nil, nil,
  17. true, 'LoadingItem', Enum.ListLoadingStatus.WaitLoad,
  18. self.GetItemByIndex, nil, self.OnBeginLoad)
  19. self.rankScroll.scrollRect.enabled = false
  20. end
  21. function UIIdolRankView:OnPageInEnd()
  22. self.super.OnPageInEnd(self)
  23. self.rankScroll.scrollRect.enabled = true
  24. end
  25. function UIIdolRankView:OnBeginLoad(isLeft)
  26. ManagerContainer.DataMgr.IdolData:SendGetVoteRankInfoReq()
  27. end
  28. function UIIdolRankView:GetItemByIndex(gridView, idx, itemIndex)
  29. local item = nil
  30. local itemLua = nil
  31. local showData = RankList[idx + 1]
  32. item = gridView:NewListViewItem('UIIdolRankItem')
  33. itemLua = CommonUtil.BindGridViewItem2Lua(self, 'UIIdolRankItem', item.gameObject)
  34. CommonUtil.UpdateItemPrefab(self, itemLua, showData, nil,self, self.OnClickSupportBtn)
  35. return item
  36. end
  37. function UIIdolRankView:RefreshPlayerInfo()
  38. self:InitUI()
  39. RankList = ManagerContainer.DataMgr.IdolData:GetRankInfoData()
  40. local maxLength = ManagerContainer.DataMgr.IdolData:GetRankInfoLimit()
  41. local dataLength = ManagerContainer.DataMgr.IdolData:GetRankInfosLength()
  42. self.loadStatusLoopListCtr:OnAllLoaded()
  43. self.loadStatusLoopListCtr:RefreshMaxDataLength(maxLength)
  44. self.loadStatusLoopListCtr:RefreshDataLength(dataLength)
  45. end
  46. function UIIdolRankView:AddEventListener()
  47. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  48. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_IDOL_RANK_PLAYER_RANK_INFO, self, self.RefreshPlayerInfo)
  49. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_IDOL_VOTE_RANK_INFO, self, self.RefreshPlayerInfo)
  50. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_VOTE_VIEW_INFO, self, self.RefreshPlayerInfo)
  51. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.REFRESH_SUPPORTTIPSVIEW, self, self.OnOpenSupportTips)
  52. end
  53. function UIIdolRankView:FillContent(data, uiBase)
  54. self.uiBase = uiBase
  55. local gameObject = self.uiBase:GetRoot()
  56. if gameObject ~= nil then
  57. self.gameObject = gameObject
  58. self.transform = gameObject.transform
  59. end
  60. self:InitGenerate(self.transform, data)
  61. self:Init()
  62. end
  63. function UIIdolRankView:Init()
  64. self:InitGrid()
  65. self:InitUI()
  66. ManagerContainer.DataMgr.IdolData:ClearVoteInfoUid()
  67. ManagerContainer.DataMgr.IdolData:ClearIdolRankInfos()
  68. ManagerContainer.DataMgr.IdolData:SendGetVoteRankInfoReq()
  69. end
  70. function UIIdolRankView:InitUI()
  71. local selfTicket = ManagerContainer.DataMgr.CompetitionData:GetScore()
  72. local selfRank = ManagerContainer.DataMgr.CompetitionData:GetRank()
  73. local logicData = {rank = selfRank,score = selfTicket, uid = ManagerContainer.DataMgr.UserData:GetUserId(),enterType = 1}
  74. UIIdolRankItemCtr:SetData(self, self.selfRankItem, logicData,nil,self, self.OnClickSupportBtn)
  75. end
  76. function UIIdolRankView:OnOpenSupportTips(data)
  77. local voteInfoUid = ManagerContainer.DataMgr.IdolData:GetVoteInfoUid()
  78. if not voteInfoUid then
  79. return
  80. end
  81. ManagerContainer.DataMgr.IdolData:ClearVoteInfoUid()
  82. local cfgId = 238
  83. local maxNum = CommonUtil.GetOwnResCountByItemId(cfgId)
  84. local logicData = {rank = data.rank,score = data.score, uid = data.uid,enterType = 2}
  85. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIIdolSupportTips,{cfgId,self,self.OnSureSupport,logicData,maxNum})
  86. end
  87. function UIIdolRankView:OnClickSupportBtn(btn,param)
  88. if not ManagerContainer.DataMgr.CompetitionData:CanOpenSeasonUI() then
  89. return
  90. end
  91. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  92. if IsOver then
  93. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("LabelOver")
  94. return
  95. end
  96. local logicData = param[0]
  97. local uid = logicData.uid
  98. local cfgId = 238 --荧光棒
  99. local selfId = ManagerContainer.DataMgr.UserData:GetUserId()
  100. local maxNum = CommonUtil.GetOwnResCountByItemId(238)
  101. if uid == selfId then
  102. local selfTicket = ManagerContainer.DataMgr.CompetitionData:GetScore()
  103. local selfRank = ManagerContainer.DataMgr.CompetitionData:GetRank()
  104. local data = {rank = selfRank,score = selfTicket, uid = ManagerContainer.DataMgr.UserData:GetUserId(),enterType = 1}
  105. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIIdolSupportTips,{cfgId,self,self.OnSureSupport,data,maxNum})
  106. else
  107. ManagerContainer.DataMgr.IdolData:SendGetPlayerVoteRankReq(uid)
  108. end
  109. end
  110. function UIIdolRankView:OnSureSupport(logicData) --确认投票
  111. if not ManagerContainer.DataMgr.CompetitionData:CanOpenSeasonUI() then
  112. return
  113. end
  114. local IsOver = ManagerContainer.DataMgr.CompetitionData:IsOveerCurSeason()
  115. if IsOver then
  116. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("LabelOver")
  117. return
  118. end
  119. local num = logicData[1]
  120. local uid = logicData[2]
  121. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_COMPETITION_ON_VOTE_REQ, { ticket_count = num,uid = uid})
  122. end
  123. function UIIdolRankView:OnClickOtherHeadBtn(button,params)
  124. local uid = params[0]
  125. local selfUid = ManagerContainer.DataMgr.UserData:GetUserId()
  126. if selfUid == uid then
  127. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("ChatError1")
  128. return
  129. end
  130. ManagerContainer.LuaUIMgr:OpenRoleMessagePanel(uid)
  131. end
  132. function UIIdolRankView:RemoveEventListener()
  133. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  134. end
  135. function UIIdolRankView:AddUIEventListener()
  136. self.uiBase:AddButtonEventListener(self.closeBtn.button, self, self.OnClickCloseBtn)
  137. self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.OnClickCloseBtn)
  138. end
  139. function UIIdolRankView:OnClickCloseBtn()
  140. self:UIClose()
  141. end
  142. function UIIdolRankView:OnHide()
  143. end
  144. function UIIdolRankView:OnShow(data)
  145. self.controller:SetData(data)
  146. ManagerContainer.DataMgr.IdolData:ClearVoteInfoUid()
  147. end
  148. function UIIdolRankView:OnClose()
  149. ManagerContainer.DataMgr.IdolData:ClearVoteInfoUid()
  150. end
  151. function UIIdolRankView:OnDispose()
  152. self.controller:OnDispose()
  153. if self.loadStatusLoopListCtr then
  154. self.loadStatusLoopListCtr:Dispose()
  155. self.loadStatusLoopListCtr = nil
  156. end
  157. ManagerContainer.DataMgr.IdolData:ClearIdolRankInfos()
  158. end
  159. return UIIdolRankView