// // RQTestResultsViewController.m // SDJK // // Created by 张嵘 on 2021/8/25. // #import "RQTestResultsViewController.h" @interface RQTestResultsViewController () /// viewModel @property (nonatomic, readonly, strong) RQTestResultsViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIView *containerView; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageViewTopToSuperView; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *repeatBtnTopToNoteLabel; @property (weak, nonatomic) IBOutlet UIImageView *headerImageView; @property (weak, nonatomic) IBOutlet UILabel *greetingsLabel; @property (weak, nonatomic) IBOutlet UILabel *scoreLabel; @property (weak, nonatomic) IBOutlet UILabel *ruleLabel; @property (weak, nonatomic) IBOutlet UILabel *useTimeLabel; @property (weak, nonatomic) IBOutlet UILabel *commentLabel; @end @implementation RQTestResultsViewController @dynamic viewModel; #pragma mark - SystemMethod - (void)viewDidLoad { [super viewDidLoad]; /// 初始化 [self rq_setup]; } #pragma mark - PrivateMethods /// 初始化 - (void)rq_setup { /// set up ... /// 设置contentSize [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(RQ_SCREEN_WIDTH); make.height.mas_equalTo(RQ_SCREEN_HEIGHT); }]; UIScrollView *scrollView = (UIScrollView *)self.view; scrollView.alwaysBounceVertical = YES; scrollView.showsHorizontalScrollIndicator = NO; scrollView.showsVerticalScrollIndicator = NO; /// 适配 iOS 11 RQAdjustsScrollViewInsets_Never(scrollView); if (RQ_IS_IPHONE_4_OR_LESS) { _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 0.f; _repeatBtnTopToNoteLabel.constant = 0.f; } else if (RQ_IS_IPHONE_6) { _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 20.5f; _repeatBtnTopToNoteLabel.constant = 55.f; } else { _imageViewTopToSuperView.constant = RQ_APPLICATION_TOP_BAR_HEIGHT + 29.5f; _repeatBtnTopToNoteLabel.constant = 75.f; } NSInteger allCount = (self.viewModel.homePageCarType == RQHomePageCarType_Motorcycle)? 30 * 60 : 45 * 60; NSInteger count = allCount - self.viewModel.count; NSUInteger sec = count%60; NSUInteger min = count/60; NSString* sec0,*min0; sec0 = sec<10 ? @"0" : @""; min0 = min<10 ? @"0" : @""; if (self.viewModel.score >=90 ) { _headerImageView.image = RQImageNamed(@"passTheExam"); _greetingsLabel.text = @"恭喜你,测试通过~"; _scoreLabel.text = [NSString stringWithFormat:@"%ld",self.viewModel.score]; _useTimeLabel.text = [NSString stringWithFormat:@"用时:%@%lu分%@%lu秒",min0,(unsigned long)min,sec0,(unsigned long)sec]; _commentLabel.text = @"天赋异禀、骨骼惊奇,想来是百年难得一见的考试奇才。"; } else { _headerImageView.image = RQImageNamed(@"failedTheExam"); _greetingsLabel.text = @"抱歉,测试未通过~"; _scoreLabel.text = [NSString stringWithFormat:@"%ld",self.viewModel.score]; _useTimeLabel.text = [NSString stringWithFormat:@"用时:%@%lu分%@%lu秒",min0,(unsigned long)min,sec0,(unsigned long)sec]; _commentLabel.text = @"学车之路,任重而道远!路漫漫其修远兮,吾将上下而求索。"; } [[RQ_HTTP_Service queryAddScoreRecordWithScore:_scoreLabel.text subject:self.viewModel.homePageSubjectType carType:self.viewModel.homePageCarType] subscribeNext:^(id _Nullable x) { }]; [self.navigationItem setLeftBarButtonItems:@[[UIBarButtonItem rq_backItemWithTitle:@"" imageName:@"back_black" target:self action:@selector(rq_back)]]]; } - (void)rq_back { [self.navigationController popToRootViewControllerAnimated:YES]; } - (IBAction)redoWrongQuestionBtnAction:(id)sender { NSArray *questionIdArr = [RQ_SDJK_DB_MANAGER queryWrongModelQuestionIdArrWithSubjectType:self.viewModel.homePageSubjectType]; [RQ_QUESTION_DB_MANAGER getQuestionsWithQuestionIdArr:questionIdArr complete:^(NSArray *modelArray) { [RQ_QUESTION_DB_MANAGER getQuestionsWithQuestionIdArr:questionIdArr complete:^(NSArray *modelArray) { RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:self.viewModel.services params:@{ RQHomePageCarTypeKey : @(self.viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(self.viewModel.homeSubPageType), RQExerciseTypeKey : @(RQExerciseType_Exam), RQViewModelIDKey : @"错题重做", RQViewModelUtilKey : modelArray, RQViewCommonValueKey : @(0), }]; dispatch_async_on_main_queue(^{ [self.viewModel.services pushViewModel:exerciseViewModel animated:YES]; }); }]; }]; } - (IBAction)retestBtnAction:(id)sender { RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{ RQHomePageCarTypeKey : @(self.viewModel.homePageCarType), RQHomePageSubjectTypeKey : @(self.viewModel.homePageSubjectType), RQHomeSubPageTypeKey : @(self.viewModel.homeSubPageType), RQExerciseTypeKey : @(RQExerciseType_Exam), RQViewModelUtilKey : self.viewModel.questionArray, RQViewCommonValueKey : @(0), }]; [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES]; } @end