From 2d0e8e120a3d589c72d3d03e31084b1f3335006e Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Tue, 15 Feb 2022 15:38:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=B8=B8=E6=88=8F=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios/Main/Room/Model/ActivityInfoModel.h | 2 + .../XPRoomActivityContainerView.m | 165 ++++++++++++++---- .../Main/Room/View/XPRoomViewController.m | 4 +- 3 files changed, 139 insertions(+), 32 deletions(-) diff --git a/xplan-ios/Main/Room/Model/ActivityInfoModel.h b/xplan-ios/Main/Room/Model/ActivityInfoModel.h index af8ace11..17628b05 100644 --- a/xplan-ios/Main/Room/Model/ActivityInfoModel.h +++ b/xplan-ios/Main/Room/Model/ActivityInfoModel.h @@ -21,6 +21,8 @@ typedef NS_ENUM(NSInteger, ActivityShowType) { }; @interface ActivityInfoModel : NSObject +///名称 +@property (nonatomic,copy) NSString *bannerName; ///活动的图片 @property (nonatomic, copy)NSString *bannerPic; ///跳转类型 diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m index a2796566..71c04daf 100644 --- a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -46,7 +46,11 @@ ///host 代理 @property (nonatomic,weak) idhostDelegate; ///房间活动的列表 -@property (nonatomic,copy) NSArray *activityList; +@property (nonatomic,copy) NSMutableArray *activityList; +///活动的地址 +@property (nonatomic,strong) NSMutableArray *imageUrlList; +///是否加载了活动 +@property (nonatomic,assign) BOOL isLoadActivity; @end @implementation XPRoomActivityContainerView @@ -99,23 +103,29 @@ - (void)requestActivityList { NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; [Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + self.isLoadActivity = YES; if (code == 200) { NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; if (array.count <=0) return; self.cycleScrollView.hidden = NO; - self.activityList = array; + [self.activityList addObjectsFromArray:array]; NSMutableArray * picList = [NSMutableArray array]; [array enumerateObjectsUsingBlock:^(ActivityInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (obj.bannerPic.length > 0) { [picList addObject:obj.bannerPic]; } }]; - self.cycleScrollView.imageURLStringsGroup = picList; - if (array.count > 1) { - [self.cycleScrollView setAutoScroll:YES]; - self.cycleScrollView.autoScrollTimeInterval = 3; + self.imageUrlList = picList; + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { + [self configLittleGameActivity]; } else { - [self.cycleScrollView setAutoScroll:NO]; + self.cycleScrollView.imageURLStringsGroup = picList; + if (array.count > 1) { + [self.cycleScrollView setAutoScroll:YES]; + self.cycleScrollView.autoScrollTimeInterval = 3; + } else { + [self.cycleScrollView setAutoScroll:NO]; + } } } } roomId:roomId type:@"2"]; @@ -136,32 +146,120 @@ } } -#pragma mark - RoomGuestDelegate -- (void)onRoomEntered { - [self onRoomUpdate]; +- (void)configLittleGameActivity { + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + UserInfoModel * userInfo = self.hostDelegate.getUserInfo; + BOOL hadContainCandy = NO; + for (ActivityInfoModel *activityInfo in self.activityList) { + if ([activityInfo.bannerName isEqualToString:@"糖果树"]) { + hadContainCandy = YES; + } + } + ///根据条件加入糖果树 + if (userInfo.userLevelVo.experLevelSeq >= [ClientConfig shareConfig].openCandyTreeLimitLevel && [ClientConfig shareConfig].openCandyTree && roomInfo.boxSwitchVo.openBoxSwitch && !hadContainCandy) { + ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init]; + activityInfo.bannerPic = roomInfo.boxSwitchVo.openBoxIcon.length > 0 ? roomInfo.boxSwitchVo.openBoxIcon : @"openBoxIcon"; + activityInfo.bannerName = @"糖果树"; + [self.activityList insertObject:activityInfo atIndex:0]; + [self.imageUrlList insertObject:activityInfo.bannerPic atIndex:0]; + } + ///是否包含首充 + BOOL hadContainFirstRecharge = NO; + for (ActivityInfoModel *activityInfo in self.activityList) { + if ([activityInfo.bannerName isEqualToString:@"首充有礼"]) { + hadContainFirstRecharge = YES; + } + } + ///是否包含糖果树 + BOOL hadContainCandy1 = NO; + for (ActivityInfoModel *activityInfo in self.activityList) { + if ([activityInfo.bannerName isEqualToString:@"糖果树"]) { + hadContainCandy1 = YES; + } + } + ///根据条件加入首充 + if (userInfo.isFirstCharge && !hadContainFirstRecharge) { + ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init]; + activityInfo.bannerPic = @"room_first_recharge_enter"; + activityInfo.bannerName = @"首充有礼"; + if (hadContainCandy1) { + [self.activityList insertObject:activityInfo atIndex:0]; + [self.imageUrlList insertObject:activityInfo.bannerPic atIndex:0]; + } else { + [self.activityList insertObject:activityInfo atIndex:1]; + [self.imageUrlList insertObject:activityInfo.bannerPic atIndex:1]; + } + } + + if (self.imageUrlList.count > 0) { + self.cycleScrollView.imageURLStringsGroup = self.imageUrlList; + [self.cycleScrollView setAutoScroll:YES]; + self.cycleScrollView.autoScrollTimeInterval = 3; + } } -- (void)onRoomUpdate { - [self configCandyTree]; - self.firstRechargeImageView.hidden = !self.hostDelegate.getUserInfo.isFirstCharge; - RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; - if (roomInfo.roomModeType == RoomModeType_Open_Blind) { - NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; - request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; - request.userIds = @[[AccountInfoStorage instance].getUid]; - [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { - if (error == nil) { - NIMChatroomMember * member = members.firstObject; - if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) { - self.joinDatingView.hidden = YES; - return; - } - } - self.joinDatingView.hidden = NO; - }]; - } else { - self.joinDatingView.hidden = YES; +- (void)dealRoomInfoChangeActivity { + __block ActivityInfoModel * firstRechargeActivity; + __block ActivityInfoModel * candyActivity; + [self.activityList enumerateObjectsUsingBlock:^(ActivityInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.bannerName isEqualToString:@"首充有礼"]) { + firstRechargeActivity = obj; + } else if([obj.bannerName isEqualToString:@"糖果树"]) { + candyActivity = obj; + } + }]; + + if (firstRechargeActivity && [self.activityList containsObject:firstRechargeActivity]) { + NSInteger index = [self.activityList indexOfObject:firstRechargeActivity]; + [self.imageUrlList removeObjectAtIndex:index]; + [self.activityList removeObject:firstRechargeActivity]; } + + if (candyActivity && [self.activityList containsObject:candyActivity]) { + NSInteger index = [self.activityList indexOfObject:candyActivity]; + [self.imageUrlList removeObjectAtIndex:index]; + [self.activityList removeObject:candyActivity]; + } +} + +#pragma mark - RoomGuestDelegat +- (void)onRoomUpdate { + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + UserInfoModel * userInfo = self.hostDelegate.getUserInfo; + if (roomInfo.type == RoomType_MiniGame) { + self.firstRechargeImageView.hidden = YES; + self.candyTreeImageView.hidden = YES; + if (self.isLoadActivity) { + [self configLittleGameActivity]; + } else { + [self requestActivityList]; + } + } else { + [self dealRoomInfoChangeActivity]; + [self configCandyTree]; + self.firstRechargeImageView.hidden = !userInfo.isFirstCharge; + if (roomInfo.roomModeType == RoomModeType_Open_Blind) { + NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; + request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; + request.userIds = @[[AccountInfoStorage instance].getUid]; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + if (error == nil) { + NIMChatroomMember * member = members.firstObject; + if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) { + self.joinDatingView.hidden = YES; + return; + } + } + self.joinDatingView.hidden = NO; + }]; + } else { + self.joinDatingView.hidden = YES; + } + } +} + +- (void)onRoomEntered { + [self onRoomUpdate]; } - (void)handleNIMCustomMessage:(NIMMessage *)message { @@ -346,5 +444,12 @@ return _joinDatingView; } +- (NSMutableArray *)activityList { + if (!_activityList) { + _activityList = [NSMutableArray array]; + } + return _activityList; +} + @end diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index da959363..d754c470 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -299,14 +299,14 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; }]; [self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(50); + make.height.mas_equalTo(70); make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5); make.left.mas_equalTo(self.view); make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10); }]; [self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.messageContainerView); + make.height.mas_equalTo(65); make.right.mas_equalTo(self.view); make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5); make.width.mas_equalTo(80);