// // StudentDetailViewController.m // LN_School // // Created by 张嵘 on 2019/7/19. // Copyright © 2019 Danson. All rights reserved. // #import "StudentDetailViewController.h" #import "StudentDetailViewModel.h" /// 登记培训 #import "RegisterTrainViewController.h" /// 培训记录 #import "StudentDetailTrainRecordViewController.h" /// 培训汇总 #import "TrainSummaryViewController.h" /// 考试信息 #import "ExamInfoViewController.h" /// 预考信息 #import "PreExamInfoViewController.h" @interface StudentDetailViewController () @property (nonatomic, readwrite, strong) HDCollectionView *collectionView; @property (nonatomic, readwrite, strong) StudentDetailViewModel *studentDetailViewModel; @property (nonatomic, readwrite, strong) UIImageView *backgroundImageView; @end @implementation StudentDetailViewController #pragma mark - Life Cycle - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; } #pragma mark - Private Functions - (void)initUI { self.title = @"学员详情"; self.view.backgroundColor = KBackGroundColor; [self goBackByNavigation]; [self.view addSubview:self.collectionView]; [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.view.hd_mas_left); make.right.mas_equalTo(self.view.hd_mas_right); make.bottom.mas_equalTo(self.view.hd_mas_bottom); make.top.mas_equalTo(self.view.hd_mas_top); }]; self.collectionView.backgroundColor = UIColor.whiteColor; self.collectionView.collectionV.backgroundColor = UIColor.whiteColor; [self.collectionView insertSubview:self.backgroundImageView belowSubview:self.collectionView.collectionV]; /// 初始化数据 __weak typeof(self) weakS = self; [self.studentDetailViewModel loadData:^(BOOL success, id _Nonnull res) { if (success) { [_collectionView hd_setAllDataArr:res]; }else{ //error } }]; [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) { if (type == HDCellCallBack) { [weakS clickCell:backModel]; }else if (type == HDSectionHeaderCallBack){ [weakS clickHeader:backModel]; } }]; [_collectionView hd_setScrollViewDidScrollCallback:^(UIScrollView *scrollView) { NSLog(@"%f",scrollView.contentOffset.y); _backgroundImageView.frame = CGRectMake(0, 0, kScreenWidth, scrollView.contentOffset.y > 0? 0 : - scrollView.contentOffset.y); }]; } - (void)clickCell:(HDCellModel*)cellM { NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item); switch (cellM.indexP.item) { case 0: { RegisterTrainViewController *vc = [[RegisterTrainViewController alloc] init]; [self navPushHideTabbarToVC:vc]; break; } case 1: { StudentDetailTrainRecordViewController *vc = [[StudentDetailTrainRecordViewController alloc] init]; [self navPushHideTabbarToVC:vc]; break; } case 2: { TrainSummaryViewController *vc = [[TrainSummaryViewController alloc] init]; [self navPushHideTabbarToVC:vc]; break; } case 3: { ExamInfoViewController *vc = [[ExamInfoViewController alloc] init]; [self navPushHideTabbarToVC:vc]; break; } case 4: { PreExamInfoViewController *vc = [[PreExamInfoViewController alloc] init]; [self navPushHideTabbarToVC:vc]; break; } default: break; } } - (void)clickHeader:(HDSectionModel*)secM { NSLog(@"点击了段头"); } #pragma mark - Lazy Load - (HDCollectionView *)collectionView { if (!_collectionView) { _collectionView = [HDCollectionView hd_makeHDCollectionView:^(HDCollectionViewMaker *maker) { maker .hd_isNeedTopStop(YES) .hd_scrollDirection(UICollectionViewScrollDirectionVertical); }]; _collectionView.collectionV.showsVerticalScrollIndicator = NO; } return _collectionView; } - (StudentDetailViewModel *)studentDetailViewModel { if (!_studentDetailViewModel) { _studentDetailViewModel = [[StudentDetailViewModel alloc] init]; } return _studentDetailViewModel; } - (UIImageView *)backgroundImageView { if (!_backgroundImageView) { _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)]; _backgroundImageView.backgroundColor = RQMianColor; } return _backgroundImageView; } @end