StudentDetailViewController.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // StudentDetailViewController.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/19.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "StudentDetailViewController.h"
  9. #import "StudentDetailViewModel.h"
  10. /// 登记培训
  11. #import "RegisterTrainViewController.h"
  12. /// 培训记录
  13. #import "StudentDetailTrainRecordViewController.h"
  14. /// 培训汇总
  15. #import "TrainSummaryViewController.h"
  16. /// 考试信息
  17. #import "ExamInfoViewController.h"
  18. /// 预考信息
  19. #import "PreExamInfoViewController.h"
  20. @interface StudentDetailViewController () <UIScrollViewDelegate>
  21. @property (nonatomic, readwrite, strong) HDCollectionView *collectionView;
  22. @property (nonatomic, readwrite, strong) StudentDetailViewModel *studentDetailViewModel;
  23. @property (nonatomic, readwrite, strong) UIImageView *backgroundImageView;
  24. @end
  25. @implementation StudentDetailViewController
  26. #pragma mark - Life Cycle
  27. - (void)viewWillAppear:(BOOL)animated {
  28. [super viewWillAppear:animated];
  29. }
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. [self initUI];
  33. }
  34. #pragma mark - Private Functions
  35. - (void)initUI {
  36. self.title = @"学员详情";
  37. self.view.backgroundColor = KBackGroundColor;
  38. [self goBackByNavigation];
  39. [self.view addSubview:self.collectionView];
  40. [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.mas_equalTo(self.view.hd_mas_left);
  42. make.right.mas_equalTo(self.view.hd_mas_right);
  43. make.bottom.mas_equalTo(self.view.hd_mas_bottom);
  44. make.top.mas_equalTo(self.view.hd_mas_top);
  45. }];
  46. self.collectionView.backgroundColor = UIColor.whiteColor;
  47. self.collectionView.collectionV.backgroundColor = UIColor.whiteColor;
  48. [self.collectionView insertSubview:self.backgroundImageView belowSubview:self.collectionView.collectionV];
  49. /// 初始化数据
  50. __weak typeof(self) weakS = self;
  51. [self.studentDetailViewModel loadData:^(BOOL success, id _Nonnull res) {
  52. if (success) {
  53. [_collectionView hd_setAllDataArr:res];
  54. }else{
  55. //error
  56. }
  57. }];
  58. [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) {
  59. if (type == HDCellCallBack) {
  60. [weakS clickCell:backModel];
  61. }else if (type == HDSectionHeaderCallBack){
  62. [weakS clickHeader:backModel];
  63. }
  64. }];
  65. [_collectionView hd_setScrollViewDidScrollCallback:^(UIScrollView *scrollView) {
  66. NSLog(@"%f",scrollView.contentOffset.y);
  67. _backgroundImageView.frame = CGRectMake(0, 0, kScreenWidth, scrollView.contentOffset.y > 0? 0 : - scrollView.contentOffset.y);
  68. }];
  69. }
  70. - (void)clickCell:(HDCellModel*)cellM {
  71. NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item);
  72. switch (cellM.indexP.item) {
  73. case 0: {
  74. RegisterTrainViewController *vc = [[RegisterTrainViewController alloc] init];
  75. [self navPushHideTabbarToVC:vc];
  76. break;
  77. }
  78. case 1: {
  79. StudentDetailTrainRecordViewController *vc = [[StudentDetailTrainRecordViewController alloc] init];
  80. [self navPushHideTabbarToVC:vc];
  81. break;
  82. }
  83. case 2: {
  84. TrainSummaryViewController *vc = [[TrainSummaryViewController alloc] init];
  85. [self navPushHideTabbarToVC:vc];
  86. break;
  87. }
  88. case 3: {
  89. ExamInfoViewController *vc = [[ExamInfoViewController alloc] init];
  90. [self navPushHideTabbarToVC:vc];
  91. break;
  92. }
  93. case 4: {
  94. PreExamInfoViewController *vc = [[PreExamInfoViewController alloc] init];
  95. [self navPushHideTabbarToVC:vc];
  96. break;
  97. }
  98. default:
  99. break;
  100. }
  101. }
  102. - (void)clickHeader:(HDSectionModel*)secM {
  103. NSLog(@"点击了段头");
  104. }
  105. #pragma mark - Lazy Load
  106. - (HDCollectionView *)collectionView {
  107. if (!_collectionView) {
  108. _collectionView = [HDCollectionView hd_makeHDCollectionView:^(HDCollectionViewMaker *maker) {
  109. maker
  110. .hd_isNeedTopStop(YES)
  111. .hd_scrollDirection(UICollectionViewScrollDirectionVertical);
  112. }];
  113. _collectionView.collectionV.showsVerticalScrollIndicator = NO;
  114. }
  115. return _collectionView;
  116. }
  117. - (StudentDetailViewModel *)studentDetailViewModel {
  118. if (!_studentDetailViewModel) {
  119. _studentDetailViewModel = [[StudentDetailViewModel alloc] init];
  120. }
  121. return _studentDetailViewModel;
  122. }
  123. - (UIImageView *)backgroundImageView {
  124. if (!_backgroundImageView) {
  125. _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 0)];
  126. _backgroundImageView.backgroundColor = RQMianColor;
  127. }
  128. return _backgroundImageView;
  129. }
  130. @end