HomePageViewController.m 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //
  2. // HomePageViewController.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/9.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "HomePageViewController.h"
  9. #import "HomePageADHeaderView.h"
  10. #import "HomePageSubViewController.h"
  11. #import "TrainSituationNumHeaderModel.h"
  12. #import "SignUpSituationViewController.h"
  13. #import "TrainSituationViewController.h"
  14. #import "StudentDetailViewController.h"
  15. #import "PreExamMarkViewController.h"
  16. #import "AppointmentManageViewController.h"
  17. #import "ExamArrangeViewController.h"
  18. #import "ExamStatisticsViewController.h"
  19. #import "AppointDriverViewController.h"
  20. #import "CoachArrangeClassViewController.h"
  21. #import "TrainRecordViewController.h"
  22. @interface HomePageViewController ()
  23. @property (nonatomic, readwrite, strong) HDCollectionView *collectionView;
  24. @property (nonatomic, readwrite, strong) HomePageViewModel *homePageViewModel;
  25. @end
  26. @implementation HomePageViewController
  27. #pragma mark - Life Cycle
  28. - (void)viewWillAppear:(BOOL)animated {
  29. [super viewWillAppear:animated];
  30. HDSectionModel *sectionModel = self.homePageViewModel.topSecArr.firstObject;
  31. HomePageADHeaderView *homePageADHeaderView = [[NSClassFromString(sectionModel.sectionHeaderClassStr) alloc] init];
  32. [homePageADHeaderView.cycleScrollView adjustWhenControllerViewWillAppera];
  33. }
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. [self initUI];
  37. }
  38. - (void)viewDidAppear:(BOOL)animated {
  39. [super viewDidAppear:animated];
  40. self.tabBarController.tabBar.hidden = NO;
  41. }
  42. #pragma mark - Private Functions
  43. - (void)initUI {
  44. self.view.backgroundColor = KBackGroundColor;
  45. [self.multipleSc mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.mas_equalTo(self.view.hd_mas_left);
  47. make.right.mas_equalTo(self.view.hd_mas_right);
  48. make.bottom.mas_equalTo(-kTabBarHeight);
  49. make.top.mas_equalTo(self.view.hd_mas_top);
  50. }];
  51. /// 初始化数据
  52. __weak typeof(self) weakS = self;
  53. [self.multipleSc configWithConfiger:^(HDMultipleScrollListConfiger * _Nonnull configer) {
  54. [weakS setWith:configer];
  55. }];
  56. /// 点击回调
  57. [self.multipleSc.mainCollecitonV hd_setAllEventCallBack:^(id backModel, HDCallBackType type) {
  58. if (type == HDCellCallBack) {
  59. [weakS clickCell:backModel];
  60. }else if (type == HDSectionHeaderCallBack){
  61. [weakS clickHeader:backModel];
  62. }
  63. }];
  64. /// 标签个性化设置
  65. [self jxCustomSetting];
  66. }
  67. /// 标签个性化设置
  68. - (void)jxCustomSetting {
  69. self.multipleSc.jxTitle.titleSelectedColor = RQSubColor;
  70. self.multipleSc.jxTitle.titleColorGradientEnabled = YES;
  71. self.multipleSc.jxLineView.indicatorLineViewColor = RQSubColor;
  72. self.multipleSc.jxLineView.lineStyle = JXCategoryIndicatorLineStyle_IQIYI;
  73. self.multipleSc.jxLineView.indicatorWidth = kScreenWidth / 10.0;
  74. self.multipleSc.jxLineView.indicatorHeight = 3;
  75. self.multipleSc.jxLineView.indicatorCornerRadius = 3;
  76. }
  77. /// 初始化数据
  78. - (void)setWith:(HDMultipleScrollListConfiger*)configer {
  79. self.title = @"首页";
  80. configer.topSecArr = self.homePageViewModel.topSecArr;
  81. configer.isHeaderNeedStop = self.homePageViewModel.headerStop;
  82. configer.titleContentSize = self.homePageViewModel.titleSize;
  83. configer.listHeight = self.homePageViewModel.listHeight;
  84. configer.diyHeaderClsStr = @"HomePageSecHeaderView";
  85. configer.controllers = self.homePageViewModel.controllers;
  86. configer.titles = self.homePageViewModel.titles;
  87. HDSectionModel *secModel = self.homePageViewModel.bottomSecArr.firstObject;
  88. if (secModel.sectionDataArr.count > 5) {
  89. secModel.sectionDataArr = [secModel.sectionDataArr subarrayWithRange:NSMakeRange(0, 5)].mutableCopy;
  90. [self.homePageViewModel.bottomSecArr replaceObjectAtIndex:0 withObject:secModel];
  91. }
  92. configer.bottomSecArr = self.homePageViewModel.bottomSecArr;
  93. configer.subSecArr = self.homePageViewModel.subViewControllerSecArr;
  94. }
  95. - (void)clickCell:(HDCellModel*)cellM {
  96. NSLog(@"点击了%zd--%zd cell",cellM.indexP.section,cellM.indexP.item);
  97. switch (cellM.indexP.section) {
  98. case 1: {
  99. switch (cellM.indexP.item) {
  100. case 0: {
  101. SignUpSituationViewController *vc = [[SignUpSituationViewController alloc] init];
  102. [self navPushHideTabbarToVC:vc];
  103. break;
  104. }
  105. case 1: {
  106. PreExamMarkViewController *vc = [[PreExamMarkViewController alloc] init];
  107. [self navPushHideTabbarToVC:vc];
  108. break;
  109. }
  110. case 2: {
  111. AppointmentManageViewController *vc = [[AppointmentManageViewController alloc] init];
  112. [self navPushHideTabbarToVC:vc];
  113. break;
  114. }
  115. case 3: {
  116. ExamArrangeViewController *vc = [[ExamArrangeViewController alloc] init];
  117. [self navPushHideTabbarToVC:vc];
  118. break;
  119. }
  120. case 4: {
  121. ExamStatisticsViewController *vc = [[ExamStatisticsViewController alloc] init];
  122. [self navPushHideTabbarToVC:vc];
  123. break;
  124. }
  125. case 5: {
  126. AppointDriverViewController * vc = [[AppointDriverViewController alloc] init];
  127. [self navPushHideTabbarToVC:vc];
  128. break;
  129. }
  130. case 6: {
  131. CoachArrangeClassViewController * vc = [[CoachArrangeClassViewController alloc] init];
  132. [self navPushHideTabbarToVC:vc];
  133. break;
  134. }
  135. case 7: {
  136. TrainRecordViewController * vc = [[TrainRecordViewController alloc] init];
  137. [self navPushHideTabbarToVC:vc];
  138. break;
  139. }
  140. default:
  141. break;
  142. }
  143. break;
  144. }
  145. case 4 : {
  146. StudentDetailViewController *vc = [[StudentDetailViewController alloc] init];
  147. [self navPushHideTabbarToVC:vc];
  148. break;
  149. }
  150. default:
  151. break;
  152. }
  153. }
  154. - (void)clickHeader:(HDSectionModel*)secM {
  155. NSLog(@"点击了段头");
  156. switch (secM.section) {
  157. case 2: {
  158. SignUpSituationViewController *vc = [[SignUpSituationViewController alloc] init];
  159. [self navPushHideTabbarToVC:vc];
  160. break;
  161. }
  162. case 4: {
  163. TrainSituationViewController *vc = [[TrainSituationViewController alloc] init];
  164. [self navPushHideTabbarToVC:vc];
  165. break;
  166. }
  167. default:
  168. break;
  169. }
  170. }
  171. #pragma mark - Lazy Load
  172. - (HomePageViewModel *)homePageViewModel {
  173. if (!_homePageViewModel) {
  174. _homePageViewModel = [[HomePageViewModel alloc] init];
  175. }
  176. return _homePageViewModel;
  177. }
  178. @end