// // YOUPAILZLiveVC.m // TIANYAN // // Created by CY on 2021/5/19. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZLiveVC.h" #import "YOUPAILZLiveListVC.h" #import "LZAlertWindow.h" #import "UIViewController+TFPresent.h" #import "YOUPAILZLiveAnchorVC.h" #import "YOUPAILZLiveVerifyResultVC.h" #import "YOUPAILZVerifyPhoneWindow.h" //#import #import "YOUPAILZLiveCategoryModel.h" #import "JXCategoryView.h" #import "JXCategoryListContainerView.h" #import "YOUPAILCBoardVC.h" #import "TYCyclePagerView.h" #import "TYPageControl.h" #import "YOUPAILZHomeBannerCell.h" #import "JXPagerListRefreshView.h" #import "YOUPAILCBannerModel.h" #define LZCategoryViewHeight 54.0f #define LZCategoryViewItemWidth 64.0f #define LZHeaderViewHeigth ScaleSize(98.0f) @interface YOUPAILZLiveVC () // //@property(nonatomic,strong)UIView* youpaipnavBaseView; //@property(nonatomic,strong)ZCNavMenuView* youpaipnavView; // //@property(nonatomic,strong)UIScrollView* scrollView; // //@property (nonatomic,assign) CGFloat youpaiplastContentOffset; // //@property (nonatomic,strong) NSArray *youpaipliveListControllers; // //@property (nonatomic,assign) NSInteger currentControllerIndex; @property (nonatomic, strong) NSArray *youpaipcategorys; @property (nonatomic, strong) JXPagerListRefreshView *youpaippagerView; @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView; @property (nonatomic, strong) UIView *youpaipcategoryBgV; /* youpaipstartLiveBtn */ @property (strong, nonatomic) UIButton *youpaipstartLiveBtn; @property (nonatomic, strong) TYCyclePagerView* youpaipbannerView; /* pageControl */ @property (strong, nonatomic) TYPageControl *youpaippageControl; @property (nonatomic, strong) NSArray *youpaipbannerArray; /* imageURLStringsGroup */ @property (strong, nonatomic) NSMutableArray *youpaipimageURLStringsGroup; @end @implementation YOUPAILZLiveVC //- (NSArray *)youpaipliveListControllers{ // if (!_youpaipliveListControllers) { // // NSArray *dataSource = @[ // @{@"title":@"推荐",@"type":@(1)}, // @{@"title":@"热门",@"type":@(2)}, // @{@"title":@"摘星站",@"type":@(3)}, // @{@"title":@"新秀",@"type":@(4)}, // ]; // // NSMutableArray *vcs = [NSMutableArray array]; // for (NSDictionary *dict in dataSource) { // YOUPAILZLiveListVC *vc = [[YOUPAILZLiveListVC alloc]init]; // vc.title = [dict valueForKey:@"title"]; // vc.scrollDelegate = self; // vc.type = [[dict valueForKey:@"type"] integerValue]; // [self addChildViewController:vc]; // [vcs addObject:vc]; // } // _youpaipliveListControllers = vcs.copy; // } // return _youpaipliveListControllers; //} // //- (UIScrollView *)scrollView{ // if (!_scrollView) { // _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,NavBarHeight, KScreenWidth, KScreenHeight-TabbarHeight-NavBarHeight)]; // _scrollView.scrollEnabled = YES; // _scrollView.pagingEnabled = YES; // _scrollView.bounces = NO; // _scrollView.delegate = self; // _scrollView.showsVerticalScrollIndicator = NO; // _scrollView.showsHorizontalScrollIndicator = NO; // } // return _scrollView; //} //- (void)viewWillAppear:(BOOL)animated{ // [super viewWillAppear:animated]; // [self show]; //} //- (void)viewWillDisappear:(BOOL)animated{ // [super viewWillDisappear:animated]; // [self show]; //} - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES animated:animated]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.navigationController setNavigationBarHidden:NO animated:animated]; } - (void)viewDidLoad { [super viewDidLoad]; // self.currentControllerIndex = 0; // if ([LCSaveModel getUserModel].userinfo.is_anchor == 1) { // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(startLiveClick) image:[UIImage imageNamed:@"vqu_images_L_live"]]; // } // // [self setupScrollView]; // [self setupNavigationView]; // /// 线上版本状态改变,接收通知 //// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onlineVersionNotification) name:@"OnlineVersion" object:nil]; // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaiftoTopAction) name:@"videoToTop" object:nil];//置顶 // [self youpaifinitUI]; dispatch_group_t group = dispatch_group_create(); dispatch_group_enter(group); dispatch_group_async(group, dispatch_get_main_queue(), ^{ NSLog(@"%@---获取 余额",[NSThread currentThread]); // 获取余额 [self youpaifrequestBannerData:^{ dispatch_group_leave(group); }]; }); dispatch_group_notify(group, dispatch_get_main_queue(), ^{ NSLog(@"%@---全部结束。。。",[NSThread currentThread]); [self youpaifrequestCategoryListData]; }); [self youpaifinitConfig]; } - (void)youpaifinitUI{ TYCyclePagerView *youpaipbannerView = [[TYCyclePagerView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,LZHeaderViewHeigth)]; youpaipbannerView.isInfiniteLoop = YES; youpaipbannerView.autoScrollInterval = 6.0; youpaipbannerView.dataSource = self; youpaipbannerView.delegate = self; [youpaipbannerView registerClass:[YOUPAILZHomeBannerCell class] forCellWithReuseIdentifier:@"cellId"]; self.youpaipbannerView = youpaipbannerView; youpaipbannerView.backgroundColor = LCBkgColor; NSMutableArray *imgUrlArray = [NSMutableArray array]; for (YOUPAILCBannerModel* model in self.youpaipbannerArray) { [imgUrlArray addObject:[LCTools getImageUrlWithAddress:model.youpaipimage]]; } self.youpaipimageURLStringsGroup = imgUrlArray; self.youpaippageControl.numberOfPages = imgUrlArray.count; TYPageControl *pageControl = [[TYPageControl alloc]initWithFrame:CGRectMake(0, CGRectGetHeight(_youpaipbannerView.frame) - 26, CGRectGetWidth(_youpaipbannerView.frame), 26)]; //pageControl.numberOfPages = _datas.count; pageControl.currentPageIndicatorSize = CGSizeMake(6, 6); pageControl.pageIndicatorSize = CGSizeMake(6, 6); // pageControl.currentPageIndicatorTintColor = [UIColor redColor]; // pageControl.pageIndicatorTintColor = [UIColor grayColor]; pageControl.pageIndicatorImage = [UIImage imageNamed:@"vqu_images_H_home_page_n"]; pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"vqu_images_H_home_page_s"]; pageControl.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; pageControl.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; pageControl.pageIndicatorSpaing = 1; [youpaipbannerView addSubview:pageControl]; self.youpaippageControl = pageControl; UIView *youpaipcategoryBgV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, LZCategoryViewHeight)]; youpaipcategoryBgV.backgroundColor = LCBkgColor; self.youpaipcategoryBgV = youpaipcategoryBgV; CGFloat categoryViewWidth = KScreenWidth - 16.0f; if ([LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor == 1 && [LCSaveData getIsLive] != 2) { UIButton *youpaipstartLiveBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 24,(LZCategoryViewHeight - 24) / 2.0f,24,24)]; self.youpaipstartLiveBtn = youpaipstartLiveBtn; [youpaipstartLiveBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_live_play"] forState:(UIControlStateNormal)]; [youpaipstartLiveBtn addTarget:self action:@selector(youpaifstartLiveClick) forControlEvents:(UIControlEventTouchUpInside)]; [youpaipcategoryBgV addSubview:youpaipstartLiveBtn]; categoryViewWidth-=24; } // UIButton *rankBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // [rankBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_L_rank_play"] forState:UIControlStateNormal]; // rankBtn.frame = CGRectMake(categoryViewWidth - 24.0f - 10.0f, (LZCategoryViewHeight - 24) / 2.0f, 24.0f, 24.0f); // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside]; // [youpaipcategoryBgV addSubview:rankBtn]; // categoryViewWidth = rankBtn.mj_x - 16.0f; // // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside]; // JXCategoryTitleView *youpaipcategoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, categoryViewWidth, LZCategoryViewHeight)]; NSMutableArray *titles = [NSMutableArray array]; for (YOUPAILZLiveCategoryModel *model in self.youpaipcategorys) { [titles addObject:model.youpaiptitle]; } youpaipcategoryView.backgroundColor = LCBkgColor; youpaipcategoryView.titles = titles.copy; youpaipcategoryView.delegate = self; youpaipcategoryView.titleSelectedColor = HexColorFromRGB(0xF4003F); youpaipcategoryView.titleColor = HexColorFromRGB(0x6C6B70); youpaipcategoryView.titleColorGradientEnabled = YES; youpaipcategoryView.titleFont = LCFont(18.0f); youpaipcategoryView.titleSelectedFont = LCBoldFont(18.0f); youpaipcategoryView.cellWidth = LZCategoryViewItemWidth; youpaipcategoryView.cellSpacing = 0.0f; youpaipcategoryView.averageCellSpacingEnabled = NO; [youpaipcategoryBgV addSubview:youpaipcategoryView]; self.youpaipcategoryView = youpaipcategoryView; JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; lineView.verticalMargin = 6.0f; lineView.indicatorHeight = 2.5f; lineView.indicatorWidth = 8; lineView.layer.cornerRadius = 1.25; lineView.layer.masksToBounds = YES; [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0xFF0084),HexColorFromRGB(0xFF3A00)] gradientType:GradientLeftToRight]]; youpaipcategoryView.indicators = @[lineView]; JXPagerListRefreshView *pagerView = [[JXPagerListRefreshView alloc] initWithDelegate:self listContainerType:JXPagerListContainerType_CollectionView]; pagerView.mainTableView.gestureDelegate = self; [self.view addSubview:pagerView]; self.youpaippagerView = pagerView; self.youpaippagerView.frame = CGRectMake(0, StatusBarHeight, KScreenWidth, KScreenHeight-(TabbarHeight + StatusBarHeight)); youpaipcategoryView.listContainer = (id)self.youpaippagerView.listContainerView; // UIButton *rankBtn = [UIButton buttonWithType:UIButtonTypeCustom]; // [rankBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_H_home_rank"] forState:UIControlStateNormal]; // rankBtn.frame = CGRectMake(KScreenWidth - 10.0f - 62.0f, KScreenHeight - 21.0f - 26.0f - TabbarHeight, 62.0f, 26.0f); // [rankBtn addTarget:self action:@selector(youpaifrankBtnClick) forControlEvents:UIControlEventTouchUpInside]; // [self.view addSubview:rankBtn]; // // UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifhandlePan:)]; // [rankBtn addGestureRecognizer:panGestureRecognizer]; } /// 获取banner数据 - (void)youpaifrequestBannerData:(void(^)(void))complete{ WeakSelf; [LCHttpHelper requestWithURLString:HomeBanner parameters:@{@"cate_id":@"2"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 weakSelf.youpaipbannerArray = [YOUPAILCBannerModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"banner"]]; if (complete) { complete(); } } } failure:^(NSError *error) { }]; } - (void)youpaifstartLiveClick{ WeakSelf; [LCHttpHelper requestWithURLString:BindInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSString *mobile = [[dict objectForKey:@"data"]objectForKey:@"mobile"]; if (mobile.length != 0) { [weakSelf youpaifverifyOfCertificationAnchor]; }else{ YOUPAILZVerifyPhoneWindow *vc= [[YOUPAILZVerifyPhoneWindow alloc]init]; vc.isTouchDismiss = YES; [vc setBlock:^(NSString * _Nonnull phone) { [weakSelf youpaifverifyOfCertificationAnchor]; }]; [weakSelf TFPresentVC:vc completion:^{}]; } }else{ [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } - (void)youpaifverifyOfCertificationAnchor{ WeakSelf; [LCHttpHelper requestWithURLString:StatusLive parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { NSInteger live_status = [[[dict objectForKey:@"data"] objectForKey:@"live_status"] integerValue]; // 认证状态 1未认证 2已认证 if (live_status == 1) { LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) { }]; cancelAction.cornerRadius = 24.0f; cancelAction.bgColor = HexColorFromRGB(0x9F9DA5); LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"去认证" handler:^(LZAlertAction *action) { [weakSelf youpaifrealNameAuthentication]; }]; confimAction.cornerRadius = 24.0f; confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight]]; LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"您还未实名认证,需认证后才能开启直播!" action:@[cancelAction,confimAction]]; [weakSelf TFPresentVC:alert completion:^{}]; }else if(live_status == 3){ YOUPAILZLiveVerifyResultVC *vc = [[YOUPAILZLiveVerifyResultVC alloc] init]; vc.youpaipstate = LZLiveVerifyStateWithInReview; vc.youpaipcontent_str = [dict objectForKey:@"message"]; [weakSelf.navigationController pushViewController:vc animated:YES]; }else if(live_status == 2){ [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom]; YOUPAILZLiveAnchorVC *anchorVC = [[YOUPAILZLiveAnchorVC alloc] init]; anchorVC.youpaipshareModel = [YOUPAILZLiveShareModel mj_objectWithKeyValues:[[dict objectForKey:@"data"] objectForKey:@"share"]]; anchorVC.youpaipcover = [[dict objectForKey:@"data"] objectForKey:@"cover"]; [weakSelf.navigationController pushViewController:anchorVC animated:YES]; } }else{ [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } /// 阿里实名认证 - (void)youpaifrealNameAuthentication{ [UCAuthorityManager cameraAuthority:^{ YMCustomCameraViewModel *customCameraVM = [[YMCustomCameraViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_CUSTOM_CAMERA) withUserInfo:@{ RouterViewModel:customCameraVM } completion:nil]; } denied:^{ YMTipsPopupView *customView = [[YMTipsPopupView alloc]init]; [customView configutationWithTips:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" TipsAlignment:NSTextAlignmentCenter IsHideTitle:NO IsHideSingleButton:NO]; YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:[YMGlobalUtils getCurrentVC].view popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade]; popupView.priority = 999; popupView.cornerRadius = adapt(10); popupView.rectCorners = UIRectCornerAllCorners; popupView.positionStyle = YMPositionStyleCenter; popupView.isHideBg = NO; popupView.bgAlpha = 0.3; @weakify(popupView) customView.buttonBlock = ^(BOOL isConfirm) { @strongify(popupView) if (isConfirm) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil]; } [popupView dismissWithStyle:YMDismissStyleFade duration:2.0]; }; [popupView pop]; }]; // WeakSelf; // [LCHttpHelper requestWithURLString:GetLiveVerifyToken parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { // NSDictionary* dict = (NSDictionary*)responseObject; // NSInteger code = [[dict objectForKey:@"code"] integerValue]; // if (code == 0) { // NSString *token = dict[@"data"][@"VerifyToken"]; // NSString *BizId = dict[@"data"][@"BizId"]; // [weakSelf youpaifpushToAliSdk:token BizId:BizId]; // // }else{ // // [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; // } // // // // } failure:^(NSError *error) { // [ZCHUDHelper showTitle:error.localizedDescription]; // // }]; // } -(void)youpaifpushToAliSdk:(NSString*)token BizId:(NSString*)bizIdStr{ // RPConfiguration *configuration = [RPConfiguration configuration]; // NSString *filePath1 = [[NSBundle mainBundle] pathForResource:@"RPCustomUI" ofType:@"bundle"]; // configuration.customUIPath = filePath1; // [RPSDK startWithVerifyToken:token viewController:self configuration:configuration completion:^(RPResult * _Nonnull result) { // // NSLog(@"实人认证结果:%@==%@", result,result.message); // switch (result.state) { // case RPStatePass: // // 认证通过。 // [self youpaifpostBizId:bizIdStr]; // break; // case RPStateFail: // // 认证不通过。 // break; // case RPStateNotVerify: // // 未认证。 // // 通常是用户主动退出或者姓名身份证号实名校验不匹配等原因导致。 // // 具体原因可通过result.errorCode来区分(详见文末错误码说明表格)。 // break; // } // }]; } -(void)youpaifpostBizId:(NSString*)ID{ NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:ID forKey:@"BizId"]; WeakSelf; [LCHttpHelper requestWithURLString:LiveVerifyTokenSuccess parameters:dict needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { YOUPAILZLiveVerifyResultVC *vc = [[YOUPAILZLiveVerifyResultVC alloc] init]; vc.youpaipstate = LZLiveVerifyStateWithInReview; vc.youpaipcontent_str = [dict objectForKey:@"message"]; [weakSelf.navigationController pushViewController:vc animated:YES]; }else{ [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } - (void)youpaifrequestCategoryListData{ WeakSelf; [LCHttpHelper requestWithURLString:GetLiveCateList parameters:@{} needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { weakSelf.youpaipcategorys = [YOUPAILZLiveCategoryModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]]; [weakSelf youpaifinitUI]; [self.youpaipbannerView reloadData]; }else{ [ZCHUDHelper showTitle:[dict objectForKey:@"message"]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } #pragma mark - JXPagerViewDelegate - (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView { return self.youpaipbannerView; } - (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView { return LZHeaderViewHeigth; } - (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView { return LZCategoryViewHeight; } - (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView { return self.youpaipcategoryBgV; } - (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView { return self.youpaipcategorys.count; } - (id)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index{ YOUPAILZLiveListVC *vc = [[YOUPAILZLiveListVC alloc] init]; if (self.youpaipcategorys.count > index) { vc.youpaiptype = [self.youpaipcategorys[index].youpaipid integerValue]; } return vc; } #pragma mark - TYCyclePagerViewDataSource - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)youpaippageView { return self.youpaipimageURLStringsGroup.count; } - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index { YOUPAILZHomeBannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cellId" forIndex:index]; NSString *url; if (self.youpaipimageURLStringsGroup) { url = [self.youpaipimageURLStringsGroup[index] absoluteString]; [cell.youpaipbgImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"banner_default"]]; } cell.layer.cornerRadius = 5; cell.layer.masksToBounds = YES; cell.backgroundColor = LCBkgColor; // cell.backgroundColor = _datas[index]; // cell.label.text = [NSString stringWithFormat:@"index->%ld",index]; return cell; } - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)youpaippageView { TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init]; layout.itemSize = CGSizeMake(CGRectGetWidth(youpaippageView.frame)*0.9, CGRectGetHeight(youpaippageView.frame)*0.9); layout.itemSpacing = 10; layout.layoutType = TYCyclePagerTransformLayoutLinear; //layout.minimumAlpha = 0.3; return layout; } - (void)pagerView:(TYCyclePagerView *)youpaippageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index{ YOUPAILCBannerModel* model = self.youpaipbannerArray[index]; if (model.youpaiplink_type==1) { ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init]; baseWeb.contentUrl = model.youpaiplink_url; [self.navigationController pushViewController:baseWeb animated:YES]; }else if (model.youpaiplink_type==2||model.youpaiplink_type==3){ [self youpaifpageToStr:model.youpaiplink_url]; } } - (void)pagerView:(TYCyclePagerView *)youpaippageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex { _youpaippageControl.currentPage = toIndex; //[_pageControl setCurrentPage:newIndex animate:YES]; // NSLog(@"%ld -> %ld",fromIndex,toIndex); } #pragma mark-点击排行榜 - (void)youpaifrankBtnClick{ if ([LCSaveData getRankH5Url].length != 0) { ZCBaseWebVC* baseWeb = [[ZCBaseWebVC alloc]init]; baseWeb.contentUrl = [LCSaveData getRankH5Url]; [self.navigationController pushViewController:baseWeb animated:YES]; }else{ YOUPAILCBoardVC *board = [[YOUPAILCBoardVC alloc]init]; board.youpaiptype = 0; board.youpaiphiddenBack = YES; [self.navigationController pushViewController:board animated:YES]; } } - (void)youpaifhandlePan:(UIPanGestureRecognizer*) recognizer{ CGPoint translation = [recognizer translationInView:self.view]; CGFloat centerX=recognizer.view.center.x+ translation.x; CGFloat thecenter=0; recognizer.view.center = CGPointMake(centerX,recognizer.view.center.y+ translation.y); [recognizer setTranslation:CGPointZero inView:self.view]; if(recognizer.state == UIGestureRecognizerStateEnded || recognizer.state == UIGestureRecognizerStateCancelled) { if(centerX > KScreenWidth/2) { thecenter = KScreenWidth-62.0f/2 - 10.0f; }else{ thecenter = 62.0f / 2 + 10.0f; } [UIView animateWithDuration:0.3 animations:^{ CGFloat y = recognizer.view.center.y; if (recognizer.view.center.y < NavBarHeight) { y = NavBarHeight + 21.0f + 62.0f / 2.0f; }else if (recognizer.view.center.y > KScreenHeight - TabbarHeight - 21.0f - 62.0f / 2.0f){ y = KScreenHeight - TabbarHeight - 21.0f - 62.0f / 2.0f; } recognizer.view.center=CGPointMake(thecenter, y + translation.y); }]; } } //// 置顶 //-(void)youpaiftoTopAction{ // YOUPAILZLiveListVC *vc = self.youpaipliveListControllers[self.currentControllerIndex]; // if (vc.dataSource.count > 0) { // NSIndexPath* indexPat = [NSIndexPath indexPathForItem:0 inSection:0]; // [vc.collectionView scrollToItemAtIndexPath:indexPat atScrollPosition:UICollectionViewScrollPositionBottom animated:YES]; // } //} //- (void)setupScrollView{ // [self.view addSubview:self.scrollView]; // self.scrollView.contentSize = CGSizeMake(self.youpaipliveListControllers.count*CGRectGetWidth(_scrollView.frame), CGRectGetHeight(_scrollView.frame)); // for (NSInteger i = 0; i < self.youpaipliveListControllers.count; i ++) { // YOUPAILZLiveListVC *vc = self.youpaipliveListControllers[i]; // vc.view.frame = CGRectMake(i * KScreenWidth, 0, KScreenWidth, CGRectGetHeight(self.scrollView.frame)); // [self.scrollView addSubview:vc.view]; // } //} // //- (void)setupNavigationView{ // self.youpaipnavBaseView = [[UIView alloc] initWithFrame:CGRectMake(0,0, KScreenWidth, 44)]; // self.navigationItem.titleView = self.youpaipnavBaseView; // // NSMutableArray *titles = [NSMutableArray array]; // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) { // [titles addObject:vc.title]; // } // // ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0,65.0f * titles.count,44) TitleArr:titles normalFont:LCBoldFont(16) normalColor:HexColorFromRGB(0x222222) selectFont:LCBoldFont(21) selectColor:HexColorFromRGB(0x222222) selectLineColor:HexColorFromRGB(0xCB44FF) currentIndex:0 isBackground:NO]; // navMenu.delegate = self; // self.youpaipnavView = navMenu; // [self.youpaipnavBaseView addSubview:self.youpaipnavView]; //} //- (void)onlineVersionNotification{ // [self setupNavigationView]; //} //- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ // if ([scrollView isEqual:self.scrollView]) { // [self show]; // }else{ // if ([scrollView.mj_footer isRefreshing] || [scrollView.mj_header isRefreshing] || scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.mj_h - 1) { // return; // } // if (scrollView.contentOffset.y < self.youpaiplastContentOffset || scrollView.contentOffset.y <= 0){ // //向上 // [self show]; // } else if (scrollView.contentOffset.y > self.youpaiplastContentOffset ){ // //向下 // [self hide]; // } // self.youpaiplastContentOffset = scrollView.contentOffset.y; // } //} //- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ // if ([scrollView isEqual:self.scrollView]) { // CGPoint offset = scrollView.contentOffset; // NSInteger index = offset.x/KScreenWidth; // [self.youpaipnavView changeCurrentSelectButton:index]; // self.currentControllerIndex = index; // } //} // //- (void)youpaifnavBtnClick:(NSInteger)index{ // self.scrollView.contentOffset = CGPointMake(index * KScreenWidth, 0.0f); // self.currentControllerIndex = index; //} // //- (void)show{ // [UIView animateWithDuration:0.25f animations:^{ // self.tabBarController.tabBar.frame = CGRectMake(0, KScreenHeight-TabbarHeight, KScreenWidth, TabbarHeight); // self.scrollView.frame = CGRectMake(0,NavBarHeight, KScreenWidth, KScreenHeight-TabbarHeight-NavBarHeight); // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) { // CGRect rect = vc.view.frame; // rect.origin.y = 0.0f; // rect.size.height = CGRectGetHeight(self.scrollView.frame); // vc.view.frame = rect; // } // }]; // [self.navigationController setNavigationBarHidden:NO animated:YES]; //} //- (void)hide{ // [UIView animateWithDuration:0.25f animations:^{ // self.tabBarController.tabBar.frame = CGRectMake(0, KScreenHeight+20, KScreenWidth, TabbarHeight); // self.scrollView.frame = CGRectMake(0,0.0f, KScreenWidth, KScreenHeight); // for (YOUPAILZLiveListVC *vc in self.youpaipliveListControllers) { // CGRect rect = vc.view.frame; // rect.origin.y = 0; // rect.size.height = CGRectGetHeight(self.scrollView.frame); // vc.view.frame = rect; // } // }]; // [self.navigationController setNavigationBarHidden:YES animated:YES]; //} // //-(void)setCurrentControllerIndex:(NSInteger)currentControllerIndex{ // _currentControllerIndex = currentControllerIndex; // if (currentControllerIndex == 0) { // if (self.youpaipliveListControllers.count != 0) { // [self.youpaipliveListControllers[0] youpaifjoin]; // } // }else{ // if (self.youpaipliveListControllers.count != 0) { // [self.youpaipliveListControllers[0] leave]; // } // } //} - (void)youpaifinitConfig{ //系统配置信息 [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[LCTools getImageUrlWithAddress:@"/v1.3/dress/bubble/lALPD3zUOqg7eJA7bg_110_59.png"] options:SDWebImageDownloaderUseNSURLCache progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { if(data != nil){ [LCSaveData saveBubbleWithKey:[LCTools getImageUrlWithAddress:@"/v1.3/dress/bubble/lALPD3zUOqg7eJA7bg_110_59.png"].absoluteString Data:data]; } }]; [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSArray *bubbles = [[[dict objectForKey:@"data"]objectForKey:@"dress"] objectForKey:@"bubble"]; for (NSDictionary *bubbleDist in bubbles) { [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[LCTools getImageUrlWithAddress:[bubbleDist objectForKey:@"bubble"]] options:SDWebImageDownloaderUseNSURLCache progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {} completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) { if(data != nil){ [LCSaveData saveBubbleWithKey:[LCTools getImageUrlWithAddress:[bubbleDist objectForKey:@"bubble"]].absoluteString Data:data]; } }]; } } } failure:^(NSError *error) { }]; } @end