个播PK搜索、PK面板

This commit is contained in:
chenguilong
2022-04-11 19:11:34 +08:00
parent a685b8c70a
commit 1bb71681af
45 changed files with 1524 additions and 16 deletions

View File

@@ -35,6 +35,7 @@
#import "XPAnchorFansRelationModel.h"
#import "XPAnchorFansJoinModel.h"
#import "XPAnchorFansTaskModel.h"
#import "AnchorPKPanelModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
@@ -52,12 +53,14 @@
#import "XPRoomViewController.h"
#import "XPLittleGameMiniStageView.h"
#import "XPLittleGameRoomListView.h"
///PK
#import "XPAnchorFansTeamEntranceView.h"
#import "XPAnchorFansTeamViewController.h"
#import "XPAnchorFansTaskViewController.h"
#import "XPAnchorPkPanelView.h"
#import "XPWebViewController.h"
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate>
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate>
///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
///
@@ -82,8 +85,11 @@
@property (nonatomic,strong) XPLittleGameMiniStageView *littleGameMiniView;
///
@property (nonatomic,strong) XPLittleGameRoomListView *gameListView;
///
@property (nonatomic, strong) XPAnchorFansRelationModel *relationFansModel;
///PK
@property (nonatomic, strong) XPAnchorPkPanelView *anchorPKPanelView;
@end
@implementation XPRoomFunctionContainerView
@@ -332,7 +338,34 @@
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:roomUid];
}
} else if (roomInfo.roomModeType == RoomModeType_Open_AnchorPK_Mode) {
[Api getAcrossRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
AnchorPKPanelModel * anchorPKPanelInfo = [AnchorPKPanelModel modelWithJSON:data.data];
if (anchorPKPanelInfo.aUid.integerValue > 0) {
if (!self.anchorPKPanelView.superview) {
[self addSubview:self.anchorPKPanelView];
[self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.bottom.mas_equalTo(330);
}];
}
self.anchorPKPanelView.pkPanelInfo = anchorPKPanelInfo;
}
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:roomUid];
} else {
if (!self.anchorPKPanelView.superview) {
[self addSubview:self.anchorPKPanelView];
[self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(kNavigationHeight);
make.left.mas_equalTo(0);
}];
}
}
if (roomInfo.type == RoomType_Anchor) {
[self.contributionButton setTitle:@"主播榜" forState:UIControlStateNormal];
self.anchorGiftValueView.hidden = !roomInfo.showGiftValue;
@@ -474,6 +507,108 @@
[TTPopup popupView:view style:TTPopupStyleAlert];
}
}
break;
case Custom_Message_Sub_AnchorPK_Invite:
{
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) {
XPAcrossRoomPKInviteView * inviteView = [[XPAcrossRoomPKInviteView alloc] init];
inviteView.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
inviteView.dataDic = attachment.data;
[self addSubview:inviteView];
[inviteView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self);
}];
}
}
}];
}
break;
case Custom_Message_Sub_AnchorPK_Accept:
{
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) {
XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init];
inviteResutView.isAccept = YES;
[self addSubview:inviteResutView];
[inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight);
make.centerX.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(281, 42));
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[inviteResutView removeFromSuperview];
});
}
}
}];
}
break;
case Custom_Message_Sub_AnchorPK_Reject:
{
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) {
XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init];
inviteResutView.isAccept = NO;
[self addSubview:inviteResutView];
[inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight);
make.centerX.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(201, 42));
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[inviteResutView removeFromSuperview];
});
}
}
}];
}
break;
case Custom_Message_Sub_AnchorPK_Panel:
{
if (!self.acrossPKPanelView.superview) {
[self addSubview:self.acrossPKPanelView];
[self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self).offset(354 + kSafeAreaTopHeight);
make.centerX.mas_equalTo(self);
}];
}
AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo;
}
break;
case Custom_Message_Sub_AnchorPK_End:
{
[self.acrossPKPanelView resetAcrossPKViewData];
[self.acrossPKPanelView removeFromSuperview];
AcrossRoomPKPanelModel * model = [AcrossRoomPKPanelModel modelWithJSON:attachment.data];
if (model.isForce) {
XPAcrossRoomPKForceEndResultView *view = [[XPAcrossRoomPKForceEndResultView alloc] initWithFrame:CGRectMake(0, 0, 281, 208)];
view.data = model;
[TTPopup popupView:view style:TTPopupStyleAlert];
} else {
XPAcrossRoomPKResultView *view = [[XPAcrossRoomPKResultView alloc] initWithFrame:CGRectMake(0, 0, 320, 453)];
view.data = model;
[TTPopup popupView:view style:TTPopupStyleAlert];
}
}
break;
default:
break;
}
@@ -581,6 +716,28 @@
[self.delegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
}
#pragma mark - XPAnchorPkPanelViewDelegate
- (void)xPAnchorPKPanelView:(XPAnchorPkPanelView *)view showUserCard:(NSString *)uid {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
NSString * targetUid = uid;
XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init];
[[self.delegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (targetUid.integerValue == obj.userInfo.uid) {
model.position = [NSString stringWithFormat:@"%d", obj.microState.position];
model.posState = obj.microState.posState;
model.micState = obj.microState.micState;
*stop = YES;
}
}];
model.nick = self.delegate.getUserInfo.nick;
model.uid = targetUid;
model.delegate = self.delegate;
model.roomInfo = roomInfo;
model.micQueue = self.delegate.getMicroQueue;
XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model];
[self.delegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
}
#pragma mark - Event Response
- (void)contributionButtonAction:(UIButton *)sender {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
@@ -1005,5 +1162,12 @@
return _gameListView;
}
- (XPAnchorPkPanelView *)anchorPKPanelView {
if (!_anchorPKPanelView) {
_anchorPKPanelView = [[XPAnchorPkPanelView alloc] init];
_anchorPKPanelView.delegate = self;
}
return _anchorPKPanelView;
}
@end