// // RQHomePageOneOrFourSmallItemViewModel.m // jiaPei // // Created by 张嵘 on 2022/6/10. // Copyright © 2022 JCZ. All rights reserved. // #import "RQHomePageOneOrFourSmallItemViewModel.h" @interface RQHomePageOneOrFourSmallItemViewModel () @property (nonatomic, readwrite, assign) RQHomePageCarType homePageCarType; @property (nonatomic, readwrite, assign) RQHomePageSubjectType homePageSubjectType; @end @implementation RQHomePageOneOrFourSmallItemViewModel /// init - (instancetype)initWithRQHomePageCarType:(RQHomePageCarType)homePageCarType homePageSubjectType:(RQHomePageSubjectType)homePageSubjectType homePageOneOrFourItemModel:(RQHomePageOneOrFourItemModel *)homePageOneOrFourItemModel { if (self = [super init]) { self.homePageCarType = homePageCarType; self.homePageSubjectType = homePageSubjectType; CGFloat width = (RQ_SCREEN_WIDTH - (16 * 2) - 11) / 2.f; CGFloat height = width * (48.f / 167.f); self.itemSize = CGSizeMake(width, height); self.title = homePageOneOrFourItemModel.titleStr; self.icon = homePageOneOrFourItemModel.iconImgStr; if ([self.title isEqualToString:@"VIP课程"]) { self.operation = ^{ [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) { if (RQ_VIP_Module.isVip) { [RQ_VIP_Module gotoVipCenter]; } else { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } }]; }; } else if ([self.title isEqualToString:@"真实考场"]) { self.operation = ^{ [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) { if (isVip) { NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&gs=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStr,RQ_USER_MANAGER.currentUser.photo]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]]; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}]; webViewModel.prefersNavigationBarHidden = YES; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; } else { if (RQ_VIP_Module.freeLookSimExamNum == 1) { NSString *urlStr = [NSString stringWithFormat:@"https://mn.zzxcx.net/#/exam/begin?username=%@&subject=%@&gs=%@&headimg=%@",[RQ_USER_MANAGER.currentUser.userName qmui_stringByEncodingUserInputQuery],RQ_YDTQuestion_Module.subjectStr,RQ_YDTQuestion_Module.carTypeStr,RQ_USER_MANAGER.currentUser.photo]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]]; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:request, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}]; webViewModel.prefersNavigationBarHidden = YES; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; RQ_VIP_Module.freeLookSimExamNum = 0; } else { [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"充值会员无限使用" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) { [RQ_AD_Module loadRewardvodAd]; }]; } } }]; }; } else if ([self.title isEqualToString:@"新规秘卷"]) { self.operation = ^{ [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) { if (isVip) { RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES]; } else { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } }]; }; } else if ([self.title isEqualToString:@"专项练习"]) { self.operation = ^{ RQSpecialPractiseViewModel *specialPractiseViewModel = [[RQSpecialPractiseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; [RQ_APPDELEGATE.services pushViewModel:specialPractiseViewModel animated:YES]; }; } else if ([self.title isEqualToString:@"精选500题"]) { self.operation = ^{ [RQ_VIP_Module isVipWithSubject:RQ_YDTQuestion_Module.subject + 1 complete:^(BOOL isVip) { if (isVip) { NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithSubject:RQ_YDTQuestion_Module.subject exerciseType:RQExerciseType_HandPick ].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) { return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel]; }].toArray; RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType), RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject), RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice), RQViewModelIDKey : homePageOneOrFourItemModel.titleStr, RQExerciseTypeKey : @(RQExerciseType_HandPick), RQViewModelUtilKey : arr, }]; [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES]; } else { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } }]; }; } else if ([self.title isEqualToString:@"错题收藏"]) { self.operation = ^{ RQErrorAndCollectViewModel *errorAndCollectViewModel = [[RQErrorAndCollectViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; [RQ_APPDELEGATE.services pushViewModel:errorAndCollectViewModel animated:YES]; }; } } return self; } @end