RQTimeSingleItemViewModel.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. //
  2. // RQTimeSingleItemViewModel.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/11/25.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQTimeSingleItemViewModel.h"
  9. #import "TrainInfoVC.h"//我的学时
  10. #import "RQCustomWebViewViewController.h"
  11. #import "ScanVC.h"
  12. #import "NYTheoryTimeViewModel.h"
  13. #import "NYGetjobTimeViewModel.h"
  14. #import "NYClassRoomViewModel.h"
  15. #import "NYTcarStudentLiveModel.h"
  16. #import "NYKaoMockExaminationModel.h"
  17. @interface RQTimeSingleItemViewModel () {
  18. // PeriodVC *KVOPeriodVC;
  19. NYBasetjTimeVC *KVOPeriodVC;
  20. // NYBasetjTimeVC *KVOCYPeriodVC;//从业
  21. ShiCaoPeriodVC *KVOSCPeriodVC;
  22. NSString *orderId; // 订单ID
  23. NSString *classCode; // 课程编码
  24. NSString *subject; // 科目
  25. NSString *coachOrderId; // 教练订单ID
  26. NSDictionary *coachQRCodeDic;
  27. }
  28. @property (nonatomic,strong) NYTcarStudentLiveModel *tcarStudentLiveModel;
  29. @property (nonatomic,strong) NYKaoMockExaminationModel *kaoMockExaminationModel;
  30. @end
  31. @implementation RQTimeSingleItemViewModel
  32. - (instancetype)init {
  33. if (self = [super init]) {
  34. @weakify(self)
  35. self.itemSize = CGSizeMake(RQ_FIT_HORIZONTAL(90.f), RQ_FIT_HORIZONTAL(120.f) - 8.f);
  36. self.operation = ^{
  37. if (RQ_USER_MANAGER.isShouldLogin) {
  38. [RQ_VIP_Module isActiveWithCcomplete:^(RQActivationModel * _Nullable activationModel, BOOL isSuccess) {
  39. @strongify(self)
  40. if (isSuccess) {
  41. if (activationModel.isShare) {
  42. if (activationModel.isActive == 1||[RQ_COMMON_MANAGER.JSJP_SHARE_CITY rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {//2108 不判断
  43. [self gotoVCWithStr:self.title];
  44. } else {
  45. [RQ_VIP_Module gotoVipViewWithDictType:RQ_USER_MANAGER.currentUser.city];
  46. }
  47. } else {
  48. [self gotoVCWithStr:self.title];
  49. }
  50. }
  51. }];
  52. }
  53. };
  54. }
  55. return self;
  56. }
  57. - (NSString *)itemClassName {
  58. return @"RQTimeSingleCell";
  59. }
  60. - (void)gotoVCWithStr:(NSString *)str {
  61. if([RQ_USER_MANAGER.currentUser.userName containsString:@"游客"]){//游客特殊处理
  62. ShowMsg(@"您是游客身份,无法使用计时");
  63. return;
  64. }
  65. if ([str isEqualToString:@"理论计时"]) {
  66. [self gotoPeriod:0];
  67. } else if ([str isEqualToString:@"从业考核"]||[str isEqualToString:@"从业计时"]) {
  68. [self gotoPeriod:1];
  69. } else if ([str isEqualToString:@"我的学时"]) {
  70. [self gotoTrainInfo];
  71. } else if ([str isEqualToString:@"课堂培训"]) {
  72. [self gotoPeriod:2];
  73. } else if ([str isEqualToString:@"模拟培训"]) {
  74. [self gotoPeriod:3];
  75. } else if ([str isEqualToString:@"实车认证"]) {
  76. [self gotoTcarStudentLive];
  77. } else if ([str isEqualToString:@"科一考核"]) {
  78. [self gotoKaoMockExamination];
  79. }
  80. }
  81. - (void)gotoPeriod:(int)type {
  82. NYBasetjTimeVC *vc = nil;
  83. if(type==0){
  84. if(RQ_USER_MANAGER.isCykh&&(RQ_USER_MANAGER.busitype == 11 || RQ_USER_MANAGER.busitype == 12)){
  85. ShowMsg(@"您是从业资格人员,请点击从业计时");
  86. return;
  87. }
  88. if ([myDelegate.tPeriodVC isKindOfClass:[NYTheoryTimeVC class]]||
  89. [myDelegate.tPeriodVC isKindOfClass:[NYGetjobTimeVC class]]) {
  90. vc = myDelegate.tPeriodVC;
  91. }else {
  92. if(myDelegate.timer){
  93. ShowMsg(@"请先关闭理论计时");
  94. return;
  95. }
  96. //ning(无奈) 判断-是否是 辽宁-并且当前是科目一时,台州加的3310 温州3303
  97. NSString *citystr = @"yntms,2101,2108,3310,3303";
  98. NSString *pxkm = RQ_USER_MANAGER.currentUser.pxjd;
  99. NSLog(@"pxkm=%@",pxkm);
  100. if(pxkm==nil) pxkm=@"1";
  101. if ([citystr rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {
  102. if(pxkm.intValue==1||
  103. [@"3310" isEqualToString:RQ_USER_MANAGER.currentUser.city]||
  104. [@"3303" isEqualToString:RQ_USER_MANAGER.currentUser.city]){
  105. RQ_USER_MANAGER.cykhPxkmStr = @"1";
  106. KVOPeriodVC = [self getNYGetLNTimeVC:1];
  107. vc = KVOPeriodVC;
  108. }else{
  109. RQ_USER_MANAGER.cykhPxkmStr = @"4"; //如果学员信息阶段是234的时候就直接默认科目四学时, 不用选择
  110. KVOPeriodVC = [self getNYGetLNTimeVC:4];
  111. vc = KVOPeriodVC;
  112. }
  113. }else{
  114. KVOPeriodVC = [self getNYTheoryTimeVC];
  115. vc = KVOPeriodVC;
  116. }
  117. }
  118. }else if(type==1){
  119. if ([myDelegate.tPeriodVC isKindOfClass:[NYGetjobTimeVC class]]) {
  120. vc = myDelegate.tPeriodVC;
  121. }else {
  122. if(myDelegate.timer){
  123. ShowMsg(@"请先关闭理论计时");
  124. return;
  125. }
  126. KVOPeriodVC = [self getNYGetjobTimeVC];
  127. vc = KVOPeriodVC;
  128. }
  129. }else if(type==2){
  130. NYClassRoomViewModel *viewModel = [[NYClassRoomViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  131. NYClassRoomVC *classViewController = [[NYClassRoomVC alloc] initWithViewModel:viewModel];
  132. //timeViewController.vcType = TimeVCTypeAJob;
  133. [self navPushHideTabbarToVC:classViewController];
  134. return;
  135. }else if(type==3){
  136. NYClassRoomViewModel *viewModel = [[NYClassRoomViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  137. viewModel.isSimulationRoom = YES;
  138. viewModel.title = @"模拟训练";
  139. NYClassRoomVC *classViewController = [[NYClassRoomVC alloc] initWithViewModel:viewModel];
  140. //timeViewController.vcType = TimeVCTypeAJob;
  141. [self navPushHideTabbarToVC:classViewController];
  142. return;
  143. }
  144. if(vc)[self navPushHideTabbarToVC:vc];
  145. // PeriodVC *vc = nil;
  146. // if (myDelegate.tPeriodVC) {
  147. // vc = myDelegate.tPeriodVC;
  148. // }else {
  149. // KVOPeriodVC = [[PeriodVC alloc] init];
  150. // vc = KVOPeriodVC;
  151. // }
  152. // [self navPushHideTabbarToVC:vc];
  153. }
  154. - (NYBasetjTimeVC *)getNYTheoryTimeVC{
  155. NYTheoryTimeViewModel *viewModel = [[NYTheoryTimeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  156. NYTheoryTimeVC *timeViewController = [[NYTheoryTimeVC alloc] initWithViewModel:viewModel];
  157. timeViewController.vcType = TimeVCTypeTheory;
  158. return timeViewController;
  159. }
  160. - (NYBasetjTimeVC *)getNYGetjobTimeVC{
  161. NYGetjobTimeViewModel *viewModel = [[NYGetjobTimeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  162. NYGetjobTimeVC *timeViewController = [[NYGetjobTimeVC alloc] initWithViewModel:viewModel];
  163. timeViewController.vcType = TimeVCTypeAJob;
  164. return timeViewController;
  165. }
  166. //辽宁 只有 1,4
  167. - (NYBasetjTimeVC *)getNYGetLNTimeVC:(int)type{
  168. NYGetjobTimeViewModel *viewModel = [[NYGetjobTimeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  169. viewModel.subject_array = type==4?@[@"2"] :@[@"0",@"2"];
  170. [viewModel setNavTitle: type==4? @"理论计时(科四)":@"理论计时(科一)"];
  171. NYGetjobTimeVC *timeViewController = [[NYGetjobTimeVC alloc] initWithViewModel:viewModel];
  172. timeViewController.vcType = TimeVCTypeAJob;
  173. return timeViewController;
  174. }
  175. - (void)gotoTimi {
  176. SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:RQ_SCREEN_WIDTH - 32];
  177. alert.backgroundViewColor = backGroundColor;
  178. alert.customViewColor = RQ_MAIN_COLOR;
  179. UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 64, RQ_SCREEN_HEIGHT * 0.5)];
  180. view.font = [UIFont systemFontOfSize:15];
  181. NSMutableString *content = [NSMutableString string];
  182. 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 为了保证您的合法利益,请遵守规定,同时也请提醒您的教练,手机不能断网或在带教过程中长时间接听电话,否则会影响您的学时有效性判断,导致学时无效";
  183. view.text = content.mutableCopy;
  184. view.backgroundColor = backGroundColor;
  185. CGFloat textHeight = [view.text heightForWid:view.width Font:15];
  186. view.height = (textHeight > RQ_SCREEN_HEIGHT/2)? RQ_SCREEN_HEIGHT/2 : textHeight;
  187. [alert addCustomView:view];
  188. [alert addButton:@"不再显示" actionBlock:^(void) {
  189. [[NSUserDefaults standardUserDefaults] setValue:@"doNotShowNotice" forKey:@"isShowNotice"];
  190. [self gotoScanVCAction];
  191. }];
  192. [alert addButton:@"同意" actionBlock:^(void) {
  193. [self gotoScanVCAction];
  194. }];
  195. if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isKindOfClass:[NSString class]] && [[[NSUserDefaults standardUserDefaults] objectForKey:@"isShowNotice"] isEqualToString:@"doNotShowNotice"]) {
  196. [self gotoScanVCAction];
  197. }else {
  198. [alert showInfo:RQControllerHelper.currentViewController title:@"" subTitle:@"" closeButtonTitle:@"不同意" duration:0.0f];
  199. }
  200. }
  201. //实车认证
  202. - (void)gotoTcarStudentLive{
  203. [self.tcarStudentLiveModel tcarStudentLivedo];
  204. }
  205. //科一考核
  206. - (void)gotoKaoMockExamination{
  207. [self.kaoMockExaminationModel studentKaoMockExaminationdo];
  208. }
  209. - (void)gotoTrainInfo {
  210. // //是否开启活体检测 0-不开启 1-开启 活体检测比对动作数量
  211. // if (RQ_USER_MANAGER.isycbd == 1 && RQ_USER_MANAGER.ycbdFaceCount == 0) {
  212. //开头有35进入H5 - 修改登录下发匹配
  213. NSString *citystr = [RQ_USER_MANAGER getParamsKey:@"SP_QUERY_TRAIN_CLASS_DQBH"];
  214. if ([citystr rangeOfString:RQ_USER_MANAGER.currentUser.city].location != NSNotFound) {
  215. 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]];
  216. RQCustomWebViewViewController *vc = [[RQCustomWebViewViewController alloc] init];
  217. vc.url = URL.absoluteString;
  218. vc.webView.scrollView.bounces = NO;
  219. RQBaseNavigationController *nav = [[RQBaseNavigationController alloc] initWithRootViewController:vc];
  220. [RQControllerHelper.topViewController presentViewController:nav animated:YES completion:nil];
  221. } else {
  222. TrainInfoVC * tvc = [[TrainInfoVC alloc]init];
  223. [self navPushHideTabbarToVC:tvc];
  224. }
  225. }
  226. // 跳转至扫码页面
  227. - (void)gotoScanVCAction {
  228. ScanVC *scan = [[ScanVC alloc] init];
  229. scan.type = 1;
  230. scan.homeVC = RQControllerHelper.currentViewController;
  231. [scan scanBlock:^(NSDictionary *scanQRCodeResultDic) {
  232. coachQRCodeDic = scanQRCodeResultDic;
  233. if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"allSignOut"]) {
  234. [self updateReserveEnd];
  235. }else if ([scanQRCodeResultDic[@"scanType"] isEqualToString:@"jhPeriod"]) {
  236. [self uploadReserveOrder];
  237. }
  238. }];
  239. [self navPushHideTabbarToVC:scan];
  240. }
  241. - (void)navPushHideTabbarToVC:(UIViewController*)vc {
  242. //判断是否是homebase的子视图控制器(它的子视图控制器直接设置self.hidesBottomBarWhenPushed = YES;会无效)
  243. dispatch_async(dispatch_get_main_queue(), ^{
  244. UIViewController *mVc = RQControllerHelper.currentViewController;
  245. mVc.hidesBottomBarWhenPushed = YES;
  246. [mVc.navigationController pushViewController:vc animated:YES];
  247. if (!mVc.navigationController.tabBarController.tabBar.isHidden) {
  248. mVc.hidesBottomBarWhenPushed = NO;
  249. }
  250. });
  251. }
  252. #pragma mark - Net Methodds
  253. //生成订单
  254. - (void)uploadReserveOrder {
  255. [LoadingView showHUD];
  256. if (![Util connectedToNetWork]) {
  257. showMsgUnconnect();
  258. return;
  259. }
  260. NSMutableArray *arr=[NSMutableArray array];
  261. [arr addPro:@"reserveId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][3]];
  262. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
  263. [arr addPro:@"dqbh" Value:RQ_USER_MANAGER.currentUser.city];
  264. [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject];
  265. [arr addPro:@"sim" Value:RQ_USER_MANAGER.currentUser.telphone];
  266. [arr addPro:@"stuOutId" Value:RQ_USER_MANAGER.currentUser.outId];
  267. [arr addPro:@"coachOutId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]];
  268. NSString* method = @"uploadReserveOrder";
  269. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  270. RemoveHUD();
  271. if (!root) {
  272. ShowMsg(@"开始计时失败,请重试!");
  273. [Tools playAudioWithString:@"开始计时失败,请崇试!"];
  274. return;
  275. }
  276. if ([root[@"code"] isEqualToString:@"1"]) {
  277. ShowMsg(root[@"body"]);
  278. [Tools playAudioWithString:root[@"body"]];
  279. return;
  280. }
  281. orderId = [root[@"body"] objectForKey:@"id"];
  282. subject = [root[@"body"] objectForKey:@"subject"];
  283. ShowMsg(@"签到成功!");
  284. [Tools playAudioWithString:@"签到成功,开始实操计时,请系好安全带"];
  285. }];
  286. }
  287. - (void)updateReserveEnd {
  288. [LoadingView showHUD];
  289. if (![Util connectedToNetWork]) {
  290. showMsgUnconnect();
  291. return;
  292. }
  293. NSMutableArray *arr = [NSMutableArray array];
  294. [arr addPro:@"orderId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"].lastObject];
  295. [arr addPro:@"userId" Value:RQ_USER_MANAGER.currentUser._id];
  296. [arr addPro:@"coachId" Value:[coachQRCodeDic[@"dataString"] componentsSeparatedByString:@";"][0]];
  297. NSString* method = @"updateReserveEnd";
  298. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  299. RemoveHUD();
  300. if (!root) {
  301. ShowMsg(@"签退失败!");
  302. [Tools playAudioWithString:@"签退失败!"];
  303. return;
  304. }
  305. if ([root[@"code"] isEqualToString:@"1"]) {
  306. ShowMsg(root[@"body"]);
  307. [Tools playAudioWithString:root[@"body"]];
  308. return;
  309. }
  310. ShowMsg(@"签退成功!");
  311. [Tools playAudioWithString:@"签退成功!"];
  312. }];
  313. }
  314. /// property
  315. - (NYTcarStudentLiveModel *)tcarStudentLiveModel{
  316. if(!_tcarStudentLiveModel){
  317. _tcarStudentLiveModel = [NYTcarStudentLiveModel new];
  318. }
  319. return _tcarStudentLiveModel;
  320. }
  321. - (NYKaoMockExaminationModel *)kaoMockExaminationModel{
  322. if(!_kaoMockExaminationModel){
  323. _kaoMockExaminationModel = [NYKaoMockExaminationModel new];
  324. //注册-通知
  325. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(examinationPostNotif:) name:RQHomeSubPageTypeKHModeKey object:nil];
  326. }
  327. return _kaoMockExaminationModel;
  328. }
  329. - (void)examinationPostNotif: (NSNotification *)notification {
  330. int score = [notification.object intValue];
  331. [self.kaoMockExaminationModel signOutHandledo:score];
  332. }
  333. @end