TrainSituationViewController.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // TrainSituationViewController.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/31.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "TrainSituationViewController.h"
  9. #import "TrainSituationViewModel.h"
  10. #import "StudentDetailViewController.h"
  11. @interface TrainSituationViewController ()
  12. @property (nonatomic, readwrite, strong) HDCollectionView *collectionView;
  13. @property (nonatomic, readwrite, strong) TrainSituationViewModel *trainSituationViewModel;
  14. @end
  15. @implementation TrainSituationViewController
  16. #pragma mark - Life Cycle
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self initUI];
  20. }
  21. #pragma mark - Private Functions
  22. - (void)initUI {
  23. self.title = @"培训情况";
  24. self.view.backgroundColor = KBackGroundColor;
  25. [self goBackByNavigation];
  26. [self.view addSubview:self.collectionView];
  27. [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.mas_equalTo(self.view.hd_mas_left);
  29. make.right.mas_equalTo(self.view.hd_mas_right);
  30. make.bottom.mas_equalTo(self.view.hd_mas_bottom);
  31. make.top.mas_equalTo(self.view.hd_mas_top);
  32. }];
  33. /// 初始化数据
  34. __weak typeof(self) weakS = self;
  35. [self.trainSituationViewModel loadData:^(BOOL success, id _Nonnull res) {
  36. if (success) {
  37. [_collectionView hd_setAllDataArr:res];
  38. }else{
  39. //error
  40. }
  41. }];
  42. [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) {
  43. if (type == HDCellCallBack) {
  44. [weakS clickCell:backModel];
  45. }else if (type == HDSectionHeaderCallBack){
  46. [weakS clickHeader:backModel];
  47. }
  48. }];
  49. }
  50. - (void)clickCell:(HDCellModel*)cellM {
  51. NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item);
  52. StudentDetailViewController *vc = [[StudentDetailViewController alloc] init];
  53. [self navPushHideTabbarToVC:vc];
  54. }
  55. - (void)clickHeader:(HDSectionModel*)secM {
  56. NSLog(@"点击了段头");
  57. }
  58. #pragma mark - Lazy Load
  59. - (HDCollectionView *)collectionView {
  60. if (!_collectionView) {
  61. _collectionView = [HDCollectionView hd_makeHDCollectionView:^(HDCollectionViewMaker *maker) {
  62. maker
  63. .hd_isNeedTopStop(YES)
  64. .hd_scrollDirection(UICollectionViewScrollDirectionVertical);
  65. }];
  66. _collectionView.backgroundColor = RQBackGroundColor;
  67. }
  68. return _collectionView;
  69. }
  70. - (TrainSituationViewModel *)trainSituationViewModel {
  71. if (!_trainSituationViewModel) {
  72. _trainSituationViewModel = [[TrainSituationViewModel alloc] init];
  73. }
  74. return _trainSituationViewModel;
  75. }
  76. @end