RQHomePageOneOrFourSmallItemViewModel.m 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // RQHomePageOneOrFourSmallItemViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/6/10.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQHomePageOneOrFourSmallItemViewModel.h"
  9. @interface RQHomePageOneOrFourSmallItemViewModel ()
  10. @property (nonatomic, readwrite, assign) RQHomePageCarType homePageCarType;
  11. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  12. @end
  13. @implementation RQHomePageOneOrFourSmallItemViewModel
  14. /// init
  15. - (instancetype)initWithRQHomePageCarType:(RQHomePageCarType)homePageCarType homePageSubjectType:(RQHomePageSubjectType)homePageSubjectType homePageOneOrFourItemModel:(RQHomePageOneOrFourItemModel *)homePageOneOrFourItemModel {
  16. if (self = [super init]) {
  17. self.homePageCarType = homePageCarType;
  18. self.homePageSubjectType = homePageSubjectType;
  19. CGFloat width = (RQ_SCREEN_WIDTH - (16 * 2) - 11) / 2.f;
  20. CGFloat height = width * (48.f / 167.f);
  21. self.itemSize = CGSizeMake(width, height);
  22. self.title = homePageOneOrFourItemModel.titleStr;
  23. self.icon = homePageOneOrFourItemModel.iconImgStr;
  24. if ([self.title isEqualToString:@"VIP课程"]) {
  25. self.operation = ^{
  26. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  27. if (RQ_VIP_Module.isVip) {
  28. [RQ_VIP_Module gotoVipCenter];
  29. } else {
  30. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  31. }
  32. }];
  33. };
  34. } else if ([self.title isEqualToString:@"真实考场"]) {
  35. self.operation = ^{
  36. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  37. if (isVip) {
  38. // username subject headimg gs 替换-> model
  39. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  40. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStrNew,RQ_USER_MANAGER.currentUser.photo];
  41. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  42. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  43. webViewModel.prefersNavigationBarHidden = YES;
  44. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  45. }else{
  46. //显示真实考场
  47. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  48. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  49. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  50. }
  51. } else {
  52. if (RQ_VIP_Module.freeLookSimExamNum == 1||
  53. RQ_COMMON_MANAGER.APP_SWITCH) {//审核状态不用看广告
  54. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  55. NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&model=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStrNew,RQ_USER_MANAGER.currentUser.photo];
  56. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  57. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  58. webViewModel.prefersNavigationBarHidden = YES;
  59. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  60. }else{
  61. //显示真实考场
  62. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  63. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  64. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  65. }
  66. RQ_VIP_Module.freeLookSimExamNum = 0;
  67. } else {
  68. if(!RQ_COMMON_MANAGER.APP_SWITCH){
  69. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"充值会员无限使用" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  70. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  71. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  72. [RQ_AD_Module loadRewardvodAd];
  73. }];
  74. }
  75. }
  76. }
  77. }];
  78. };
  79. } else if ([self.title isEqualToString:@"新规秘卷"]) {
  80. self.operation = ^{
  81. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  82. if (isVip) {
  83. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  84. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  85. } else {
  86. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  87. }
  88. }];
  89. };
  90. } else if ([self.title isEqualToString:@"专项练习"]) {
  91. self.operation = ^{
  92. RQSpecialPractiseViewModel *specialPractiseViewModel = [[RQSpecialPractiseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  93. [RQ_APPDELEGATE.services pushViewModel:specialPractiseViewModel animated:YES];
  94. };
  95. } else if ([self.title isEqualToString:@"精选500题"]||[self.title isEqualToString:@"精选300题"]) {
  96. self.operation = ^{
  97. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  98. if (isVip) {
  99. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  100. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  101. }].toArray;
  102. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  103. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  104. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  105. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  106. RQViewModelIDKey : homePageOneOrFourItemModel.titleStr,
  107. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  108. RQViewModelUtilKey : arr,
  109. }];
  110. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  111. } else {
  112. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  113. }
  114. }];
  115. };
  116. } else if ([self.title isEqualToString:@"错题收藏"]) {
  117. self.operation = ^{
  118. RQErrorAndCollectViewModel *errorAndCollectViewModel = [[RQErrorAndCollectViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  119. [RQ_APPDELEGATE.services pushViewModel:errorAndCollectViewModel animated:YES];
  120. };
  121. }
  122. }
  123. return self;
  124. }
  125. @end