StudentDetailViewModel.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // StudentDetailViewModel.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/25.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "StudentDetailViewModel.h"
  9. #import "StudentDetailSecOneModel.h"
  10. #import "StudentDetailCommonHeaderModel.h"
  11. #import "StudentDetailInfoModel.h"
  12. @implementation StudentDetailViewModel
  13. - (void)loadData:(void (^)(BOOL, id _Nonnull))calback {
  14. //发起网络请求、处理后返回(这里省略)
  15. NSMutableArray *sectionArr = @[[self makeSecZeroModel], [self makeSecOneModel], [self makeSecTwoModel], [self makeSecThreeModel]].mutableCopy;
  16. //如果没有对callback强引用,外部可以不用weakSelf
  17. if (calback) {
  18. calback(YES,sectionArr);
  19. }
  20. }
  21. - (HDSectionModel*)makeSecZeroModel {
  22. //该段layout
  23. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
  24. layout.headerSize = CGSizeMake(kScreenWidth, kScreenWidth * (5.5f / 12.f));
  25. //该段的所有数据封装
  26. HDSectionModel *secModel = [HDSectionModel new];
  27. secModel.sectionHeaderClassStr = @"StudentDetailInfoHeaderView";
  28. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  29. secModel.layout = layout;
  30. return secModel;
  31. }
  32. - (HDSectionModel*)makeSecOneModel {
  33. NSArray *titlesArr = @[@"登记培训",@"培训记录",@"培训汇总",@"考试信息",@"预考信息"];
  34. NSArray *imageName = @[@"registerTrain",@"trainRecord",@"trainSummary",@"examInformation",@"preExamInformation"];
  35. //该段cell数据源
  36. NSMutableArray *cellModelArr = @[].mutableCopy;
  37. NSInteger cellCount = titlesArr.count;
  38. for (int i = 0; i < cellCount; i++) {
  39. HDCellModel *model = [HDCellModel new];
  40. StudentDetailSecOneModel *studentDetailSecOneModel = [StudentDetailSecOneModel new];
  41. studentDetailSecOneModel.title = titlesArr[i];
  42. studentDetailSecOneModel.imageName = imageName[i];
  43. model.orgData = studentDetailSecOneModel;
  44. model.cellSize = CGSizeMake((kScreenWidth - 32)/5.f, (kScreenWidth - 32)/5.f + 16);
  45. model.cellClassStr = @"StudentDetailSecOneCell";
  46. [cellModelArr addObject:model];
  47. }
  48. //该段layout
  49. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];
  50. layout.secInset = UIEdgeInsetsMake(0, 16, 0, 16);
  51. layout.justify = YGJustifyCenter;
  52. layout.verticalGap = 0;
  53. layout.horizontalGap = 0;
  54. layout.headerSize = CGSizeZero;
  55. layout.footerSize = CGSizeMake(kScreenWidth, 10);
  56. //该段的所有数据封装
  57. HDSectionModel *secModel = [HDSectionModel new];
  58. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  59. secModel.sectionDataArr = cellModelArr;
  60. secModel.layout = layout;
  61. return secModel;
  62. }
  63. - (HDSectionModel*)makeSecTwoModel {
  64. //该段cell数据源
  65. NSArray *titlesArr = @[@"身份证号",@"技能准考证编号",@"来至何处",@"联系地址",@"是否本地",@"电子邮箱"];
  66. NSArray *contentsArr = @[@"350128199909099999",@"350128199909099999",@"福州市",@"鼓楼区",@"是",@"888888888@qq.com"];
  67. NSMutableArray *cellModelArr = @[].mutableCopy;
  68. NSInteger cellCount = titlesArr.count;
  69. for (int i =0; i < cellCount; i++) {
  70. HDCellModel *model = [HDCellModel new];
  71. StudentDetailInfoModel *studentDetailInfoModel = [StudentDetailInfoModel new];
  72. studentDetailInfoModel.titleString = titlesArr[i];
  73. studentDetailInfoModel.contentString = contentsArr[i];
  74. model.orgData = studentDetailInfoModel;
  75. model.cellSize = CGSizeMake(kScreenWidth, 44);
  76. model.cellClassStr = @"StudentDetailInfoCell";
  77. [cellModelArr addObject:model];
  78. }
  79. //该段layout
  80. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  81. layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
  82. layout.justify = YGJustifyCenter;
  83. layout.verticalGap = 0;
  84. layout.horizontalGap = 0;
  85. layout.headerSize = CGSizeMake(kScreenWidth, 44);
  86. layout.footerSize = CGSizeMake(kScreenWidth, 10);
  87. //该段的所有数据封装
  88. HDSectionModel *secModel = [HDSectionModel new];
  89. secModel.sectionHeaderClassStr = @"StudentDetailCommonHeaderView";
  90. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  91. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  92. secModel.isNeedAutoCountCellHW = NO;
  93. secModel.sectionDataArr = cellModelArr;
  94. secModel.layout = layout;
  95. StudentDetailCommonHeaderModel *headerModel = [[StudentDetailCommonHeaderModel alloc] init];
  96. headerModel.title = @"个人信息";
  97. secModel.headerObj = headerModel;
  98. return secModel;
  99. }
  100. - (HDSectionModel*)makeSecThreeModel {
  101. //该段cell数据源
  102. NSArray *titlesArr = @[@"车牌号",@"报名时间",@"考试状态",@"考核状态",@"申请类型",@"申请准驾",@"培训课程"];
  103. NSArray *contentsArr = @[@"350128199909099999",@"2018-06-30",@"未考试",@"未考试",@"C1",@"C1",@"科目一"];
  104. NSMutableArray *cellModelArr = @[].mutableCopy;
  105. NSInteger cellCount = titlesArr.count;
  106. for (int i =0; i < cellCount; i++) {
  107. HDCellModel *model = [HDCellModel new];
  108. StudentDetailInfoModel *studentDetailInfoModel = [StudentDetailInfoModel new];
  109. studentDetailInfoModel.titleString = titlesArr[i];
  110. studentDetailInfoModel.contentString = contentsArr[i];
  111. model.orgData = studentDetailInfoModel;
  112. model.cellSize = CGSizeMake(kScreenWidth, 44);
  113. model.cellClassStr = @"StudentDetailInfoCell";
  114. [cellModelArr addObject:model];
  115. }
  116. //该段layout
  117. HDYogaFlowLayout *layout = [HDYogaFlowLayout new];//isUseSystemFlowLayout为YES时只支持HDBaseLayout
  118. layout.secInset = UIEdgeInsetsMake(0, 10, 0, 10);
  119. layout.justify = YGJustifyCenter;
  120. layout.verticalGap = 0;
  121. layout.horizontalGap = 0;
  122. layout.headerSize = CGSizeMake(kScreenWidth, 44);
  123. layout.footerSize = CGSizeMake(0, 0);
  124. //该段的所有数据封装
  125. HDSectionModel *secModel = [HDSectionModel new];
  126. secModel.sectionHeaderClassStr = @"StudentDetailCommonHeaderView";
  127. secModel.sectionFooterClassStr = @"CommonSecFooterView";
  128. secModel.headerTopStopType = HDHeaderStopOnTopTypeNormal;
  129. secModel.isNeedAutoCountCellHW = NO;
  130. secModel.sectionDataArr = cellModelArr;
  131. secModel.layout = layout;
  132. StudentDetailCommonHeaderModel *headerModel = [[StudentDetailCommonHeaderModel alloc] init];
  133. headerModel.title = @"培训信息";
  134. secModel.headerObj = headerModel;
  135. return secModel;
  136. }
  137. @end