// // KDPOderDetailListVC.m // KuDianProject // // Created by 学丽 on 2019/7/12. // Copyright © 2019 KDP. All rights reserved. // #import "KDPOderDetailListVC.h" @interface KDPOderDetailListVC () { NSMutableArray *titleArray; UIView *backv; } @property (nonatomic, strong) XLPageViewController *pageVC; @property(nonatomic,strong)UILabel *tipeLabel; @end @implementation KDPOderDetailListVC - (void)viewDidLoad { [super viewDidLoad]; self.navBar.hidden=NO; self.navBar.navTitleLabel.text=@"订单明细"; [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)]; self.navigationController.navigationBar.hidden=YES; self.view.backgroundColor=[UIColor whiteColor]; [self orderHeadTitle]; [self addtipeView]; } -(void)addtipeView { backv=[[UIView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, 50)]; backv.backgroundColor=[UIColor whiteColor]; UIImageView *lineV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5)]; lineV.backgroundColor=[UIColor colorWithHexString:LineColor]; [backv addSubview:lineV]; UIImageView *iconimg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_message"]]; iconimg.frame=CGRectMake(10, 15, 20, 20); [backv addSubview:iconimg]; self.tipeLabel=[[UILabel alloc]initWithFrame:CGRectMake(40, 5, SCREEN_WIDTH-50, 40)]; _tipeLabel.numberOfLines=2; self.tipeLabel.textColor=[UIColor colorWithHexString:ThemeColor]; self.tipeLabel.font=[UIFont systemFontOfSize:12]; [backv addSubview:self.tipeLabel]; UIImageView *bottomlineV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 5)]; bottomlineV.backgroundColor=[UIColor colorWithHexString:LineColor]; [backv addSubview:bottomlineV]; [self.view addSubview:backv]; } - (void)setUpPageVc{ XLPageViewControllerConfig *config = [[XLPageViewControllerConfig alloc] init]; //标题间距 config.titleSpace = 0; //标题高度 config.titleViewHeight =70; config.titleViewInset = UIEdgeInsetsMake(0, 0, 0, 0); config.titleWidth=SCREEN_WIDTH/titleArray.count; if (self.tipeLabel.text.length>0) { config.navHeight=KDNavBarHeight+50; }else{ config.navHeight=KDNavBarHeight; } config.contentHeight=SCREEN_HEIGHT-KDNavBarHeight; self.pageVC = [[XLPageViewController alloc] initWithConfig:config]; //需要先注册cell [self.pageVC registerClass:KDPOrderTitleCell.class forTitleViewCellWithReuseIdentifier:@"title"]; self.pageVC.view.bounds = CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT); self.pageVC.delegate = self; self.pageVC.dataSource = self; [self addChildViewController:self.pageVC]; [self.view addSubview:self.pageVC.view]; } -(void)orderHeadTitle { [LoadingView show]; [KDPNetworkRequestHTTP postURL:orderHeadTitleURL params:nil success:^(id _Nonnull json) { [LoadingView dismiss]; if ([json[@"alert"] length]>0) { self.tipeLabel.text=json[@"alert"]; backv.hidden=NO; }else{ backv.hidden=YES; } titleArray =[NSMutableArray arrayWithArray:json[@"list"]]; [self setUpPageVc]; } failure:^(NSError * _Nonnull error) { [LoadingView dismiss]; }]; } #pragma mark - XLPageViewController datasource and delegate //cell创建方法 - (XLPageTitleCell *)pageViewController:(XLPageViewController *)pageViewController titleViewCellForItemAtIndex:(NSInteger)index { KDPOrderTitleCell *cell = [pageViewController dequeueReusableTitleViewCellWithIdentifier:@"title" forIndex:index]; NSDictionary *dic =titleArray[index]; cell.titlelabel.text=dic[@"title"]; cell.numLabel.text=[NSString stringWithFormat:@"%ld",[dic[@"count"]integerValue]]; return cell; } //通过此父类方法配置标题cell是否被选中样式 - (void)configCellOfSelected:(BOOL)selected { } //通过此父类方法配置标题cell动画;type:区分是当前选中cell/将要被选中的cell;progress:动画进度0~1 - (void)showAnimationOfProgress:(CGFloat)progress type:(XLPageTitleCellAnimationType)type { } - (NSInteger)pageViewControllerNumberOfPage{ return titleArray.count; } - (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index{ NSDictionary *dic =titleArray[index]; return dic[@"title"]; } - (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index{ NSLog(@"%ld",index); } - (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index{ KDPOrderDetailListNewVC *contentVC = [[KDPOrderDetailListNewVC alloc] init]; contentVC.typeDic=titleArray[index]; return contentVC; } -(void)returnClickBtn { [self.navigationController popViewControllerAnimated:YES]; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden=YES; self.tabBarController.tabBar.hidden=YES; } -(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.tabBarController.tabBar.hidden=NO; } @end