local UISpecialTeamPlatform = UIViewClass() function UISpecialTeamPlatform:OnOpened(context) self:RegistSystemEvent(EventID.UI_SpecialTeam_RecommendTeamListChange, self.RefreshRightTeamList) self:RegistSystemEvent(EventID.UI_SpecialTeam_TeamInfoChange, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_SpecialTeam_MemberInfoChange, self.RefreshButtonState) self:RegistSystemEvent(EventID.UI_SpecialTeam_LeaveTeam, self.OnLeaveTeam) self:RegistSystemEvent(EventID.UI_SpecialTeam_JoinTeam, self.OnJoinTeam) self:RefreshButtonState() MDL.SpecialTeam.GetRecommendListReq() UIUtils.SetActive(self.lab_TeamInfo, CTL.SpecialTeam.IsShowCreateTeamTip()) UIUtils.SetLabelText(self.lab_TeamInfo, CTL.SpecialTeam.GetShowCreateTeamTipIds()) end function UISpecialTeamPlatform:OnClosed() MDL.SpecialTeam.ClearRecommendTeamList() end function UISpecialTeamPlatform:OnLeaveTeam() MDL.SpecialTeam.GetRecommendListReq() self:RefreshButtonState() end function UISpecialTeamPlatform:OnJoinTeam() self.loop_TeamList:RefreshCells(false) self:RefreshButtonState() end function UISpecialTeamPlatform:RefreshButtonState() local hasTeam = MDL.SpecialTeam.HasTeam() if hasTeam then UIUtils.SetActive(self.btn_Action, false) else UIUtils.SetActive(self.btn_Action, true) end end function UISpecialTeamPlatform:RefreshRightTeamList(beginIndex) local recommendTeamList = MDL.SpecialTeam.GetRecommendTeamList() self.targetIndex = #recommendTeamList - 1 for i, v in ipairs(recommendTeamList) do if i >= beginIndex + 1 then self.loop_TeamList:AddData(v, 0) end end UIUtils.SetActive(self.group_Empty, self.loop_TeamList.Count == 0) end function UISpecialTeamPlatform:OnClickRefresh() self.loop_TeamList:ClearCells() MDL.SpecialTeam.ClearRecommendTeamList() MDL.SpecialTeam.GetRecommendListReq() end function UISpecialTeamPlatform:OnButtonClicked(comp) if comp == self.btn_Action then --创建 CTL.SpecialTeam.OpenTeamCreatePopUp() elseif comp == self.event_Refresh then self:OnClickRefresh() end end function UISpecialTeamPlatform:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_TeamList then cellTable.txt_TeamName.text = data.teamName cellTable.txt_Server.text = CTL.CrossServer.GetFormatServerShow(data.members[1].playerShowInfo.ShowServerId) UIUtils.SetActive(cellTable.txt_Server, CTL.SpecialTeam.IsShowPlayerServer()) for i, v in ipairs(cellTable.group_Head) do if data.members[i] then self:RefreshSingleMember(data.members[i], v) UIUtils.SetActive(v.group_Hero.gameObject, true) else UIUtils.SetActive(v.group_Hero.gameObject, false) end end if MDL.SpecialTeam.HasTeam() or #data.members == 3 then UIUtils.SetActive(cellTable.btn_Apply, false) else UIUtils.SetActive(cellTable.btn_Apply, true) end if self.targetIndex and index == self.targetIndex then --不依赖OnScrollBottom了,加载到最后一个cell请求下一页数据 MDL.SpecialTeam.GetRecommendListReq() self.targetIndex = nil end end end function UISpecialTeamPlatform:RefreshSingleMember(memberInfo, cell) local baseInfo = memberInfo.playerShowInfo CTL.Character.SetPortraitAndFrame(cell.UIHeroHead150, baseInfo.PortraitId, baseInfo.FrameId) UIUtils.SetCanvasSortingOrderByMainCanvas(cell.UIHeroHead150.effectUpCanvas, cell.UpCanvas, CTL.Character.UpOrder.Common) UIUtils.SetActive(cell.ico_Leader.gameObject, memberInfo.type == MDL.Team.MemberType.Leader) cell.lab_RoleName.text = baseInfo.name UIUtils.SetActive(cell.group_BR, CTL.SpecialTeam.IsShowPlayerGs()) CTL.Player.OperateGenderImage(cell.group_Gender, baseInfo.sex) CTL.Guild.SetGuildEmblem(cell.img_GuildMark, cell.txt_GuildInitiate, baseInfo.EmblemFrame, baseInfo.EmblemContent) cell.txt_NumCE.text = baseInfo.gsSum if cell.txt_CountNum then UIUtils.SetLabel(cell.txt_CountNum, baseInfo.SyncTvTEloScore) end end function UISpecialTeamPlatform:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_TeamList then if target == cellTable.btn_Apply then CTL.SpecialTeam.TryApplyTeam(data.teamId) else --弹出交互页面弹窗 for i, v in ipairs(cellTable.group_Head) do if target == v.btn then CTL.PlayerInteract.OpenFriendInteractView(data.members[i].memberId) break end end end end end return UISpecialTeamPlatform