NYLIHomePageSimulationExamItemViewModel.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // NYLIHomePageSimulationExamItemViewModel.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2025/2/14.
  6. // Copyright © 2025 JCZ. All rights reserved.
  7. //
  8. #import "NYLIHomePageSimulationExamItemViewModel.h"
  9. @interface NYLIHomePageSimulationExamItemViewModel ()
  10. @property (nonatomic, readwrite, assign) RQHomePageCarType homePageCarType;
  11. @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType;
  12. @end
  13. @implementation NYLIHomePageSimulationExamItemViewModel
  14. /// init
  15. - (instancetype)initWithRQHomePageCarType:(RQHomePageCarType)homePageCarType homePageSubjectType:(RQHomePageSubjectType)homePageSubjectType {
  16. if (self = [super init]) {
  17. @weakify(self)
  18. self.homePageCarType = homePageCarType;
  19. self.homePageSubjectType = homePageSubjectType;
  20. self.itemSize = CGSizeMake(RQ_SCREEN_WIDTH, RQ_FIT_HORIZONTAL(303.f));
  21. self.operationLI = ^{
  22. RQHomePageSubjectType subType = RQHomePageSubjectType_SubjectOne_LI;
  23. NSString *ftv = @"1";
  24. NSString *examName = @"科一专项精品课";
  25. if(homePageSubjectType == RQHomePageSubjectType_SubjectFour){
  26. ftv = @"4";
  27. examName = @"科四专项精品课";
  28. subType = RQHomePageSubjectType_SubjectFour_LI;
  29. }
  30. [MBProgressHUD rq_showProgressHUD:@""];
  31. [[RQ_HTTP_Service getFiveTeachingList:ftv] subscribeNext:^(NSArray *fiveModels) {
  32. [MBProgressHUD rq_hideHUD];
  33. @strongify(self)
  34. RQPlaceVideoListModel *placeVideoListModel = [[RQPlaceVideoListModel alloc] init];
  35. placeVideoListModel.examName = examName;
  36. placeVideoListModel.items = fiveModels;
  37. NSIndexPath *indexPath = [NSIndexPath indexPathWithIndex:0];
  38. NYLIVideoDetailViewModel *videoDetailViewModel = [[NYLIVideoDetailViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  39. RQViewModelUtilKey : placeVideoListModel,
  40. RQVideoItemIndexKey : @(0),
  41. RQVideoItemIndexPathKey : indexPath,
  42. RQHomePageSubjectTypeKey : @(subType),
  43. }];
  44. [RQ_APPDELEGATE.services pushViewModel:videoDetailViewModel animated:YES];
  45. } error:^(NSError * _Nullable error) {
  46. [MBProgressHUD rq_hideHUD];
  47. [MBProgressHUD rq_showErrorTips:error];
  48. }];
  49. };
  50. self.operation = ^{
  51. if(myDelegate.isTrain&&RQ_USER_MANAGER.currentUser.isNotGcbd){//在计时-同时需要过程照片-提示
  52. ShowMsg(@"请先结束理论计时在进行真实考场!");
  53. return;
  54. }
  55. [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) {
  56. if (isVip) {
  57. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  58. 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];
  59. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  60. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  61. webViewModel.prefersNavigationBarHidden = YES;
  62. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  63. }else{
  64. //显示真实考场
  65. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  66. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  67. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  68. }
  69. } else {
  70. if (RQ_VIP_Module.freeLookSimExamNum == 1||
  71. RQ_COMMON_MANAGER.APP_SWITCH) {//审核状态不用看广告
  72. if(RQ_COMMON_MANAGER.APP_SWITCH){//审核状态走web 页
  73. 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];
  74. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
  75. RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}];
  76. webViewModel.prefersNavigationBarHidden = YES;
  77. [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES];
  78. }else{
  79. //显示真实考场
  80. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  81. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  82. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  83. }
  84. RQ_VIP_Module.freeLookSimExamNum = 0;
  85. } else {
  86. if(!RQ_COMMON_MANAGER.APP_SWITCH){
  87. // 修改后的弹窗调用逻辑
  88. NSString *ukey = [NSString stringWithFormat:@"%@%d",RQ_USER_MANAGER.currentUser.loginCode,RQ_YDTQuestion_Module.subjectStr.intValue];
  89. if (![NYTools hasUserWatchedAdToday:ukey]) {
  90. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"车管所实题,为防恶意刷屏,每日须观看一次广告,即可正常使用。点击观看无反应。请稍等5到10秒。" confirmTitle:@"充值使用" cancelTitle:@"看广告解锁" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  91. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  92. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  93. [RQ_AD_Module loadRewardvodAd];
  94. [NYTools saveUWatchedAdToday:ukey];
  95. }];
  96. }else{
  97. //显示真实考场
  98. NYExaminationViewModel *examinationViewModel = [[NYExaminationViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{}];
  99. examinationViewModel.km = RQ_YDTQuestion_Module.subjectStr.intValue;
  100. [RQ_APPDELEGATE.services pushViewModel:examinationViewModel animated:YES];
  101. }
  102. }
  103. }
  104. }
  105. }];
  106. };
  107. }
  108. return self;
  109. }
  110. - (NSString *)itemClassName {
  111. return @"NYLIHomePageSimulationExamCell";
  112. }
  113. @end