小游戏活动样式的修改
This commit is contained in:
@@ -21,6 +21,8 @@ typedef NS_ENUM(NSInteger, ActivityShowType) {
|
||||
};
|
||||
|
||||
@interface ActivityInfoModel : NSObject
|
||||
///名称
|
||||
@property (nonatomic,copy) NSString *bannerName;
|
||||
///活动的图片
|
||||
@property (nonatomic, copy)NSString *bannerPic;
|
||||
///跳转类型
|
||||
|
@@ -46,7 +46,11 @@
|
||||
///host 代理
|
||||
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
||||
///房间活动的列表
|
||||
@property (nonatomic,copy) NSArray<ActivityInfoModel *> *activityList;
|
||||
@property (nonatomic,copy) NSMutableArray<ActivityInfoModel *> *activityList;
|
||||
///活动的地址
|
||||
@property (nonatomic,strong) NSMutableArray<NSString *> *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 <ActivityInfoModel *>* 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<NIMChatroomMember *> * _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<NIMChatroomMember *> * _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<ActivityInfoModel *> *)activityList {
|
||||
if (!_activityList) {
|
||||
_activityList = [NSMutableArray array];
|
||||
}
|
||||
return _activityList;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user