| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786 |
- //
- // MOSquareListVC.m
- // MiMoLive
- //
- // Created by SuperC on 2023/10/17.
- //
- #define SetBtnWidthAndHeight 26.0
- //一页的size
- #define kPageSize 30
- #define kCollectionViewLeftAndRight 13.0
- #define kShowTopRightActivityBubbleKey @"kShowTopRightActivityBubbleKey"
- #import <Foundation/Foundation.h>
- #import "MOSquareListVC.h"
- #import "MOSquareTopMenuView.h"
- #import "MONewSquareTopMenuView.h"
- #import "MOScrollMenuView.h"
- #import "MOLiveCell.h"
- #import "MOShowLivePagesVC.h"
- #import "MOFollowInfoView.h"
- #import "MOFollowNoDataView.h"
- #import "MOSquareBaseCollectionView.h"
- //Banner
- //#import "MOSquareBannerReusableView.h"
- #import "MOLiveBase.h"
- #import "MOLiveList.h"
- #import "MOCountryBaseData.h"
- #import "MOCountryList.h"
- #import "MOMoreCountryView.h"
- #import "MOSearchUserVC.h"
- #import "MOWatchHistoryVC.h"
- #import "MONoMoreDataView.h"
- #import "MOWebViewController.h"
- #import "UIDevice+MOAddition.h"
- #import "MOWameListVC.h"
- #import "MOActivityManageView.h"
- #import "MOThemeManager.h"
- #import "MOHomeHeaderView.h"
- #import "MONewComerGiftView.h"
- #import "MOActivityCenterVC.h"
- #import "MOTeDownloadView.h"
- #import "MOBeautyDownloadManager.h"
- #import "MOCreateLiveVC.h"
- #import "MOClickConfigManager.h"
- #import "MOWebViewController.h"
- #import <AVFoundation/AVFoundation.h>
- @interface MOSquareListVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
- /** 顶部背景*/
- @property (nonatomic, strong) UIImageView *topBgView;
- @property (nonatomic, strong) MOHomeHeaderView *headerView;
- @property (nonatomic, strong) MOJumpList *jumpData;
- @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @property (nonatomic, strong) MOSquareBaseCollectionView *hotTabView;//热门tab
- /** 右下角入口 */
- @property (nonatomic, strong) UIStackView *entranceStackView;
- @property (nonatomic, strong) UIButton *rechargeButton;
- @property (nonatomic, strong) UIButton *taskButton;
- @property (nonatomic, strong) UIButton *liveButton;
- @property (nonatomic, copy) NSArray *dialogsArray;//弹窗数据
- @property (nonatomic, strong) MOTeDownloadView *downloadView;
- @end
- @implementation MOSquareListVC
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [super touchesBegan:touches withEvent:event];
-
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- [self.navigationController setNavigationBarHidden:YES animated:animated];
-
- [[MOMainTabController sharedSingleton] showTabbarWithAnimation:NO];
- [self checkIfNeedShowNewUserGiftView];
-
- if (self.homePageShowBlock) {
- self.homePageShowBlock();
- }
- }
- - (void)checkIfNeedShowNewUserGiftView {
- MODialogsData *giftModel = (MODialogsData *)[[MODataCache sharedYYCache] objectForKey:kNewUserGiftPack];
- if (giftModel) {
- [self showNewComerGiftViewWithModel:giftModel];
- }
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self setupUI];
-
- [self addNotification];
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self checkHaveActivityView];
- }
- - (void)addNotification{
- ReceiveNotification(@selector(beginRefreshData), @"MOSquareListVC_Refresh")//其他设备登录
- ReceiveNotification(@selector(toShowH5VCWith:), @"MOSquareListVC_H5Jump")//H5点击跳转
- ReceiveNotification(@selector(toUpdataTheFirstRecharge:), @"MOFirstRecharge_UpdataView")//首冲图层更新
- // ReceiveNotification(@selector(updateTheSignInView), @"MOSquareListVC_ShowSignInView")//活动入口
- ReceiveNotification(@selector(toShowActivityManageViewWith:), @"Noti_MOActivityManageView")//活动弹窗
- ReceiveNotification(@selector(setupUI), @"kNotification_RefreshTheme")//更新主题
- ReceiveNotification(@selector(toHandleNewComerGiftNotification:), @"kNotification_ShowNewComerGiftView")//新人礼包弹窗
- ReceiveNotification(@selector(updateFirstRechargeWithChangeLanguage), @"kNotification_ChangeLanguage")//改变语言刷新
- }
- - (void)toHandleNewComerGiftNotification:(NSNotification *)notification {
- MODialogsData *model = (MODialogsData *)notification.object;
-
- dispatch_async(dispatch_get_main_queue(), ^{
- if (!(self.isViewLoaded && self.view.window)) {//不在当前页面,不弹窗
- return;
- }
- [self showNewComerGiftViewWithModel:model];
- });
- }
- - (void)showNewComerGiftViewWithModel:(MODialogsData *)dialogModel {
- MONewComerGiftView *newComerGiftView = [[MONewComerGiftView alloc] init];
- WEAKSELF
- newComerGiftView.getBlock = ^{
- [kHttpManager claimNewUserGiftPackWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_2_new_user_get_success")];
- } else{
- NSString *errorString = [MODataManager objectOrNilForKey:@"msg" fromDictionary:data];
- [MBProgressHUD showTipMessageInView:errorString];
- }
- }];
- };
- newComerGiftView.dismissBlock = ^{
- [weakSelf performSelector:@selector(showEnterRoomGuideView) withObject:nil afterDelay:2.0];
- };
- newComerGiftView.model = dialogModel;
- [newComerGiftView show];
-
- [[MODataCache sharedYYCache] removeObjectForKey:kNewUserGiftPack];
- }
- - (void)showEnterRoomGuideView {
- [self.hotTabView showEnterRoomGuideView];
- }
- - (void)checkHaveActivityView{
-
- UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
- // 递归遍历所有子视图
- for (UIView *subview in keyWindow.subviews) {
- if ([subview isKindOfClass:[MOActivityManageView class]]) {
- subview.hidden = NO;
-
- [UIView animateWithDuration:0.3 animations:^{
- [self.view layoutIfNeeded];
- }];
-
- break;
- }
- }
- }
- static BOOL MOActivityManageViewTag = NO;
- - (void)toShowActivityManageViewWith:(NSNotification *)noti{
- NSArray *dataArr = noti.object;
- self.dialogsArray = [dataArr copy];
- if(MOActivityManageViewTag){
- return;
- }
-
- MOActivityManageViewTag = YES;
- [self performSelector:@selector(updateMOActivityManageViewTag) withObject:nil afterDelay:1.0];
-
- if(self){
- MOActivityManageView *view = [MOActivityManageView moActivityManageView];
- view.codesArr = dataArr;
- [view showActivityManageView];
- }
- }
- - (void)updateMOActivityManageViewTag{
- MOActivityManageViewTag = NO;
- }
- - (void)toUpdataTheFirstRecharge:(NSNotification *)noti{
- NSArray *floatingsArr = noti.object;
- [self.entranceStackView removeArrangedSubview:self.rechargeButton];
- if (floatingsArr.count > 0) {
- [self.entranceStackView insertArrangedSubview:self.rechargeButton atIndex:0];
- }
- }
- - (void)updateFirstRechargeWithChangeLanguage {
- //置空重新走懒加载方法
- _entranceStackView = nil;
-
- [self.view addSubview:self.entranceStackView];
- [self.entranceStackView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-kBottomSafeAreaInset - 92);
- make.right.mas_equalTo(-12);
- make.width.mas_equalTo(52);
- }];
- }
- - (void)beginRefreshData{
-
-
- WEAKSELF
- [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
- NSInteger theIndex = key.integerValue;
- if(theIndex == weakSelf.titleCategoryView.selectedIndex){
- MOSquareBaseCollectionView *listView = (MOSquareBaseCollectionView *)obj;
- [listView toBeginRefresh];
- }
- }];
- }
- //- (void)updateTheSignInView{
- //
- //}
- - (void)toShowH5VCWith:(NSNotification *)noti{
- MOJumpList *jumpData = noti.object;
- self.jumpData = jumpData;
-
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(toShowH5VC) object:nil];
- [self performSelector:@selector(toShowH5VC) withObject:nil afterDelay:0.5];
- }
- - (void)toShowH5VC{
- MOJumpList *jumpData = self.jumpData;
-
- if(!jumpData){
- return;
- }
- WEAKSELF
- BOOL isURL = [jumpData.jump hasPrefix:@"http://"] || [jumpData.jump hasPrefix:@"https://"];
- if(jumpData.jump.length != 0 && isURL){
-
- MOMainTabController *mainTabbar = [MOMainTabController sharedSingleton];
- UINavigationController *nav = mainTabbar.selectedViewController;
-
- UINavigationController *baseNav = nav;
- if (nav.presentedViewController) {
- if ([nav isKindOfClass:[UINavigationController class]]) {
- UINavigationController *presentingNavigationController = (UINavigationController *)nav.presentedViewController;
- baseNav = presentingNavigationController;
-
- BOOL isHaveLive = NO;
-
- for (UIViewController *vc in presentingNavigationController.viewControllers) {
- if([vc isKindOfClass:[MOShowLivePagesVC class]]){
- isHaveLive = YES;
- break;
- }
- }
-
- //直播间的触发逻辑 (例如直播间的快速充值里面的广告栏)
- if(isHaveLive){
- UINavigationController *presentingNavigationController = (UINavigationController *)nav.presentedViewController;
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- NSString *urlStr = jumpData.jump;
- vc.webUrl = [NSURL URLWithString:urlStr];
- if(jumpData.target == 2){
- vc.isHalfShow = YES;
- UINavigationController *newNav = [[UINavigationController alloc] initWithRootViewController:vc];
- newNav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- [presentingNavigationController presentViewController:newNav animated:YES completion:nil];
- }
- else{
- if(jumpData.title.length != 0){
- vc.titleStr = jumpData.title;
- }
- vc.hidesBottomBarWhenPushed = YES;
- [presentingNavigationController mo_pushViewController:vc animated:YES];
- }
- return;
- }
- }
- }
-
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- vc.isFirstAdWeb = jumpData.isFirstAdWeb;
- NSString *urlStr = jumpData.jump;
- vc.webUrl = [NSURL URLWithString:urlStr];
- vc.closeViewBlock = ^{
- if(weakSelf.jumpData.isFirstAdWeb){
- //开屏广告关闭, 需要弹出相应的弹窗
- MOMainTabController *mainTabbar = [MOMainTabController sharedSingleton];
- [mainTabbar ChangeNeedShowAlert];
- }
- };
- if(jumpData.target == 2){
- vc.isHalfShow = YES;
- UINavigationController *newNav = [[UINavigationController alloc] initWithRootViewController:vc];
- newNav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- [mainTabbar presentViewController:newNav animated:YES completion:nil];
- }
- else{
- if(jumpData.title.length != 0){
- vc.titleStr = jumpData.title;
- }
- vc.hidesBottomBarWhenPushed = YES;
- [baseNav mo_pushViewController:vc animated:YES];
- }
- }
- else if([jumpData.jump containsString:@"mimo://"]){
- NSURL *urlUrl = [NSURL URLWithString:jumpData.jump];
-
- if ([[UIApplication sharedApplication] canOpenURL:urlUrl])
- {
- [[UIApplication sharedApplication] openURL:urlUrl];
- }
- }
- }
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- #pragma mark - UI
- - (void)setupUI{
- self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
-
- [self.view addSubview:self.topBgView];
- [self.topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.equalTo(self.view);
- make.height.mas_equalTo(kScaleWidth(SCREENWIDTH));
- }];
-
- if ([MOThemeManager shareManager].canUseTheme && [MOThemeManager shareManager].themeModel.slideBackgroundMain) {
- [self.topBgView sd_setImageWithURL:[NSURL URLWithString:[MOThemeManager shareManager].themeModel.slideBackgroundMain]];
- } else {
- [self.topBgView setImage:[UIImage imageNamed:@"img_home_top_bg"]];
- }
-
- [self.view addSubview:self.headerView];
- [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(kTopSafeAreaInset);
- make.left.right.mas_equalTo(0);
- make.height.mas_equalTo(48);
- }];
- // NSArray *titleDataArr = @[NSLocalString(@"mimo_square_Follow"),NSLocalString(@"mimo_square_LIVE"),NSLocalString(@"mimo_square_Newstar")];
- NSArray *titleDataArr = @[NSLocalString(@"mimo_square_LIVE"),NSLocalString(@"mimo_square_Newstar"),NSLocalString(@"mimo_square_Follow")];
- CGFloat titleWidth = 0.0;
- for (NSString *titleStr in titleDataArr) {
- CGFloat width = [MOTools getWidthWithString:titleStr font:[MOTextTools poppinsExtraBoldFont:20]];
- titleWidth = titleWidth + width + 24.0;
- }
-
- [self.view addSubview:self.titleCategoryView];
- [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(6.0);
- make.top.equalTo(self.headerView.mas_bottom);
- make.width.mas_equalTo(titleWidth);
- make.height.mas_equalTo(48);
- }];
-
- self.titleCategoryView.titles = titleDataArr;
- self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:0.7];
- self.titleCategoryView.titleSelectedColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
- if ([MOThemeManager shareManager].canUseTheme) {
- if ([MOThemeManager shareManager].themeModel.titleColor.length > 0) {
- self.titleCategoryView.titleColor = [MOTools colorWithHexString:[MOThemeManager shareManager].themeModel.titleColor];
- }
- if ([MOThemeManager shareManager].themeModel.titleColorOn.length > 0) {
- self.titleCategoryView.titleSelectedColor = [MOTools colorWithHexString:[MOThemeManager shareManager].themeModel.titleColorOn];
- }
- }
-
- self.titleCategoryView.titleFont = [MOTextTools poppinsBoldFont:18];
- self.titleCategoryView.titleSelectedFont = [MOTextTools poppinsExtraBoldFont:26];
- self.titleCategoryView.backgroundColor = [UIColor clearColor];
- self.titleCategoryView.defaultSelectedIndex = 0;
- self.titleCategoryView.cellSpacing = 24.0;
- self.titleCategoryView.contentEdgeInsetLeft = 12.0;
-
- JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundView.indicatorHeight = 12;
- backgroundView.indicatorWidth = 47.0;
- backgroundView.indicatorWidthIncrement = 0;
- backgroundView.indicatorColor = [UIColor clearColor];
- backgroundView.componentPosition = JXCategoryComponentPosition_Bottom;
- backgroundView.verticalMargin = -15.0;
-
- UIImageView *imgBgView = [[UIImageView alloc] init];
- imgBgView.contentMode = UIViewContentModeScaleToFill;
- [imgBgView setImage:[UIImage imageNamed:@"icon_home_line_bottom"]];
- if ([MOThemeManager shareManager].canUseTheme && [MOThemeManager shareManager].themeModel.titleBottom.length > 0) {
- [imgBgView sd_setImageWithURL:[NSURL URLWithString:[MOThemeManager shareManager].themeModel.titleBottom]];
- }
- [backgroundView addSubview:imgBgView];
- [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backgroundView);
- }];
- self.titleCategoryView.indicators = @[backgroundView];
-
- [self.view addSubview:self.listContainerView];
- [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleCategoryView.mas_bottom).offset(10.0);
- make.left.right.bottom.equalTo(self.view);
- }];
- self.titleCategoryView.listContainer = self.listContainerView;
-
- [self.view addSubview:self.entranceStackView];
- [self.entranceStackView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-kBottomSafeAreaInset - 92);
- make.right.mas_equalTo(-12);
- make.width.mas_equalTo(52);
- }];
- }
- // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
- MOLogV(@"变换了");
- }
- #pragma mark - JXCategoryListContainerViewDelegate
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
- return self.titleCategoryView.titles.count;
- }
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
-
- BOOL isFollow = NO;
- if(index == 2){//关注
- isFollow = YES;
- }
-
- WEAKSELF
- MOSquareBaseCollectionView *view = [[MOSquareBaseCollectionView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT) AndIsFollow:isFollow];
- view.beginScrollBlock = ^{
- [NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:@selector(showEnterRoomGuideView) object:nil];
- };
- if(index == 0){//热门
- self.hotTabView = view;
- view.searchType = 2;
- }
- else if (index == 1){//新人
- view.searchType = 4;
- }
- view.isFollow = isFollow;
- view.homeVC = self;
- return view;
- }
- - (void)listContainerViewDidScroll:(UIScrollView *)scrollView {
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- }
- - (void)liveButtonAction {
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- BOOL isAnchor = GetIsAnchor;
- if (!isAnchor) {
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_live_tip_no_anchor")];
- return;
- }
-
- [self toOpenTheLiveRoom];
- }
- - (void)toOpenTheLiveRoom {
-
- //个人信息对象
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- if(userInfoData.userProfile.mysterious){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_2_vip_mystery_man_tip_2")];
- return;
- }
-
- BOOL isHaveBeautyRes = [TEDownloader toCheckTheBeautyRes];
- if(!isHaveBeautyRes){
- [[MOBeautyDownloadManager shareManager] checkAndDownloadBeautyData];
- WEAKSELF
- [MOBeautyDownloadManager shareManager].progressBlock = ^(CGFloat progress) {
- weakSelf.downloadView.hidden = NO;
- weakSelf.downloadView.progress = progress;
- };
- [MOBeautyDownloadManager shareManager].completeBlock = ^{
- weakSelf.downloadView.hidden = YES;
- };
- return;
- }
- WEAKSELF
- [kHttpManager theAnchorGetLiveRoomWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MOLiveDetail *dataModel = [MOLiveDetail modelObjectWithDictionary:data[@"data"]];
-
- if(dataModel.currentRoom.id.length > 0){
- [weakSelf toCloseTheRoomOrContinueWith:dataModel];
- }
- else{
- MOCreateLiveVC *vc = [[MOCreateLiveVC alloc] init];
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [weakSelf presentViewController:nav animated:YES completion:nil];
- }
- }
- else{
- kShowNetError(data)
- MOLogV(@"theAnchorGetLiveRoomWithParams 接口报错了");
- }
- }];
- }
- - (void)toCloseTheRoomOrContinueWith:(MOLiveDetail *)model{
-
- WEAKSELF
- if(model.currentRoom.id.length > 0){
- //中心弹窗
- MOTitleNormalAlertView *alertView = [[MOTitleNormalAlertView alloc] init];
- alertView.subTitleLabel.text = NSLocalString(@"mimo_room_living_open_tip");
- [alertView.cancelBtn setTitle:NSLocalString(@"mimo_room_living_close_living") forState:UIControlStateNormal];
- [alertView.confirmBtn setTitle:NSLocalString(@"mimo_room_living_continue_living") forState:UIControlStateNormal];
- alertView.isStrongBg = YES;
- alertView.cancelBlock = ^{
- [weakSelf toCloseTheLiveRoomWithRoomId:model.currentRoom.id];
- };
- alertView.confirmBlock = ^{
- [weakSelf toShowRoomWith:model];
- };
- [alertView show];
- }
- }
- //关闭直播间
- - (void)toCloseTheLiveRoomWithRoomId:(NSString *)roomId{
- WEAKSELF
- NSDictionary *dict = @{@"id":roomId};
- [kHttpManager toCloseTheLiveRoomWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- MOLogV(@"关闭直播间接口调用");
- [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_room_end_tip_anchor")];
- SendNotification(@"MOSquareListVC_Refresh");
- }];
- }
- - (void)toShowRoomWith:(MOLiveDetail *)model{
-
- //MARK 检查用户是否对摄像头麦克风授权,未授权不能调用录制功能
- AVAuthorizationStatus videoStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
- AVAuthorizationStatus audioStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
-
- //没有打开摄像头权限
- if(videoStatus != AVAuthorizationStatusAuthorized){
- [MOCreateLiveVC requestCameraPermissionWithCompletion:^(BOOL open) {
- if(!open){
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalString(@"mimo_get_video_authority_fail_tip") message:NSLocalString(@"mimo_get_video_authority_fail_content_tip") delegate:self cancelButtonTitle:NSLocalString(@"mimo_get_video_authority_normal_sure") otherButtonTitles:NSLocalString(@"mimo_get_video_authority_go_sure"), nil];
- [alert show];
- }
- }];
- return;
- }
-
- //没有打开麦克风权限
- if(audioStatus != AVAuthorizationStatusAuthorized){
- [MOCreateLiveVC requestAudioPermissionWithCompletion:^(BOOL open) {
- if(!open){
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalString(@"mimo_get_audio_authority_fail_tip") message:NSLocalString(@"mimo_get_audio_authority_fail_content_tip") delegate:self cancelButtonTitle:NSLocalString(@"mimo_get_video_authority_normal_sure") otherButtonTitles:NSLocalString(@"mimo_get_video_authority_go_sure"), nil];
- [alert show];
- }
- }];
- return;
- }
-
- [MOShowAgoraKitManager shareManager].isCreatLive = YES;
-
- MOClickConfigManager *configManager = [MOClickConfigManager shareManager];
- configManager.durationTask = model.durationTask;
-
- MOShowLivePagesVC *vc = [[MOShowLivePagesVC alloc] init];
- vc.isCreatLive = YES;
- vc.userType = MOShowLiveAnchorType;
- vc.roomList = @[model.currentRoom].mutableCopy;
- vc.liveModel = model;
- vc.isNeedSetBeauty = YES;
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:nav animated:YES completion:nil];
- }
- - (void)taskButtonAction {
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- NSString *urlStr = [NSString stringWithFormat:@"%@/#/taskCenter?tagName=dailyTasks",kNetPath_Web_Base];
- vc.webUrl = [NSURL URLWithString:urlStr];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController mo_pushViewController:vc animated:YES];
- }
- - (void)rechargeButtonAction {
- [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showEnterRoomGuideView) object:nil];
- NSMutableArray *dataArr = [NSMutableArray array];
- for (MODialogsData *object in self.dialogsArray) {
- if(object.type > 0 && object.type < 4){
- [dataArr addObject:object];
- }
- }
-
- NSArray *sortedArray = [dataArr sortedArrayUsingComparator:^NSComparisonResult(MODialogsData * obj1, MODialogsData * obj2) {
- if (obj1.type == 2 && obj2.type != 2) {
- return NSOrderedAscending; // obj1排在前面
- }
- if (obj2.type == 2 && obj1.type != 2) {
- return NSOrderedDescending; // obj2排在前面
- }
-
- if (obj1.type == 1 && obj2.type != 1) {
- return NSOrderedAscending; // obj1排在前面
- }
- if (obj2.type == 1 && obj1.type != 1) {
- return NSOrderedDescending; // obj2排在前面
- }
-
- return NSOrderedSame; // 如果 type 相等,保持原顺序
- }];
-
- MOActivityManageView *view = [MOActivityManageView moActivityManageView];
- view.codesArr = sortedArray;
- [view showActivityManageView];
- }
- - (void)updateDownloadBeautyData:(CGFloat)progress {
- self.downloadView.hidden = NO;
- self.downloadView.progress = progress;
- }
- - (void)downloadBeautyDataSuccess {
- self.downloadView.hidden = YES;
- }
- #pragma mark - Lazy
- - (UIImageView *)topBgView{
- if (!_topBgView)
- {
- _topBgView = [[UIImageView alloc] init];
- _topBgView.clipsToBounds = YES;
- _topBgView.userInteractionEnabled = NO;
- _topBgView.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _topBgView;
- }
- - (MOHomeHeaderView *)headerView {
- if (!_headerView) {
- _headerView = [[MOHomeHeaderView alloc] init];
- WEAKSELF
- _headerView.searchActionBlock = ^{
- [weakSelf searchBtnClick];
- };
- _headerView.historyActionBlock = ^{
- [weakSelf historyBtnClick];
- };
- }
- return _headerView;
- }
- //MARK: 查找页面
- - (void)searchBtnClick{
- MOSearchUserVC *vc = [[MOSearchUserVC alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController mo_pushViewController:vc animated:YES];
- }
- //MARK: 历史记录页面
- - (void)historyBtnClick{
- MOWatchHistoryVC *vc = [[MOWatchHistoryVC alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController mo_pushViewController:vc animated:YES];
- }
- - (JXCategoryTitleView *)titleCategoryView{
- if(!_titleCategoryView){
- _titleCategoryView = [[JXCategoryTitleView alloc] init];
- _titleCategoryView.delegate = self;
- }
- return _titleCategoryView;
- }
- - (JXCategoryListContainerView *)listContainerView{
- if(!_listContainerView){
- _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- }
- return _listContainerView;
- }
- - (UIStackView *)entranceStackView {
- if (!_entranceStackView) {
- _entranceStackView = [[UIStackView alloc] init];
- _entranceStackView.axis = UILayoutConstraintAxisVertical;
- _entranceStackView.spacing = 16;
-
- if ([MOMainTabController sharedSingleton].floatingsArr.count > 0) {
- [_entranceStackView addArrangedSubview:self.rechargeButton];
- }
- [_entranceStackView addArrangedSubview:self.taskButton];
- [_entranceStackView addArrangedSubview:self.liveButton];
- }
- return _entranceStackView;
- }
- - (UIButton *)liveButton {
- if (!_liveButton) {
- _liveButton = [[UIButton alloc] init];
- [_liveButton setImage:[UIImage imageNamed:@"icon_entrance_live"] forState:UIControlStateNormal];
- [_liveButton addTarget:self action:@selector(liveButtonAction) forControlEvents:UIControlEventTouchUpInside];
-
- [_liveButton addSubview:self.downloadView];
- [self.downloadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.mas_equalTo(0);
- }];
- }
- return _liveButton;
- }
- - (MOTeDownloadView *)downloadView{
- if(!_downloadView){
- _downloadView = [[MOTeDownloadView alloc] initWithFrame:CGRectMake(0.0, 0.0, 52.0, 52.0)];
- _downloadView.hidden = YES;
- }
- return _downloadView;
- }
- - (UIButton *)taskButton {
- if (!_taskButton) {
- _taskButton = [[UIButton alloc] init];
- [_taskButton setImage:[UIImage imageNamed:@"icon_entrance_task"] forState:UIControlStateNormal];
- [_taskButton addTarget:self action:@selector(taskButtonAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _taskButton;
- }
- - (UIButton *)rechargeButton {
- if (!_rechargeButton) {
- _rechargeButton = [[UIButton alloc] init];
- [_rechargeButton setImage:[UIImage imageNamed:@"icon_entrance_recharge"] forState:UIControlStateNormal];
- [_rechargeButton addTarget:self action:@selector(rechargeButtonAction) forControlEvents:UIControlEventTouchUpInside];
- }
- return _rechargeButton;
- }
- #pragma mark - 横屏
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
- return UIInterfaceOrientationMaskPortrait;
- }
- @end
|