123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // StudentDetailViewModel.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/25.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "StudentDetailViewModel.h"
- #import "StudentDetailSecOneModel.h"
- #import "StudentDetailCommonHeaderModel.h"
- #import "StudentDetailInfoModel.h"
- @implementation StudentDetailViewModel
- - (void)loadData:(void (^)(BOOL, id _Nonnull))calback {
- //发起网络请求、处理后返回(这里省略)
- NSMutableArray *sectionArr = @[[self makeSecZeroModel], [self makeSecOneModel], [self makeSecTwoModel], [self makeSecThreeModel]].mutableCopy;
- //如果没有对callback强引用,外部可以不用weakSelf
- if (calback) {
- calback(YES,sectionArr);
- }
- }
- - (HDSectionModel*)makeSecZeroModel {
-
- //该段layout
- HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
- layout.headerSize = CGSizeMake(kScreenWidth, kScreenWidth * (5.5f / 12.f));
- //该段的所有数据封装
- HDSectionModel *secModel = [HDSectionModel new];
- secModel.sectionHeaderClassStr = @"StudentDetailInfoHeaderView";
- secModel.sectionFooterClassStr = @"CommonSecFooterView";
- secModel.layout = layout;
- return secModel;
- }
- - (HDSectionModel*)makeSecOneModel {
-
- NSArray *titlesArr = @[@"登记培训",@"培训记录",@"培训汇总",@"考试信息",@"预考信息"];
- NSArray *imageName = @[@"registerTrain",@"trainRecord",@"trainSummary",@"examInformation",@"preExamInformation"];
- //该段cell数据源
- NSMutableArray *cellModelArr = @[].mutableCopy;
- NSInteger cellCount = titlesArr.count;
- for (int i = 0; i < cellCount; i++) {
- HDCellModel *model = [HDCellModel new];
- StudentDetailSecOneModel *studentDetailSecOneModel = [StudentDetailSecOneModel new];
- studentDetailSecOneModel.title = titlesArr[i];
- studentDetailSecOneModel.imageName = imageName[i];
- model.orgData = studentDetailSecOneModel;
- model.cellSize = CGSizeMake((kScreenWidth - 32)/5.f, (kScreenWidth - 32)/5.f + 16);
- model.cellClassStr = @"StudentDetailSecOneCell";
- [cellModelArr addObject:model];
- }
-
- //该段layout
- HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
- layout.secInset = UIEdgeInsetsMake(0, 16, 0, 16);
- layout.justify = YGJustifyCenter;
- layout.verticalGap = 0;
- layout.horizontalGap = 0;
- layout.headerSize = CGSizeZero;
- layout.footerSize = CGSizeMake(kScreenWidth, 10);
-
- //该段的所有数据封装
- HDSectionModel *secModel = [HDSectionModel new];
- secModel.sectionFooterClassStr = @"CommonSecFooterView";
- secModel.sectionDataArr = cellModelArr;
- secModel.layout = layout;
- return secModel;
- }
- - (HDSectionModel*)makeSecTwoModel {
-
- //该段cell数据源
- NSArray *titlesArr = @[@"身份证号",@"技能准考证编号",@"来至何处",@"联系地址",@"是否本地",@"电子邮箱"];
- NSArray *contentsArr = @[@"350128199909099999",@"350128199909099999",@"福州市",@"鼓楼区",@"是",@"888888888@qq.com"];
- NSMutableArray *cellModelArr = @[].mutableCopy;
- NSInteger cellCount = titlesArr.count;
- for (int i =0; i < cellCount; i++) {
- HDCellModel *model = [HDCellModel new];
- StudentDetailInfoModel *studentDetailInfoModel = [StudentDetailInfoModel new];
- studentDetailInfoModel.titleString = titlesArr[i];
- studentDetailInfoModel.contentString = contentsArr[i];
- model.orgData = studentDetailInfoModel;
- model.cellSize = CGSizeMake(kScreenWidth, 44);
- model.cellClassStr = @"StudentDetailInfoCell";
- [cellModelArr addObject:model];
- }
-
- //该段layout
- HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
- layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
- layout.justify = YGJustifyCenter;
- layout.verticalGap = 0;
- layout.horizontalGap = 0;
- layout.headerSize = CGSizeMake(kScreenWidth, 44);
- layout.footerSize = CGSizeMake(kScreenWidth, 10);
-
- //该段的所有数据封装
- HDSectionModel *secModel = [HDSectionModel new];
-
- secModel.sectionHeaderClassStr = @"StudentDetailCommonHeaderView";
- secModel.sectionFooterClassStr = @"CommonSecFooterView";
- secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
- secModel.isNeedAutoCountCellHW = NO;
- secModel.sectionDataArr = cellModelArr;
- secModel.layout = layout;
- StudentDetailCommonHeaderModel *headerModel = [[StudentDetailCommonHeaderModel alloc] init];
- headerModel.title = @"个人信息";
- secModel.headerObj = headerModel;
- return secModel;
- }
- - (HDSectionModel*)makeSecThreeModel {
-
- //该段cell数据源
- NSArray *titlesArr = @[@"车牌号",@"报名时间",@"考试状态",@"考核状态",@"申请类型",@"申请准驾",@"培训课程"];
- NSArray *contentsArr = @[@"350128199909099999",@"2018-06-30",@"未考试",@"未考试",@"C1",@"C1",@"科目一"];
- NSMutableArray *cellModelArr = @[].mutableCopy;
- NSInteger cellCount = titlesArr.count;
- for (int i =0; i < cellCount; i++) {
- HDCellModel *model = [HDCellModel new];
- StudentDetailInfoModel *studentDetailInfoModel = [StudentDetailInfoModel new];
- studentDetailInfoModel.titleString = titlesArr[i];
- studentDetailInfoModel.contentString = contentsArr[i];
- model.orgData = studentDetailInfoModel;
- model.cellSize = CGSizeMake(kScreenWidth, 44);
- model.cellClassStr = @"StudentDetailInfoCell";
- [cellModelArr addObject:model];
- }
-
- //该段layout
- HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
- layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
- layout.justify = YGJustifyCenter;
- layout.verticalGap = 0;
- layout.horizontalGap = 0;
- layout.headerSize = CGSizeMake(kScreenWidth, 44);
- layout.footerSize = CGSizeMake(0, 0);
-
- //该段的所有数据封装
- HDSectionModel *secModel = [HDSectionModel new];
- secModel.sectionHeaderClassStr = @"StudentDetailCommonHeaderView";
- secModel.sectionFooterClassStr = @"CommonSecFooterView";
- secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
- secModel.isNeedAutoCountCellHW = NO;
- secModel.sectionDataArr = cellModelArr;
- secModel.layout = layout;
- StudentDetailCommonHeaderModel *headerModel = [[StudentDetailCommonHeaderModel alloc] init];
- headerModel.title = @"培训信息";
- secModel.headerObj = headerModel;
- return secModel;
- }
- @end
|