local UITeamApplyPanel = UIViewClass() function UITeamApplyPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_Team_ApplyInfoHandle, self.UpdateApplyTeamList) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS["IDS_TeamUI_ApplyList"]) --如果是自动弹出,则跳过init,因为还会执行update方法,导致出现重复的信息 if not context or not context.isAutoPopUp then self:InitApplyTeamList() end self.isAutoPopUpValue = CTL.Team.IsAutoPopUpApplyview() self.toggle_Skip.isOn = not self.isAutoPopUpValue end function UITeamApplyPanel:OnClosed() --关闭页面的时候,做一个检查,防止主城界面的小按钮不消失 if #MDL.Team.GetApplyTeamList() == 0 then CTL.Team.TeamEchoManager(CTL.Team.EchoType.ApplyInfoHandle, true) end if self.toggle_Skip.isOn then if CTL.Team.IsAutoPopUpApplyview() then PersistentData.DeviceData:Set(CTL.Team.TeamApplyAutoPopUPKey, UTL.Time.GetServerTimestamp(), true) end else if not CTL.Team.IsAutoPopUpApplyview() then PersistentData.DeviceData:Set(CTL.Team.TeamApplyAutoPopUPKey, 0, true) end end end function UITeamApplyPanel:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UITeamApplyPanel:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.btn_IgnoreAll then MDL.Team.ClearApplyTeamList() self:CloseView() end end function UITeamApplyPanel:InitApplyTeamList() local applyList = MDL.Team.GetApplyTeamList() if #applyList > 0 then for i, v in ipairs(applyList) do self.LoopScroll_ApplyTeamList:AddData(v, 0) end UIUtils.SetActive(self.group_Empty.gameObject, false) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, true) else UIUtils.SetActive(self.group_Empty.gameObject, true) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, false) end end function UITeamApplyPanel:UpdateApplyTeamList(isAdd, applyInfo) if isAdd then local index = MDL.Team.GetApplyListIndexById(applyInfo.applyPlayerId) if index and index >= 0 then self.LoopScroll_ApplyTeamList:AddData(applyInfo, 0) end else local index = MDL.Team.GetApplyListIndexById(applyInfo) if index then self.LoopScroll_ApplyTeamList:RemoveIndex(index) end end if self.LoopScroll_ApplyTeamList.Count > 0 then UIUtils.SetActive(self.group_Empty.gameObject, false) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, true) else UIUtils.SetActive(self.group_Empty.gameObject, true) UIUtils.SetActive(self.btn_IgnoreAll.gameObject, false) end end function UITeamApplyPanel:RefreshSingleApplyTeamInfo(applyInfo, cell) local baseInfo = applyInfo.playerShowInfo CTL.Character.SetPortraitAndFrame(cell.UIHeroHead, baseInfo.PortraitId, baseInfo.FrameId, baseInfo.level, baseInfo.acid) if CTL.CrossServer.IsInCrossServerScene() then cell.lab_RoleName.text = baseInfo.name .. CTL.CrossServer.GetServerShowStr(baseInfo.ShowServerId, CTL.CrossServer.IsSameServer(baseInfo.MergeServerId)) else cell.lab_RoleName.text = baseInfo.name end cell.lab_CE.text = baseInfo.gsSum or baseInfo.power CTL.Player.OperateGenderImage(cell.image_Gender, baseInfo.sex) --非同势力,有工会,显示普通颜色公会名字,势力徽记 if not string.isNilOrEmpty(baseInfo.guildName) then --同势力显示不同颜色工会名字 if MDL.Guild.IsSameGuild(baseInfo.guildId) then UIUtils.SetLabel(cell.lab_GuildName,UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, baseInfo.guildName)) else UIUtils.SetLabel(cell.lab_GuildName,baseInfo.guildName) end UIUtils.SetLabel(cell.txt_GuildInitiate,baseInfo.EmblemContent) if baseInfo.EmblemFrame > 0 then UTL.Item.SetAtlasSprite(cell.img_GuildMark, "UI_Guild", DataSheetManager.GuildEmblem:GetDataByID(baseInfo.EmblemFrame).Image) end UIUtils.SetActive(cell.lab_GuildName.gameObject, true) UIUtils.SetActive(cell.txt_GuildInitiate, true) UIUtils.SetActive(cell.img_GuildMark, true) else UIUtils.SetActive(cell.txt_GuildInitiate, false) UIUtils.SetActive(cell.img_GuildMark, false) UIUtils.SetActive(cell.lab_GuildName.gameObject, false) end end function UITeamApplyPanel:OnCellInit(scrollRect, index, cellTable, data) self:RefreshSingleApplyTeamInfo(data, cellTable) end function UITeamApplyPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Ignore then MDL.Team.TeamApplyHandleReq(data.applyPlayerId, false) elseif target == cellTable.btn_Accept then MDL.Team.TeamApplyHandleReq(data.applyPlayerId, true) elseif target == cellTable.UIHeroHead.img_PlayerAvatarBg then if data.playerShowInfo.acid ~= BattleDataGetter.GetAcID() then CTL.PlayerInteract.OpenFriendInteractView(data.playerShowInfo.acid, nil, {isJoinTeam = true}) end end end return UITeamApplyPanel