dkahgld

ZBOrderListViewController.m 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // ZBOrderListViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/3.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBOrderListViewController.h"
  9. #import "ZBOrdertitleMOdel.h"
  10. #import "ZBChildOrderViewController.h"
  11. @interface ZBOrderListViewController ()<ITDatePickerControllerDelegate>
  12. @property (nonatomic, strong) TopTypeHeader *titleView;
  13. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  14. @property (nonatomic, strong) NSMutableArray *vcList;
  15. @property (nonatomic, assign) BOOL canScroll;
  16. @property(nonatomic,strong)UILabel *contentlabel;
  17. @property (nonatomic, strong) LDCalendarView *calendarView ;
  18. @property (nonatomic, strong) CCAlertShowView *alertShowView;
  19. @end
  20. @implementation ZBOrderListViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self initNavs];
  24. [self loadTitleData];
  25. }
  26. -(void)initNavs
  27. {
  28. self.vcList =[NSMutableArray array];
  29. self.view.backgroundColor=[UIColor lineColor];
  30. self.navBar.navTitleLabel.text=@"订单明细";
  31. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
  32. [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
  33. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  34. returnBtn.adjustsImageWhenHighlighted = NO;
  35. [self.navBar setCustomLeftButtons:@[returnBtn]];
  36. }
  37. -(void)returnClickBtn
  38. {
  39. [self.navigationController popViewControllerAnimated:YES];
  40. }
  41. - (void)loadTitleData {
  42. if (![AccountTool isLogin]) {
  43. return;
  44. }
  45. NSString *url = [NSString stringWithFormat:@"%@api/order/getOrderTop",BASEURL];
  46. [LoadingView showInView:self.view];
  47. [ZBHTTP post:url params:nil success:^(id json) {
  48. [LoadingView dismiss];
  49. NSArray *arr = [NSArray yy_modelArrayWithClass:[ZBOrdertitleMOdel class] json:json[@"list"]];
  50. if (arr.count >0) {
  51. [self creatHeaderViewAndFooterView:arr WithLabel:json[@"alert"]];
  52. }
  53. } failure:^(NSError *error) {
  54. [LoadingView dismiss];
  55. // [MBProgressHUD showMessage:@"网络错误"];
  56. }];
  57. }
  58. - (void)creatHeaderViewAndFooterView:(NSArray *)modelArr WithLabel:(NSString *)str {
  59. NSMutableArray *titleArr = [NSMutableArray array];
  60. NSMutableArray *subTitles = [NSMutableArray array];
  61. NSInteger counts =0;
  62. for (int i = 0; i < modelArr.count; i++) {
  63. ZBOrdertitleMOdel *model = modelArr[i];
  64. ZBChildOrderViewController *child = [[ZBChildOrderViewController alloc] init];
  65. child.type = [model.type integerValue];
  66. [titleArr addObject:model.title];
  67. [subTitles addObject:model.count];
  68. [self.vcList addObject:child];
  69. if (model.type.integerValue == 4) {
  70. counts =model.count.integerValue;//全部订单数量
  71. }
  72. }
  73. CGFloat height =0;
  74. if (str.length>0) {
  75. CGFloat contentHeight=[self cellHeightWithMsg:str];
  76. UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(10)+contentHeight)];
  77. accountBtn.backgroundColor =[UIColor whiteColor];
  78. [self.view addSubview:accountBtn];
  79. UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), contentHeight/2-FITSIZE(2.5), FITSIZE(15), FITSIZE(15))];
  80. imgv.image =[UIImage imageNamed:@"message_icon"];
  81. [accountBtn addSubview:imgv];
  82. accountBtn.tag = 1111;
  83. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, SCREEN_WIDTH-FITSIZE(60), FITSIZE(5)+contentHeight)];
  84. label.text=str;
  85. label.numberOfLines=0;
  86. label.textColor=[UIColor YHColorWithHex:0xFB6526];
  87. label.font=[UIFont systemFontOfSize:FITSIZE(12)];
  88. [accountBtn addSubview:label];
  89. label.tag = 1234;
  90. [self.view addSubview:accountBtn];
  91. height =FITSIZE(20)+contentHeight;
  92. }
  93. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+70+height, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70-height) vcOrViews:self.vcList];
  94. self.segScroll.bounces = NO;
  95. self.segScroll.loadAll = YES;
  96. self.titleView = [[TopTypeHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight+height, SCREEN_WIDTH, 70) titles:titleArr headStyle:TopTypeHeadStyleDefault layoutStyle:TopTypeLayoutDefault];
  97. self.titleView.headColor = [UIColor whiteColor];
  98. self.titleView.bottomLineHeight = 1;
  99. self.titleView.subTitles = subTitles;
  100. self.titleView.bottomLineColor = [UIColor yhGrayColor];
  101. self.titleView.fontScale = 1;
  102. self.titleView.fontSize = 14;
  103. self.titleView.equalSize = YES;
  104. self.titleView.showIndex = _showIndex;
  105. self.titleView.selectColor = [UIColor baseColor];
  106. self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
  107. [TopTypeSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  108. [self.view addSubview:self.titleView];
  109. [self.view addSubview:self.segScroll];
  110. }];
  111. }
  112. -(void)clickAction
  113. {
  114. if (self.alertShowView) {
  115. [self.alertShowView show];
  116. return;
  117. }
  118. CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES];
  119. self.alertShowView = showView;
  120. [self.alertShowView show];
  121. // ITDatePickerController *datePickerController = [[ITDatePickerController alloc] init];
  122. // datePickerController.tag = 100;
  123. // datePickerController.delegate = self;
  124. // datePickerController.showToday = NO;
  125. //// datePickerController.defaultDate = self.startDate;
  126. // datePickerController.minimumDate = nil;
  127. // datePickerController.maximumDate = nil;
  128. // [self presentViewController:datePickerController animated:YES completion:nil];
  129. }
  130. - (LDCalendarView *)calendarView {
  131. if (!_calendarView) {
  132. __weak typeof(self) weakSelf = self;
  133. _calendarView = [[LDCalendarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-40, 0)];
  134. _calendarView.cancelBlock = ^{
  135. [weakSelf.alertShowView dismiss];
  136. };
  137. _calendarView.makeSureBlock = ^(NSString *dateStr) {
  138. if (dateStr) {
  139. // yearMonthDay = dateStr;
  140. // page = 1;
  141. // [weakSelf requestAndRefresh:YES];
  142. // [weakSelf.topView setTitleStr:dateStr];
  143. [weakSelf.navBar setNavTitle:dateStr];
  144. weakSelf.navBar.navTitleLabel.textColor = [UIColor whiteColor];
  145. [weakSelf.alertShowView dismiss];
  146. }else {
  147. [weakSelf.alertShowView dismiss];
  148. }
  149. };
  150. }
  151. return _calendarView;
  152. }
  153. #pragma mark - ITDatePickerControllerDelegate
  154. - (void)datePickerController:(ITDatePickerController *)datePickerController didSelectedDate:(NSDate *)date dateString:(NSString *)dateString {
  155. NSLog(@"%@",dateString);
  156. }
  157. - (CGFloat)cellHeightWithMsg:(NSString *)msg
  158. {
  159. UILabel *label = [[UILabel alloc] init];
  160. label.text = msg;
  161. label.font = [UIFont systemFontOfSize:16];
  162. label.numberOfLines = 0;
  163. CGSize size = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH-FITSIZE(60), CGFLOAT_MAX)];
  164. return size.height;
  165. }
  166. @end