小游戏-选择开房类型的界面的逻辑的完善

This commit is contained in:
fengshuo
2022-01-22 11:35:44 +08:00
committed by chenguilong
parent 29f0fa6658
commit fed928c8e9
11 changed files with 87 additions and 19 deletions

View File

@@ -202,9 +202,10 @@
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
roomInfo.isReselect = YES;
if (roomInfo.isReselect) {
XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init];
roomOpenView.roomInfo = roomInfo;
roomOpenView.currentVC = self;
[TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet];
} else {
[XPRoomViewController openRoom:roomUid viewController:self];

View File

@@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
/// @param backPic 房间背景
/// @param uid 用户的uid
/// @param ticket 用户的ticket
/// @param mgId 小游戏的id
+ (void)openRoom:(HttpRequestHelperCompletion)complection
title:(NSString *)title
type:(RoomType)type
@@ -36,7 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
roomDesc:(NSString *)roomDesc
backPic:(NSString *)backPic
uid:(NSString *)uid
ticket:(NSString *)ticket;
ticket:(NSString *)ticket
mgId:(NSString *)mgId;
/// 房间上麦
/// @param complection 完成

View File

@@ -27,6 +27,7 @@
/// @param backPic
/// @param uid uid
/// @param ticket ticket
/// @param mgId id
+ (void)openRoom:(HttpRequestHelperCompletion)complection
title:(NSString *)title
type:(RoomType)type
@@ -34,8 +35,9 @@
roomDesc:(NSString *)roomDesc
backPic:(NSString *)backPic
uid:(NSString *)uid
ticket:(NSString *)ticket {
[Api makeRequest:@"room/open" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, title, @(type), roomPwd, roomDesc, backPic, uid, ticket,nil];
ticket:(NSString *)ticket
mgId:(NSString *)mgId {
[Api makeRequest:@"room/open" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, title, @(type), roomPwd, roomDesc, backPic, uid, ticket, mgId,nil];
}

View File

@@ -11,7 +11,8 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, RoomType) {
RoomType_Game = 3,
RoomType_Anchor = 6 // 个播房
RoomType_Anchor = 6, // 个播房
RoomType_MiniGame = 7//小游戏房
};
typedef NS_ENUM(NSInteger, RoomModeType){

View File

@@ -24,11 +24,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param roomPwd 房间密码
/// @param roomDesc 房间介绍
/// @param backPic 房间背景
/// @param mgId 小游戏的id
- (void)openRoom:(NSString *)title
type:(RoomType)type
roomPwd:(NSString *)roomPwd
roomDesc:(NSString *)roomDesc
backPic:(NSString *)backPic;
backPic:(NSString *)backPic
mgId:(NSString *)mgId;
///福袋礼物爆出的礼物的bug
///进入房间的时候需要获取一次礼物信息 因为如果有人送礼物的话 如果是福袋礼物的话 爆出的礼物需要从礼物列表中获取 会导致公屏不显示那个礼物

View File

@@ -97,11 +97,13 @@
/// @param roomPwd
/// @param roomDesc
/// @param backPic
/// @param mgId id
- (void)openRoom:(NSString *)title
type:(RoomType)type
roomPwd:(NSString *)roomPwd
roomDesc:(NSString *)roomDesc
backPic:(NSString *)backPic {
backPic:(NSString *)backPic
mgId:(NSString *)mgId{
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
if (title.length <= 0) {
@@ -119,13 +121,17 @@
if (backPic.length <= 0) {
backPic = @"";
}
if (mgId.length <= 0) {
mgId = @"";
}
[Api openRoom:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomInfoModel * infoModel = [RoomInfoModel modelWithJSON:data.data];
[[self getView] openRoomSuccess:infoModel];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] enterRoomFail:code];
} showLoading:YES] title:title type:type roomPwd:roomPwd roomDesc:roomDesc backPic:backPic uid:uid ticket:ticket];
} showLoading:YES] title:title type:type roomPwd:roomPwd roomDesc:roomDesc backPic:backPic uid:uid ticket:ticket mgId:mgId];
}
///bug

View File

