123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574 |
- //
- // RQHomeSubPageCell.m
- // XinShouJiaDao
- //
- // Created by 张嵘 on 2021/7/9.
- // Copyright © 2021 JCZ. All rights reserved.
- //
- #import "RQHomeSubPageCell.h"
- #import "ListVC.h"
- #import "ExamVC.h"
- #import "StatisVC.h"
- #import "MyGradeVC.h"
- #import "ScoreRankVC.h"
- #import "StrongVC.h"
- #import "RQMultiButtons.h"
- #import "OliveappLivenessDetectionViewController.h"
- #import "OliveappCameraPreviewController.h"
- #import "OliveappDetectedFrame.h"
- #import "OliveappBase64Helper.h"
- @interface RQHomeSubPageCell () <RQMultiButtonsDelegate, OliveappLivenessResultDelegate, FaceDetectorsDelegate>
- @property (weak, nonatomic) IBOutlet UIView *randomPracticeView;
- @property (weak, nonatomic) IBOutlet UIView *zhangjieView;
- @property (weak, nonatomic) IBOutlet UIView *beitiView;
- @property (weak, nonatomic) IBOutlet UIView *shunxuView;
- @property (weak, nonatomic) IBOutlet UIView *paichuView;
- @property (weak, nonatomic) IBOutlet UIView *myNewRuleView;
- @property (weak, nonatomic) IBOutlet UIView *lianXiTongJiView;
- @property (weak, nonatomic) IBOutlet UIView *strongExerciseView;
- @property (weak, nonatomic) IBOutlet UIView *SimulationTestTopicsView;
- @property (weak, nonatomic) IBOutlet UIView *netEduView;
- @property (weak, nonatomic) IBOutlet UIImageView *eduImageView;
- @property (weak, nonatomic) IBOutlet UILabel *eduLabel;
- @property (nonatomic, readwrite, strong) RQHomeSubPageItemViewModel *viewModel;
- @property (nonatomic, readwrite, strong) RQMultiButtons *multibuttons;
- @property (weak, nonatomic) IBOutlet UIImageView *customOneImageView;
- @property (weak, nonatomic) IBOutlet UILabel *customOneLabel;
- @property (weak, nonatomic) IBOutlet UIImageView *customTwoImageView;
- @property (weak, nonatomic) IBOutlet UILabel *customTwoLabel;
- @property (weak, nonatomic) IBOutlet UILabel *myNewRuleLabel;
- @property (weak, nonatomic) IBOutlet UIImageView *myNewRuleImageView;
- @property (weak, nonatomic) IBOutlet UILabel *paichuLabel;
- @property (nonatomic, readwrite, assign) CLLocationCoordinate2D myLocation;
- @end
- @implementation RQHomeSubPageCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"RQHomeSubPageCell";
- [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
- RQHomeSubPageCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
- if (!cell) cell = [self rq_viewFromXib];
- return cell;
- }
- - (void)bindViewModel:(RQHomeSubPageItemViewModel *)viewModel {
- @weakify(self)
- _viewModel = viewModel;
-
- [[RACObserve(defUser, car_type) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
- @strongify(self)
- self.customOneLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"我的成绩" : ([defUser.car_type isEqualToString:@"2"]? @"顺序练习" : @"模拟考试");
- 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")];
- self.customTwoLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"顺序练习" : ([defUser.car_type isEqualToString:@"2"]? @"结业考核" : @"顺序练习");
- 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")];
- self.eduLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"模拟考试" : @"远程教育";
- self.eduImageView.image = [UIImage imageNamed:RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"subject1_simalate_excercise_icon" : @"edu"];
- self.paichuLabel.text = RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN? @"考前密卷" : @"排除的题";
- }];
- /// 随机练习
- [_randomPracticeView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [myDelegate setType:@"2"];
- [self gotoExerVC];
- } else {
- if ([defUser.car_type isEqualToString:@"2"]) {
- // if (_multibuttons) {
- // [_multibuttons hide];
- // _multibuttons = nil;
- // }
- // _multibuttons = [[RQMultiButtons alloc] initWithPoint:CGPointMake(self.center.x, self.shunxuView.center.y + 50) radius:140 inView:self];
- // _multibuttons.bubbleRadius = 40;
- // _multibuttons.delegate = self;
- // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"subject1_random_excercise_icon.png"] title:@"随机练习"
- // backgroundColor:UIColor.whiteColor
- // andButtonId:103];
- // _multibuttons.faderAlpha = 0.2f;
- // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习"
- // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
- // andButtonId:104];
- // [_multibuttons show];
- [myDelegate setType:@"1"];
- [self gotoExerVC];
- } else {
- [myDelegate setType:@"2"];
- [self gotoExerVC];
- }
- }
- }];
- /// 章节练习
- [_zhangjieView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- [myDelegate setType:@"3"];
- [self gotoListVC];
- }];
- /// 背题模式
- [_beitiView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- [myDelegate setType:@"8"];
- [self gotoExerVC];
- }];
- /// 顺序练习
- [_shunxuView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [myDelegate setType:@"1"];
- [self gotoExerVC];
- } else {
- if ([defUser.car_type isEqualToString:@"2"]) {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }else {
- [MBProgressHUD showMessage:@"正在获取当前位置..." toView:RQControllerHelper.currentViewController.view];
- [[MapManager sharedManager] updateLocationWithCompleteBlock:^(BOOL success, CLLocation *location) {
- [MBProgressHUD hideHUDForView:RQControllerHelper.currentViewController.view animated:YES];
- if (success) {
- self.myLocation = location.coordinate;
- [[RACScheduler mainThreadScheduler] schedule:^{
- [RQ_CHECKBODY_MANAGER beginCheckBodyWithCheckNum:RQ_COMMON_MANAGER.LN_HY_FACE_NUM completeBlock:^(BOOL success, NSDictionary * _Nullable dic) {
- [self face2faceJykhWithPhotoStr:dic[@"normalImg"] ResultBlock:^(BOOL faceIsSuccess) {
- @strongify(self)
- if (faceIsSuccess) {
- //模拟考试
- [myDelegate setType:@"9"];
- [self gotoExamVC];
- }
- }];
- }];
- }];
- // [self takePhoto];
- }
- }];
- }
- } else {
- [myDelegate setType:@"1"];
- [self gotoExerVC];
- // if (_multibuttons) {
- // [_multibuttons hide];
- // _multibuttons = nil;
- // }
- // _multibuttons = [[RQMultiButtons alloc] initWithPoint:CGPointMake(self.center.x, self.SelectedTestQuestionsView.center.y + 50) radius:140 inView:self];
- // _multibuttons.bubbleRadius = 40;
- // _multibuttons.faderAlpha = 0.2f;
- // _multibuttons.delegate = self;
- // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"exCircle.png"] title:@"顺序练习"
- // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
- // andButtonId:100];
- // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"模拟考试"
- // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
- // andButtonId:101];
-
- // [_multibuttons addCustomButtonWithIcon:[UIImage imageNamed:@"examCircle.png"] title:@"VIP课程"
- // backgroundColor:[UIColor colorWithRed:0.0 green:164.0/255.0 blue:120.0/255.0 alpha:1.0]
- // andButtonId:102];
- // [_multibuttons show];
- }
- }
-
- }];
- /// 排除的题
- [_paichuView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- if (RQ_COMMON_MANAGER.freeLookSimExamNum == 1) {
- RQHoursBeforeExamHomeViewModel *hoursBeforeExamHomeViewModel = [[RQHoursBeforeExamHomeViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];
- [RQ_APPDELEGATE.services pushViewModel:hoursBeforeExamHomeViewModel animated:YES];
- RQ_COMMON_MANAGER.freeLookSimExamNum = 0;
- } else {
- [RQ_ALERTVIEW_MANAGER showAlertWithAlertType:RQAlertType_AD title:@"" message:@"" confirmTitle:@"取消" cancelTitle:@"看广告解锁使用" confirmAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
-
- } cancelAction:^(__kindof QMUIDialogViewController * _Nonnull dialogViewController) {
- [QMUITips showLoading:@"请求中..." inView:DefaultTipsParentView];
- [RQ_AD_MODULE loadAdWithAdType:GromoreAdTypeRewardedVideo customView:nil];
- [RQ_AD_MODULE initADStatusChangeBlock:^(GromoreAdType adType, RQADDoType adDoType) {
- if (adType == GromoreAdTypeRewardedVideo) {
- if (adDoType == RQADDoType_Success || adDoType == RQADDoType_Faild) {
- [QMUITips hideAllTips];
- }
- }
- }];
- }];
- }
- } else {
- [myDelegate setType:@"6"];
- [self gotoExerVC];
- }
- }];
- /// 新规考题
- [_myNewRuleView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- [myDelegate setType:@"11"];
- [self gotoExerVC];
- }];
-
- /// 练习统计
- [_lianXiTongJiView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- [self gotoStaticVC];
- }];
- /// 强化练习
- [_strongExerciseView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- [myDelegate setType:@"5"];
- [self gotoStrongVC];
- }];
- /// 模拟考试
- [_SimulationTestTopicsView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- MyGradeVC* vc = [[MyGradeVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- } else {
- if ([defUser.car_type isEqualToString:@"2"]) {
- [myDelegate setType:@"1"];
- [self gotoExerVC];
- } else {
- [myDelegate setType:@"9"];
- [self gotoExamVC];
- }
- }
- }];
- /// 远程教育
- [_netEduView setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
- @strongify(self)
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [myDelegate setType:@"9"];
- [self gotoExamVC];
- } else {
- if (!myDelegate.isLogin) {
- ShowMsg(@"请登录后再操作!");
- [self userLoginAction];
- }else {
- [Tools confirmImeiWithLogType:@"5" successBlock:^{
- @strongify(self)
- [self postCheckEduStu];
- }];
- }
- }
- }];
-
-
- }
- #pragma mark - SystemMethods
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self rq_setViewAction];
- }
- #pragma mark - PrivateMethods
- - (void)rq_setViewAction {
-
- }
- - (void)navPushHideTabbarToVC:(UIViewController *)vc {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
- } else {
- vc.hidesBottomBarWhenPushed = YES;
- [RQControllerHelper.topNavigationController qmui_pushViewController:vc animated:YES completion:nil];
- vc.hidesBottomBarWhenPushed = NO;
- }
- }
- - (void)gotoExerVC {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
- return;
- }
- }
- ExerciseVC* vc = [[ExerciseVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoListVC{
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
- return;
- }
- }
- ListVC* vc = [[ListVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoExamVC {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
- return;
- }
- }
- ExamVC* vc = [[ExamVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoStaticVC {
- StatisVC* vc = [[StatisVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoMyGradeVC {
- MyGradeVC* vc = [[MyGradeVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoScoreRank {
- ScoreRankVC* vc = [[ScoreRankVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)gotoStrongVC {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- if ([[RQPreferenceSettingHelper objectForKey:@"exerciseState"] isEqualToString:@"0"] && ![defUser.car_type isEqualToString:@"2"]) {
- [NSObject rq_showAlertViewWithTitle:@"温馨提示" message:[RQPreferenceSettingHelper objectForKey:@"exerciseMsg"] confirmTitle:@"确定"];
- return;
- }
- }
- StrongVC *vc = [[StrongVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- - (void)userLoginAction {
- LoginViewController* vc = [[LoginViewController alloc] init];
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- vc.modalPresentationStyle = UIModalPresentationFullScreen;
- [RQControllerHelper.topNavigationController presentViewController:vc animated:YES completion:nil];
- }
- - (void)postCheckEduStu {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- @weakify(self)
- NSMutableArray *aArray=[NSMutableArray array];
- [aArray addPro:@"idcard" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"loginCode"]]];
- [aArray addPro:@"pxcx" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"car_type"]]];
- [aArray addPro:@"outid" Value:[NSString stringWithFormat:@"%@",defUser.userDict[@"outId"]]];
-
- NSString* method = @"checkEduStu";
- [MBProgressHUD showHUDAddedTo:RQControllerHelper.currentViewController.view animated:YES];
- [jiaPeiManager requestAnythingWithURL:method array:aArray data:nil completion:^(NSDictionary *root) {
- [MBProgressHUD hideHUDForView:RQControllerHelper.currentViewController.view];
- if (!root) {
- ShowMsgFailed();
- return ;
- }
-
- if ([root[@"code"] isEqualToString:@"0"]) {
- //远程教育
- SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:kScreenWidth - 32];
- alert.customViewColor = defGreen;
- alert.showAnimationType = SCLAlertViewShowAnimationFadeIn;
- alert.viewText.textAlignment = NSTextAlignmentLeft;
- UITextView *view = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 64, kScreenHeight * 0.5)];
- view.font = [UIFont systemFontOfSize:15];
- view.editable = NO;
- [alert addButton:@"确定" actionBlock:^(void) {
- @strongify(self)
- RQWebViewViewController *vc = [[RQWebViewViewController alloc] init];
- vc.webType = WebTypeEDU;
- if (root[@"data"][@"url"] && ![root[@"data"][@"url"] isEqualToString:@""]) {
- vc.url = [NSString stringWithFormat:@"%@", root[@"data"][@"url"]];
- }else {
- 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"]];
- }
- NSLog(@"%@",vc.url);
- [self navPushHideTabbarToVC:vc];
- }];
- NSMutableString *content = [NSMutableString string];
- NSArray *strArr = root[@"data"][@"precautions"];
- [strArr.rac_sequence.signal subscribeNext:^(NSString *str) {
- if (strArr.count > 1) {
- [content appendFormat:@"%d.%@\n\n",(int)[strArr indexOfObject:str] + 1,str];
- }else {
- [content appendFormat:@"%@\n\n",str];
- }
- } completed:^{
- dispatch_main_async_safe(^{
- if (content.length == 0) {
- content.string = @"1.训练已学习过的课件,学时不累加;\n\n2.每个科目的课件全部都学习完后可以重置,重置后的课件学习时可以再次累加学时;\n\n3.科目一科目四,混合训练时会产生多段培训记录;\n\n4.如果训练过程异常退出,30分钟内重新登录训练的,继续学习同一个科目将继续累加学时,继续学习不同科目上一段将做为异常记录上报;\n\n5.如果训练过程异常退出,超过30分钟内重新登录训练的, 上一段将做为异常记录上报;\n\n";
- }
- view.text = content.mutableCopy;
- CGFloat textHeight = [view.text heightForWid:view.width Font:15];
- view.height = (textHeight > kScreenHeight/2)? kScreenHeight/2 : textHeight;
- [alert addCustomView:view];
- [alert showInfo:@"温馨提示" subTitle:@"" closeButtonTitle:@"取消" duration:0.0f];
- })
- }];
-
- } else {
- ShowMsg(root[@"msg"]);
- return ;
- }
- }];
- }
- // 人脸比对
- - (void)takePhoto {
- UIStoryboard * board = [UIStoryboard storyboardWithName:@"LivenessDetection" bundle:nil];
- OliveappLivenessDetectionViewController * livenessDetectionViewController;
- livenessDetectionViewController = (OliveappLivenessDetectionViewController *)[ board instantiateViewControllerWithIdentifier:@"LivenessDetectionStoryboard"];
- livenessDetectionViewController.modalPresentationStyle = 0;
- livenessDetectionViewController.faceDelegate = self;
- OliveappSessionManagerConfig* config = [OliveappSessionManagerConfig new];
- // config.timeoutMs = 100000;
- [config usePredefinedConfig: 4]; // 这里配置检测步骤
- livenessDetectionViewController.cusConfig = config;
- NSError *error;
- BOOL isSuccess = [livenessDetectionViewController setConfigLivenessDetection:self withError: &error];
- if (isSuccess){
- [RQControllerHelper.currentViewController presentViewController:livenessDetectionViewController animated:YES completion:nil];
- }
- }
- - (void)onLivenessSuccess:(OliveappDetectedFrame *)detectedFrame{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
- });
- }
- - (void)onLivenessFail:(int)sessionState withDetectedFrame:(OliveappDetectedFrame *)detectedFrame{
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
- UIAlertController *actionsheet = [UIAlertController alertControllerWithTitle:@"提示" message:@"获取人脸失败,是否重新进行人脸比对" preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self takePhoto];
- }];
-
- UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
- }];
- [actionsheet addAction:action1];
- [actionsheet addAction:action2];
-
- [RQControllerHelper.currentViewController presentViewController:actionsheet animated:YES completion:nil];
- });
- }
- - (void)onLivenessCancel{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [RQControllerHelper.currentViewController dismissViewControllerAnimated:YES completion:nil];
- });
- }
- - (void)sendFaceImage:(UIImage *)faceImage {
- UIImage *normalImage = [UIImage fixOrientation:faceImage];
- NSData *imgData = UIImageJPEGRepresentation(normalImage, .2f);
- NSString *backString = [NSString stringWithFormat:@"%@",[OliveappBase64Helper encode:imgData]];
- [self face2faceJykhWithPhotoStr:backString ResultBlock:^(BOOL success) {
- if (success) {
- //模拟考试
- [myDelegate setType:@"9"];
- [self gotoExamVC];
- }
- }];
- }
- - (void)sendFaceImageError {
-
- }
- - (void)face2faceJykhWithPhotoStr:(NSString *)photoStr ResultBlock:(void (^)(BOOL success))resultBlock {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- resultBlock(NO);
- return;
- }
-
- if (_myLocation.longitude == 0.0) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"位置获取失败" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alert show];
- resultBlock(NO);
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"stunum" Value:defUser.userDict[@"stuNum"]];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- [arr addPro:@"outId" Value:defUser.userDict[@"outId"]];
- [arr addPro:@"lng" Value:[NSString stringWithFormat:@"%f",_myLocation.longitude]];
- [arr addPro:@"lat" Value:[NSString stringWithFormat:@"%f",_myLocation.latitude]];
- [arr addPro:@"photo" Value:photoStr];
- NSString *method = @"face2faceJykh";
- [MBProgressHUD rq_showProgressHUD:@"请求中..."];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD rq_hideHUD];
- if (!root) {
- ShowMsg(@"操作失败,请重试!");
- [Tools playAudioWithString:@"操作失败,请重试!"];
- resultBlock(NO);
- return;
- }
-
- resultBlock([root[@"code"] integerValue] == 0);
-
- [Tools playAudioWithString:root[@"msg"]];
- ShowMsg(root[@"msg"]);
- }];
- }
- #pragma mark - RQMultiButtonsDelegate
- - (void)rqMultiButtons:(RQMultiButtons *)multiButtons tappedButtonWithType:(RQMultiButtonsType)buttonType {
- switch (buttonType) {
- case 100:
- case 104:
- //顺序练习
- [myDelegate setType:@"1"];
- [self gotoExerVC];
- break;
- case 101:
- //模拟考试
- [myDelegate setType:@"9"];
- [self gotoExamVC];
- break;
- case 102:
- //VIP课程
- // [self gotoVipVC];
- break;
- case 103:
- //随机练习
- [myDelegate setType:@"2"];
- [self gotoExerVC];
- break;
-
- default:
- break;
- }
-
- }
- @end
|