UIGuildAuditApplyView.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. local UIGuildAuditApplyView = require("UIGuild/UIGuildAuditApplyView_Generate")
  2. local HeadItemCtr = require('Common/HeadItemCtr')
  3. function UIGuildAuditApplyView:OnAwake(data)
  4. self.controller = require("UIGuild/UIGuildAuditApplyCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIGuildAuditApplyView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_GET_AUDIT_APPLY_BASE_LIST_CHANGED, self, self.OnGetAuditApplyBaseListChanged)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_GET_AUDIT_APPLY_LIST_CHANGED, self, self.OnGetAuditApplyListChanged)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_GET_OTHER_PLAYER_BRIEF_INFO_ACK, self, self.OnGetOtherPlayerBriefInfoAck)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
  15. end
  16. function UIGuildAuditApplyView:FillContent(data, uiBase)
  17. self.uiBase = uiBase
  18. local gameObject = self.uiBase:GetRoot()
  19. if gameObject ~= nil then
  20. self.gameObject = gameObject
  21. self.transform = gameObject.transform
  22. end
  23. self:InitGenerate(self.transform, data)
  24. self:Init()
  25. end
  26. function UIGuildAuditApplyView:Init()
  27. self.peopleList.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  28. return self:GetItemByRowColumn(gridView, itemIndex, row, column)
  29. end, nil)
  30. self:RefreshPeople()
  31. self:RefreshList()
  32. local errorCode = self.controller:SendGetAuditApplyListReq()
  33. if errorCode ~= 0 then
  34. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  35. end
  36. end
  37. function UIGuildAuditApplyView:RemoveEventListener()
  38. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  39. end
  40. function UIGuildAuditApplyView:AddUIEventListener()
  41. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  42. self.uiBase:AddButtonUniqueEventListener(self.AnyBtn.button, self, self.OnClickCloseBtn)
  43. self.uiBase:AddButtonUniqueEventListener(self.btnClose.button, self, self.OnClickCloseBtn)
  44. self.uiBase:AddButtonUniqueEventListener(self.allRefuseBtn.button, self, self.OnClickAllRefuseBtn)
  45. self.uiBase:AddButtonUniqueEventListener(self.allAllowBtn.button, self, self.OnClickAllAllowBtn)
  46. end
  47. function UIGuildAuditApplyView:OnHide()
  48. end
  49. function UIGuildAuditApplyView:OnShow(data)
  50. self.controller:SetData(data)
  51. end
  52. function UIGuildAuditApplyView:OnClose()
  53. end
  54. function UIGuildAuditApplyView:OnDispose()
  55. self.peopleList.loopGridView:Dispose()
  56. self.controller:OnDispose()
  57. end
  58. function UIGuildAuditApplyView:OnGetAuditApplyBaseListChanged()
  59. local isHasReq = self.controller:SendGetAuditApplyInfoListReq()
  60. if not isHasReq then
  61. self:RefreshPeople()
  62. self:RefreshList()
  63. end
  64. end
  65. function UIGuildAuditApplyView:OnGetAuditApplyListChanged()
  66. self:RefreshPeople()
  67. self:RefreshList()
  68. end
  69. function UIGuildAuditApplyView:OnGetOtherPlayerBriefInfoAck(data)
  70. self.controller:SetAuditApplyPlayBrief(data.brief_info)
  71. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.GuildAuditApply, self.controller:GetIsHasApply())
  72. local isHasReq = self.controller:SendGetAuditApplyInfoListReq()
  73. if not isHasReq then
  74. self:RefreshPeople()
  75. self:RefreshList()
  76. end
  77. end
  78. function UIGuildAuditApplyView:OnGuildDisBandSuccess()
  79. self:UIClose()
  80. end
  81. function UIGuildAuditApplyView:OnGuildQuitSuccess()
  82. self:UIClose()
  83. end
  84. function UIGuildAuditApplyView:OnGuildKickoutSuccess()
  85. self:UIClose()
  86. end
  87. function UIGuildAuditApplyView:OnClickCloseBtn()
  88. self:UIClose()
  89. end
  90. function UIGuildAuditApplyView:OnClickAllRefuseBtn()
  91. local errorCode = self.controller:SendAllRefuseReq()
  92. if errorCode ~= 0 then
  93. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  94. end
  95. end
  96. function UIGuildAuditApplyView:OnClickAllAllowBtn()
  97. local errorCode = self.controller:SendAllAllowReq()
  98. if errorCode ~= 0 then
  99. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  100. end
  101. end
  102. function UIGuildAuditApplyView:OnClickPlayerHead(btn, param)
  103. local uid = param[0]
  104. ManagerContainer.LuaUIMgr:OpenRoleMessagePanel(uid)
  105. end
  106. function UIGuildAuditApplyView:OnClickRefuseBtn(btn, param)
  107. local uid = param[0]
  108. local errorCode = self.controller:SendRefuseReq(uid)
  109. if errorCode ~= 0 then
  110. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  111. end
  112. end
  113. function UIGuildAuditApplyView:OnClickAllowBtn(btn, param)
  114. local uid = param[0]
  115. local errorCode = self.controller:SendAllowReq(uid)
  116. if errorCode ~= 0 then
  117. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  118. end
  119. end
  120. function UIGuildAuditApplyView:RefreshPeople()
  121. local curNum = self.controller:GetGuildMemberNum()
  122. local limitNum = self.controller:GetGuildMemberLimit()
  123. self.peopleNum.text.text = tostring(curNum) .. '/' .. tostring(limitNum)
  124. end
  125. function UIGuildAuditApplyView:RefreshList()
  126. local length = self.controller:GetAuditApplyNum()
  127. self.bottom:SetActive(length > 0)
  128. if length <= 0 then
  129. self.bottom:SetActive(false)
  130. self.peopleList:SetActive(false)
  131. self.emptyTips:SetActive(true)
  132. return
  133. end
  134. self.bottom:SetActive(true)
  135. self.peopleList:SetActive(true)
  136. self.emptyTips:SetActive(false)
  137. self.peopleList.loopGridView:RefreshListByIndex(length, 0)
  138. end
  139. function UIGuildAuditApplyView:GetItemByRowColumn(gridView, itemIndex, row, column)
  140. local showData = self.controller:GetNextAuditApplyById(itemIndex)
  141. local item = nil
  142. if showData then
  143. item = gridView:NewListViewItem('GuildPeopleApplyItem')
  144. local itemLua = CommonUtil.BindGridViewItem2Lua(self, 'GuildPeopleApplyItem', item.gameObject)
  145. local playerBrief = showData.playerBrief
  146. local uid
  147. local data = {}
  148. local headFrameId = nil
  149. local vipLv = nil
  150. if playerBrief then
  151. uid = playerBrief.uid
  152. vipLv = playerBrief.vipLv
  153. headFrameId = playerBrief.headFrame
  154. if int64.equals(uid, ManagerContainer.DataMgr.UserData:GetUserId()) then
  155. headFrameId = ManagerContainer.DataMgr.UserData:GetHeadFrameId()
  156. vipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
  157. end
  158. local jobCfg = ManagerContainer.CfgMgr:GetJobDataById(playerBrief.configId)
  159. local jobIcon = ''
  160. if jobCfg then
  161. jobIcon = jobCfg.JobIcon
  162. end
  163. data = {Level = playerBrief.level, ProfessionIcon = jobIcon, HeadIcon = playerBrief.headPortraitName, IsHero = true}
  164. itemLua.nameTxt.text.text = tostring(playerBrief.nickName)
  165. itemLua.atkTxt.text.text = tostring(playerBrief.fightPower)
  166. itemLua.onlineTxt.text.text = CommonUtil.GetOnlineStatus(playerBrief.onlineState, playerBrief.onlineTime)
  167. else
  168. itemLua.nameTxt.text.text = ''
  169. itemLua.atkTxt.text.text = ''
  170. itemLua.onlineTxt.text.text = ''
  171. end
  172. CommonUtil.SetPlayerHeadAndFrame(self, itemLua.headItem, data, false, headFrameId, self, self.OnClickPlayerHead, uid)
  173. itemLua.vipIcon.image.enabled = false
  174. itemLua.vipIcon.image.sprite = nil
  175. if vipLv and vipLv >= 0 then
  176. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
  177. if vipCfg then
  178. CommonUtil.LoadIcon(self, vipCfg.SmallIcon, function(sprite)
  179. if sprite then
  180. itemLua.vipIcon.image.sprite = sprite
  181. itemLua.vipIcon.image.enabled = true
  182. end
  183. end, itemLua, 'VipIcon')
  184. end
  185. end
  186. self.uiBase:AddButtonUniqueEventListener(itemLua.refuseBtn.button, self, self.OnClickRefuseBtn, uid)
  187. self.uiBase:AddButtonUniqueEventListener(itemLua.allowBtn.button, self, self.OnClickAllowBtn, uid)
  188. end
  189. return item
  190. end
  191. return UIGuildAuditApplyView