KLUITeamApplicationPanel.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ---@class KLUITeamApplicationPanel:UIKmlLuaPanelBase
  2. ---@field view KLUITeamApplicationPanelView
  3. local KLUITeamApplicationPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUITeamApplicationPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:DataListInitData( self.view.application_datalist,function()
  8. return self:ListItemCountFunc()
  9. end,function(realIndex)
  10. return self:ListItemGetFunc(realIndex)
  11. end,function(realIndex, kmlcontrol)
  12. return self:ListItemInitFunc(realIndex, kmlcontrol)
  13. end, function(realIndex, kmlcontrol)
  14. return self:ListItemUpdateFunc(realIndex, kmlcontrol)
  15. end)
  16. end
  17. function this:ListItemCountFunc()
  18. return #self.InviteListOrApplyList
  19. end
  20. function this:ListItemGetFunc(realIndex)
  21. end
  22. function this:ListItemInitFunc(realIndex, kmlcontrol)
  23. end
  24. function this:ListItemUpdateFunc(realIndex, kmlcontrol)
  25. local info = self.InviteListOrApplyList[realIndex + 1]
  26. local apply_name = GUI:GetChildControl(self.view.application_datalist,realIndex,'apply_name')
  27. local apply_level = GUI:GetChildControl(self.view.application_datalist,realIndex,'apply_level')
  28. local apply_career = GUI:GetChildControl(self.view.application_datalist,realIndex,'apply_career')
  29. local apply_tips = GUI:GetChildControl(self.view.application_datalist,realIndex,'apply_tips')
  30. local refuse_btn = GUI:GetChildControl(self.view.application_datalist,realIndex,'refuse_btn')
  31. local agree_btn = GUI:GetChildControl(self.view.application_datalist,realIndex,'agree_btn')
  32. if self.type == 1 then
  33. GUI:Text_setString(apply_name, info.roleInfo.name)
  34. GUI:Text_setString(apply_level, "Lv : " .. info.roleInfo.level)
  35. local career = info.roleInfo.career
  36. ---@type cfg_career_column[]
  37. local career_tbl = SL:GetConfigTable("cfg_career")
  38. for _, v in pairs(career_tbl) do
  39. if v.baseCareer == career.baseCareer and v.careerRank == career.careerRank then
  40. GUI:Text_setString(apply_career, v.name)
  41. break
  42. end
  43. end
  44. GUI:Text_setString(apply_tips, "邀请加入队伍")
  45. GUI:AddOnClickEvent(refuse_btn, self, self.RefuseOtherInvite,{ leaderId = info.roleInfo.rid })
  46. GUI:AddOnClickEvent(agree_btn, self, self.AgreeOtherInvite,{ leaderId = info.roleInfo.rid })
  47. elseif self.type == 2 then
  48. GUI:Text_setString(apply_name, info.name)
  49. GUI:Text_setString(apply_level, "Lv." .. info.level)
  50. local career = info.career
  51. ---@type cfg_career_column[]
  52. local career_tbl = SL:GetConfigTable("cfg_career")
  53. for _, v in pairs(career_tbl) do
  54. if v.baseCareer == career.baseCareer and v.careerRank == career.careerRank then
  55. GUI:Text_setString(apply_career, v.name)
  56. break
  57. end
  58. end
  59. GUI:Text_setString(apply_tips, "申请加入队伍")
  60. GUI:AddOnClickEvent(refuse_btn, self, self.RefuseOtherApply,{ leaderId = info.rid })
  61. GUI:AddOnClickEvent(agree_btn, self, self.AgreeOtherApply,{ leaderId = info.rid })
  62. end
  63. end
  64. function this:RefuseOtherInvite(_, eventData)
  65. SL:RequestRefuseTeamInvite(eventData.leaderId)
  66. end
  67. function this:AgreeOtherInvite(_, eventData)
  68. SL:RequestAgreeTeamInvite(eventData.leaderId)
  69. end
  70. function this:RefuseOtherApply(_, eventData)
  71. SL:ReqRefuseReplyApply(eventData.leaderId)
  72. end
  73. function this:AgreeOtherApply(_, eventData)
  74. SL:ReqAgreeReplyApply(eventData.leaderId)
  75. end
  76. ---创建或者刷新界面数据时调用
  77. function this:Refresh()
  78. SL:DelBubbleTips(15)
  79. SL:RequestApplyData()
  80. self.scheduleId = SL:Schedule( self.scheduleId,10, 10, -1, function()
  81. SL:RequestApplyData()
  82. end)
  83. end
  84. ---注册UI事件和服务器消息
  85. function this:RegistEvents()
  86. SL:RegisterLuaNetMsg(MessageDef.ResInvitationListMessage, self.ResInvitationListMessage, self)
  87. SL:RegisterLuaNetMsg(MessageDef.ResApplicationListMessage, self.ResApplicationListMessage, self)
  88. GUI:AddOnClickEvent(self.view.clearbtn, self, self.ClearAllRequestList)
  89. GUI:AddOnClickEvent(self.view.agreebtn, self, self.AgreeAllRequestList)
  90. end
  91. function this:AgreeAllRequestList()
  92. SL:SendLuaNetMsg(LuaMessageIdToSever.LEADER_AGREE_APPLY)
  93. self.InviteListOrApplyList = {}
  94. GUI:DataListUpdateData(self.view.application_datalist)
  95. GUI:SetActive(self.view.agreebtn,false)
  96. GUI:SetActive(self.view.clearbtn,false)
  97. end
  98. function this:ClearAllRequestList()
  99. SL:ReqClearAllRequestList()
  100. self.InviteListOrApplyList = {}
  101. GUI:DataListUpdateData(self.view.application_datalist)
  102. GUI:SetActive(self.view.agreebtn,false)
  103. GUI:SetActive(self.view.clearbtn,false)
  104. end
  105. ---@param message TeamProto.InvitationList
  106. function this:ResInvitationListMessage(_, message)
  107. self.type = 1
  108. self.InviteListOrApplyList = message.invitation
  109. GUI:DataListUpdateData(self.view.application_datalist)
  110. GUI:SetActive(self.view.agreebtn,false)
  111. GUI:SetActive(self.view.clearbtn,#self.InviteListOrApplyList > 0)
  112. end
  113. ---@param message TeamProto.ApplicationList
  114. function this:ResApplicationListMessage(_, message)
  115. self.type = 2
  116. self.InviteListOrApplyList = message.roleInfo
  117. GUI:DataListUpdateData(self.view.application_datalist)
  118. GUI:SetActive(self.view.agreebtn,#self.InviteListOrApplyList > 0)
  119. GUI:SetActive(self.view.clearbtn,#self.InviteListOrApplyList > 0)
  120. end
  121. function this:Close()
  122. SL:UnSchedule(self.scheduleId)
  123. end
  124. return this