房间内PK非管理员点击pk面板的时候弹出报名

This commit is contained in:
fengshuo
2022-05-24 21:04:54 +08:00
parent ad31f49823
commit f8fb7e2dfa
6 changed files with 92 additions and 30 deletions

View File

@@ -91,8 +91,13 @@
- (void)setUserInfo:(ArrangeMicUserModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.nameLabel.text= _userInfo.nick;
NSString * nick = _userInfo.nick;
if (nick.length > 6) {
nick = [nick substringToIndex:6];
}
self.nameLabel.text= nick;
self.avaratImageView.imageUrl = _userInfo.avatar;
self.sexImageView.image = _userInfo.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"];
self.rankLabel.text = [NSString stringWithFormat:@"%ld", _userInfo.number];
if (self.isManager) {
if (_userInfo.arrangeMicType == ArrangeMicType_Dating) {
@@ -180,4 +185,13 @@
}
return _avaratImageView;
}
- (UIImageView *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIImageView alloc] init];
_sexImageView.userInteractionEnabled = YES;
}
return _sexImageView;
}
@end

View File

@@ -294,7 +294,7 @@
#pragma mark - PK
- (void)configRoomPKPanelView:(BOOL)isEnter {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
self.roompkPanelView.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
self.roompkPanelView.roomInfo = roomInfo;
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
if (!self.roompkPanelView.superview) {
[self addSubview:self.roompkPanelView];
@@ -303,12 +303,10 @@
make.top.mas_equalTo(self).offset(35 + (58 + 5 + 6 + 12) + 38 + (55 + 10 + 12 + 5+16) * 2 + 15 * 2 + kNavigationHeight + 5);
}];
}
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
if (isEnter) {
self.roompkPanelView.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
self.roompkPanelView.roomId = roomId;
[self.roompkPanelView enterRoomGetRoomPKDetailInfo];
}
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
NSString * uid = [AccountInfoStorage instance].getUid;
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = roomId;

View File

@@ -25,6 +25,8 @@
@property (nonatomic,strong) NSMutableArray<NSMutableArray<RoomPKTimeItemModel *> *> *datasource;
///0
@property (nonatomic,strong) RoomPKTimeItemModel *zeroModel;
///30
@property (nonatomic,strong) RoomPKTimeItemModel *thirdModel;
///
@property (nonatomic,strong) RoomPKTimeItemModel *selectMinModel;
///
@@ -63,11 +65,9 @@
self.selectMinModel = minArray.firstObject;
self.selectSecondModel = self.zeroModel;
NSMutableArray * secondArray = [NSMutableArray array];
[secondArray addObject:self.thirdModel];
RoomPKTimeItemModel * thirdModel = [[RoomPKTimeItemModel alloc] init];
thirdModel.title = @"30秒";
thirdModel.time = 30;
[secondArray addObject:thirdModel];
self.selectSecondModel = self.thirdModel;
[self.datasource addObject:minArray];
[self.datasource addObject:secondArray];
@@ -123,23 +123,40 @@
if (component == 0) {
RoomPKTimeItemModel * model = [[self.datasource objectAtIndex:component] objectAtIndex:row];
self.selectMinModel = model;
self.selectSecondModel = self.zeroModel;
if ([model.title isEqualToString:@"0分钟"]) {
NSMutableArray * array = [self.datasource objectAtIndex:1];
if ([array containsObject:self.zeroModel]) {
[array removeObject:self.zeroModel];
}
if (![array containsObject:self.thirdModel]) {
[array addObject:self.thirdModel];
}
}else if ([model.title isEqualToString:@"30分钟"]) {
NSMutableArray * array = [self.datasource objectAtIndex:1];
if ([array containsObject:self.thirdModel]) {
[array removeObject:self.thirdModel];
}
if (![array containsObject:self.zeroModel]) {
[array insertObject:self.zeroModel atIndex:0];
}
} else {
NSMutableArray * array = [self.datasource objectAtIndex:1];
if (![array containsObject:self.zeroModel]) {
[array insertObject:self.zeroModel atIndex:0];
}
if (![array containsObject:self.thirdModel]) {
[array addObject:self.thirdModel];
}
}
[pickerView reloadComponent:1];
} else {
RoomPKTimeItemModel * model = [[self.datasource objectAtIndex:component] objectAtIndex:row];
self.selectSecondModel = model;
}
}
#pragma mark - Event Response
@@ -212,11 +229,18 @@
return _zeroModel;
}
- (RoomPKTimeItemModel *)thirdModel {
if (!_thirdModel) {
_thirdModel = [[RoomPKTimeItemModel alloc] init];
_thirdModel.title = @"30秒";
_thirdModel.time = 30;
}
return _thirdModel;
}
- (RoomPKTimeItemModel *)selectModel {
if (!_selectModel) {
_selectModel = [[RoomPKTimeItemModel alloc] init];
_selectModel.title = @"30秒";
_selectModel.time = 30;
}
return _selectModel;
}

View File

@@ -8,14 +8,12 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class RoomPKDetailInfoModel, MicroQueueModel, AttachmentModel;
@class RoomPKDetailInfoModel, MicroQueueModel, AttachmentModel, RoomInfoModel;
@interface XPRoomPKProgressView : UIView
///房主的uid
@property (nonatomic,copy) NSString *roomUid;
///群聊的id
@property (nonatomic,copy) NSString *roomId;
@property (nonatomic, strong) NSMutableDictionary<NSString *, MicroQueueModel *> *micQueue;
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
///房间信息
@property (nonatomic,strong) RoomInfoModel *roomInfo;
///是否是管理员
@property (nonatomic,assign) BOOL isManager;
///收到礼物

View File

