RQTimeSingleItemViewModel.m 13 KB

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