RQHomeSubPageCell.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // RQHomeSubPageCell.m
  3. // XinShouJiaDao
  4. //
  5. // Created by 张嵘 on 2021/7/9.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "RQHomeSubPageCell.h"
  9. @interface RQHomeSubPageCell ()
  10. @property (weak, nonatomic) IBOutlet UIView *SequentialPracticeView;
  11. @property (weak, nonatomic) IBOutlet UIView *LocalTopicsView;
  12. @property (weak, nonatomic) IBOutlet UIView *ClassificationExerciseView;
  13. @property (weak, nonatomic) IBOutlet UIView *SelectedTestQuestionsView;
  14. @property (weak, nonatomic) IBOutlet UIView *WrongTopicCollectionView;
  15. @property (weak, nonatomic) IBOutlet UIView *RealExaminationRoomSimulationView;
  16. @property (weak, nonatomic) IBOutlet UIView *NotesBeforeExaminationView;
  17. @property (weak, nonatomic) IBOutlet UIView *SimulationResultsView;
  18. @property (weak, nonatomic) IBOutlet UIView *SimulationTestTopicsView;
  19. @property (weak, nonatomic) IBOutlet UIView *LearnToSeeView;
  20. @property (nonatomic, readwrite, strong) RQHomeSubPageItemViewModel *viewModel;
  21. @end
  22. @implementation RQHomeSubPageCell
  23. #pragma mark - PublicMethods
  24. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  25. static NSString *ID = @"RQHomeSubPageCell";
  26. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  27. RQHomeSubPageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  28. if (!cell) cell = [self rq_viewFromXib];
  29. return cell;
  30. }
  31. - (void)bindViewModel:(RQHomeSubPageItemViewModel *)viewModel {
  32. _viewModel = viewModel;
  33. /// 顺序练习
  34. [_SequentialPracticeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  35. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  36. if (isVip > 0) {
  37. RQHomeSubPageListViewModel *homeSubPageListViewModel = [[RQHomeSubPageListViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  38. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  39. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  40. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice)}];
  41. [RQ_APPDELEGATE.services pushViewModel:homeSubPageListViewModel animated:YES];
  42. }
  43. }];
  44. }];
  45. /// 地方专题
  46. [_LocalTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  47. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  48. if (isVip > 0) {
  49. RQHomeSubPageLocalTopicListViewModel *homeSubPageLocalTopicListViewModel = [[RQHomeSubPageLocalTopicListViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  50. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  51. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  52. RQHomeSubPageTypeKey : @(RQHomeSubPageType_LocalTopics)}];
  53. [RQ_APPDELEGATE.services pushViewModel:homeSubPageLocalTopicListViewModel animated:YES];
  54. }
  55. }];
  56. }];
  57. /// 分类练习
  58. [_ClassificationExerciseView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  59. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  60. if (isVip > 0) {
  61. RQHomeSubPageSortViewModel *homeSubPageSortViewModel = [[RQHomeSubPageSortViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  62. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  63. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  64. RQHomeSubPageTypeKey : @(RQHomeSubPageType_ClassificationExercise)}];
  65. [RQ_APPDELEGATE.services pushViewModel:homeSubPageSortViewModel animated:YES];
  66. }
  67. }];
  68. }];
  69. /// 精选考题
  70. [_SelectedTestQuestionsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  71. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  72. if (isVip > 0) {
  73. RQHomeSubPageSortViewModel *homeSubPageSortViewModel = [[RQHomeSubPageSortViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  74. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  75. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  76. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SelectedTestQuestions)}];
  77. [RQ_APPDELEGATE.services pushViewModel:homeSubPageSortViewModel animated:YES];
  78. }
  79. }];
  80. }];
  81. /// 错题·收藏
  82. [_WrongTopicCollectionView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  83. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  84. if (isVip > 0) {
  85. RQWrongAndCollectionViewModel *wrongAndCollectionViewModel = [[RQWrongAndCollectionViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  86. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  87. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  88. RQHomeSubPageTypeKey : @(RQHomeSubPageType_WrongTopicAndCollection)}];
  89. [RQ_APPDELEGATE.services pushViewModel:wrongAndCollectionViewModel animated:YES];
  90. }
  91. }];
  92. }];
  93. /// 真实模拟考试
  94. [_RealExaminationRoomSimulationView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  95. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  96. if (isVip > 0) {
  97. #if defined(DEBUG)||defined(_DEBUG)
  98. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",RQ_USER_MANAGER.nickName,[RQ_COMMON_MANAGER getSubjectTypeNumStrWithSubjectType:self.viewModel.homePageSubjectType],[RQ_COMMON_MANAGER getCarTypeSimpleCNStrWithCarTypeNew:self.viewModel.homePageCarType],RQ_USER_MANAGER.headImage];
  99. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  100. webViewModel.prefersNavigationBarHidden = YES;
  101. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  102. // NSString *urlStr = @"https://m.solot.com/interesting/1";
  103. // RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Common)}];
  104. // webViewModel.prefersNavigationBarHidden = YES;
  105. // [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  106. #else
  107. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",RQ_USER_MANAGER.nickName,[RQ_COMMON_MANAGER getSubjectTypeNumStrWithSubjectType:self.viewModel.homePageSubjectType],[RQ_COMMON_MANAGER getCarTypeSimpleCNStrWithCarTypeNew:self.viewModel.homePageCarType],RQ_USER_MANAGER.headImage];
  108. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  109. webViewModel.prefersNavigationBarHidden = YES;
  110. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  111. #endif
  112. }
  113. }];
  114. }];
  115. /// 考前须知
  116. [_NotesBeforeExaminationView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  117. NSString *urlStr = @"https://jpcj-h5.zzxcx.net/marked?markdown=考前须知&navbar=false";
  118. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr}];
  119. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  120. }];
  121. /// 模拟成绩
  122. [_SimulationResultsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  123. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  124. if (isVip > 0) {
  125. RQSimulationResultsViewModel *simulationResultsViewModel = [[RQSimulationResultsViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  126. [RQ_APPDELEGATE.services pushViewModel:simulationResultsViewModel animated:YES];
  127. }
  128. }];
  129. }];
  130. /// 模拟考试
  131. [_SimulationTestTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  132. [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) {
  133. if (isVip > 0) {
  134. RQSimulationTestTopicsViewModel *simulationTestTopicsViewModel = [[RQSimulationTestTopicsViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  135. RQHomePageCarTypeKey : @(viewModel.homePageCarType),
  136. RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType),
  137. RQHomeSubPageTypeKey : @(RQHomeSubPageType_MockExamination),
  138. RQExerciseTypeKey : @(RQExerciseType_Exam)}];
  139. [RQ_APPDELEGATE.services pushViewModel:simulationTestTopicsViewModel animated:YES];
  140. }
  141. }];
  142. }];
  143. /// 学车必看
  144. [_LearnToSeeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  145. NSString *urlStr = @"https://jpcj-h5.zzxcx.net/marked?markdown=学车必看&navbar=false";
  146. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr}];
  147. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  148. }];
  149. }
  150. #pragma mark - SystemMethods
  151. - (void)awakeFromNib {
  152. [super awakeFromNib];
  153. [self rq_setViewAction];
  154. }
  155. #pragma mark - PrivateMethods
  156. - (void)rq_setViewAction {
  157. }
  158. @end