// // LDCommissionMainViewController.m // YouHuiProject // // Created by 小花 on 2018/5/18. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LDCommissionMainViewController.h" #import "MLMSegmentHead.h" #import "MLMSegmentManager.h" #import "LDOrderTableView.h" #import "LDChildCommissionController.h" #import "LDCommissionHeaderView.h" #import "LDChildCommissionController.h" #import "LDCalendarView.h" #import "CCAlertShowView.h" #import "TopTypeHeader.h" #import "TopTypeSegmentManager.h" #import "LDCommissionHeaderModel.h" #import "LDCommissionMainViewController.h" #import "LDPrivilegeReferralViewController.h" @interface LDCommissionMainViewController () @property (nonatomic, strong) LDOrderTableView *tableView; @property (nonatomic, strong) LDCommissionHeaderView *headerView; @property (nonatomic, strong) TopTypeHeader *titleView; @property (nonatomic, strong) MLMSegmentScroll *segScroll; @property (nonatomic, strong) NSMutableArray *vcList; @property (nonatomic, assign) BOOL canScroll; @property (nonatomic, strong) LDCalendarView *calendarView ; @property (nonatomic, strong) CCAlertShowView *alertShowView; @end @implementation LDCommissionMainViewController - (void)dealloc { } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [LoadingView dismiss]; } - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; [self loadTitleData]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } - (void)configNavigationBar { [self.navigationBar setNavTitle:@"订单明细"]; self.navigationBar.backgroundColor = [UIColor changeColor]; self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor]; UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal]; [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomLeftButtons:@[leftBtn]]; UIButton *calendar = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [calendar setImage:[UIImage imageNamed:@"white_canlendar"] forState:UIControlStateNormal]; [calendar addTarget:self action:@selector(showCalendar) forControlEvents:UIControlEventTouchUpInside]; [self.navigationBar setCustomRightButtons:@[calendar]]; self.view.backgroundColor = [UIColor backgroudColor]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)showCalendar { if (self.alertShowView) { [self.alertShowView show]; return; } CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES]; self.alertShowView = showView; [self.alertShowView show]; } - (void)loadTitleData { NSString *url = [NSString stringWithFormat:@"%@/api/v2/adzoneCreate/getOrderTop",BaseURL]; [LoadingView show]; [LDHttp post:url params:nil success:^(id json) { [LoadingView dismiss]; NSArray *arr = [NSArray yy_modelArrayWithClass:[LDCommissionHeaderModel class] json:json[@"data"]]; [self creatHeaderViewAndFooterView:arr]; } failure:^(NSError *error) { }]; } - (void)creatHeaderViewAndFooterView:(NSArray *)modelArr { NSMutableArray *titleArr = [NSMutableArray array]; NSMutableArray *subTitles = [NSMutableArray array]; NSInteger counts =0; for (int i = 0; i < modelArr.count; i++) { LDCommissionHeaderModel *model = modelArr[i]; LDChildCommissionController *child = [[LDChildCommissionController 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; //取值(key值同名的时候会覆盖的) NSDictionary * userinfoDic =[LDUserInfoManager shareManager].userInfoDic; if ([userinfoDic[@"user_level"] integerValue ] == 1) {//会员 UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(30))]; [accountBtn setImage:[UIImage imageNamed:@"goto_detail"] forState:UIControlStateNormal]; [accountBtn setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7.5), SCREEN_WIDTH-FITSIZE(30), FITSIZE(7.5), FITSIZE(15))]; accountBtn.backgroundColor =[UIColor whiteColor]; [self.view addSubview:accountBtn]; [accountBtn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside]; UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), FITSIZE(7.5), FITSIZE(15), FITSIZE(15))]; imgv.image =[UIImage imageNamed:@"order_notice"]; [accountBtn addSubview:imgv]; UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, FITSIZE(300), FITSIZE(30))]; label.text=@"你还不是超级会员,成为超级会员就能购物有收益啦"; label.textColor=[UIColor YHColorWithHex:0xFB6526]; label.font=[UIFont systemFontOfSize:FITSIZE(12)]; [accountBtn addSubview:label]; label.tag = 1234; [self.view addSubview:accountBtn]; height =FITSIZE(40); }else{ if (counts !=0) { UIButton *accountBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, FITSIZE(5)+NavBarHeight, SCREEN_WIDTH, FITSIZE(30))]; [accountBtn setImage:[UIImage imageNamed:@"order_cancel"] forState:UIControlStateNormal]; [accountBtn setImageEdgeInsets:UIEdgeInsetsMake(FITSIZE(7.5), SCREEN_WIDTH-FITSIZE(30), FITSIZE(7.5), FITSIZE(15))]; accountBtn.backgroundColor =[UIColor whiteColor]; [self.view addSubview:accountBtn]; [accountBtn addTarget:self action:@selector(clickCloseBtn) forControlEvents:UIControlEventTouchUpInside]; UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(15), FITSIZE(7.5), FITSIZE(15), FITSIZE(15))]; imgv.image =[UIImage imageNamed:@"order_notice"]; [accountBtn addSubview:imgv]; accountBtn.tag = 1111; UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(FITSIZE(40), 0, FITSIZE(300), FITSIZE(30))]; label.text=@"订单收益一般10分钟内同步,最迟3小时,请稍等一会儿~"; label.textColor=[UIColor YHColorWithHex:0xFB6526]; label.font=[UIFont systemFontOfSize:FITSIZE(12)]; [accountBtn addSubview:label]; label.tag = 1234; [self.view addSubview:accountBtn]; height =FITSIZE(40); } 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 homeRedColor]; 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)clickCloseBtn { UIButton *accountB =[self.view viewWithTag:1111]; [accountB removeFromSuperview]; self.segScroll.frame=CGRectMake(0, NavBarHeight+70, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70); self.titleView.frame=CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 70); } -(void)clickBtn { LDPrivilegeReferralViewController *Privilege = [[LDPrivilegeReferralViewController alloc] init]; [self.navigationController pushViewController:Privilege animated:YES]; } #pragma mark ----- nofi ----- //- (void)changeScrollStatus { // self.canScroll = YES; // for (LDChildCommissionController *childVc in self.vcList) { // childVc.childCanScroll = NO; // } //} - (NSMutableArray *)vcList { if (!_vcList) { _vcList = [NSMutableArray array]; } return _vcList; } - (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) { for (LDChildCommissionController *child in weakSelf.vcList) { [child refreshWithDate:dateStr]; } [weakSelf.alertShowView dismiss]; }; } return _calendarView; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end