Files
yuyin_ios/SweetParty/Expand/YBKit/UIViewController+PushUtils.m

208 lines
7.5 KiB
Mathematica
Raw Normal View History

2025-08-08 11:05:33 +08:00
//
// 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