酷店

KDPOderDetailListVC.m 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // KDPOderDetailListVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/12.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPOderDetailListVC.h"
  9. @interface KDPOderDetailListVC ()<XLPageViewControllerDelegate,XLPageViewControllerDataSrouce>
  10. {
  11. NSMutableArray *titleArray;
  12. UIView *backv;
  13. }
  14. @property (nonatomic, strong) XLPageViewController *pageVC;
  15. @property(nonatomic,strong)UILabel *tipeLabel;
  16. @end
  17. @implementation KDPOderDetailListVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.navBar.hidden=NO;
  21. self.navBar.navTitleLabel.text=@"订单明细";
  22. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  23. self.navigationController.navigationBar.hidden=YES;
  24. self.view.backgroundColor=[UIColor whiteColor];
  25. [self orderHeadTitle];
  26. [self addtipeView];
  27. }
  28. -(void)addtipeView
  29. {
  30. backv=[[UIView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, 50)];
  31. backv.backgroundColor=[UIColor whiteColor];
  32. UIImageView *lineV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5)];
  33. lineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  34. [backv addSubview:lineV];
  35. UIImageView *iconimg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"icon_message"]];
  36. iconimg.frame=CGRectMake(10, 15, 20, 20);
  37. [backv addSubview:iconimg];
  38. self.tipeLabel=[[UILabel alloc]initWithFrame:CGRectMake(40, 5, SCREEN_WIDTH-50, 40)];
  39. _tipeLabel.numberOfLines=2;
  40. self.tipeLabel.textColor=[UIColor colorWithHexString:ThemeColor];
  41. self.tipeLabel.font=[UIFont systemFontOfSize:12];
  42. [backv addSubview:self.tipeLabel];
  43. UIImageView *bottomlineV=[[UIImageView alloc]initWithFrame:CGRectMake(0, 45, SCREEN_WIDTH, 5)];
  44. bottomlineV.backgroundColor=[UIColor colorWithHexString:LineColor];
  45. [backv addSubview:bottomlineV];
  46. [self.view addSubview:backv];
  47. }
  48. - (void)setUpPageVc{
  49. XLPageViewControllerConfig *config = [[XLPageViewControllerConfig alloc] init];
  50. //标题间距
  51. config.titleSpace = 0;
  52. //标题高度
  53. config.titleViewHeight =70;
  54. config.titleViewInset = UIEdgeInsetsMake(0, 0, 0, 0);
  55. config.titleWidth=SCREEN_WIDTH/titleArray.count;
  56. if (self.tipeLabel.text.length>0) {
  57. config.navHeight=KDNavBarHeight+50;
  58. }else{
  59. config.navHeight=KDNavBarHeight;
  60. }
  61. config.contentHeight=SCREEN_HEIGHT-KDNavBarHeight;
  62. self.pageVC = [[XLPageViewController alloc] initWithConfig:config];
  63. //需要先注册cell
  64. [self.pageVC registerClass:KDPOrderTitleCell.class forTitleViewCellWithReuseIdentifier:@"title"];
  65. self.pageVC.view.bounds = CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT);
  66. self.pageVC.delegate = self;
  67. self.pageVC.dataSource = self;
  68. [self addChildViewController:self.pageVC];
  69. [self.view addSubview:self.pageVC.view];
  70. }
  71. -(void)orderHeadTitle
  72. {
  73. [LoadingView show];
  74. [KDPNetworkRequestHTTP postURL:orderHeadTitleURL params:nil success:^(id _Nonnull json) {
  75. [LoadingView dismiss];
  76. if ([json[@"alert"] length]>0) {
  77. self.tipeLabel.text=json[@"alert"];
  78. backv.hidden=NO;
  79. }else{
  80. backv.hidden=YES;
  81. }
  82. titleArray =[NSMutableArray arrayWithArray:json[@"list"]];
  83. [self setUpPageVc];
  84. } failure:^(NSError * _Nonnull error) {
  85. [LoadingView dismiss];
  86. }];
  87. }
  88. #pragma mark - XLPageViewController datasource and delegate
  89. //cell创建方法
  90. - (XLPageTitleCell *)pageViewController:(XLPageViewController *)pageViewController titleViewCellForItemAtIndex:(NSInteger)index {
  91. KDPOrderTitleCell *cell = [pageViewController dequeueReusableTitleViewCellWithIdentifier:@"title" forIndex:index];
  92. NSDictionary *dic =titleArray[index];
  93. cell.titlelabel.text=dic[@"title"];
  94. cell.numLabel.text=[NSString stringWithFormat:@"%ld",[dic[@"count"]integerValue]];
  95. return cell;
  96. }
  97. //通过此父类方法配置标题cell是否被选中样式
  98. - (void)configCellOfSelected:(BOOL)selected {
  99. }
  100. //通过此父类方法配置标题cell动画;type:区分是当前选中cell/将要被选中的cell;progress:动画进度0~1
  101. - (void)showAnimationOfProgress:(CGFloat)progress type:(XLPageTitleCellAnimationType)type {
  102. }
  103. - (NSInteger)pageViewControllerNumberOfPage{
  104. return titleArray.count;
  105. }
  106. - (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index{
  107. NSDictionary *dic =titleArray[index];
  108. return dic[@"title"];
  109. }
  110. - (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index{
  111. NSLog(@"%ld",index);
  112. }
  113. - (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index{
  114. KDPOrderDetailListNewVC *contentVC = [[KDPOrderDetailListNewVC alloc] init];
  115. contentVC.typeDic=titleArray[index];
  116. return contentVC;
  117. }
  118. -(void)returnClickBtn
  119. {
  120. [self.navigationController popViewControllerAnimated:YES];
  121. }
  122. -(void)viewWillAppear:(BOOL)animated
  123. {
  124. [super viewWillAppear:animated];
  125. self.navigationController.navigationBar.hidden=YES;
  126. self.tabBarController.tabBar.hidden=YES;
  127. }
  128. -(void)viewWillDisappear:(BOOL)animated
  129. {
  130. [super viewWillDisappear:animated];
  131. self.tabBarController.tabBar.hidden=NO;
  132. }
  133. @end