123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- //
- // ZBOrderListViewController.m
- // ZBProject
- //
- // Created by 学丽 on 2019/4/3.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBOrderListViewController.h"
- #import "ZBOrdertitleMOdel.h"
- #import "ZBChildOrderViewController.h"
- @interface ZBOrderListViewController ()<ITDatePickerControllerDelegate>
- @property (nonatomic, strong) TopTypeHeader *titleView;
- @property (nonatomic, strong) MLMSegmentScroll *segScroll;
- @property (nonatomic, strong) NSMutableArray *vcList;
- @property (nonatomic, assign) BOOL canScroll;
- @property(nonatomic,strong)UILabel *contentlabel;
- @property (nonatomic, strong) LDCalendarView *calendarView ;
- @property (nonatomic, strong) CCAlertShowView *alertShowView;
- @end
- @implementation ZBOrderListViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initNavs];
- [self loadTitleData];
- }
- -(void)initNavs
- {
- self.vcList =[NSMutableArray array];
- self.view.backgroundColor=[UIColor lineColor];
- self.navBar.navTitleLabel.text=@"订单明细";
- UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
- [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
- [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
- returnBtn.adjustsImageWhenHighlighted = NO;
- [self.navBar setCustomLeftButtons:@[returnBtn]];
-
-
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)loadTitleData {
- if (![AccountTool isLogin]) {
- return;
- }
- NSString *url = [NSString stringWithFormat:@"%@api/order/getOrderTop",BASEURL];
- [LoadingView showInView:self.view];
- [ZBHTTP post:url params:nil success:^(id json) {
- [LoadingView dismiss];
- NSArray *arr = [NSArray yy_modelArrayWithClass:[ZBOrdertitleMOdel class] json:json[@"list"]];
- if (arr.count >0) {
- [self creatHeaderViewAndFooterView:arr WithLabel:json[@"alert"]];
- }
-
-
- } failure:^(NSError *error) {
- [LoadingView dismiss];
- // [MBProgressHUD showMessage:@"网络错误"];
- }];
- }
- - (void)creatHeaderViewAndFooterView:(NSArray *)modelArr WithLabel:(NSString *)str {
-
-
- NSMutableArray *titleArr = [NSMutableArray array];
- NSMutableArray *subTitles = [NSMutableArray array];
- NSInteger counts =0;
- for (int i = 0; i < modelArr.count; i++) {
-
- ZBOrdertitleMOdel *model = modelArr[i];
- ZBChildOrderViewController *child = [[ZBChildOrderViewController alloc] init];
- child.type = [model.type integerValue];
- [titleArr addObject:model.title];
- [subTitles addObject:model.count];
- [self.vcList addObject:child];
- if (model.type.integerValue == 4) {
- counts =model.count.integerValue;//全部订单数量
-
- }
-
-
- }
- CGFloat height =0;
- if (str.length>0) {
- CGFloat contentHeight=[self cellHeightWithMsg:str];
- UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(10)+contentHeight)];
- accountBtn.backgroundColor =[UIColor whiteColor];
- [self.view addSubview:accountBtn];
- UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), contentHeight/2-FITSIZE(2.5), FITSIZE(15), FITSIZE(15))];
- imgv.image =[UIImage imageNamed:@"message_icon"];
-
- [accountBtn addSubview:imgv];
- accountBtn.tag = 1111;
- UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, SCREEN_WIDTH-FITSIZE(60), FITSIZE(5)+contentHeight)];
- label.text=str;
- label.numberOfLines=0;
- label.textColor=[UIColor YHColorWithHex:0xFB6526];
- label.font=[UIFont systemFontOfSize:FITSIZE(12)];
- [accountBtn addSubview:label];
-
- label.tag = 1234;
- [self.view addSubview:accountBtn];
- height =FITSIZE(20)+contentHeight;
- }
-
-
-
- self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+70+height, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70-height) vcOrViews:self.vcList];
- self.segScroll.bounces = NO;
- self.segScroll.loadAll = YES;
- self.titleView = [[TopTypeHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight+height, SCREEN_WIDTH, 70) titles:titleArr headStyle:TopTypeHeadStyleDefault layoutStyle:TopTypeLayoutDefault];
- self.titleView.headColor = [UIColor whiteColor];
- self.titleView.bottomLineHeight = 1;
- self.titleView.subTitles = subTitles;
- self.titleView.bottomLineColor = [UIColor yhGrayColor];
- self.titleView.fontScale = 1;
- self.titleView.fontSize = 14;
- self.titleView.equalSize = YES;
- self.titleView.showIndex = _showIndex;
- self.titleView.selectColor = [UIColor baseColor];
- self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
- [TopTypeSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
- [self.view addSubview:self.titleView];
- [self.view addSubview:self.segScroll];
- }];
-
-
-
- }
- -(void)clickAction
- {
- if (self.alertShowView) {
- [self.alertShowView show];
- return;
- }
- CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES];
- self.alertShowView = showView;
- [self.alertShowView show];
-
- // ITDatePickerController *datePickerController = [[ITDatePickerController alloc] init];
- // datePickerController.tag = 100;
- // datePickerController.delegate = self;
- // datePickerController.showToday = NO;
- //// datePickerController.defaultDate = self.startDate;
- // datePickerController.minimumDate = nil;
- // datePickerController.maximumDate = nil;
- // [self presentViewController:datePickerController animated:YES completion:nil];
- }
- - (LDCalendarView *)calendarView {
- if (!_calendarView) {
- __weak typeof(self) weakSelf = self;
- _calendarView = [[LDCalendarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-40, 0)];
- _calendarView.cancelBlock = ^{
- [weakSelf.alertShowView dismiss];
- };
- _calendarView.makeSureBlock = ^(NSString *dateStr) {
- if (dateStr) {
- // yearMonthDay = dateStr;
- // page = 1;
- // [weakSelf requestAndRefresh:YES];
- // [weakSelf.topView setTitleStr:dateStr];
- [weakSelf.navBar setNavTitle:dateStr];
- weakSelf.navBar.navTitleLabel.textColor = [UIColor whiteColor];
- [weakSelf.alertShowView dismiss];
- }else {
- [weakSelf.alertShowView dismiss];
- }
-
- };
- }
- return _calendarView;
- }
- #pragma mark - ITDatePickerControllerDelegate
- - (void)datePickerController:(ITDatePickerController *)datePickerController didSelectedDate:(NSDate *)date dateString:(NSString *)dateString {
- NSLog(@"%@",dateString);
-
- }
- - (CGFloat)cellHeightWithMsg:(NSString *)msg
- {
- UILabel *label = [[UILabel alloc] init];
- label.text = msg;
- label.font = [UIFont systemFontOfSize:16];
- label.numberOfLines = 0;
- CGSize size = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH-FITSIZE(60), CGFLOAT_MAX)];
- return size.height;
- }
- @end
|