// // YOUPAILCBoardVC.m // LiveChat // // Created by 张灿 on 2018/9/26. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCBoardVC.h" #import "YOUPAILCBoardDetailVC.h" #import "ZCNavMenuView.h" @interface YOUPAILCBoardVC () @property(nonatomic,strong)ZCNavMenuView* youpaipnavView; @property(nonatomic,strong)UIScrollView* youpaipscrollView; @property(nonatomic,strong)YOUPAILCBoardDetailVC* youpaipwealthBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC* youpaipbigCastBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC* youpaipgiftBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC* youpaipfeeBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC *youpaipguardBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC *youpaipxianNvBangBoardVC; @property(nonatomic,strong)YOUPAILCBoardDetailVC *youpaipboLeBangBoardVC; @property(nonatomic,strong)UILabel *youpaiptitleLab; @property(nonatomic,strong)NSMutableArray *youpaiptitleArray; @end @implementation YOUPAILCBoardVC - (UIScrollView *)youpaipscrollView{ if (!_youpaipscrollView) { _youpaipscrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)]; _youpaipscrollView.scrollEnabled = YES; _youpaipscrollView.pagingEnabled = YES; _youpaipscrollView.bounces = NO; _youpaipscrollView.delegate = self; _youpaipscrollView.showsVerticalScrollIndicator = NO; _youpaipscrollView.showsHorizontalScrollIndicator = NO; _youpaipscrollView.contentSize = CGSizeMake(5*CGRectGetWidth(_youpaipscrollView.frame), CGRectGetHeight(_youpaipscrollView.frame)); } return _youpaipscrollView; } - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; //导航栏渐变色 [self.navigationController.navigationBar setBackgroundImage:[LCTools ColorImage:CGSizeMake(KScreenWidth, NavBarHeight) FromColors:@[HexColorFromRGB(0xFFCECE),HexColorFromRGB(0xE3BDD8)] ByGradientType:GradientTopToBottom] forBarMetrics:UIBarMetricsDefault]; [LCHttpHelper requestWithURLString:GetRankTab parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSInteger is_switch = [[NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"is_switch"]] integerValue];//仙女榜 1开启 2关闭 NSInteger is_bole = [[NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"is_bole"]] integerValue];//伯乐榜 1开启 2关闭 BOOL needRefresh = NO; if (is_switch == 1) { if (![LCSaveData getIsXianNvBang]) { [self->_youpaiptitleArray insertObject:@"仙女榜" atIndex:0]; [LCSaveData saveIsXianNvBang:YES]; needRefresh = YES; } }else{ if ([LCSaveData getIsXianNvBang]) { [LCSaveData saveIsXianNvBang:NO]; if ([self->_youpaiptitleArray containsObject:@"仙女榜"]) { [self->_youpaiptitleArray removeObject:@"仙女榜"]; } needRefresh = YES; } } if (is_bole == 1) { if (![LCSaveData getIsBoLeBang]) { [self->_youpaiptitleArray addObject:@"伯乐榜"]; [LCSaveData saveIsBoLeBang:YES]; needRefresh = YES; } }else{ if ([LCSaveData getIsBoLeBang]) { [LCSaveData saveIsBoLeBang:NO]; if ([self->_youpaiptitleArray containsObject:@"伯乐榜"]) { [self->_youpaiptitleArray removeObject:@"伯乐榜"]; } needRefresh = YES; } } NSLog(@"%@",self->_youpaiptitleArray); if (needRefresh) { [self.youpaipscrollView removeFromSuperview]; [self youpaifsetXianNvBangAndBoLeBangUI]; } } } failure:^(NSError *error) { }]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.navigationController.navigationBar setDefaultBar]; self.navigationController.navigationBar.barTintColor = LCWhiteColor; // [_youpaiptitleLab setHidden:YES]; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackClick) image:[UIImage imageNamed:@"vqu_images_navigation_back_black"]]; // self.sx_disableInteractivePop = YES; [self.view addSubview:self.youpaipscrollView]; // @[@"魅力榜",@"礼物榜",@"守护榜",@"消费榜",@"新人榜"] self.youpaiptitleArray = [NSMutableArray arrayWithArray:@[@"魅力榜",@"女神榜",@"新人榜"]]; if ([LCSaveData getIsXianNvBang]) { [self->_youpaiptitleArray insertObject:@"仙女榜" atIndex:0]; } if ([LCSaveData getIsBoLeBang]) { [self->_youpaiptitleArray addObject:@"伯乐榜"]; } [self youpaifsetXianNvBangAndBoLeBangUI]; } -(void)youpaifsetXianNvBangAndBoLeBangUI{ self->_youpaipscrollView.contentSize = CGSizeMake(self.youpaiptitleArray.count*CGRectGetWidth(self->_youpaipscrollView.frame), CGRectGetHeight(self->_youpaipscrollView.frame)); UIScrollView *navScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 60.0f, 28.0f)]; navScrollView.showsVerticalScrollIndicator = NO; navScrollView.showsHorizontalScrollIndicator = NO; navScrollView.contentSize = CGSizeMake(self.youpaiptitleArray.count * 68.0f, 28); ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0,self.youpaiptitleArray.count * 68.0f, 28) TitleArr:self.youpaiptitleArray normalFont:LCBoldFont(14) normalColor:HexColorFromRGB(0xffffff) selectFont:LCBoldFont(16) selectColor:HexColorFromRGB(0xffffff) selectLineColor:HexColorFromRGB(0xA7A9FD) currentIndex:0 isBackground:YES]; navMenu.delegate = self; self.youpaipnavView = navMenu; [navScrollView addSubview:navMenu]; self.navigationItem.titleView = navScrollView; [self.view addSubview:self.youpaipscrollView]; int i = 0; if ([LCSaveData getIsXianNvBang]) { self.youpaipxianNvBangBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; self.youpaipxianNvBangBoardVC.youpaiptype = 5; self.youpaipxianNvBangBoardVC.view.frame = CGRectMake(0, 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipxianNvBangBoardVC.view]; [self addChildViewController:self.youpaipxianNvBangBoardVC]; i = 1; } self.youpaipbigCastBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipbigCastBoardVC.youpaiptype = 0; self.youpaipbigCastBoardVC.view.frame = CGRectMake(KScreenWidth*i, 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipbigCastBoardVC.view]; [self addChildViewController:self.youpaipbigCastBoardVC]; self.youpaipgiftBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipgiftBoardVC.youpaiptype = 7; self.youpaipgiftBoardVC.view.frame = CGRectMake(KScreenWidth*(i+1), 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipgiftBoardVC.view]; [self addChildViewController:self.youpaipgiftBoardVC]; self.youpaipguardBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipguardBoardVC.youpaiptype = 4; self.youpaipguardBoardVC.view.frame = CGRectMake(KScreenWidth*(i+2), 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipguardBoardVC.view]; [self addChildViewController:self.youpaipguardBoardVC]; self.youpaipfeeBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipfeeBoardVC.youpaiptype = 3; self.youpaipfeeBoardVC.view.frame = CGRectMake(KScreenWidth*(i+3), 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipfeeBoardVC.view]; [self addChildViewController:self.youpaipfeeBoardVC]; self.youpaipwealthBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipwealthBoardVC.youpaiptype = 4; self.youpaipwealthBoardVC.view.frame = CGRectMake(KScreenWidth*(i+4), 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipwealthBoardVC.view]; [self addChildViewController:self.youpaipwealthBoardVC]; [self youpaifnavBtnClick:self->_youpaipindex]; if ([LCSaveData getIsBoLeBang]) { self.youpaipboLeBangBoardVC = [[YOUPAILCBoardDetailVC alloc] init]; self.youpaipboLeBangBoardVC.youpaiptype = 6; self.youpaipboLeBangBoardVC.view.frame = CGRectMake(KScreenWidth*(i+5), 0, KScreenWidth, CGRectGetHeight(self->_youpaipscrollView.frame)); [self.youpaipscrollView addSubview:self.youpaipboLeBangBoardVC.view]; [self addChildViewController:self.youpaipboLeBangBoardVC]; } } //// 仙女榜有 伯乐榜无 //-(void)setHaveXianNvBangAndNOBoLeBangUI //{ // self->_scrollView.contentSize = CGSizeMake(6*CGRectGetWidth(self->_scrollView.frame), CGRectGetHeight(self->_scrollView.frame)); // ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0, 310, 28) TitleArr:@[@"仙女榜",@"魅力榜",@"礼物榜",@"守护榜",@"消费榜",@"钻石榜"] normalFont:LCBoldFont(14) normalColor:HexColorFromRGB(0xffffff) selectFont:LCBoldFont(16) selectColor:ZYPinkColor selectLineColor:HexColorFromRGBA(0xffffff,1.0) currentIndex:0 isBackground:YES]; // navMenu.delegate = self; // self.navView = navMenu; // self.navigationItem.titleView = navMenu; // [self.view addSubview:self.scrollView]; // self.youpaipxianNvBangBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipxianNvBangBoardVC.type = 5; // self.youpaipxianNvBangBoardVC.view.frame = CGRectMake(0, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipxianNvBangBoardVC.view]; // [self addChildViewController:self.youpaipxianNvBangBoardVC]; // // self.youpaipbigCastBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipbigCastBoardVC.type = 0; // self.youpaipbigCastBoardVC.view.frame = CGRectMake(KScreenWidth*1, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipbigCastBoardVC.view]; // [self addChildViewController:self.youpaipbigCastBoardVC]; // // self.youpaipgiftBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipgiftBoardVC.type = 1; // self.youpaipgiftBoardVC.view.frame = CGRectMake(KScreenWidth*2, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipgiftBoardVC.view]; // [self addChildViewController:self.youpaipgiftBoardVC]; // // self.youpaipguardBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipguardBoardVC.type = 2; // self.youpaipguardBoardVC.view.frame = CGRectMake(KScreenWidth*3, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipguardBoardVC.view]; // [self addChildViewController:self.youpaipguardBoardVC]; // // self.youpaipfeeBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipfeeBoardVC.type = 3; // self.youpaipfeeBoardVC.view.frame = CGRectMake(KScreenWidth*4, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipfeeBoardVC.view]; // [self addChildViewController:self.youpaipfeeBoardVC]; // // self.wealthBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.wealthBoardVC.type = 4; // self.wealthBoardVC.view.frame = CGRectMake(KScreenWidth*5, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.wealthBoardVC.view]; // [self addChildViewController:self.wealthBoardVC]; // [self youpaifnavBtnClick:self->_index]; // //} //// 仙女榜无 伯乐榜有 //-(void)setNoXianNvBangAndHaveBoLeBangUI{ // //} //// 仙女榜无 伯乐榜无 //-(void)setNOXianNvBangAndNOBoLeBangUI //{ // //} //// 没有仙女榜 //- (void)setNoXianNvBangUI //{ // self->_scrollView.contentSize = CGSizeMake(5*CGRectGetWidth(self->_scrollView.frame), CGRectGetHeight(self->_scrollView.frame)); // ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0, 310, 28) TitleArr:@[@"魅力榜",@"礼物榜",@"守护榜",@"消费榜",@"钻石榜"] normalFont:LCBoldFont(14) normalColor:HexColorFromRGB(0xffffff) selectFont:LCBoldFont(16) selectColor:ZYPinkColor selectLineColor:HexColorFromRGBA(0xffffff,1.0) currentIndex:0 isBackground:YES]; // navMenu.delegate = self; // self.navView = navMenu; // self.navigationItem.titleView = navMenu; // [self.view addSubview:self.scrollView]; // // // self.youpaipbigCastBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipbigCastBoardVC.type = 0; // self.youpaipbigCastBoardVC.view.frame = CGRectMake(0, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipbigCastBoardVC.view]; // [self addChildViewController:self.youpaipbigCastBoardVC]; // self.youpaipgiftBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipgiftBoardVC.type = 1; // self.youpaipgiftBoardVC.view.frame = CGRectMake(KScreenWidth, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipgiftBoardVC.view]; // [self addChildViewController:self.youpaipgiftBoardVC]; // self.youpaipguardBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipguardBoardVC.type = 2; // self.youpaipguardBoardVC.view.frame = CGRectMake(KScreenWidth*2, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipguardBoardVC.view]; // [self addChildViewController:self.youpaipguardBoardVC]; // // self.youpaipfeeBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipfeeBoardVC.type = 3; // self.youpaipfeeBoardVC.view.frame = CGRectMake(KScreenWidth*3, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipfeeBoardVC.view]; // [self addChildViewController:self.youpaipfeeBoardVC]; // // self.wealthBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.wealthBoardVC.type = 4; // self.wealthBoardVC.view.frame = CGRectMake(KScreenWidth*4, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.wealthBoardVC.view]; // [self addChildViewController:self.wealthBoardVC]; // [self youpaifnavBtnClick:self->_index]; // //} ////有仙女榜 //- (void)setHaveXianNvBangUI //{ // self->_scrollView.contentSize = CGSizeMake(6*CGRectGetWidth(self->_scrollView.frame), CGRectGetHeight(self->_scrollView.frame)); // ZCNavMenuView* navMenu = [[ZCNavMenuView alloc]initWithFrame:CGRectMake(0, 0, 310, 28) TitleArr:@[@"仙女榜",@"魅力榜",@"礼物榜",@"守护榜",@"消费榜",@"钻石榜"] normalFont:LCBoldFont(14) normalColor:HexColorFromRGB(0xffffff) selectFont:LCBoldFont(16) selectColor:ZYPinkColor selectLineColor:HexColorFromRGBA(0xffffff,1.0) currentIndex:0 isBackground:YES]; // navMenu.delegate = self; // self.navView = navMenu; // self.navigationItem.titleView = navMenu; // [self.view addSubview:self.scrollView]; // self.youpaipxianNvBangBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipxianNvBangBoardVC.type = 5; // self.youpaipxianNvBangBoardVC.view.frame = CGRectMake(0, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipxianNvBangBoardVC.view]; // [self addChildViewController:self.youpaipxianNvBangBoardVC]; // // self.youpaipbigCastBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipbigCastBoardVC.type = 0; // self.youpaipbigCastBoardVC.view.frame = CGRectMake(KScreenWidth*1, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipbigCastBoardVC.view]; // [self addChildViewController:self.youpaipbigCastBoardVC]; // // self.youpaipgiftBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipgiftBoardVC.type = 1; // self.youpaipgiftBoardVC.view.frame = CGRectMake(KScreenWidth*2, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipgiftBoardVC.view]; // [self addChildViewController:self.youpaipgiftBoardVC]; // // self.youpaipguardBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipguardBoardVC.type = 2; // self.youpaipguardBoardVC.view.frame = CGRectMake(KScreenWidth*3, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipguardBoardVC.view]; // [self addChildViewController:self.youpaipguardBoardVC]; // // self.youpaipfeeBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.youpaipfeeBoardVC.type = 3; // self.youpaipfeeBoardVC.view.frame = CGRectMake(KScreenWidth*4, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.youpaipfeeBoardVC.view]; // [self addChildViewController:self.youpaipfeeBoardVC]; // // self.wealthBoardVC = [[YOUPAILCBoardDetailVC alloc]init]; // self.wealthBoardVC.type = 4; // self.wealthBoardVC.view.frame = CGRectMake(KScreenWidth*5, 0, KScreenWidth, CGRectGetHeight(self->_scrollView.frame)); // [self.scrollView addSubview:self.wealthBoardVC.view]; // [self addChildViewController:self.wealthBoardVC]; // [self youpaifnavBtnClick:self->_index]; // // //} - (void)youpaifbackClick{ [self.navigationController popViewControllerAnimated:YES]; } -(UILabel *)youpaiptitleLab { if(!_youpaiptitleLab) { _youpaiptitleLab = [[UILabel alloc]initWithFrame:CGRectMake(80, 0, KScreenWidth-160, 44)]; [_youpaiptitleLab setBackgroundColor:[UIColor clearColor]]; [_youpaiptitleLab setTextColor:[UIColor whiteColor]]; _youpaiptitleLab.font = [UIFont systemFontOfSize:18]; _youpaiptitleLab.textAlignment = NSTextAlignmentCenter; } return _youpaiptitleLab; } -(void)setYoupaipindex:(NSInteger)youpaipindex { _youpaipindex = youpaipindex; [self youpaifnavBtnClick:youpaipindex]; [self.youpaipnavView changeCurrentSelectButton:youpaipindex]; } - (void)youpaifnavBtnClick:(NSInteger)index{ self.youpaipscrollView.contentOffset = CGPointMake(KScreenWidth*index, 0); } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self.view endEditing:YES]; if ([scrollView isEqual:self.youpaipscrollView]) { CGFloat offsetX = scrollView.contentOffset.x; // if ([LCSaveData getIsXianNvBang]) { // self.navView.selectView.frame = CGRectMake((self.navView.frame.size.width/self.titleArray.count)*(offsetX/KScreenWidth), self.navView.selectView.frame.origin.y, self.navView.selectView.frame.size.width, self.navView.selectView.frame.size.height); // }else{ // self.navView.selectView.frame = CGRectMake((self.navView.frame.size.width/5)*(offsetX/KScreenWidth), self.navView.selectView.frame.origin.y, self.navView.selectView.frame.size.width, self.navView.selectView.frame.size.height); // } self.youpaipnavView.selectView.frame = CGRectMake((self.youpaipnavView.frame.size.width/self.youpaiptitleArray.count)*(offsetX/KScreenWidth), self.youpaipnavView.selectView.frame.origin.y, self.youpaipnavView.selectView.frame.size.width, self.youpaipnavView.selectView.frame.size.height); // _selectView.frame = CGRectMake((_selectIndex-1000)*self.frame.size.width/_titleArr.count,0,self.frame.size.width/_titleArr.count, self.frame.size.height); } } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ if ([scrollView isEqual:self.youpaipscrollView]) { CGPoint offset = scrollView.contentOffset; NSInteger index = offset.x/KScreenWidth; [self.youpaipnavView changeCurrentSelectButton:index]; } } -(void)dealloc { NSLog(@"lcboardvc dealloc"); } @end