@@ -19,6 +19,7 @@
#import "XPGiftStorage.h"
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "XCCurrentVCStackManager.h"
///Model
#import "RoomPKDetailInfoModel.h"
#import "MicroQueueModel.h"
@@ -26,12 +27,15 @@
#import "RoomPKChooseUserModel.h"
#import "AttachmentModel.h"
#import "MicroExtModel.h"
#import "XPArrangeMicInfoModel.h"
#import "RoomInfoModel.h"
///View
#import "XPRoomPKPanelUserView.h"
#import "XPRoomPKSelectUserView.h"
#import "XPRoomPKPlayingView.h"
#import "XPRoomPKPlayingView.h"
#import "XPRoomPKResultView.h"
#import "XPArrangeMicViewController.h"
@interface XPRoomPKProgressView ()<XPRoomPKPanelUserViewDelegate, XPRoomPKSelectUserViewDelegate, XPRoomPKPlayingViewDelegate>
///
@@ -200,6 +204,7 @@
}
- (void)enterRoomGetRoomPKDetailInfo {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
[Api getRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKDetailInfoModel * pkDetailInfo = [RoomPKDetailInfoModel modelWithDictionary:data.data];
@@ -270,7 +275,7 @@
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:self.roomUid];
} roomUid:roomUid];
}
@@ -357,6 +362,7 @@
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self.isReceivePKResult) {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
if (self.pkDetailInfo.roomPK.pkId.length > 0) {
NSString * pkId = self.pkDetailInfo.roomPK.pkId;
[Api checkRoomPKResult:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@@ -367,7 +373,7 @@
self.checkResultNum++;
[self checkRoomPKResult];
}
} roomUid:self.roomUid operUid:uid pkId:pkId];
} roomUid:roomUid operUid:uid pkId:pkId];
}
}
@@ -597,7 +603,8 @@
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = [NSString stringWithFormat:@"%d", micModel.microState.position];
request.value = [[self userInfoToQueueExt:micModel.userInfo] toJSONString];
request.roomId = self.roomId;
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
}];
@@ -662,6 +669,18 @@
chooseUserView.groupType = type;
chooseUserView.microQueueArray = self.micQueue.allValues;
[TTPopup popupView:chooseUserView style:TTPopupStyleAlert];
} else {
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
info.roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
info.roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
info.nick = self.roomInfo.nick;
info.roomAvatar = self.roomInfo.avatar;
info.roomTitle = self.roomInfo.title;
info.micQueue = self.micQueue;
info.isManager = self.isManager;
info.type = ArrangeMicType_Room_PK;
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController presentViewController:arrangeMicVC animated:YES completion:nil];
}
}
@@ -708,7 +727,8 @@
attachment.first = CustomMessageType_Room_PK;
attachment.second = Custom_Message_Sub_Room_PK_Manager_Up_Mic;
attachment.data = dic;
NSString *sessionID = self.roomId;
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
NSString *sessionID = roomId;
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
@@ -725,6 +745,7 @@
[TTPopup dismiss];
[TTPopup alertWithMessage:@"重新开始将会提前结束本次PK\n确认重新开始吗?" confirmHandler:^{
RoomPKInfoModel * roompkInfo = self.pkDetailInfo.roomPK;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
[Api createRoomPK:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKInfoModel * newRoomPKInfo = [RoomPKInfoModel modelWithDictionary:data.data];
@@ -737,11 +758,11 @@
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:self.roomUid pkId:newRoomPKInfo.pkId joinUsers:teamJsonStr];
} roomUid:roomUid pkId:newRoomPKInfo.pkId joinUsers:teamJsonStr];
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:self.roomUid operUid:[AccountInfoStorage instance].getUid];
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:roomUid operUid:[AccountInfoStorage instance].getUid];
} cancelHandler:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_Playing) {
@@ -759,6 +780,7 @@
- (void)beginButtonAction:(UIButton *)sender {
if (self.pkDetailInfo) {
RoomPKInfoModel * roompkInfo = self.pkDetailInfo.roomPK;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
if (self.redChooseArray.count > 0 && self.blueChooseArray.count > 0) {
if (self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_End || self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_ReStart) {
[TTPopup alertWithMessage:@"是否再次开始PK?" confirmHandler:^{
@@ -774,11 +796,11 @@
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:self.roomUid pkId:newRoomPKInfo.pkId joinUsers:teamJsonStr];
} roomUid:roomUid pkId:newRoomPKInfo.pkId joinUsers:teamJsonStr];
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:self.roomUid operUid:[AccountInfoStorage instance].getUid];
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:roomUid operUid:[AccountInfoStorage instance].getUid];
} cancelHandler:^{
}];
@@ -795,7 +817,7 @@
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:self.roomUid pkId:self.pkDetailInfo.roomPK.pkId joinUsers:teamJsonStr];
} roomUid:roomUid pkId:self.pkDetailInfo.roomPK.pkId joinUsers:teamJsonStr];
} cancelHandler:^{
}];

View File

@@ -295,6 +295,7 @@
}
- (void)createRoomPKSuccess:(RoomPKInfoModel *)roompkInfo {
[self showSuccessToast:@"创建成功"];
if (self.redUserArray.count > 0 || self.blueUserArray.count > 0) {
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
for (int i = 0 ; i< self.redUserArray.count; i++) {
@@ -355,8 +356,13 @@
}
- (void)onceAgainPKButtonAction:(UIButton *)sender {
NSString * title = @"创建此PK会覆盖现在进行的PK,\n 确定覆盖当前PK吗";
[TTPopup alertWithMessage:title confirmHandler:^{
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
[self.presenter createRoomPKMode:2 voteMode:self.voteType duration:self.duraTime roomUid:roomUid];
} cancelHandler:^{
}];
}
- (void)rightNavAction:(UIButton *)sender {