RQHomePageOneOrFourSmallItemViewModel.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. if(myDelegate.isTrain&&RQ_USER_MANAGER.currentUser.isNotGcbd){//在计时-同时需要过程照片-提示
  37. ShowMsg(@"请先结束理论计时在进行真实考场!");
  38. return;
  39. }
  40. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  41. if (isVip) {
  42. // username subject headimg gs 替换-> model
  43. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  44. 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];
  45. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  46. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  47. webViewModel.prefersNavigationBarHidden = YES;
  48. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  49. }else{
  50. //显示真实考场
  51. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  52. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  53. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  54. }
  55. } else {
  56. if (RQ_VIP_Module.freeLookSimExamNum == 1||
  57. RQ_COMMON_MANAGER.APP_SWITCH) {//审核状态不用看广告
  58. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  59. 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];
  60. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  61. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  62. webViewModel.prefersNavigationBarHidden = YES;
  63. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  64. }else{
  65. //显示真实考场
  66. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  67. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  68. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  69. }
  70. RQ_VIP_Module.freeLookSimExamNum = 0;
  71. } else {
  72. if(!RQ_COMMON_MANAGER.APP_SWITCH){
  73. // 修改后的弹窗调用逻辑
  74. NSString *ukey = [NSString stringWithFormat:@"%@%d",RQ_USER_MANAGER.currentUser.loginCode,RQ_YDTQuestion_Module.subjectStr.intValue];
  75. if (![NYTools hasUserWatchedAdToday:ukey]) {
  76. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"车管所实题,为防恶意刷屏,每日须观看一次广告,即可正常使用。点击观看无反应。请稍等5到10秒。" confirmTitle:@"充值使用" cancelTitle:@"看广告解锁" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  77. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  78. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  79. [RQ_AD_Module loadRewardvodAd];
  80. [NYTools saveUWatchedAdToday:ukey];
  81. }];
  82. }else{
  83. //显示真实考场
  84. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  85. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  86. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  87. }
  88. }
  89. }
  90. }
  91. }];
  92. };
  93. } else if ([self.title isEqualToString:@"考前秘卷"]) {
  94. self.operation = ^{
  95. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  96. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  97. // [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  98. // if (isVip) {
  99. // RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  100. // [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  101. // } else {
  102. // [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  103. // }
  104. // }];
  105. };
  106. } else if ([self.title isEqualToString:@"专项练习"]) {
  107. self.operation = ^{
  108. RQSpecialPractiseViewModel *specialPractiseViewModel = [[RQSpecialPractiseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  109. [RQ_APPDELEGATE.services pushViewModel:specialPractiseViewModel animated:YES];
  110. };
  111. } else if ([self.title isEqualToString:@"精选500题"]||[self.title isEqualToString:@"精选300题"]) {
  112. self.operation = ^{
  113. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  114. if (isVip) {
  115. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  116. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  117. }].toArray;
  118. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  119. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  120. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  121. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  122. RQViewModelIDKey : homePageOneOrFourItemModel.titleStr,
  123. RQExerciseTypeKey : @(RQExerciseType_HandPick),
  124. RQViewModelUtilKey : arr,
  125. }];
  126. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  127. } else {
  128. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  129. }
  130. }];
  131. };
  132. } else if ([self.title isEqualToString:@"错题收藏"]) {
  133. self.operation = ^{
  134. RQErrorAndCollectViewModel *errorAndCollectViewModel = [[RQErrorAndCollectViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  135. [RQ_APPDELEGATE.services pushViewModel:errorAndCollectViewModel animated:YES];
  136. };
  137. }
  138. }
  139. return self;
  140. }
  141. @end