RQHomeSubPageCell.m 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. //
  2. // RQHomeSubPageCell.m
  3. // XinShouJiaDao
  4. //
  5. // Created by 张嵘 on 2021/7/9.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "RQHomeSubPageCell.h"
  9. #import "ListVC.h"
  10. #import "ExamVC.h"
  11. #import "StatisVC.h"
  12. #import "MyGradeVC.h"
  13. #import "ScoreRankVC.h"
  14. #import "StrongVC.h"
  15. #import "RQMultiButtons.h"
  16. #import "OliveappLivenessDetectionViewController.h"
  17. #import "OliveappCameraPreviewController.h"
  18. #import "OliveappDetectedFrame.h"
  19. #import "OliveappBase64Helper.h"
  20. @interface RQHomeSubPageCell () <RQMultiButtonsDelegate, OliveappLivenessResultDelegate, FaceDetectorsDelegate>
  21. @property (weak, nonatomic) IBOutlet UIView *randomPracticeView;
  22. @property (weak, nonatomic) IBOutlet UIView *zhangjieView;
  23. @property (weak, nonatomic) IBOutlet UIView *beitiView;
  24. @property (weak, nonatomic) IBOutlet UIView *shunxuView;
  25. @property (weak, nonatomic) IBOutlet UIView *paichuView;
  26. @property (weak, nonatomic) IBOutlet UIView *myNewRuleView;
  27. @property (weak, nonatomic) IBOutlet UIView *lianXiTongJiView;
  28. @property (weak, nonatomic) IBOutlet UIView *strongExerciseView;
  29. @property (weak, nonatomic) IBOutlet UIView *SimulationTestTopicsView;
  30. @property (weak, nonatomic) IBOutlet UIView *netEduView;
  31. @property (weak, nonatomic) IBOutlet UIImageView *eduImageView;
  32. @property (weak, nonatomic) IBOutlet UILabel *eduLabel;
  33. @property (nonatomic, readwrite, strong) RQHomeSubPageItemViewModel *viewModel;
  34. @property (nonatomic, readwrite, strong) RQMultiButtons *multibuttons;
  35. @property (weak, nonatomic) IBOutlet UIImageView *customOneImageView;
  36. @property (weak, nonatomic) IBOutlet UILabel *customOneLabel;
  37. @property (weak, nonatomic) IBOutlet UIImageView *customTwoImageView;
  38. @property (weak, nonatomic) IBOutlet UILabel *customTwoLabel;
  39. @property (weak, nonatomic) IBOutlet UILabel *myNewRuleLabel;
  40. @property (weak, nonatomic) IBOutlet UIImageView *myNewRuleImageView;
  41. @property (weak, nonatomic) IBOutlet UILabel *paichuLabel;
  42. @property (nonatomic, readwrite, assign) CLLocationCoordinate2D myLocation;
  43. @end
  44. @implementation RQHomeSubPageCell
  45. #pragma mark - PublicMethods
  46. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  47. static NSString *ID = @"RQHomeSubPageCell";
  48. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  49. RQHomeSubPageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  50. if (!cell) cell = [self rq_viewFromXib];
  51. return cell;
  52. }
  53. - (void)bindViewModel:(RQHomeSubPageItemViewModel *)viewModel {
  54. @weakify(self)
  55. _viewModel = viewModel;
  56. [[RACObserve(defUser, car_type) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  57. @strongify(self)
  58. self.customOneLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"我的成绩" : ([defUser.car_type isEqualToString:@"2"]? @"顺序练习" : @"模拟考试");
  59. self.customOneImageView.image = [UIImage imageNamed:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"subject1_simulate_result_icon" : ([defUser.car_type isEqualToString:@"2"]? @"subject1_execercise_icon" : @"subject1_simalate_excercise_icon")];
  60. self.customTwoLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"顺序练习" : ([defUser.car_type isEqualToString:@"2"]? @"结业考核" : @"顺序练习");
  61. self.customTwoImageView.image = [UIImage imageNamed:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"subject1_execercise_icon" : ([defUser.car_type isEqualToString:@"2"]? @"subject1_simalate_excercise_icon" : @"subject1_execercise_icon")];
  62. self.eduLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"模拟考试" : @"远程教育";
  63. self.eduImageView.image = [UIImage imageNamed:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"subject1_simalate_excercise_icon" : @"edu"];
  64. self.paichuLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"考前密卷" : @"排除的题";
  65. }];
  66. /// 随机练习
  67. [_randomPracticeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  68. @strongify(self)
  69. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  70. [myDelegate setType:@"2"];
  71. [self gotoExerVC];
  72. } else {
  73. if ([defUser.car_type isEqualToString:@"2"]) {
  74. // if (_multibuttons) {
  75. // [_multibuttons hide];
  76. // _multibuttons = nil;
  77. // }
  78. // _multibuttons = [[RQMultiButtons alloc] initWithPoint:CGPointMake(self.center.x, self.shunxuView.center.y + 50) radius:140 inView:self];
  79. // _multibuttons.bubbleRadius = 40;
  80. // _multibuttons.delegate = self;
  81. // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"subject1_random_excercise_icon.png"] title:@"随机练习"
  82. // backgroundColor:UIColor.whiteColor
  83. // andButtonId:103];
  84. // _multibuttons.faderAlpha = 0.2f;
  85. // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习"
  86. // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
  87. // andButtonId:104];
  88. // [_multibuttons show];
  89. [myDelegate setType:@"1"];
  90. [self gotoExerVC];
  91. } else {
  92. [myDelegate setType:@"2"];
  93. [self gotoExerVC];
  94. }
  95. }
  96. }];
  97. /// 章节练习
  98. [_zhangjieView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  99. @strongify(self)
  100. [myDelegate setType:@"3"];
  101. [self gotoListVC];
  102. }];
  103. /// 背题模式
  104. [_beitiView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  105. @strongify(self)
  106. [myDelegate setType:@"8"];
  107. [self gotoExerVC];
  108. }];
  109. /// 顺序练习
  110. [_shunxuView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  111. @strongify(self)
  112. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  113. [myDelegate setType:@"1"];
  114. [self gotoExerVC];
  115. } else {
  116. if ([defUser.car_type isEqualToString:@"2"]) {
  117. if (!myDelegate.isLogin) {
  118. ShowMsg(@"请登录后再操作!");
  119. [self userLoginAction];
  120. }else {
  121. [MBProgressHUD showMessage:@"正在获取当前位置..." toView:RQControllerHelper.currentViewController.view];
  122. [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation *location) {
  123. [MBProgressHUD hideHUDForView:RQControllerHelper.currentViewController.view animated:YES];
  124. if (success) {
  125. self.myLocation = location.coordinate;
  126. [[RACScheduler mainThreadScheduler] schedule:^{
  127. [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_COMMON_MANAGER.LN_HY_FACE_NUM completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
  128. [self face2faceJykhWithPhotoStr:dic[@"normalImg"] ResultBlock:^(BOOL faceIsSuccess) {
  129. @strongify(self)
  130. if (faceIsSuccess) {
  131. //模拟考试
  132. [myDelegate setType:@"9"];
  133. [self gotoExamVC];
  134. }
  135. }];
  136. }];
  137. }];
  138. // [self takePhoto];
  139. }
  140. }];
  141. }
  142. } else {
  143. [myDelegate setType:@"1"];
  144. [self gotoExerVC];
  145. // if (_multibuttons) {
  146. // [_multibuttons hide];
  147. // _multibuttons = nil;
  148. // }
  149. // _multibuttons = [[RQMultiButtons alloc] initWithPoint:CGPointMake(self.center.x, self.SelectedTestQuestionsView.center.y + 50) radius:140 inView:self];
  150. // _multibuttons.bubbleRadius = 40;
  151. // _multibuttons.faderAlpha = 0.2f;
  152. // _multibuttons.delegate = self;
  153. // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习"
  154. // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
  155. // andButtonId:100];
  156. // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"模拟考试"
  157. // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
  158. // andButtonId:101];
  159. // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"VIP课程"
  160. // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
  161. // andButtonId:102];
  162. // [_multibuttons show];
  163. }
  164. }
  165. }];
  166. /// 排除的题
  167. [_paichuView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  168. @strongify(self)
  169. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  170. if (RQ_COMMON_MANAGER.freeLookSimExamNum == 1) {
  171. RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
  172. [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
  173. RQ_COMMON_MANAGER.freeLookSimExamNum = 0;
  174. } else {
  175. [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"取消" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  176. } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
  177. [QMUITips showLoading:@"请求中..." inView:DefaultTipsParentView];
  178. [RQ_AD_MODULE loadAdWithAdType:GromoreAdTypeRewardedVideo customView:nil];
  179. [RQ_AD_MODULE initADStatusChangeBlock:^(GromoreAdType adType, RQADDoType adDoType) {
  180. if (adType == GromoreAdTypeRewardedVideo) {
  181. if (adDoType == RQADDoType_Success || adDoType == RQADDoType_Faild) {
  182. [QMUITips hideAllTips];
  183. }
  184. }
  185. }];
  186. }];
  187. }
  188. } else {
  189. [myDelegate setType:@"6"];
  190. [self gotoExerVC];
  191. }
  192. }];
  193. /// 新规考题
  194. [_myNewRuleView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  195. @strongify(self)
  196. [myDelegate setType:@"11"];
  197. [self gotoExerVC];
  198. }];
  199. /// 练习统计
  200. [_lianXiTongJiView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  201. @strongify(self)
  202. [self gotoStaticVC];
  203. }];
  204. /// 强化练习
  205. [_strongExerciseView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  206. @strongify(self)
  207. [myDelegate setType:@"5"];
  208. [self gotoStrongVC];
  209. }];
  210. /// 模拟考试
  211. [_SimulationTestTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  212. @strongify(self)
  213. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  214. MyGradeVC* vc = [[MyGradeVC alloc] init];
  215. [self navPushHideTabbarToVC:vc];
  216. } else {
  217. if ([defUser.car_type isEqualToString:@"2"]) {
  218. [myDelegate setType:@"1"];
  219. [self gotoExerVC];
  220. } else {
  221. [myDelegate setType:@"9"];
  222. [self gotoExamVC];
  223. }
  224. }
  225. }];
  226. /// 远程教育
  227. [_netEduView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  228. @strongify(self)
  229. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  230. [myDelegate setType:@"9"];
  231. [self gotoExamVC];
  232. } else {
  233. if (!myDelegate.isLogin) {
  234. ShowMsg(@"请登录后再操作!");
  235. [self userLoginAction];
  236. }else {
  237. [Tools confirmImeiWithLogType:@"5" successBlock:^{
  238. @strongify(self)
  239. [self postCheckEduStu];
  240. }];
  241. }
  242. }
  243. }];
  244. }
  245. #pragma mark - SystemMethods
  246. - (void)awakeFromNib {
  247. [super awakeFromNib];
  248. [self rq_setViewAction];
  249. }
  250. #pragma mark - PrivateMethods
  251. - (void)rq_setViewAction {
  252. }
  253. - (void)navPushHideTabbarToVC:(UIViewController *)vc {
  254. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  255. [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
  256. } else {
  257. vc.hidesBottomBarWhenPushed = YES;
  258. [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
  259. vc.hidesBottomBarWhenPushed = NO;
  260. }
  261. }
  262. - (void)gotoExerVC {
  263. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  264. } else {
  265. if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
  266. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
  267. return;
  268. }
  269. }
  270. ExerciseVC* vc = [[ExerciseVC alloc] init];
  271. [self navPushHideTabbarToVC:vc];
  272. }
  273. - (void)gotoListVC{
  274. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  275. } else {
  276. if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
  277. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
  278. return;
  279. }
  280. }
  281. ListVC* vc = [[ListVC alloc] init];
  282. [self navPushHideTabbarToVC:vc];
  283. }
  284. - (void)gotoExamVC {
  285. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  286. } else {
  287. if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
  288. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
  289. return;
  290. }
  291. }
  292. ExamVC* vc = [[ExamVC alloc] init];
  293. [self navPushHideTabbarToVC:vc];
  294. }
  295. - (void)gotoStaticVC {
  296. StatisVC* vc = [[StatisVC alloc] init];
  297. [self navPushHideTabbarToVC:vc];
  298. }
  299. - (void)gotoMyGradeVC {
  300. MyGradeVC* vc = [[MyGradeVC alloc] init];
  301. [self navPushHideTabbarToVC:vc];
  302. }
  303. - (void)gotoScoreRank {
  304. ScoreRankVC* vc = [[ScoreRankVC alloc] init];
  305. [self navPushHideTabbarToVC:vc];
  306. }
  307. - (void)gotoStrongVC {
  308. if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
  309. } else {
  310. if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
  311. [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
  312. return;
  313. }
  314. }
  315. StrongVC *vc = [[StrongVC alloc] init];
  316. [self navPushHideTabbarToVC:vc];
  317. }
  318. - (void)userLoginAction {
  319. LoginViewController* vc = [[LoginViewController alloc] init];
  320. vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  321. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  322. [RQControllerHelper.topNavigationController presentViewController:vc animated:YES completion:nil];
  323. }
  324. - (void)postCheckEduStu {
  325. if (![Util connectedToNetWork]) {
  326. showMsgUnconnect();
  327. return;
  328. }
  329. @weakify(self)
  330. NSMutableArray *aArray=[NSMutableArray array];
  331. [aArray addPro:@"idcard" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"loginCode"]]];
  332. [aArray addPro:@"pxcx" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"car_type"]]];
  333. [aArray addPro:@"outid" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"outId"]]];
  334. NSString* method = @"checkEduStu";
  335. [MBProgressHUD showHUDAddedTo:RQControllerHelper.currentViewController.view animated:YES];
  336. [jiaPeiManager requestAnythingWithURL:method array:aArray data:nil completion:^(NSDictionary *root) {
  337. [MBProgressHUD hideHUDForView:RQControllerHelper.currentViewController.view];
  338. if (!root) {
  339. ShowMsgFailed();
  340. return ;
  341. }
  342. if ([root[@"code"] isEqualToString:@"0"]) {
  343. //远程教育
  344. SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:kScreenWidth - 32];
  345. alert.customViewColor = defGreen;
  346. alert.showAnimationType = SCLAlertViewShowAnimationFadeIn;
  347. alert.viewText.textAlignment = NSTextAlignmentLeft;
  348. UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 64, kScreenHeight * 0.5)];
  349. view.font = [UIFont systemFontOfSize:15];
  350. view.editable = NO;
  351. [alert addButton:@"确定" actionBlock:^(void) {
  352. @strongify(self)
  353. RQWebViewViewController *vc = [[RQWebViewViewController alloc] init];
  354. vc.webType = WebTypeEDU;
  355. if (root[@"data"][@"url"] && ![root[@"data"][@"url"] isEqualToString:@""]) {
  356. vc.url = [NSString stringWithFormat:@"%@", root[@"data"][@"url"]];
  357. }else {
  358. vc.url = [NSString stringWithFormat:@"http://lncx.anjia365.com/h5/xzz/#/login?state=1&userName=%@&pwd=%@&area=2101&type=cx&pxcx=%@",defUser.userDict[@"loginCode"],defUser.userDict[@"password"],defUser.userDict[@"car_type"]];
  359. }
  360. NSLog(@"%@",vc.url);
  361. [self navPushHideTabbarToVC:vc];
  362. }];
  363. NSMutableString *content = [NSMutableString string];
  364. NSArray *strArr = root[@"data"][@"precautions"];
  365. [strArr.rac_sequence.signal subscribeNext:^(NSString *str) {
  366. if (strArr.count > 1) {
  367. [content appendFormat:@"%d.%@\n\n",(int)[strArr indexOfObject:str] + 1,str];
  368. }else {
  369. [content appendFormat:@"%@\n\n",str];
  370. }
  371. } completed:^{
  372. dispatch_main_async_safe(^{
  373. if (content.length == 0) {
  374. content.string = @"1.训练已学习过的课件,学时不累加;\n\n2.每个科目的课件全部都学习完后可以重置,重置后的课件学习时可以再次累加学时;\n\n3.科目一科目四,混合训练时会产生多段培训记录;\n\n4.如果训练过程异常退出,30分钟内重新登录训练的,继续学习同一个科目将继续累加学时,继续学习不同科目上一段将做为异常记录上报;\n\n5.如果训练过程异常退出,超过30分钟内重新登录训练的, 上一段将做为异常记录上报;\n\n";
  375. }
  376. view.text = content.mutableCopy;
  377. CGFloat textHeight = [view.text heightForWid:view.width Font:15];
  378. view.height = (textHeight > kScreenHeight/2)? kScreenHeight/2 : textHeight;
  379. [alert addCustomView:view];
  380. [alert showInfo:@"温馨提示" subTitle:@"" closeButtonTitle:@"取消" duration:0.0f];
  381. })
  382. }];
  383. } else {
  384. ShowMsg(root[@"msg"]);
  385. return ;
  386. }
  387. }];
  388. }
  389. // 人脸比对
  390. - (void)takePhoto {
  391. UIStoryboard * board = [UIStoryboard storyboardWithName:@"LivenessDetection" bundle:nil];
  392. OliveappLivenessDetectionViewController * livenessDetectionViewController;
  393. livenessDetectionViewController = (OliveappLivenessDetectionViewController *)[ board instantiateViewControllerWithIdentifier:@"LivenessDetectionStoryboard"];
  394. livenessDetectionViewController.modalPresentationStyle = 0;
  395. livenessDetectionViewController.faceDelegate = self;
  396. OliveappSessionManagerConfig* config = [OliveappSessionManagerConfig new];
  397. // config.timeoutMs = 100000;
  398. [config usePredefinedConfig: 4]; // 这里配置检测步骤
  399. livenessDetectionViewController.cusConfig = config;
  400. NSError *error;
  401. BOOL isSuccess = [livenessDetectionViewController setConfigLivenessDetection:self withError: &error];
  402. if (isSuccess){
  403. [RQControllerHelper.currentViewController presentViewController:livenessDetectionViewController animated:YES completion:nil];
  404. }
  405. }
  406. - (void)onLivenessSuccess:(OliveappDetectedFrame *)detectedFrame{
  407. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  408. [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
  409. });
  410. }
  411. - (void)onLivenessFail:(int)sessionState withDetectedFrame:(OliveappDetectedFrame *)detectedFrame{
  412. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  413. [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
  414. UIAlertController *actionsheet = [UIAlertController alertControllerWithTitle:@"提示" message:@"获取人脸失败,是否重新进行人脸比对" preferredStyle:UIAlertControllerStyleAlert];
  415. UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  416. [self takePhoto];
  417. }];
  418. UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  419. }];
  420. [actionsheet addAction:action1];
  421. [actionsheet addAction:action2];
  422. [RQControllerHelper.currentViewController presentViewController:actionsheet animated:YES completion:nil];
  423. });
  424. }
  425. - (void)onLivenessCancel{
  426. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  427. [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
  428. });
  429. }
  430. - (void)sendFaceImage:(UIImage *)faceImage {
  431. UIImage *normalImage = [UIImage fixOrientation:faceImage];
  432. NSData *imgData = UIImageJPEGRepresentation(normalImage, .2f);
  433. NSString *backString = [NSString stringWithFormat:@"%@",[OliveappBase64Helper encode:imgData]];
  434. [self face2faceJykhWithPhotoStr:backString ResultBlock:^(BOOL success) {
  435. if (success) {
  436. //模拟考试
  437. [myDelegate setType:@"9"];
  438. [self gotoExamVC];
  439. }
  440. }];
  441. }
  442. - (void)sendFaceImageError {
  443. }
  444. - (void)face2faceJykhWithPhotoStr:(NSString *)photoStr ResultBlock:(void (^)(BOOL success))resultBlock {
  445. if (![Util connectedToNetWork]) {
  446. showMsgUnconnect();
  447. resultBlock(NO);
  448. return;
  449. }
  450. if (_myLocation.longitude == 0.0) {
  451. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"位置获取失败" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  452. [alert show];
  453. resultBlock(NO);
  454. return;
  455. }
  456. NSMutableArray *arr=[NSMutableArray array];
  457. [arr addPro:@"stunum" Value:defUser.userDict[@"stuNum"]];
  458. [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  459. [arr addPro:@"outId" Value:defUser.userDict[@"outId"]];
  460. [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",_myLocation.longitude]];
  461. [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",_myLocation.latitude]];
  462. [arr addPro:@"photo" Value:photoStr];
  463. NSString *method = @"face2faceJykh";
  464. [MBProgressHUD rq_showProgressHUD:@"请求中..."];
  465. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  466. [MBProgressHUD rq_hideHUD];
  467. if (!root) {
  468. ShowMsg(@"操作失败,请重试!");
  469. [Tools playAudioWithString:@"操作失败,请重试!"];
  470. resultBlock(NO);
  471. return;
  472. }
  473. resultBlock([root[@"code"] integerValue] == 0);
  474. [Tools playAudioWithString:root[@"msg"]];
  475. ShowMsg(root[@"msg"]);
  476. }];
  477. }
  478. #pragma mark - RQMultiButtonsDelegate
  479. - (void)rqMultiButtons:(RQMultiButtons *)multiButtons tappedButtonWithType:(RQMultiButtonsType)buttonType {
  480. switch (buttonType) {
  481. case 100:
  482. case 104:
  483. //顺序练习
  484. [myDelegate setType:@"1"];
  485. [self gotoExerVC];
  486. break;
  487. case 101:
  488. //模拟考试
  489. [myDelegate setType:@"9"];
  490. [self gotoExamVC];
  491. break;
  492. case 102:
  493. //VIP课程
  494. // [self gotoVipVC];
  495. break;
  496. case 103:
  497. //随机练习
  498. [myDelegate setType:@"2"];
  499. [self gotoExerVC];
  500. break;
  501. default:
  502. break;
  503. }
  504. }
  505. @end