// // RQTimeSingleItemViewModel.m // jiaPei // // Created by 张嵘 on 2022/11/25. // Copyright © 2022 JCZ. All rights reserved. // #import "RQTimeSingleItemViewModel.h" #import "TrainInfoVC.h"//我的学时 #import "RQCustomWebViewViewController.h" #import "ScanVC.h" #import "NYTheoryTimeViewModel.h" #import "NYGetjobTimeViewModel.h" @interface RQTimeSingleItemViewModel () { // PeriodVC *KVOPeriodVC; NYBasetjTimeVC *KVOPeriodVC; ShiCaoPeriodVC *KVOSCPeriodVC; NSString *orderId; // 订单ID NSString *classCode; // 课程编码 NSString *subject; // 科目 NSString *coachOrderId; // 教练订单ID NSDictionary *coachQRCodeDic; } @end @implementation RQTimeSingleItemViewModel - (instancetype)init { if (self = [super init]) { @weakify(self) self.itemSize = CGSizeMake(RQ_FIT_HORIZONTAL(90.f), RQ_FIT_HORIZONTAL(120.f) - 8.f); self.operation = ^{ if (RQ_USER_MANAGER.isShouldLogin) { [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) { @strongify(self) if (isSuccess) { if (activationModel.isShare) { if (activationModel.isActive == 1) { [self gotoVCWithStr:self.title]; } else { [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city]; } } else { [self gotoVCWithStr:self.title]; } } }]; } }; } return self; } - (NSString *)itemClassName { return @"RQTimeSingleCell"; } - (void)gotoVCWithStr:(NSString *)str { if ([str isEqualToString:@"理论计时"]) { [self gotoPeriod:0]; } else if ([str isEqualToString:@"从业考核"]||[str isEqualToString:@"从业计时"]) { [self gotoPeriod:1]; } else if ([str isEqualToString:@"我的学时"]) { [self gotoTrainInfo]; } else { } } - (void)gotoPeriod:(int)type { NYBasetjTimeVC *vc = nil; if(type==0){ if ([myDelegate.tPeriodVC isKindOfClass:[NYTheoryTimeVC class]]) { vc = myDelegate.tPeriodVC; }else { KVOPeriodVC = [self getNYTheoryTimeVC] ; vc = KVOPeriodVC; } }else if(type==1){ if ([myDelegate.tPeriodVC isKindOfClass:[NYGetjobTimeVC class]]) { vc = myDelegate.tPeriodVC; }else { KVOPeriodVC = [self getNYGetjobTimeVC]; vc = KVOPeriodVC; } } if(vc)[self navPushHideTabbarToVC:vc]; // PeriodVC *vc = nil; // if (myDelegate.tPeriodVC) { // vc = myDelegate.tPeriodVC; // }else { // KVOPeriodVC = [[PeriodVC alloc] init]; // vc = KVOPeriodVC; // } // [self navPushHideTabbarToVC:vc]; } - (NYBasetjTimeVC *)getNYTheoryTimeVC{ NYTheoryTimeViewModel *viewModel = [[NYTheoryTimeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; NYTheoryTimeVC *timeViewController = [[NYTheoryTimeVC alloc] initWithViewModel:viewModel]; return timeViewController; } - (NYBasetjTimeVC *)getNYGetjobTimeVC{ NYGetjobTimeViewModel *viewModel = [[NYGetjobTimeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil]; NYGetjobTimeVC *timeViewController = [[NYGetjobTimeVC alloc] initWithViewModel:viewModel]; return timeViewController; } - (void)gotoTimi { SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:RQ_SCREEN_WIDTH - 32]; alert.backgroundViewColor = backGroundColor; alert.customViewColor = RQ_MAIN_COLOR; UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 64, RQ_SCREEN_HEIGHT * 0.5)]; view.font = [UIFont systemFontOfSize:15]; NSMutableString *content = [NSMutableString string]; content.string = @"请注意:\n\n 本系统是按照2016驾驶员培训新国标要求,严格照规范设计,终端上传分钟学时来计算,在计时过程中请注意以下几点: \n\n1、如果所在地市有开启围栏,请注意确保您当前的位置在规定的围栏内训练,否则分钟学时无效 \n\n2、如果所在地市有开启培训时段,请确保您当前训练时间符合规定,比如早上6:00-20:00 \n\n3、确保教练手机是正常联网且安装支持3G以上的移动,联通和电信的SIM,否则无法采集到手机终端的位置,系统会判定分钟学时无效 \n\n4、系统为防止特殊情况,教练带教过程接到电话,允许断网一段时间,默认15分钟,如果超过15分钟,所带教学员的分钟学时无效 \n\n5、学员和教练的有效距离不能超过规定距离,否则分钟学时无效,详情请咨询教练或您所在的驾校 \n\n6、系统默认在2分钟及以上时间段内,如果移动距离为0米,视为无效分钟学时 \n\n7、根据规定,学员科目二和科目三1分钟内移动距离不能低于规定的数值,否则分钟学时无效,具体询问驾校或教练 \n\n8、如果您选择计时收费训练,您可以在训练结束且支付完成后对教练进行评价和投诉,如果训练完成后不支付,您的学时将无效且无法进行下一次训练 \n\n 为了保证您的合法利益,请遵守规定,同时也请提醒您的教练,手机不能断网或在带教过程中长时间接听电话,否则会影响您的学时有效性判断,导致学时无效"; view.text = content.mutableCopy; view.backgroundColor = backGroundColor; CGFloat textHeight = [view.text heightForWid:view.width Font:15]; view.height = (textHeight > RQ_SCREEN_HEIGHT/2)? RQ_SCREEN_HEIGHT/2 : textHeight; [alert addCustomView:view]; [alert addButton:@"不再显示" actionBlock:^(void) { [[NSUserDefaults standardUserDefaults] setValue:@"doNotShowNotice" forKey:@"isShowNotice"]; [self gotoScanVCAction]; }]; [alert addButton:@"同意" actionBlock:^(void) { [self gotoScanVCAction]; }]; if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isKindOfClass:[NSString class]] && [[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isEqualToString:@"doNotShowNotice"]) { [self gotoScanVCAction]; }else { [alert showInfo:RQControllerHelper.currentViewController title:@"" subTitle:@"" closeButtonTitle:@"不同意" duration:0.0f]; } } - (void)gotoTrainInfo { if (RQ_USER_MANAGER.isycbd == 1 && RQ_USER_MANAGER.ycbdFaceCount == 0) { NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://fj.jppt.com.cn/jsjp/wechat/toClassHourQueryByStuId.html?stuId=%@&dqbh=%@&app=ios",RQ_USER_MANAGER.currentUser.outId, RQ_USER_MANAGER.currentUser.city]]; RQCustomWebViewViewController *vc = [[RQCustomWebViewViewController alloc] init]; vc.url = URL.absoluteString; vc.webView.scrollView.bounces = NO; RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:vc]; [RQControllerHelper.topViewController presentViewController:nav animated:YES completion:nil]; } else { TrainInfoVC * tvc = [[TrainInfoVC alloc]init]; [self navPushHideTabbarToVC:tvc]; } } // 跳转至扫码页面 - (void)gotoScanVCAction { ScanVC *scan = [[ScanVC alloc] init]; scan.type = 1; scan.homeVC = RQControllerHelper.currentViewController; [scan scanBlock:^(NSDictionary *scanQRCodeResultDic) { coachQRCodeDic = scanQRCodeResultDic; if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"allSignOut"]) { [self updateReserveEnd]; }else if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"jhPeriod"]) { [self uploadReserveOrder]; } }]; [self navPushHideTabbarToVC:scan]; } - (void)navPushHideTabbarToVC:(UIViewController*)vc { //判断是否是homebase的子视图控制器(它的子视图控制器直接设置self.hidesBottomBarWhenPushed = YES;会无效) dispatch_async(dispatch_get_main_queue(), ^{ UIViewController *mVc = RQControllerHelper.currentViewController; mVc.hidesBottomBarWhenPushed = YES; [mVc.navigationController pushViewController:vc animated:YES]; if (!mVc.navigationController.tabBarController.tabBar.isHidden) { mVc.hidesBottomBarWhenPushed = NO; } }); } #pragma mark - Net Methodds //生成订单 - (void)uploadReserveOrder { [LoadingView showHUD]; if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *arr=[NSMutableArray array]; [arr addPro:@"reserveId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][3]]; [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id]; [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city]; [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject]; [arr addPro:@"sim" Value:RQ_USER_MANAGER.currentUser.telphone]; [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId]; [arr addPro:@"coachOutId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]]; NSString* method = @"uploadReserveOrder"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) { RemoveHUD(); if (!root) { ShowMsg(@"开始计时失败,请重试!"); [Tools playAudioWithString:@"开始计时失败,请崇试!"]; return; } if ([root[@"code"] isEqualToString:@"1"]) { ShowMsg(root[@"body"]); [Tools playAudioWithString:root[@"body"]]; return; } orderId = [root[@"body"] objectForKey:@"id"]; subject = [root[@"body"] objectForKey:@"subject"]; ShowMsg(@"签到成功!"); [Tools playAudioWithString:@"签到成功,开始实操计时,请系好安全带"]; }]; } - (void)updateReserveEnd { [LoadingView showHUD]; if (![Util connectedToNetWork]) { showMsgUnconnect(); return; } NSMutableArray *arr = [NSMutableArray array]; [arr addPro:@"orderId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject]; [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id]; [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]]; NSString* method = @"updateReserveEnd"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) { RemoveHUD(); if (!root) { ShowMsg(@"签退失败!"); [Tools playAudioWithString:@"签退失败!"]; return; } if ([root[@"code"] isEqualToString:@"1"]) { ShowMsg(root[@"body"]); [Tools playAudioWithString:root[@"body"]]; return; } ShowMsg(@"签退成功!"); [Tools playAudioWithString:@"签退成功!"]; }]; } @end