// // YOUPAIZYShortVideoVC.m // VQU // // Created by Elaine on 2020/11/6. // Copyright © 2020 leo. All rights reserved. // #import "YOUPAIZYShortVideoVC.h" #import "YOUPAIZYVideoModel.h" #import "YOUPAIEyeCatchingWaiterCell.h" #import "ZFPlayer.h" #import "ZFAVPlayerManager.h" #import "YOUPAIZFDouYinControlView.h" #import "YOUPAILZUserShowVC.h" #import "YOUPAILCIMSessionVC.h" #import "YOUPAIZYBiXinVC.h" #import "UIViewController+TFPresent.h" #import "YOUPAIZYVideoHeartGiftModel.h" #import "YOUPAILZCommonGiftView.h" #import "GKPushTransitionAnimation.h" #import "YOUPAIXRWalletVC.h" #import "YOUPAIHRChatRoomGiftView.h" @interface YOUPAIZYShortVideoVC () @property (nonatomic, strong) UITableView *youpaiptableView; @property (nonatomic, strong) ZFPlayerController *youpaipzFplayer; @property (nonatomic, strong) YOUPAIZFDouYinControlView *youpaipcontrolView; @property (nonatomic, strong) NSMutableArray * youpaipmp4UrlArray; @property (nonatomic,strong) NSMutableArray * youpaipvideoDataArray; @property(nonatomic,assign)NSInteger youpaipcurrentPage;//代表当前页码 @property(nonatomic,assign)NSInteger youpaiptotalPage;//总页码 @property(nonatomic,strong)UIImageView *youpaippromptImgView;//提示双击置顶 @property(nonatomic,strong)YOUPAIZYVideoHeartGiftModel *youpaipheartGiftModel; @property (nonatomic,assign)BOOL youpaipisLeavePage;// 是否离开 @property (nonatomic, strong) UIPercentDrivenInteractiveTransition *youpaippercentDrivenTransition; @end @implementation YOUPAIZYShortVideoVC //-(void)viewWillAppear:(BOOL)animated //{ // [super viewWillAppear:animated]; //// self.isLeavePage = NO; // [self.zFplayer.currentPlayerManager play]; // [self.controlView youpaifresetControlView]; // //} - (void)viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; self.youpaipisLeavePage = NO; if(!self.youpaipzFplayer.currentPlayerManager.isPlaying){ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 需要延迟执行的代码 [self.youpaipzFplayer.currentPlayerManager play]; [self.youpaipcontrolView youpaifresetControlView]; }); // [self performSelector:@selector(play) withObject:nil afterDelay:0.25f]; // [self.controlView youpaifresetControlView]; } self.navigationController.delegate = self; } //-(void)viewWillDisappear:(BOOL)animated{ // [super viewWillDisappear:animated]; // self.isLeavePage = YES; // [self.zFplayer.currentPlayerManager pause]; // self.navigationController.delegate = nil; //} - (void)viewDidDisappear:(BOOL)animated{ [super viewDidDisappear:animated]; self.youpaipisLeavePage = YES; [self.youpaipzFplayer.currentPlayerManager pause]; self.navigationController.delegate = nil; } -(void)youpaifdeletePromptImgView { [self.youpaippromptImgView removeFromSuperview]; } -(void)youpaifdisplayPromptImgView { if (![LCSaveData getFirstDisplayVideoDynamicPage] && kAppDelegate.isDisplayVideoDynamicPage) { [LCSaveData saveFirstDisplayVideoDynamicPage:YES]; self.youpaippromptImgView = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth/5.0+KScreenWidth/10.0-KScreenWidth*(135/375.0)/3.0,KScreenHeight-TabbarHeight-KScreenWidth*(135/375.0)*(83/135.0)-10,KScreenWidth*(135/375.0),KScreenWidth*(135/375.0)*(83/135.0))]; self.youpaippromptImgView.image = [UIImage imageNamed:@"vqu_images_double_click"]; [self.view addSubview:self.youpaippromptImgView]; [NSTimer scheduledTimerWithTimeInterval:10.0f target:self selector:@selector(youpaifdeletePromptImgView) userInfo:nil repeats:NO]; } } -(NSMutableArray *)youpaipvideoDataArray { if (!_youpaipvideoDataArray) { _youpaipvideoDataArray = [NSMutableArray array]; } return _youpaipvideoDataArray; } -(NSMutableArray *)youpaipmp4UrlArray { if (!_youpaipmp4UrlArray) { _youpaipmp4UrlArray = [NSMutableArray array]; } return _youpaipmp4UrlArray; } -(void)youpaifsetVideoType:(NSInteger)type andGender:(NSInteger)gender { self.youpaiptype = type; self.youpaipgender = gender; [self.youpaiptableView.mj_header beginRefreshing]; } - (void)youpaifloadNewData{ self.youpaiptableView.mj_footer.hidden = YES; [self.youpaiptableView.mj_footer endRefreshing];//先结束上拉,假如有的话 [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData]; self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)]; self.youpaipcurrentPage = 1; NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:@(self.youpaipcurrentPage) forKey:@"page"]; [dict setObject:@(1) forKey:@"type"]; [dict setObject:@(self.youpaipgender) forKey:@"gender"]; [LCHttpHelper requestWithURLString:TrendsLists parameters:dict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [self.youpaipvideoDataArray removeAllObjects]; [self.youpaipmp4UrlArray removeAllObjects]; self.youpaipheartGiftModel = [YOUPAIZYVideoHeartGiftModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"heart_gift"]]; self.youpaipvideoDataArray = [YOUPAIZYVideoModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"list"]]; self.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue]; NSInteger youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue]; self.youpaipcurrentPage = youpaipcurrentPage; for (YOUPAIZYVideoModel *model in self.youpaipvideoDataArray) { [self.youpaipmp4UrlArray addObject:[NSURL URLWithString:model.youpaipfile_url]]; } NSLog(@"%@",self.youpaipmp4UrlArray); self.youpaipzFplayer.assetURLs = self.youpaipmp4UrlArray; [self.youpaiptableView reloadData]; // __weak typeof(self) weakSelf = self; [self.youpaipzFplayer.currentPlayerManager pause]; if (self.youpaipvideoDataArray.count != 0) { NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self youpaifplayTheVideoAtIndexPath:indexPath]; if (self.youpaipisLeavePage) { [self.youpaipzFplayer.currentPlayerManager pause]; } } // [self.zFplayer zf_filterShouldPlayCellWhileScrolled:^(NSIndexPath *indexPath) { // [weakSelf youpaifplayTheVideoAtIndexPath:indexPath]; // NSLog(@"%@",indexPath); // }]; if (youpaipcurrentPage >= self.youpaiptotalPage) { [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData]; self.youpaiptableView.mj_footer.hidden = YES; } [self.youpaiptableView.mj_header endRefreshing]; }else{ [self.youpaiptableView.mj_header endRefreshing]; } } failure:^(NSError *error) { [self.youpaiptableView.mj_header endRefreshing]; }]; } - (void)youpaifloadMoreData{ //先结束下拉 假如有的话 [self.youpaiptableView.mj_header endRefreshing]; [LCHttpHelper requestWithURLString:TrendsLists parameters:@{@"page":@(self.youpaipcurrentPage+1),@"type":@(1),@"gender":@(self.youpaipgender)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSInteger count = self.youpaipvideoDataArray.count; NSLog(@"count == %ld",count); NSMutableArray* modelArray = [YOUPAIZYVideoModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]]; [self.youpaipvideoDataArray addObjectsFromArray:modelArray]; self.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue]; NSInteger youpaipcurrentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue]; self.youpaipcurrentPage = youpaipcurrentPage; NSLog(@"self.youpaipcurrentPage === %ld---",self.youpaipcurrentPage); for (YOUPAIZYVideoModel *model in modelArray) { [self.youpaipmp4UrlArray addObject:[NSURL URLWithString:model.youpaipfile_url]]; } NSLog(@"count === %ld----%ld",self.youpaipvideoDataArray.count,self.youpaipmp4UrlArray.count); self.youpaipzFplayer.assetURLs = self.youpaipmp4UrlArray; [self.youpaiptableView reloadData]; NSIndexPath* indexPath = [NSIndexPath indexPathForRow:count inSection:0]; [self.youpaiptableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; [self youpaifplayTheVideoAtIndexPath:indexPath]; if (self.youpaipisLeavePage) { [self.youpaipzFplayer.currentPlayerManager pause]; } // __weak typeof(self) weakSelf = self; // [self.zFplayer zf_filterShouldPlayCellWhileScrolled:^(NSIndexPath *indexPath) { // NSLog(@"row == %ld",indexPath.row); // NSIndexPath* index = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:0]; // [self.tableView scrollToRowAtIndexPath:index atScrollPosition:UITableViewScrollPositionTop animated:YES]; // [weakSelf youpaifplayTheVideoAtIndexPath:index]; // }]; if (youpaipcurrentPage>=self.youpaiptotalPage) { [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData]; self.youpaiptableView.mj_footer.hidden = YES; } [self.youpaiptableView.mj_header endRefreshing]; } [self.youpaiptableView.mj_footer endRefreshing]; } failure:^(NSError *error) { [self.youpaiptableView.mj_footer endRefreshing]; }]; } -(void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } -(void)youpaiftoTopAction { if (self.youpaipmp4UrlArray.count > 0) { // NSIndexPath* indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; // [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; [UIView animateWithDuration:0.25f animations:^{ self.youpaiptableView.contentOffset = CGPointMake(0, 0); }]; } if (!self.youpaiptableView.mj_header.isRefreshing) { [self.youpaiptableView.mj_header beginRefreshing]; } } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftoTopAction) name:@"videoToTop" object:nil];//置顶 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangeFollowStateNotification:) name:@"ChangeFollowState" object:nil]; self.navigationController.navigationBarHidden = YES; [self youpaifinitTableView]; // [self getData]; // [self.tableView.mj_header beginRefreshing]; @weakify(self); self.youpaipzFplayer.zf_playerShouldPlayInScrollView = ^(NSIndexPath * _Nonnull indexPath) { NSLog(@"%@",indexPath); @strongify(self); YOUPAIEyeCatchingWaiterCell *cell = (YOUPAIEyeCatchingWaiterCell*)[self.youpaiptableView cellForRowAtIndexPath:indexPath]; for(UIView*firstView in cell.subviews) { for(UIView*lastView in firstView.subviews) { if(lastView.tag == 100) { for(UIView*playerPresentView in lastView.subviews) { playerPresentView.backgroundColor= [UIColor clearColor]; } } } } }; // 添加屏幕边缘手势 UIScreenEdgePanGestureRecognizer *edgePagGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifpanGestureAction:)]; edgePagGesture.edges = UIRectEdgeRight; [self.view addGestureRecognizer:edgePagGesture]; UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifpanGestureAction:)]; panGesture.maximumNumberOfTouches = 1; panGesture.delegate = self; [self.view addGestureRecognizer:panGesture]; } - (void)youpaifpanGestureAction:(UIPanGestureRecognizer *)gesture { CGPoint transition = [gesture translationInView:gesture.view]; if (transition.x > 0) { // 右滑 return; } // 进度 CGFloat progress = transition.x / gesture.view.bounds.size.width; if (progress < 0) { progress = -progress; progress = MIN(1.0f, MAX(0.0f, progress)); if (gesture.state == UIGestureRecognizerStateBegan) { self.youpaippercentDrivenTransition = [[UIPercentDrivenInteractiveTransition alloc] init]; [self youpaifpushToNextViewController]; }else if (gesture.state == UIGestureRecognizerStateChanged) { // 手势在慢慢划入 // 把手势的进度告诉 UIPercentDrivenInteractiveTransition [self.youpaippercentDrivenTransition updateInteractiveTransition:progress]; }else if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateCancelled) { if (progress > 0.3) { [self.youpaippercentDrivenTransition finishInteractiveTransition]; }else{ [self.youpaippercentDrivenTransition cancelInteractiveTransition]; } self.youpaippercentDrivenTransition = nil; } } } - (void)youpaifpushToNextViewController{ self.youpaipisLeavePage = YES; [self.youpaipzFplayer.currentPlayerManager pause]; NSArray *visiblePaths = [self.youpaiptableView indexPathsForVisibleRows]; if (visiblePaths.count != 0) { NSIndexPath *indexPath = visiblePaths[0]; if (self.youpaipvideoDataArray.count >= indexPath.row) { YOUPAIZYVideoModel *model = self.youpaipvideoDataArray[indexPath.row]; YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; userShow.youpaipuserId = model.youpaipuser_id; [self.navigationController pushViewController:userShow animated:YES]; } } } - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer{ // 根据transition判断是左滑还是右滑 CGPoint transition = [gestureRecognizer translationInView:gestureRecognizer.view]; if (transition.x < 0) { // 左滑 return YES; }else if (transition.x > 0) { // 右滑 return NO; } // 忽略导航控制器正在做转场动画 if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) return NO; return YES; } -(void)youpaifchangeFollowStateNotification:(NSNotification*)notification{ NSDictionary *dict = [notification userInfo]; NSString *idStr = dict[@"follow_uid"]; NSInteger isfollow = [dict[@"is_follow"] intValue]; NSArray *arr = self.youpaipvideoDataArray; if (arr.count>0) { NSIndexPath *index; NSMutableArray *arrM = [NSMutableArray new]; for (int i = 0; i0?NO:YES; return self.youpaipvideoDataArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YOUPAIEyeCatchingWaiterCell * cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIEyeCatchingWaiterCell" forIndexPath:indexPath]; cell.backgroundColor = [UIColor blackColor]; YOUPAIZYVideoModel *model = self.youpaipvideoDataArray[indexPath.row]; cell.model = model; cell.delegate = self; cell.hidesBottomBar = self.hidesBottomBarWhenPushed; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self youpaifplayTheVideoAtIndexPath:indexPath]; } #pragma mark - UIScrollViewDelegate 列表播放必须实现 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [scrollView zf_scrollViewDidEndDecelerating]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate { [scrollView zf_scrollViewDidEndDraggingWillDecelerate:decelerate]; } - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView { [scrollView zf_scrollViewDidScrollToTop]; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [scrollView zf_scrollViewDidScroll]; } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [scrollView zf_scrollViewWillBeginDragging]; } #pragma mark - JXCategoryListContainerViewDelegate - (UIView *)listView{ return self.view; } #pragma mark --- 懒加载 - (YOUPAIZFDouYinControlView *)youpaipcontrolView { if (!_youpaipcontrolView) { _youpaipcontrolView = [YOUPAIZFDouYinControlView new]; } return _youpaipcontrolView; } - (ZFPlayerController *)youpaipzFplayer{ if (_youpaipzFplayer == nil) { ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init]; _youpaipzFplayer = [ZFPlayerController playerWithScrollView:self.youpaiptableView playerManager:playerManager containerViewTag:100]; _youpaipzFplayer.disableGestureTypes = ZFPlayerDisableGestureTypesDoubleTap | ZFPlayerDisableGestureTypesPan | ZFPlayerDisableGestureTypesPinch; _youpaipzFplayer.allowOrentitaionRotation = NO; _youpaipzFplayer.WWANAutoPlay = YES; _youpaipzFplayer.playerDisapperaPercent = 1.0; _youpaipzFplayer.controlView = self.youpaipcontrolView; __weak typeof(self) weakSelf = self; _youpaipzFplayer.playerDidToEnd = ^(id _Nonnull asset) { // 播放结束后重新播放 [weakSelf.youpaipzFplayer.currentPlayerManager replay]; }; _youpaipzFplayer.presentationSizeChanged = ^(id _Nonnull asset, CGSize size) { // 视频画面显示的模式 NSInteger index = [weakSelf.youpaipmp4UrlArray indexOfObject:asset.assetURL]; if (weakSelf.youpaipvideoDataArray.count >= index) { YOUPAIZYVideoModel *model = weakSelf.youpaipvideoDataArray[index]; if (model.youpaipmode == 0) { if (size.width >= size.height) { model.youpaipmode = UIViewContentModeScaleAspectFit; } else { model.youpaipmode = UIViewContentModeScaleAspectFill; } } if (model.youpaipmode == UIViewContentModeScaleAspectFit) { weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFit; }else{ weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFill; } } }; [_youpaipzFplayer setPlayerPrepareToPlay:^(id _Nonnull asset, NSURL * _Nonnull assetURL) { NSInteger index = [weakSelf.youpaipmp4UrlArray indexOfObject:asset.assetURL]; if (weakSelf.youpaipvideoDataArray.count >= index) { YOUPAIZYVideoModel *model = weakSelf.youpaipvideoDataArray[index]; if (model.youpaipmode == UIViewContentModeScaleAspectFit) { weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFit; }else{ weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFill; } } }]; /// 停止的时候找出最合适的播放 _youpaipzFplayer.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) { if (weakSelf.youpaipzFplayer.playingIndexPath) return; /// 加载下一页数据 weakSelf.youpaipzFplayer.assetURLs = weakSelf.youpaipmp4UrlArray; [weakSelf.youpaiptableView reloadData]; [weakSelf youpaifplayTheVideoAtIndexPath:indexPath]; }; } return _youpaipzFplayer; } #pragma EyeCatchingWaiterCellDelegate //cell的代理 - (void)youpaifclickAvatar:(YOUPAIZYVideoModel*)model;//点击了头像 { // LCUserShowVC* userShow = [[LCUserShowVC alloc]init]; YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; userShow.youpaipuserId = model.youpaipuser_id; // userShow.videoModel = model; // userShow.delegate = self; [self.navigationController pushViewController:userShow animated:YES]; } -(void)youpaifclickNikname:(YOUPAIZYVideoModel *)model { YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init]; userShow.youpaipuserId = model.youpaipuser_id; // userShow.videoModel = model; // userShow.delegate = self; [self.navigationController pushViewController:userShow animated:YES]; } - (void)youpaifclickAttention:(YOUPAIZYVideoModel*)model;//点击了关注 { if (model.youpaipis_follow == 0) {//+关注 [LCCommonHttp followUserId:model.youpaipuser_id]; model.youpaipis_follow = 1; [self.youpaiptableView reloadData]; }else{ [LCCommonHttp followUserId:model.youpaipuser_id]; model.youpaipis_follow = 0; [self.youpaiptableView reloadData]; } } - (void)youpaifclickSupport:(YOUPAIZYVideoModel*)model;//点击了点赞 { [self.youpaiptableView reloadData]; } -(void)youpaifclickImVideo:(YOUPAIZYVideoModel *)model;//点击了视频 { if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) { [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"]; return; } [UCAuthorityManager cameraAuthority:^{ [LCHttpHelper requestWithURLString:CallChatType parameters:@{@"to_uid":model.youpaipuser_id,@"type":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]]; [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom]; [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init]; chatRequest.youpaipvideoModel = videoModel; //modify by leo fix bug ios13 ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest]; chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55); chatRequest.definesPresentationContext = YES; nav.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self.navigationController presentViewController:nav animated:YES completion:^{ // chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55); }]; }); } } failure:^(NSError *error) { }]; } denied:^{ dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){ if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } else { // 去系统设置页面 if (@available(iOS 10.0, *)) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil]; } else { // Fallback on earlier versions } } }]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]; [systemAlert addAction:cancelAction]; [systemAlert addAction:action]; [self presentViewController: systemAlert animated: YES completion: nil]; }); }]; } //累加视频动态浏览量 -(void)youpaiftrendsBrowser:(YOUPAIZYVideoModel *)model{ [LCHttpHelper requestWithURLString:TrendsBrowser parameters:@{@"vt_id":model.youpaipvideoId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSString *view_count = [NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"view_count"]]; model.youpaipview_count = [view_count integerValue]; [self.youpaiptableView reloadData]; } } failure:^(NSError *error) { }]; } //点击了比心 -(void)youpaifclickBiXin:(YOUPAIZYVideoModel *)model { NSLog(@"点击了比心"); YOUPAIZYBiXinVC *VC= [[YOUPAIZYBiXinVC alloc]init]; VC.youpaipdelegate = self; VC.vWidth = KScreenWidth-54; VC.vHeight = ((KScreenWidth-54)*165)/321.0+191; VC.youpaipvideoModel = model; VC.youpaipheartGiftModel = self.youpaipheartGiftModel; VC.isTouchDismiss = YES; [self TFPresentVC:VC completion:^{ }]; } // 点击了礼物 - (void)youpaifclickGift:(YOUPAIZYVideoModel *)model{ YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new]; view.isTouchDismiss = YES; view.youpaipisAnchor = NO; [view setJumToWalletBlock1:^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[NSNotificationCenter defaultCenter] postNotificationName:@"InsufficientBalanceNotice" object:nil userInfo:nil]; YOUPAIXRWalletVC *coinRecharge = [[YOUPAIXRWalletVC alloc]init]; [self.navigationController pushViewController:coinRecharge animated:YES]; }); }]; [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSInteger count,NSString*categoryID) { [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(6),@"to_uid":model.youpaipuser_id,@"gift_id":giftModel.youpaipid,@"num":@(count),@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:@"礼物赠送成功"]; } } failure:^(NSError *error) { }]; }]; [self TFPresentVC:view completion:^{ }]; } #pragma mark -- LZUserShowVCDelegate -(void)youpaifclickUserShowVCAttention:(YOUPAIZYVideoModel *)model { [self.youpaiptableView reloadData]; } #pragma mark -- ZYBiXinDelegate -(void)youpaifaddBiXinSuccess:(NSInteger)heart_count andVideoModel:(YOUPAIZYVideoModel *)model{//比心成功 model.youpaipheart_count = heart_count; [self.youpaiptableView reloadData]; } // 执行手势驱动代理方法 - (id)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id)animationController{ if (self.youpaippercentDrivenTransition && [animationController isKindOfClass:[GKPushTransitionAnimation class]]) { return self.youpaippercentDrivenTransition; } return nil; } - (id)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC{ if (self.youpaippercentDrivenTransition && operation == UINavigationControllerOperationPush) { return [[GKPushTransitionAnimation alloc] initWithScale:NO]; } return nil; } @end