@@ -48,7 +48,6 @@
}
- (void)setGameInfo:(LittleGameInfoModel *)gameInfo{
if (gameInfo) {
NSString *encodedUrl = [gameInfo.pic stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
self.logoImageView.imageUrl = gameInfo.pic;
if (gameInfo.isSelect) {
self.logoImageView.layer.borderWidth = 2;

View File

@@ -8,9 +8,12 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class RoomInfoModel;
@interface XPLittleGameRoomOpenView : UIView
///当前房间的信息
@property (nonatomic,weak) UIViewController *currentVC;
///当前房间的信息
@property (nonatomic,strong) RoomInfoModel *roomInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -14,10 +14,17 @@
#import "TTPopup.h"
#import "XPMacro.h"
#import "Api+LittleGame.h"
#import "AccountInfoStorage.h"
#import "DESEncrypt.h"
#import "XPConstant.h"
#import "Api+RoomSetting.h"
#import "XCHudTool.h"
///Model
#import "LittleGameInfoModel.h"
#import "RoomInfoModel.h"
///View
#import "XPCreateLittleGameCollectionViewCell.h"
#import "XPRoomViewController.h"
@interface XPLittleGameRoomOpenView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///
@@ -127,16 +134,16 @@
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(118);
}];
[self.normalRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(135);
make.width.mas_equalTo(KScreenWidth - 16 * 2);
}];
[self.gameRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(135);
make.width.mas_equalTo(125);
}];
[self.normalRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(125);
}];
[self.modelStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(65);
}];
@@ -186,6 +193,20 @@
[TTPopup dismiss];
}
- (void)createRoomButtonAction:(UIButton *)sender {
if (self.normalRoomButton.selected) {
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid viewController:self.currentVC];
}else {
RoomInfoModel * roomInfo = self.roomInfo;
if (self.selectGameInfo.mgId.length > 0 && roomInfo) {
[XPRoomViewController openRoom:[AccountInfoStorage instance].getUid mgId:self.selectGameInfo.mgId viewController:self.currentVC];
} else {
[XCHUDTool showErrorWithMessage:@"请求房间信息失败请重试!"];
[TTPopup dismiss];
}
}
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
@@ -220,7 +241,7 @@
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.alignment = UIStackViewAlignmentLeading;
_stackView.spacing = 16;
}
return _stackView;
@@ -261,6 +282,7 @@
[_normalRoomButton setImage:[UIImage imageNamed:@"room_little_game_normal_room"] forState:UIControlStateNormal];
[_normalRoomButton setImage:[UIImage imageNamed:@"room_little_game_normal_room_select"] forState:UIControlStateSelected];
[_normalRoomButton addTarget:self action:@selector(normalRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_normalRoomButton.selected = YES;
}
return _normalRoomButton;
}
@@ -271,6 +293,7 @@
[_gameRoomButton setImage:[UIImage imageNamed:@"room_little_game_game_room"] forState:UIControlStateNormal];
[_gameRoomButton setImage:[UIImage imageNamed:@"room_little_game_game_room_select"] forState:UIControlStateSelected];
[_gameRoomButton addTarget:self action:@selector(gameRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_gameRoomButton.selected = NO;
}
return _gameRoomButton;
}
@@ -284,6 +307,7 @@
_createRoomButton.titleLabel.textColor = [ThemeColor confirmButtonTextColor];
_createRoomButton.layer.cornerRadius = 20;
_createRoomButton.layer.masksToBounds = YES;
[_createRoomButton addTarget:self action:@selector(createRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _createRoomButton;
}

View File

@@ -26,6 +26,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (BOOL)openRoom:(NSString*)roomUid fromNick:(NSString * __nullable)fromNick fromType:(UserEnterRoomFromType)fromType fromUid:(NSString * __nullable)fromUid viewController:(UIViewController*)viewController;
/** XPRoomViewController 不允许外部 init ,请通过该方法启动房间。
* @params roomUid 房主uid
* @params viewController 启动方
* @params mgId 小游戏的id
*/
+ (BOOL)openRoom:(NSString*)roomUid mgId:(NSString *)mgId viewController:(UIViewController*)viewController;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (id)copy NS_UNAVAILABLE;

View File

@@ -74,6 +74,8 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
@property (nonatomic,strong) XPRoomFunctionContainerView *functionView;
///Uid
@property (nonatomic,copy) NSString * roomUid;
///id
@property (nonatomic,copy) NSString *mgId;
///
@property (nonatomic,strong) UserInfoModel *userInfo;
///
@@ -104,6 +106,21 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
return YES;
}
/** XPRoomViewController init
* @params roomUid uid
* @params viewController
* @params mgId id
*/
+ (BOOL)openRoom:(NSString*)roomUid mgId:(NSString *)mgId viewController:(UIViewController*)viewController {
XPRoomViewController * roomVC = [[self alloc] init];
roomVC.roomUid = roomUid;
roomVC.mgId = mgId;
BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC];
baseNav.modalPresentationStyle = UIModalPresentationFullScreen;
[viewController presentViewController:baseNav animated:YES completion:nil];
return YES;
}
- (void)dealloc {
#warning to dox -
@@ -378,10 +395,14 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
} else { //
if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { //
if (roomInfo.roomId > 0) { // 使
[self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@""];
[self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:self.mgId];
} else { //
NSString* title = [NSString stringWithFormat:@"%@的房间", userInfo.nick];
[self.presenter openRoom:title type:RoomType_Game roomPwd:@"" roomDesc:@"" backPic:@""];
RoomType type = RoomType_Game;
if (self.mgId.length > 0) {
type = RoomType_MiniGame;
}
[self.presenter openRoom:title type:type roomPwd:@"" roomDesc:@"" backPic:@"" mgId:self.mgId];
}
} else { //
// TODO: 线