// // PreExamMarkViewController.m // LN_School // // Created by 张嵘 on 2019/7/31. // Copyright © 2019 Danson. All rights reserved. // #import "PreExamMarkViewController.h" #import "PreExamMarkViewModel.h" @interface PreExamMarkViewController () @property (nonatomic, readwrite, strong) HDCollectionView *collectionView; @property (nonatomic, readwrite, strong) PreExamMarkViewModel *preExamMarkViewModel; @end @implementation PreExamMarkViewController #pragma mark - Life Cycle - (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); }]; /// 初始化数据 __weak typeof(self) weakS = self; _collectionView.collectionV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [self.preExamMarkViewModel loadData:^(BOOL success, id _Nonnull res) { [_collectionView.collectionV.mj_header endRefreshing]; if (success) { [_collectionView hd_setAllDataArr:res]; }else{ //error } }]; }]; _collectionView.collectionV.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ [_collectionView.collectionV.mj_footer endRefreshing]; [self.preExamMarkViewModel loadData:^(BOOL success, id _Nonnull res) { if (success) { [_collectionView hd_setAllDataArr:res]; }else{ //error } }]; }]; [_collectionView.collectionV.mj_header beginRefreshing]; [_collectionView hd_setAllEventCallBack:^(id backModel, HDCallBackType type) { if (type == HDCellCallBack) { [weakS clickCell:backModel]; }else if (type == HDSectionHeaderCallBack){ [weakS clickHeader:backModel]; } }]; } - (void)clickCell:(HDCellModel*)cellM { NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item); } - (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.backgroundColor = RQBackGroundColor; } return _collectionView; } - (PreExamMarkViewModel *)preExamMarkViewModel { if (!_preExamMarkViewModel) { _preExamMarkViewModel = [[PreExamMarkViewModel alloc] init]; } return _preExamMarkViewModel; } @end