// // RQHomeSubPageCell.m // XinShouJiaDao // // Created by 张嵘 on 2021/7/9. // Copyright © 2021 JCZ. All rights reserved. // #import "RQHomeSubPageCell.h" @interface RQHomeSubPageCell () @property (weak, nonatomic) IBOutlet UIView *SequentialPracticeView; @property (weak, nonatomic) IBOutlet UIView *LocalTopicsView; @property (weak, nonatomic) IBOutlet UIView *ClassificationExerciseView; @property (weak, nonatomic) IBOutlet UIView *SelectedTestQuestionsView; @property (weak, nonatomic) IBOutlet UIView *WrongTopicCollectionView; @property (weak, nonatomic) IBOutlet UIView *RealExaminationRoomSimulationView; @property (weak, nonatomic) IBOutlet UIView *NotesBeforeExaminationView; @property (weak, nonatomic) IBOutlet UIView *SimulationResultsView; @property (weak, nonatomic) IBOutlet UIView *SimulationTestTopicsView; @property (weak, nonatomic) IBOutlet UIView *LearnToSeeView; @property (nonatomic, readwrite, strong) RQHomeSubPageItemViewModel *viewModel; @end @implementation RQHomeSubPageCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQHomeSubPageCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQHomeSubPageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; return cell; } - (void)bindViewModel:(RQHomeSubPageItemViewModel *)viewModel { _viewModel = viewModel; /// 顺序练习 [_SequentialPracticeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQHomeSubPageListViewModel *homeSubPageListViewModel = [[RQHomeSubPageListViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice)}]; [RQ_APPDELEGATE.services pushViewModel:homeSubPageListViewModel animated:YES]; } }]; }]; /// 地方专题 [_LocalTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQHomeSubPageLocalTopicListViewModel *homeSubPageLocalTopicListViewModel = [[RQHomeSubPageLocalTopicListViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_LocalTopics)}]; [RQ_APPDELEGATE.services pushViewModel:homeSubPageLocalTopicListViewModel animated:YES]; } }]; }]; /// 分类练习 [_ClassificationExerciseView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQHomeSubPageSortViewModel *homeSubPageSortViewModel = [[RQHomeSubPageSortViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_ClassificationExercise)}]; [RQ_APPDELEGATE.services pushViewModel:homeSubPageSortViewModel animated:YES]; } }]; }]; /// 精选考题 [_SelectedTestQuestionsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQHomeSubPageSortViewModel *homeSubPageSortViewModel = [[RQHomeSubPageSortViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_SelectedTestQuestions)}]; [RQ_APPDELEGATE.services pushViewModel:homeSubPageSortViewModel animated:YES]; } }]; }]; /// 错题·收藏 [_WrongTopicCollectionView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQWrongAndCollectionViewModel *wrongAndCollectionViewModel = [[RQWrongAndCollectionViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_WrongTopicAndCollection)}]; [RQ_APPDELEGATE.services pushViewModel:wrongAndCollectionViewModel animated:YES]; } }]; }]; /// 真实模拟考试 [_RealExaminationRoomSimulationView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { #if defined(DEBUG)||defined(_DEBUG) 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]; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}]; webViewModel.prefersNavigationBarHidden = YES; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; // NSString *urlStr = @"https://m.solot.com/interesting/1"; // RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Common)}]; // webViewModel.prefersNavigationBarHidden = YES; // [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; #else 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]; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr, RQViewModelWebViewTypeKey:@(RQWebViewType_Exam)}]; webViewModel.prefersNavigationBarHidden = YES; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; #endif } }]; }]; /// 考前须知 [_NotesBeforeExaminationView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { NSString *urlStr = @"https://jpcj-h5.zzxcx.net/marked?markdown=考前须知&navbar=false"; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr}]; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; }]; /// 模拟成绩 [_SimulationResultsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQSimulationResultsViewModel *simulationResultsViewModel = [[RQSimulationResultsViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; [RQ_APPDELEGATE.services pushViewModel:simulationResultsViewModel animated:YES]; } }]; }]; /// 模拟考试 [_SimulationTestTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { [RQ_USER_MANAGER isShouldVipWithComplete:^(NSInteger isVip) { if (isVip > 0) { RQSimulationTestTopicsViewModel *simulationTestTopicsViewModel = [[RQSimulationTestTopicsViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(RQHomeSubPageType_MockExamination), RQExerciseTypeKey : @(RQExerciseType_Exam)}]; [RQ_APPDELEGATE.services pushViewModel:simulationTestTopicsViewModel animated:YES]; } }]; }]; /// 学车必看 [_LearnToSeeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) { NSString *urlStr = @"https://jpcj-h5.zzxcx.net/marked?markdown=学车必看&navbar=false"; RQWebViewModel *webViewModel = [[RQWebViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelRequestKey:urlStr}]; [RQ_APPDELEGATE.services pushViewModel:webViewModel animated:YES]; }]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; [self rq_setViewAction]; } #pragma mark - PrivateMethods - (void)rq_setViewAction { } @end