RQTimeSingleItemViewModel.m 15 KB

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