From bcd50fd944b9e6c62799bf36d0a312054b1036b5 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Tue, 29 Mar 2022 16:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=86=85PK=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 6 + xplan-ios/Base/MVP/Model/UserInfoModel.h | 2 +- xplan-ios/Global/XPEnum.h | 9 +- .../View/XPArrangeMicViewController.m | 4 +- .../XPRoomFunctionContainerView.m | 81 +++++++++ .../Main/Room/View/RoomPK/Api/Api+RoomPK.m | 1 + .../View/RoomPK/Model/RoomPKDetailInfoModel.h | 19 ++ .../View/RoomPK/Model/RoomPKDetailInfoModel.m | 15 ++ .../Room/View/RoomPK/Model/RoomPKInfoModel.h | 11 ++ .../View/RoomPK/Model/RoomPKRecordModel.h | 6 - .../View/Cell/XPRoomPKRecordTableViewCell.m | 2 +- .../View/SubViews/XPRoomPKPanelUserView.h | 9 +- .../View/SubViews/XPRoomPKPanelUserView.m | 59 ++++--- .../View/SubViews/XPRoomPKSelectUserView.h | 4 +- .../View/SubViews/XPRoomPKSelectUserView.m | 14 +- .../View/RoomPK/View/XPRoomPKProgressView.h | 13 +- .../View/RoomPK/View/XPRoomPKProgressView.m | 167 ++++++++++++++++-- .../View/RoomPK/View/XPRoomPKViewController.m | 4 +- 18 files changed, 370 insertions(+), 56 deletions(-) create mode 100644 xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.h create mode 100644 xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index efa9ef56..db8233b5 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -299,6 +299,7 @@ E80B0712280D0A6700A79F63 /* FansInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0711280D0A6700A79F63 /* FansInfoModel.m */; }; E80B0734280D740600A79F63 /* MessageContentGuildView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0733280D740600A79F63 /* MessageContentGuildView.m */; }; E80B0737280D790400A79F63 /* GuildMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0736280D790400A79F63 /* GuildMessageModel.m */; }; + E80A086227F2AC190027B30C /* RoomPKDetailInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */; }; E80CBDE627D0C1CF001E1EC2 /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */; }; E80CBDEA27D0C53F001E1EC2 /* XPWeakTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE927D0C53F001E1EC2 /* XPWeakTimer.m */; }; E80CBDED27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDEC27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m */; }; @@ -1413,6 +1414,8 @@ E80B0733280D740600A79F63 /* MessageContentGuildView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageContentGuildView.m; sourceTree = ""; }; E80B0735280D790400A79F63 /* GuildMessageModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GuildMessageModel.h; sourceTree = ""; }; E80B0736280D790400A79F63 /* GuildMessageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GuildMessageModel.m; sourceTree = ""; }; + E80A086027F2AC190027B30C /* RoomPKDetailInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomPKDetailInfoModel.h; sourceTree = ""; }; + E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomPKDetailInfoModel.m; sourceTree = ""; }; E80CBDE427D0C1CF001E1EC2 /* HomeMenuSourceModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeMenuSourceModel.h; sourceTree = ""; }; E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = ""; }; E80CBDE827D0C53F001E1EC2 /* XPWeakTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWeakTimer.h; sourceTree = ""; }; @@ -4101,6 +4104,8 @@ E8A88D2C27E81E8700CA8837 /* RoomPKChooseUserModel.m */, E8A88D2E27E85EEA00CA8837 /* RoomPKInfoModel.h */, E8A88D2F27E85EEA00CA8837 /* RoomPKInfoModel.m */, + E80A086027F2AC190027B30C /* RoomPKDetailInfoModel.h */, + E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */, ); path = Model; sourceTree = ""; @@ -7321,6 +7326,7 @@ E8E5E19127C369F000F457D8 /* XPHomeRecommendListView.m in Sources */, 9B208A362779B50100F9E54A /* GiftNobleInfoModel.m in Sources */, E8C6FFDA2754BE81004DC9F0 /* ThemeColor+Home.m in Sources */, + E80A086227F2AC190027B30C /* RoomPKDetailInfoModel.m in Sources */, E824545126F5CE6E00BE8163 /* XPMineModifPayPwdPresenter.m in Sources */, E8A86DF727BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m in Sources */, E880B3AF278BE1D800A83B0D /* Api+AcrossRoomPK.m in Sources */, diff --git a/xplan-ios/Base/MVP/Model/UserInfoModel.h b/xplan-ios/Base/MVP/Model/UserInfoModel.h index 493be27c..fc2fd9d4 100644 --- a/xplan-ios/Base/MVP/Model/UserInfoModel.h +++ b/xplan-ios/Base/MVP/Model/UserInfoModel.h @@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) LittleGamePlayStatus gameStatus; ///用户的参加PK的类型 @property (nonatomic, assign) GroupType groupType; -/// +///礼物墙中的礼物 @property (nonatomic,strong) NSArray *userGiftWall; ///是否防被踢 @property (nonatomic, assign) BOOL preventKick; diff --git a/xplan-ios/Global/XPEnum.h b/xplan-ios/Global/XPEnum.h index 46dc13f1..0d00521c 100644 --- a/xplan-ios/Global/XPEnum.h +++ b/xplan-ios/Global/XPEnum.h @@ -40,7 +40,7 @@ typedef NS_ENUM(NSInteger, DressUpLabelType) { typedef NS_ENUM(NSInteger, GroupType) { GroupType_default = 0,//默认 GroupType_Blue = 1,//蓝队 男神 - GroupTyp_red = 2, //红队 女神 + GroupTyp_Red = 2, //红队 女神 }; typedef NS_ENUM(NSInteger, UserEnterRoomFromType) { @@ -65,4 +65,11 @@ typedef NS_ENUM(NSInteger, RoomPKVoteModeType){ RoomPKVoteModeType_NumberPerson = 2, //按送礼物的人数 }; +typedef NS_ENUM(NSInteger, RoomPKResultType) { + RoomPKResultType_Draw = 0,//平局 + RoomPKResultType_Blue = 1,//蓝方胜 + RoomPKResultType_Red = 2, //红方胜 +}; + + #endif /* XPEnum_h */ diff --git a/xplan-ios/Main/Room/View/ArrangeMic/View/XPArrangeMicViewController.m b/xplan-ios/Main/Room/View/ArrangeMic/View/XPArrangeMicViewController.m index 5bc1e4c5..5d50ff7e 100644 --- a/xplan-ios/Main/Room/View/ArrangeMic/View/XPArrangeMicViewController.m +++ b/xplan-ios/Main/Room/View/ArrangeMic/View/XPArrangeMicViewController.m @@ -254,7 +254,7 @@ return [obj1 compare:obj2]; //升序 }]; if (result.count > 0) { - if (groupType == GroupTyp_red) { + if (groupType == GroupTyp_Red) { for (NSString *key in result) { MicroQueueModel *microQueue = [self.micQueue objectForKey:key]; UserInfoModel *userInfo = microQueue.userInfo; @@ -603,7 +603,7 @@ if ([self isOnMicro:[AccountInfoStorage instance].getUid]) { [self showErrorToast:@"已经在麦上不需要报名啦"]; } else { - [self.presenter applyRoomArrangeMic:self.userInfo.roomUid groupType:GroupTyp_red]; + [self.presenter applyRoomArrangeMic:self.userInfo.roomUid groupType:GroupTyp_Red]; } } diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 1f83b473..6b376e62 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -27,6 +27,7 @@ #import "Api+RoomSetting.h" #import "RtcManager.h" #import "XPRoomMiniManager.h" +#import "Api+RoomPK.h" ///Model #import "RoomInfoModel.h" #import "MicroQueueModel.h" @@ -39,6 +40,7 @@ #import "XPAnchorFansJoinModel.h" #import "XPAnchorFansTaskModel.h" #import "AcrossRoomPKPanelModel.h" +#import "RoomPKDetailInfoModel.h" ///View #import "XPRoomHalfWebView.h" #import "XPAnchorAudienceUpMicView.h" @@ -113,6 +115,8 @@ @property (nonatomic,strong) XPRoomBackMusicPlayerView *musicPlayView; ///房间PKview @property (nonatomic,strong) XPRoomPKProgressView *roompkPanelView; +///房间PK信息 +@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo; @end @implementation XPRoomFunctionContainerView @@ -283,8 +287,10 @@ return isGamePlaying; } +#pragma mark - 房间PK - (void)configRoomPKPanelView { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; + self.roompkPanelView.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { if (!self.roompkPanelView.superview) { [self addSubview:self.roompkPanelView]; @@ -293,6 +299,22 @@ make.top.mas_equalTo(self).offset((58 + 5 + 6 + 12) + 33 + (60 + 6 + 12) * 2 + 15 * 2 + kNavigationHeight); }]; } + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; + NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; + request.roomId = roomId; + request.userIds = @[uid]; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + if (error == nil) { + NIMChatroomMember * member = members.firstObject; + if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) { + self.roompkPanelView.isManager = YES; + }else { + self.roompkPanelView.isManager = NO; + } + } + }]; + } else { if (self.roompkPanelView.superview) { [self.roompkPanelView removeFromSuperview]; @@ -300,6 +322,39 @@ } } +- (void)getRoomPKDetailInfo { + RoomInfoModel * roomInfo = self.delegate.getRoomInfo; + if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { + [Api getRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + RoomPKDetailInfoModel * pkDetailInfo = [RoomPKDetailInfoModel modelWithDictionary:data.data]; + self.pkDetailInfo = pkDetailInfo; + self.roompkPanelView.pkDetailInfo = pkDetailInfo; + if (self.pkDetailInfo.roomPK.pkStatus != RoomPKStatusType_Playing) { + NSMutableArray * redArray = [NSMutableArray array]; + NSMutableArray * blueArray = [NSMutableArray array]; + NSMutableDictionary * queue = self.delegate.getMicroQueue; + for (int i = 0 ; i < queue.allValues.count; i++) { + MicroQueueModel * micModel = [queue.allValues objectAtIndex:i]; + if (micModel.userInfo && micModel.userInfo.uid > 0) { + UserInfoModel * userInfo = micModel.userInfo; + if (userInfo.groupType == GroupTyp_Red) { + [redArray addObject:userInfo]; + } else if(userInfo.groupType == GroupType_Blue) { + [blueArray addObject:userInfo]; + } + } + } + self.roompkPanelView.redUserArray = redArray; + self.roompkPanelView.blueUserArray = blueArray; + } + } else { + [XCHUDTool showErrorWithMessage:msg]; + } + } roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid]]; + } +} + #pragma mark - RoomGuestDelegate - (void)onRoomUpdate { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; @@ -428,6 +483,7 @@ [self showLittleGameMiniView:roomInfo.type micCount:roomInfo.mgMicNum]; [self configLittleGameState]; [self configRoomPKPanelView]; + [self getRoomPKDetailInfo]; } - (void)onRoomMiniEntered { @@ -696,6 +752,7 @@ for (NIMChatroomNotificationMember * member in content.targets) { if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) { self.editButton.hidden = NO; + self.roompkPanelView.isManager = NO; break; } } @@ -706,6 +763,7 @@ for (NIMChatroomNotificationMember * member in content.targets) { if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) { self.editButton.hidden = YES; + self.roompkPanelView.isManager = YES; break; } } @@ -720,6 +778,29 @@ - (void)onMicroQueueUpdate:(NSMutableDictionary *)queue { if (self.delegate.getRoomInfo.type == RoomType_MiniGame) { [self.littleGameMiniView needRefreshPosition:queue]; + } else if(self.delegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) { + self.roompkPanelView.micQueue = queue; + if (self.pkDetailInfo) { + if (self.pkDetailInfo.roomPK.pkStatus != RoomPKStatusType_Playing) { + NSMutableArray * redArray = [NSMutableArray array]; + NSMutableArray * blueArray = [NSMutableArray array]; + for (int i = 0 ; i < queue.allValues.count; i++) { + MicroQueueModel * micModel = [queue.allValues objectAtIndex:i]; + if (micModel.userInfo && micModel.userInfo.uid > 0) { + UserInfoModel * userInfo = micModel.userInfo; + if (userInfo.groupType == GroupTyp_Red) { + [redArray addObject:userInfo]; + } else if(userInfo.groupType == GroupType_Blue) { + [blueArray addObject:userInfo]; + } + } + } + self.roompkPanelView.redUserArray = redArray; + self.roompkPanelView.blueUserArray = blueArray; + } + } else { + [self getRoomPKDetailInfo]; + } }else { MicroQueueModel * currentUserModel; NSString * uid = [AccountInfoStorage instance].getUid; diff --git a/xplan-ios/Main/Room/View/RoomPK/Api/Api+RoomPK.m b/xplan-ios/Main/Room/View/RoomPK/Api/Api+RoomPK.m index 2003b041..68d72f4c 100644 --- a/xplan-ios/Main/Room/View/RoomPK/Api/Api+RoomPK.m +++ b/xplan-ios/Main/Room/View/RoomPK/Api/Api+RoomPK.m @@ -52,6 +52,7 @@ + (void)createRoomPK:(HttpRequestHelperCompletion)completion pkMode:(NSString *)pkMode voteMode:(NSString *)voteMode duration:(NSString *)duration roomUid:(NSString *)roomUid operUid:(NSString *)operUid { [self makeRequest:@"room/pk/create" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, pkMode, voteMode, duration, roomUid, operUid, nil]; } + @end diff --git a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.h b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.h new file mode 100644 index 00000000..b45fa7c7 --- /dev/null +++ b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.h @@ -0,0 +1,19 @@ +// +// RoomPKDetailInfoModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/3/29. +// + +#import +#import "RoomPKInfoModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface RoomPKDetailInfoModel : NSObject +/** 当前时间*/ +@property (nonatomic, assign) long now; +/** PK的实体*/ +@property (nonatomic, strong) RoomPKInfoModel *roomPK; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.m b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.m new file mode 100644 index 00000000..9ad6e33a --- /dev/null +++ b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKDetailInfoModel.m @@ -0,0 +1,15 @@ +// +// RoomPKDetailInfoModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/3/29. +// + +#import "RoomPKDetailInfoModel.h" + +@implementation RoomPKDetailInfoModel + ++ (NSDictionary *)objectClassInArray { + return @{@"teams":RoomPKTeamModel.class}; +} +@end diff --git a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKInfoModel.h b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKInfoModel.h index ee5a9417..bf555088 100644 --- a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKInfoModel.h +++ b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKInfoModel.h @@ -7,6 +7,7 @@ #import #import "XPEnum.h" +#import "RoomPKTeamModel.h" NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger,RoomPKStatusType){ @@ -33,6 +34,16 @@ typedef NS_ENUM(NSInteger,RoomPKStatusType){ @property (nonatomic,copy) NSString *roomUid; ///当前PK的状态 @property (nonatomic,assign) RoomPKStatusType pkStatus; +///PK结束时间(重新开始立即结束,否则为beginTime+duration) +@property (nonatomic, assign) long endTime; +///PK的模式(1:个人模式;2.团队模式) 都是团队模式 就不写枚举了 +@property (nonatomic,assign) NSInteger pkMode; +///pk的结果 +@property (nonatomic, assign) RoomPKResultType result; +/// {红队or蓝队 : { 队员uid : 送礼人uid }} +@property (nonatomic, copy) NSDictionary *> *> *sendGiftUids; +///参与PK的队伍 +@property (nonatomic, strong) NSArray * teams; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKRecordModel.h b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKRecordModel.h index 6213b1fd..294f57ac 100644 --- a/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKRecordModel.h +++ b/xplan-ios/Main/Room/View/RoomPK/Model/RoomPKRecordModel.h @@ -10,12 +10,6 @@ #import "RoomPKTeamModel.h" NS_ASSUME_NONNULL_BEGIN -typedef NS_ENUM(NSInteger, RoomPKResultType) { - RoomPKResultType_Draw = 0,//平局 - RoomPKResultType_Blue = 1,//蓝方胜 - RoomPKResultType_Red = 2, //红方胜 -}; - @interface RoomPKRecordModel : NSObject ///pk的主键 @property (nonatomic, copy) NSString * pkId; diff --git a/xplan-ios/Main/Room/View/RoomPK/View/Cell/XPRoomPKRecordTableViewCell.m b/xplan-ios/Main/Room/View/RoomPK/View/Cell/XPRoomPKRecordTableViewCell.m index 11ab5e91..b861987a 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/Cell/XPRoomPKRecordTableViewCell.m +++ b/xplan-ios/Main/Room/View/RoomPK/View/Cell/XPRoomPKRecordTableViewCell.m @@ -134,7 +134,7 @@ RoomPKTeamModel *redTeam; RoomPKTeamModel * blueTeam; for (RoomPKTeamModel *team in _pkDetailInfo.teams) { - if (team.team == GroupTyp_red) { + if (team.team == GroupTyp_Red) { redTeam = team; }else{ blueTeam = team; diff --git a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.h b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.h index efdc1d7f..aa6f010b 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.h +++ b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.h @@ -8,10 +8,17 @@ #import #import "XPEnum.h" NS_ASSUME_NONNULL_BEGIN +@class XPRoomPKPanelUserView, UserInfoModel; +@protocol XPRoomPKPanelUserViewDelegate +///选择红队还是蓝队的添加人 +- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type; +@end @interface XPRoomPKPanelUserView : UIView @property (nonatomic,assign) GroupType type; -@property (nonatomic,strong) NSArray *userArray; +@property (nonatomic,strong) NSArray *userArray; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.m b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.m index 23ff5c11..8816f5e3 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.m +++ b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKPanelUserView.m @@ -11,6 +11,8 @@ ///Tool #import "NetImageView.h" #import "ThemeColor.h" +///Model +#import "UserInfoModel.h" @interface XPRoomPKPanelUserView () ///容器 @@ -55,7 +57,6 @@ [self.userView addSubview:self.thirdUserView]; [self.userView addSubview:self.secondUserView]; [self.userView addSubview:self.firstUserView]; - self.viewArray = @[self.firstUserView, self.secondUserView, self.thirdUserView, self.fourthUserView, self.fifthUserView]; } - (void)initSubViewConstraints { @@ -79,7 +80,15 @@ #pragma mark - Event Response - (void)addButtonAction:(UIButton *)sender { - + if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomPKPanelUserView:didClickAddButton:)]) { + [self.delegate xPRoomPKPanelUserView:self didClickAddButton:self.type]; + } +} + +- (void)didTapUserViewRecognizer { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomPKPanelUserView:didClickAddButton:)]) { + [self.delegate xPRoomPKPanelUserView:self didClickAddButton:self.type]; + } } #pragma mark - Getters And Setters @@ -91,13 +100,15 @@ for (int i = 0 ; i< self.viewArray.count; i++) { NetImageView * view = [self.viewArray objectAtIndex:i]; if (i < self.userArray.count) { - view.hidden = YES; - } else { + UserInfoModel * userInfo = [self.userArray objectAtIndex:i]; view.hidden = NO; + view.imageUrl = userInfo.avatar; + } else { + view.hidden = YES; } } CGFloat userViewWidth = (_userArray.count - 1) * 15 + 25; - [self.userView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.userView mas_updateConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(userViewWidth); }]; } else { @@ -108,7 +119,7 @@ - (void)setType:(GroupType)type { _type = type; - if (_type == GroupTyp_red) { + if (_type == GroupTyp_Red) { CGColorRef color = UIColorFromRGB(0xFFA572).CGColor; self.firstUserView.layer.borderColor = color; self.secondUserView.layer.borderColor = color; @@ -131,16 +142,16 @@ make.left.mas_equalTo(self.secondUserView.mas_left).offset(-5); }]; - [self.fourthUserView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.centerY.mas_equalTo(self.firstUserView); - make.left.mas_equalTo(self.secondUserView.mas_left).offset(-5); + make.left.mas_equalTo(self.thirdUserView.mas_left).offset(-5); }]; [self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.centerY.mas_equalTo(self.firstUserView); make.left.mas_equalTo(self.fourthUserView.mas_left).offset(-5); }]; + self.viewArray = @[self.firstUserView, self.secondUserView, self.thirdUserView, self.fourthUserView, self.fifthUserView]; } else { CGColorRef color = UIColorFromRGB(0x3ECAFC).CGColor; self.firstUserView.layer.borderColor = color; @@ -149,31 +160,32 @@ self.fourthUserView.layer.borderColor = color; self.fifthUserView.layer.borderColor = color; [self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_blue_add"] forState:UIControlStateNormal]; - [self.firstUserView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(25, 25)); make.left.centerY.mas_equalTo(self.userView); }]; - [self.secondUserView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.centerY.mas_equalTo(self.firstUserView); - make.left.mas_equalTo(self.firstUserView.mas_left).offset(5); + [self.fourthUserView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.centerY.mas_equalTo(self.fifthUserView); + make.left.mas_equalTo(self.fifthUserView.mas_left).offset(5); }]; [self.thirdUserView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.centerY.mas_equalTo(self.firstUserView); - make.right.mas_equalTo(self.secondUserView.mas_left).offset(5); + make.size.centerY.mas_equalTo(self.fifthUserView); + make.left.mas_equalTo(self.fourthUserView.mas_left).offset(5); }]; - [self.fourthUserView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.centerY.mas_equalTo(self.firstUserView); - make.right.mas_equalTo(self.secondUserView.mas_left).offset(5); + [self.secondUserView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.centerY.mas_equalTo(self.fifthUserView); + make.left.mas_equalTo(self.thirdUserView.mas_left).offset(5); }]; - [self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.centerY.mas_equalTo(self.firstUserView); - make.right.mas_equalTo(self.fourthUserView.mas_left).offset(5); + [self.firstUserView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.centerY.mas_equalTo(self.fifthUserView); + make.left.mas_equalTo(self.secondUserView.mas_left).offset(5); }]; + self.viewArray = @[self.fifthUserView, self.fourthUserView, self.thirdUserView, self.secondUserView, self.firstUserView]; } } @@ -193,6 +205,8 @@ _userView = [[UIView alloc] init]; _userView.backgroundColor = [UIColor clearColor]; _userView.hidden = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapUserViewRecognizer)]; + [_userView addGestureRecognizer:tap]; } return _userView; } @@ -206,6 +220,7 @@ _firstUserView.layer.masksToBounds = YES; _firstUserView.layer.cornerRadius = 25/2; _firstUserView.layer.borderWidth = 1; + _firstUserView.userInteractionEnabled = YES; } return _firstUserView; } @@ -219,6 +234,7 @@ _secondUserView.layer.masksToBounds = YES; _secondUserView.layer.cornerRadius = 25/2; _secondUserView.layer.borderWidth = 1; + _secondUserView.userInteractionEnabled = YES; } return _secondUserView; } @@ -233,6 +249,7 @@ _thirdUserView.layer.masksToBounds = YES; _thirdUserView.layer.cornerRadius = 25/2; _thirdUserView.layer.borderWidth = 1; + _secondUserView.userInteractionEnabled = YES; } return _thirdUserView; } @@ -246,6 +263,7 @@ _fourthUserView.layer.masksToBounds = YES; _fourthUserView.layer.cornerRadius = 25/2; _fourthUserView.layer.borderWidth = 1; + _fourthUserView.userInteractionEnabled = YES; } return _fourthUserView; } @@ -259,6 +277,7 @@ _fifthUserView.layer.masksToBounds = YES; _fifthUserView.layer.cornerRadius = 25/2; _fifthUserView.layer.borderWidth = 1; + _fifthUserView.userInteractionEnabled = YES; } return _fifthUserView; } diff --git a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.h b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.h index 794b1c7e..9345f32a 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.h +++ b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.h @@ -18,9 +18,9 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomPKSelectUserView : UIView ///红队的成员 -@property (nonatomic,copy) NSArray *redUserArray; +@property (nonatomic,copy) NSArray *redUserArray; ///蓝队的成员 -@property (nonatomic,copy) NSArray *blueUserArray; +@property (nonatomic,copy) NSArray *blueUserArray; ///红队的还是蓝队的 @property (nonatomic,assign) GroupType groupType; ///麦序的信息 diff --git a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.m b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.m index ddfb6ebc..8996fd9f 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.m +++ b/xplan-ios/Main/Room/View/RoomPK/View/SubViews/XPRoomPKSelectUserView.m @@ -195,7 +195,7 @@ #pragma mark - Getters And Setters - (void)setGroupType:(GroupType)groupType { _groupType = groupType; - if (_groupType == GroupTyp_red) { + if (_groupType == GroupTyp_Red) { [self.chooseArray addObjectsFromArray:self.redUserArray]; } else if (_groupType == GroupType_Blue) { [self.chooseArray addObjectsFromArray:self.blueUserArray]; @@ -218,12 +218,13 @@ userInfoModel.nick = microModel.userInfo.nick; userInfoModel.groupType = self.groupType; userInfoModel.isEnableChoose = YES; - if (self.groupType == GroupTyp_red) { + if (self.groupType == GroupTyp_Red) { for (int i = 0; i NS_ASSUME_NONNULL_BEGIN - +@class RoomPKDetailInfoModel, MicroQueueModel, UserInfoModel; @interface XPRoomPKProgressView : UIView - +///群聊的id +@property (nonatomic,copy) NSString *roomId; +@property (nonatomic, strong) NSMutableDictionary *micQueue; +@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo; +///是否是管理员 +@property (nonatomic,assign) BOOL isManager; +///红队 +@property (nonatomic,strong) NSArray *redUserArray; +///蓝队 +@property (nonatomic,strong) NSArray *blueUserArray; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKProgressView.m b/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKProgressView.m index 934788dd..ac995709 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKProgressView.m +++ b/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKProgressView.m @@ -11,11 +11,19 @@ ///Tool #import "ThemeColor.h" #import "XPMacro.h" +#import "TTPopup.h" #import "UIImage+Utils.h" +///Model +#import "RoomPKDetailInfoModel.h" +#import "MicroQueueModel.h" +#import "UserInfoModel.h" +#import "RoomPKChooseUserModel.h" +#import "AttachmentModel.h" ///View #import "XPRoomPKPanelUserView.h" +#import "XPRoomPKSelectUserView.h" -@interface XPRoomPKProgressView () +@interface XPRoomPKProgressView () ///背景 @property (nonatomic,strong) UIImageView *backImageView; ///开始 @@ -38,6 +46,10 @@ @property (nonatomic,strong) UIImageView * blueProgressView; ///进度的分割线 @property (nonatomic,strong) UIImageView *progressLineView; +///红色的 +@property (nonatomic,strong) NSArray *redChooseArray; +///蓝色的 +@property (nonatomic,strong) NSArray *blueChooseArray; @end @@ -67,9 +79,6 @@ [self.progressView addSubview:self.redProgressView]; [self.progressView addSubview:self.blueProgressView]; [self.progressView addSubview:self.progressLineView]; - - self.redTeamView.userArray = @[@"1", @"2", @"222"]; - self.blueTeamView.userArray = @[@"222", @"333"]; } - (void)initSubViewConstraints { @@ -141,20 +150,146 @@ }]; } +- (BOOL)isOnMicro:(NSString *)uid { + for (int i = 0; i < self.micQueue.allValues.count; i++) { + MicroQueueModel * micModel = [self.micQueue.allValues objectAtIndex:i]; + if (micModel.userInfo && micModel.userInfo.uid > 0 && micModel.userInfo.uid == uid.integerValue) { + return YES; + } + } + return NO; +} + +#pragma mark - XPRoomPKPanelUserViewDelegate +- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type { + if (self.isManager) { + NSMutableArray * redArrar= [NSMutableArray array]; + for (int i = 0; i < self.redUserArray.count; i++) { + UserInfoModel * userInfo = [self.redUserArray objectAtIndex:i]; + RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init]; + model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid]; + model.groupType = GroupTyp_Red; + model.nick = userInfo.nick; + [redArrar addObject:model]; + } + self.redChooseArray = redArrar.copy; + NSMutableArray * blueArrar= [NSMutableArray array]; + for (int i = 0; i < self.blueUserArray.count; i++) { + UserInfoModel * userInfo = [self.blueUserArray objectAtIndex:i]; + RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init]; + model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid]; + model.groupType = GroupType_Blue; + model.nick = userInfo.nick; + [blueArrar addObject:model]; + } + self.blueChooseArray = blueArrar.copy; + + XPRoomPKSelectUserView * chooseUserView = [[XPRoomPKSelectUserView alloc] init]; + chooseUserView.delegate = self; + chooseUserView.redUserArray = redArrar; + chooseUserView.blueUserArray = blueArrar; + chooseUserView.groupType = type; + chooseUserView.microQueueArray = self.micQueue.allValues; + [TTPopup popupView:chooseUserView style:TTPopupStyleAlert]; + } +} + +#pragma mark - XPRoomPKSelectUserViewDelegate +- (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray *)userInfos { + [TTPopup dismiss]; + if (groupType == GroupTyp_Red) { + self.redChooseArray = userInfos; + } else { + self.blueChooseArray = userInfos; + } + if (self.redChooseArray.count > 0 || self.blueChooseArray.count > 0) { + NSMutableDictionary * dic = [NSMutableDictionary dictionary]; + for (int i = 0 ; i< self.redChooseArray.count; i++) { + RoomPKChooseUserModel * model = [self.redChooseArray objectAtIndex:i]; + if (model.uid.integerValue <= 0) { + continue; + } + NSMutableDictionary * data =[[model model2dictionary] mutableCopy]; + [data removeObjectForKey:@"title"]; + [data removeObjectForKey:@"imageName"]; + [data removeObjectForKey:@"userUrl"]; + [data removeObjectForKey:@"isSelect"]; + [data removeObjectForKey:@"isEnableChoose"]; + [dic setValue:data forKey:model.uid]; + } + + for (int i = 0 ; i< self.blueChooseArray.count; i++) { + RoomPKChooseUserModel * model = [self.blueChooseArray objectAtIndex:i]; + if (model.uid.integerValue <= 0) { + continue; + } + NSMutableDictionary * data =[[model model2dictionary] mutableCopy]; + [data removeObjectForKey:@"title"]; + [data removeObjectForKey:@"imageName"]; + [data removeObjectForKey:@"userUrl"]; + [data removeObjectForKey:@"isSelect"]; + [data removeObjectForKey:@"isEnableChoose"]; + [dic setValue:data forKey:model.uid]; + } + + if (dic.allKeys.count > 0) { + AttachmentModel * attachment = [[AttachmentModel alloc] init]; + attachment.first = CustomMessageType_Room_PK; + attachment.second = Custom_Message_Sub_Room_PK_Manager_Up_Mic; + attachment.data = dic; + NSString *sessionID = self.roomId; + NIMMessage *message = [[NIMMessage alloc]init]; + NIMCustomObject *object = [[NIMCustomObject alloc] init]; + object.attachment = attachment; + message.messageObject = object; + //构造会话 + NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom]; + [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; + } + } +} + + #pragma mark - Event Response -- (void)redAddButtonAction:(UIButton *)sender { - -} - -- (void)blueAddButtonAction:(UIButton *)sender { - -} - - (void)beginButtonAction:(UIButton *)sender { } #pragma mark - Getters And Setters +- (void)setIsManager:(BOOL)isManager { + _isManager = isManager; + if (_isManager) { + self.beginButton.hidden = !_isManager; + } +} + +- (void)setPkDetailInfo:(RoomPKDetailInfoModel *)pkDetailInfo { + _pkDetailInfo = pkDetailInfo; + if (_pkDetailInfo) { + RoomPKInfoModel * infoModel = pkDetailInfo.roomPK; + if (infoModel.teams.count > 0) { + NSMutableArray * redArray = [NSMutableArray array]; + NSMutableArray * blueArray = [NSMutableArray array]; + for (int i = 0; i < infoModel.teams.count; i++) { + RoomPKTeamModel * teamInfo = [infoModel.teams objectAtIndex:i]; + if (infoModel.pkStatus == RoomPKStatusType_End || infoModel.pkStatus == RoomPKStatusType_NonStart) { + + } + } + } + } +} + +- (void)setRedUserArray:(NSArray *)redUserArray { + _redUserArray = redUserArray; + self.redTeamView.userArray = _redUserArray; +} + +- (void)setBlueUserArray:(NSArray *)blueUserArray { + _blueUserArray = blueUserArray; + self.blueTeamView.userArray = _blueUserArray; +} + - (UIImageView *)backImageView { if (!_backImageView) { _backImageView = [[UIImageView alloc] init]; @@ -170,7 +305,7 @@ _timeLabel.font = [UIFont systemFontOfSize:10]; _timeLabel.textColor = UIColorFromRGB(0x602A06); _timeLabel.textAlignment = NSTextAlignmentCenter; - _timeLabel.text= @"00:00"; + _timeLabel.text= @"未开始"; } return _timeLabel; } @@ -178,7 +313,8 @@ - (XPRoomPKPanelUserView *)redTeamView { if (!_redTeamView) { _redTeamView = [[XPRoomPKPanelUserView alloc] init]; - _redTeamView.type = GroupTyp_red; + _redTeamView.type = GroupTyp_Red; + _redTeamView.delegate = self; } return _redTeamView; } @@ -187,6 +323,7 @@ if (!_blueTeamView) { _blueTeamView = [[XPRoomPKPanelUserView alloc] init]; _blueTeamView.type = GroupType_Blue; + _blueTeamView.delegate = self; } return _blueTeamView; } @@ -256,7 +393,7 @@ if (!_beginButton) { _beginButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_beginButton setTitle:@"开始PK" forState:UIControlStateNormal]; - [_beginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + [_beginButton setTitleColor:UIColorFromRGB(0x602A06) forState:UIControlStateNormal]; _beginButton.titleLabel.font = [UIFont systemFontOfSize:15]; [_beginButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFDAA8), UIColorFromRGB(0xFFBD64)] gradientType:GradientTypeUpleftToLowright imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; _beginButton.layer.masksToBounds = YES; diff --git a/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKViewController.m b/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKViewController.m index 40d3c61f..9c32d7a7 100644 --- a/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKViewController.m +++ b/xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKViewController.m @@ -237,7 +237,7 @@ #pragma mark - XPRoomPKSelectUserViewDelegate - (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray *)userInfos { [TTPopup dismiss]; - if (groupType == GroupTyp_red) { + if (groupType == GroupTyp_Red) { self.redUserArray = userInfos; } else { self.blueUserArray = userInfos; @@ -360,7 +360,7 @@ chooseUserView.delegate = self; chooseUserView.redUserArray = self.redUserArray; chooseUserView.blueUserArray = self.blueUserArray; - chooseUserView.groupType = GroupTyp_red; + chooseUserView.groupType = GroupTyp_Red; chooseUserView.microQueueArray = self.hostDelegate.getMicroQueue.allValues; [TTPopup popupView:chooseUserView style:TTPopupStyleAlert]; }