PreExamMarkViewController.m 2.7 KB

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