123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // 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 () <UIScrollViewDelegate>
- @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
|