208 lines
7.5 KiB
Objective-C
Executable File
208 lines
7.5 KiB
Objective-C
Executable File
//
|
||
// UIViewController+PushUtils.m
|
||
// buymore
|
||
//
|
||
// Created by yuebin on 2020/6/22.
|
||
// Copyright © 2020 JLC. All rights reserved.
|
||
//
|
||
|
||
#import "UIViewController+PushUtils.h"
|
||
#import "BJMicCreateRoomCtrl.h"
|
||
#import "RCMicRoomViewController.h"
|
||
#import "Room_passRoomView.h"
|
||
#import "BJFloatRoomManager.h"
|
||
#import "SAIdentityAuthVC.h"
|
||
#import "BJRoomManager.h"
|
||
#import "BJWebVC.h"
|
||
#import "SPWalletContainerVC.h"
|
||
#import "SPWalletJinbiVC.h"
|
||
|
||
@implementation UIViewController (PushUtils)
|
||
|
||
|
||
- (void)closeSelfAndPush:(UIViewController *)vc {
|
||
NSArray *viewControlles = self.navigationController.viewControllers;
|
||
NSMutableArray *newviewControlles = [NSMutableArray array];
|
||
if ([viewControlles count] > 0) {
|
||
for (int i=0; i < [viewControlles count]-1; i++) {
|
||
[newviewControlles addObject:[viewControlles objectAtIndex:i]];
|
||
}
|
||
}
|
||
[newviewControlles addObject:vc];
|
||
[self.navigationController setViewControllers:newviewControlles animated:YES];
|
||
}
|
||
|
||
- (void)pushSelf {
|
||
[UIViewController.currentViewController.navigationController pushViewController:self animated:YES];
|
||
}
|
||
|
||
- (void)popOrDismissSelf {
|
||
if (UIViewController.currentViewController.navigationController) {
|
||
[UIViewController.currentViewController.navigationController popViewControllerAnimated:YES];
|
||
}else {
|
||
[self dismissViewControllerAnimated:YES completion:nil];
|
||
}
|
||
}
|
||
|
||
|
||
#pragma mark - 去到各种控制器
|
||
|
||
+ (void)goWebWithUrl:(NSString *)webUrl {
|
||
if (![webUrl isKindOfClass:NSString.class]) {
|
||
return;
|
||
}
|
||
|
||
BJWebVC *next = [[BJWebVC alloc] init];
|
||
next.webUrl = C_string(webUrl);
|
||
next.useH5NavBar = 0;
|
||
[next pushSelf];
|
||
}
|
||
|
||
+ (void)goRoomSetWithId:(NSString *)rid roomInfo:(nonnull void (^)(void))roomSetBLock{
|
||
NSDictionary *dict = @{@"rid":C_string(rid)};
|
||
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
[paras addEntriesFromDictionary:dict];
|
||
|
||
[SVProgressHUD showWithStatus:nil];
|
||
[RCMicHTTP postWithURLString:@"/api/room/get_room_info" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
[SVProgressHUD dismiss];
|
||
if (result.success) {
|
||
if (result.errorCode == 200) {
|
||
//已经创建过语音房了
|
||
BJMicCreateRoomCtrl *next = [[BJMicCreateRoomCtrl alloc] init];
|
||
next.roomDict = result.content;
|
||
next.finishRoomSet = ^{
|
||
roomSetBLock();
|
||
};
|
||
[next pushSelf];
|
||
}
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
}
|
||
}];
|
||
}
|
||
|
||
+ (void)roomOwnerGoSelfRoom {
|
||
if ([GVUSER.rawUserDict safeIntForKey:@"is_real"] == 2) {
|
||
[SAIdentityAuthVC.new pushSelf];
|
||
return;
|
||
}else if ([GVUSER.rawUserDict safeIntForKey:@"is_real"] == 3) {
|
||
[SVProgressHUD showInfoWithStatus:@"实名认证审核中"];
|
||
return;
|
||
}
|
||
|
||
NSDictionary *dict = @{};
|
||
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
[paras addEntriesFromDictionary:dict];
|
||
|
||
[SVProgressHUD showWithStatus:nil];
|
||
[RCMicHTTP postWithURLString:@"/api/room/user_get_room_info" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
[SVProgressHUD dismiss];
|
||
if (result.success) {
|
||
if (result.errorCode == 200 || [result.content isKindOfClass:NSDictionary.class]) {
|
||
//已经创建过语音房了
|
||
NSString *roomId = [result.content safeStringForKey:@"rid"];
|
||
NSString *pwd = [result.content safeStringForKey:@"room_password"];
|
||
[UIViewController goMicRoomWithRid:roomId withPwd:pwd];
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:result.message];
|
||
}
|
||
}else {
|
||
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
}
|
||
}];
|
||
}
|
||
|
||
+ (void)goMicRoomWithRid:(NSString *)rId withPwd:(NSString *)pwd {
|
||
[BJRoomManager goMicRoomWithRid:rId withPwd:pwd];
|
||
|
||
// if (BJFloatRoomManager.sharedBJFloatRoomManager.viewModel) {
|
||
// if ([BJFloatRoomManager.sharedBJFloatRoomManager.viewModel.roomInfo.roomId isEqualToString:rId]) {
|
||
// [BJFloatRoomManager.sharedBJFloatRoomManager reEnterSameRoom];
|
||
// return;
|
||
// }else {
|
||
// [BJFloatRoomManager.sharedBJFloatRoomManager closeFloatWindow];
|
||
// }
|
||
// }
|
||
// NSDictionary *dict = @{@"rid":C_string(rId)};
|
||
// NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
||
// [paras addEntriesFromDictionary:dict];
|
||
// if (pwd.length > 0) {
|
||
// [paras setObject:C_string(pwd) forKey:@"password"];
|
||
// }
|
||
//
|
||
// [SVProgressHUD showWithStatus:nil];
|
||
// [RCMicHTTP postWithURLString:@"/api/room/enter_room_info" parameters:paras response:^(RCMicHTTPResult *result) {
|
||
// [SVProgressHUD dismiss];
|
||
// if (result.success) {
|
||
// if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
|
||
//
|
||
// RCMicRoomInfo *model = [RCMicRoomInfo mj_objectWithKeyValues:result.content];
|
||
// if (model.room_status.integerValue == 1) {
|
||
//
|
||
// RCMicRoleType type = RCMicRoleType_Audience;
|
||
// if ([GVUSER.rid integerValue]==[model.roomId integerValue]) {
|
||
// //如果是自己的房间,type传主播
|
||
// type = RCMicRoleType_Host;
|
||
// }
|
||
// GVUSER.publicType = @"0";
|
||
// GVUSER.is_calculator = model.is_calculator;
|
||
// //每次进入房间之前,默认公屏筛选是0,全部
|
||
// RCMicRoomViewController *next = [[RCMicRoomViewController alloc] initWithRoomInfo:model Role:type]; //退出房间不保持,所以刚进来都是audience
|
||
// [next pushSelf];
|
||
// }else {
|
||
// [SVProgressHUD showInfoWithStatus:@"房间被封禁或关闭"];
|
||
// }
|
||
// }else {
|
||
// if (result.errorCode==202) {
|
||
// //表示密码房间
|
||
// Room_passRoomView *view = [[NSBundle mainBundle] loadNibNamed:@"Room_passRoomView" owner:nil options:nil].lastObject;
|
||
// [MainWindow() addSubview:view];
|
||
// view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
|
||
// view.passBlock = ^(NSString * passText) {
|
||
// [UIViewController goMicRoomWithRid:rId withPwd:passText];
|
||
// };
|
||
//
|
||
// }else{
|
||
// [SVProgressHUD showInfoWithStatus:result.message];
|
||
// }
|
||
// }
|
||
// }else {
|
||
// [SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||
// }
|
||
// }];
|
||
}
|
||
+ (void)goUserMainpageWith:(NSString *)userid withRid:(NSString *)rid{
|
||
SPHomepageVC *vc = [[SPHomepageVC alloc] init];
|
||
vc.userId = userid;
|
||
[vc pushSelf];
|
||
}
|
||
|
||
+ (void)goPeiwanPageWith:(NSString *)userid {
|
||
|
||
}
|
||
|
||
+ (void)goRechageCtrl {
|
||
SPWalletJinbiVC *Jinbiv = [[SPWalletJinbiVC alloc] init];
|
||
[Jinbiv pushSelf];
|
||
}
|
||
+ (void)goRankPageWithRid:(NSString *)rid{
|
||
// QQRankVC *vc = [QQRankVC new];
|
||
// vc.type = 1;
|
||
// vc.rid = rid;
|
||
// [vc pushSelf];
|
||
}
|
||
|
||
+ (void)goUserAlertWithUid:(NSString *)uid {
|
||
RCMicRoomViewController *curRoom;
|
||
for (UIViewController *each in UIViewController.currentViewController.navigationController.viewControllers) {
|
||
if ([each isKindOfClass:RCMicRoomViewController.class]) {
|
||
curRoom = (RCMicRoomViewController *)each;
|
||
break;
|
||
}
|
||
}
|
||
[curRoom onRankPopUserAlert:uid];
|
||
}
|
||
|
||
@end
|