Commit 8177a10d5ea7280c54660a2ba87f7296374df80c

Authored by 王军波
1 parent 32fe407a

增加新的提示框,优化代码

CNLiveBPersonalVerificationModule/Classes/CNBPersonCardInfo/Controller/ApplyForShootController.m
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 8
9 #import "ApplyForShootController.h" 9 #import "ApplyForShootController.h"
10 #import <AipOcrSdk/AipOcrSdk.h> 10 #import <AipOcrSdk/AipOcrSdk.h>
11 -#import <objc/runtime.h>  
12 #import "AFNetworking.h" 11 #import "AFNetworking.h"
13 #import "ApplyForShootCell.h" 12 #import "ApplyForShootCell.h"
14 #import "ApplyForConfirmCell.h" 13 #import "ApplyForConfirmCell.h"
@@ -29,7 +28,8 @@ @@ -29,7 +28,8 @@
29 #import <CNLiveImagePickerController/TZImagePickerController.h> 28 #import <CNLiveImagePickerController/TZImagePickerController.h>
30 #import <CNLiveImagePickerController/TZImageManager.h> 29 #import <CNLiveImagePickerController/TZImageManager.h>
31 #import <CNLiveCommonCategory/CNLiveCommonCategory.h> 30 #import <CNLiveCommonCategory/CNLiveCommonCategory.h>
32 -@interface ApplyForShootController ()<UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate, UIImagePickerControllerDelegate> 31 +#import "CNLiveIDCardAuthAlertView.h"
  32 +@interface ApplyForShootController ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate, UIImagePickerControllerDelegate, IDCardAuthAlertViewDelegate>
33 33
34 @property (nonatomic, strong) UITableView *tableView; 34 @property (nonatomic, strong) UITableView *tableView;
35 @property (nonatomic, strong) NSArray <AgreementModel*>*dataArray; 35 @property (nonatomic, strong) NSArray <AgreementModel*>*dataArray;
@@ -66,50 +66,20 @@ @@ -66,50 +66,20 @@
66 [super viewDidLoad]; 66 [super viewDidLoad];
67 self.title = @"拍摄照片"; 67 self.title = @"拍摄照片";
68 self.view.backgroundColor = [UIColor whiteColor]; 68 self.view.backgroundColor = [UIColor whiteColor];
  69 + self.edgesForExtendedLayout = UIRectEdgeNone;
  70 +// self.extendedLayoutIncludesOpaqueBars = YES;
69 self.imageDatas = [NSMutableArray array]; 71 self.imageDatas = [NSMutableArray array];
70 self.pickerVC = [[UIImagePickerController alloc] init]; 72 self.pickerVC = [[UIImagePickerController alloc] init];
71 self.pickerVC.delegate = self; 73 self.pickerVC.delegate = self;
72 [[AipOcrService shardService] authWithAK:BDAppKey andSK:BDSecret]; 74 [[AipOcrService shardService] authWithAK:BDAppKey andSK:BDSecret];
73 [self loadData]; 75 [self loadData];
74 [self.view addSubview:self.tableView]; 76 [self.view addSubview:self.tableView];
75 -// if (@available(iOS 11.0, *)) {  
76 -// self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;  
77 -// }else{  
78 -// self.automaticallyAdjustsScrollViewInsets = NO;  
79 -// }  
80 - [self configCallback];  
81 -  
82 -}  
83 -  
84 -- (void)loadData {  
85 -  
86 - NSArray *array = @[  
87 - @{  
88 - @"shootTitle":@"第一步",  
89 - @"shootImage":@"observer_idcard_front",  
90 - @"isFront":@"1",  
91 - @"isOwn":@"0"  
92 - },  
93 - @{  
94 - @"shootTitle":@"第二步",  
95 - @"shootImage":@"observer_idcard_back",  
96 - @"isFront":@"0",  
97 - @"isOwn":@"0"  
98 - },  
99 - @{  
100 - @"shootTitle":@"第三步",  
101 - @"shootImage":@"observer_idcard_own",  
102 - @"isFront":@"0",  
103 - @"isOwn":@"1"  
104 - },  
105 - ];  
106 - NSMutableArray *arrayM = [NSMutableArray array];  
107 - for (NSDictionary *dic in array) {  
108 - AgreementModel *model = [AgreementModel mj_objectWithKeyValues:dic];  
109 - [arrayM addObject:model]; 77 + if (@available(iOS 11.0, *)) {
  78 + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  79 + }else{
  80 + self.automaticallyAdjustsScrollViewInsets = NO;
110 } 81 }
111 - self.dataArray = arrayM.copy;  
112 - [self.tableView reloadData]; 82 + [self configCallback];
113 83
114 } 84 }
115 85
@@ -119,6 +89,9 @@ @@ -119,6 +89,9 @@
119 89
120 // 这是默认的识别成功的回调 90 // 这是默认的识别成功的回调
121 _successHandler = ^(id result){ 91 _successHandler = ^(id result){
  92 + dispatch_async(dispatch_get_main_queue(), ^{
  93 + [weakSelf dismissViewControllerAnimated:YES completion:nil];
  94 + });
122 if (!weakSelf.isHandler) { 95 if (!weakSelf.isHandler) {
123 return ; 96 return ;
124 } 97 }
@@ -132,7 +105,7 @@ @@ -132,7 +105,7 @@
132 if (weakSelf.isFont) { ///////// 前 105 if (weakSelf.isFont) { ///////// 前
133 if ([dict count] < 6) { 106 if ([dict count] < 6) {
134 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 107 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
135 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 108 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf];
136 [alertView show]; 109 [alertView show];
137 weakSelf.isFontSucc = NO; 110 weakSelf.isFontSucc = NO;
138 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0]; 111 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
@@ -146,7 +119,7 @@ @@ -146,7 +119,7 @@
146 } else { 119 } else {
147 if ([dict count] < 3) { 120 if ([dict count] < 3) {
148 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 121 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
149 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 122 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf];
150 [alertView show]; 123 [alertView show];
151 weakSelf.isBackSucc = NO; 124 weakSelf.isBackSucc = NO;
152 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; 125 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
@@ -158,7 +131,7 @@ @@ -158,7 +131,7 @@
158 return ; 131 return ;
159 } else if ([[CNLiveTimeTools getyyMMddStr] integerValue] > [dict[@"失效日期"][@"words"] integerValue] && ![[NSString stringWithFormat:@"%@",dict[@"失效日期"][@"words"]] isEqualToString:@"长期"]) { 132 } else if ([[CNLiveTimeTools getyyMMddStr] integerValue] > [dict[@"失效日期"][@"words"] integerValue] && ![[NSString stringWithFormat:@"%@",dict[@"失效日期"][@"words"]] isEqualToString:@"长期"]) {
160 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 133 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
161 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"身份证已失效,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 134 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"身份证已失效,请重新拍摄" delegate:weakSelf];
162 [alertView show]; 135 [alertView show];
163 weakSelf.isBackSucc = NO; 136 weakSelf.isBackSucc = NO;
164 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; 137 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
@@ -186,7 +159,7 @@ @@ -186,7 +159,7 @@
186 }else{ 159 }else{
187 [message appendFormat:@"%@: %@\n", key, obj]; 160 [message appendFormat:@"%@: %@\n", key, obj];
188 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 161 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
189 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,获取信息失败,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 162 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,获取信息失败,请重新拍摄" delegate:weakSelf];
190 [alertView show]; 163 [alertView show];
191 weakSelf.isDataSucc = NO; 164 weakSelf.isDataSucc = NO;
192 if (weakSelf.isFont) { 165 if (weakSelf.isFont) {
@@ -221,7 +194,10 @@ @@ -221,7 +194,10 @@
221 weakSelf.idCardNo = dict[@"公民身份号码"][@"words"]; 194 weakSelf.idCardNo = dict[@"公民身份号码"][@"words"];
222 weakSelf.address = dict[@"住址"][@"words"]; 195 weakSelf.address = dict[@"住址"][@"words"];
223 weakSelf.isFontSucc = YES; 196 weakSelf.isFontSucc = YES;
224 - 197 + NSString *message = [NSString stringWithFormat:@"姓名:%@\n身份证号码:%@\n住址:%@",weakSelf.realName,weakSelf.idCardNo,weakSelf.address];
  198 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:@"请确认身份证信息是否准确" message:message delegate:weakSelf];
  199 + alertView.messageLabTextAlignmentLeft = YES;
  200 + [alertView show];
225 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0]; 201 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
226 ApplyForShootCell *cell = [weakSelf.tableView cellForRowAtIndexPath:index]; 202 ApplyForShootCell *cell = [weakSelf.tableView cellForRowAtIndexPath:index];
227 cell.imgV.image = weakSelf.fontImage; 203 cell.imgV.image = weakSelf.fontImage;
@@ -256,7 +232,7 @@ @@ -256,7 +232,7 @@
256 if (weakSelf.isFont) { 232 if (weakSelf.isFont) {
257 if ([array count] < 6) { 233 if ([array count] < 6) {
258 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 234 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
259 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 235 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf];
260 [alertView show]; 236 [alertView show];
261 weakSelf.isFontSucc = NO; 237 weakSelf.isFontSucc = NO;
262 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0]; 238 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
@@ -270,7 +246,7 @@ @@ -270,7 +246,7 @@
270 } else { 246 } else {
271 if ([array count] < 3) { 247 if ([array count] < 3) {
272 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 248 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
273 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 249 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,信息不全,请重新拍摄" delegate:weakSelf];
274 [alertView show]; 250 [alertView show];
275 weakSelf.isBackSucc = NO; 251 weakSelf.isBackSucc = NO;
276 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0]; 252 NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
@@ -289,7 +265,7 @@ @@ -289,7 +265,7 @@
289 }else{ 265 }else{
290 [message appendFormat:@"%@\n", obj]; 266 [message appendFormat:@"%@\n", obj];
291 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 267 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
292 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片不规范,信息获取失败,请重新拍摄" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 268 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片不规范,信息获取失败,请重新拍摄" delegate:weakSelf];
293 [alertView show]; 269 [alertView show];
294 weakSelf.isDataSucc = NO; 270 weakSelf.isDataSucc = NO;
295 if (weakSelf.isFont) { 271 if (weakSelf.isFont) {
@@ -328,7 +304,10 @@ @@ -328,7 +304,10 @@
328 } 304 }
329 }]; 305 }];
330 } 306 }
331 - 307 + NSString *message = [NSString stringWithFormat:@"姓名:%@\n身份证号码:%@\n住址:%@",weakSelf.realName,weakSelf.idCardNo,weakSelf.address];
  308 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:@"请确认身份证信息是否准确" message:message delegate:weakSelf];
  309 + alertView.messageLabTextAlignmentLeft = YES;
  310 + [alertView show];
332 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0]; 311 NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
333 ApplyForShootCell *cell = [weakSelf.tableView cellForRowAtIndexPath:index]; 312 ApplyForShootCell *cell = [weakSelf.tableView cellForRowAtIndexPath:index];
334 cell.imgV.image = weakSelf.fontImage; 313 cell.imgV.image = weakSelf.fontImage;
@@ -355,7 +334,7 @@ @@ -355,7 +334,7 @@
355 }else{ 334 }else{
356 [message appendFormat:@"%@", result]; 335 [message appendFormat:@"%@", result];
357 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 336 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
358 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:@"照片识别失败,请重试" delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 337 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:title message:@"照片识别失败,请重试" delegate:weakSelf];
359 [alertView show]; 338 [alertView show];
360 if (weakSelf.isFont) { 339 if (weakSelf.isFont) {
361 weakSelf.isFontSucc = NO; 340 weakSelf.isFontSucc = NO;
@@ -377,6 +356,9 @@ @@ -377,6 +356,9 @@
377 }; 356 };
378 357
379 _failHandler = ^(NSError *error){ 358 _failHandler = ^(NSError *error){
  359 + dispatch_async(dispatch_get_main_queue(), ^{
  360 + [weakSelf dismissViewControllerAnimated:YES completion:nil];
  361 + });
380 if (!weakSelf.isHandler) { 362 if (!weakSelf.isHandler) {
381 return ; 363 return ;
382 } 364 }
@@ -390,7 +372,7 @@ @@ -390,7 +372,7 @@
390 errorMsg = @"识别失败,请重拍"; 372 errorMsg = @"识别失败,请重拍";
391 } 373 }
392 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 374 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
393 - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"识别结果" message:[NSString stringWithFormat:@"%@",errorMsg] delegate:weakSelf cancelButtonTitle:@"确定" otherButtonTitles:nil]; 375 + CNLiveIDCardAuthAlertView *alertView = [[CNLiveIDCardAuthAlertView alloc] initWithTitle:@"识别结果" message:[NSString stringWithFormat:@"%@",errorMsg] delegate:weakSelf];
394 [alertView show]; 376 [alertView show];
395 if (weakSelf.isFont) { 377 if (weakSelf.isFont) {
396 weakSelf.isFontSucc = NO; 378 weakSelf.isFontSucc = NO;
@@ -411,75 +393,8 @@ @@ -411,75 +393,8 @@
411 }; 393 };
412 } 394 }
413 395
414 -#pragma mark - 调用百度SDK 拍照Action !!!!!!!!!!!!!!!!  
415 -- (void)takePhoto:(BOOL)isFront {  
416 -  
417 - self.isHandler = YES;  
418 - AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];  
419 - if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)  
420 - {  
421 - //无权限  
422 - NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
423 -  
424 - NSString *appName = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
425 - if (appName == nil)  
426 - {  
427 - appName = @"APP";  
428 - }  
429 -// NSString *errorStr = @"无相机权限,请在设置中启用";  
430 - NSString *message = [NSString stringWithFormat:@"请在iPhone的“设置-隐私”选项中,允许%@访问你的相机。", appName];  
431 -  
432 - UIAlertController *actionAlert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];  
433 -// UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {  
434 -// // 引导去设置  
435 -// NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];  
436 -// if ([[UIApplication sharedApplication]canOpenURL:url]) {  
437 -// [[UIApplication sharedApplication]openURL:url];  
438 -// }  
439 -// }];  
440 - UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleCancel handler:NULL];  
441 - [actionAlert addAction:action2];  
442 -// [actionAlert addAction:action1];  
443 - [self presentViewController:actionAlert animated:YES completion:nil];  
444 -  
445 -// [QMUITips showError:errorStr inView:self.view hideAfterDelay:1.5f];  
446 - return;  
447 - }  
448 -  
449 - if (isFront) {  
450 - _isFont = YES;  
451 - UIViewController * vc =  
452 - [AipCaptureCardVC ViewControllerWithCardType:CardTypeIdCardFont  
453 - andImageHandler:^(UIImage *image) {  
454 -  
455 - self.fontImage = image;  
456 - [[AipOcrService shardService] detectIdCardFrontFromImage:image  
457 - withOptions:nil  
458 - successHandler:_successHandler  
459 - failHandler:_failHandler];  
460 - }];  
461 -  
462 - [self presentViewController:vc animated:YES completion:nil];  
463 -  
464 - } else if (!isFront) {  
465 -  
466 - _isFont = NO;  
467 - UIViewController * vc =  
468 - [AipCaptureCardVC ViewControllerWithCardType:CardTypeIdCardBack  
469 - andImageHandler:^(UIImage *image) {  
470 -  
471 - self.backImage = image;  
472 - [[AipOcrService shardService] detectIdCardBackFromImage:image  
473 - withOptions:nil  
474 - successHandler:_successHandler  
475 - failHandler:_failHandler];  
476 - }];  
477 - [self presentViewController:vc animated:YES completion:nil];  
478 - }  
479 -}  
480 -  
481 #pragma mark - 396 #pragma mark -
482 -#pragma mark - 提交 Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 397 +#pragma mark - 提交 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
483 - (void)submit:(UIButton *)sender { 398 - (void)submit:(UIButton *)sender {
484 399
485 sender.selected = !sender.selected; 400 sender.selected = !sender.selected;
@@ -574,23 +489,7 @@ @@ -574,23 +489,7 @@
574 }]; 489 }];
575 } 490 }
576 491
577 -#pragma mark - Action !!!!!!!!!!!!!!!!!!!  
578 -- (void)backAction  
579 -{  
580 -// if (self.delegate && [self.delegate respondsToSelector:@selector(completeRefresh)]) {  
581 -// [self.delegate completeRefresh];  
582 -// }  
583 -// [[AppDelegate sharedAppDelegate] popToRootViewController];  
584 - [self.navigationController popViewControllerAnimated:YES];  
585 -}  
586 -  
587 -- (BOOL)shouldPopViewControllerByBackButtonOrPopGesture:(BOOL)byPopGesture {  
588 -  
589 - [self backAction];  
590 - return NO;  
591 -}  
592 -  
593 -#pragma mark - Image 转 Data !!!!!!!!!!!!!!!!!!!!!!!!!!!! 492 +// Image 转 Data
594 - (NSData *)imageDatasWithImage:(UIImage *)image { 493 - (NSData *)imageDatasWithImage:(UIImage *)image {
595 494
596 NSData *imageData; 495 NSData *imageData;
@@ -602,82 +501,105 @@ @@ -602,82 +501,105 @@
602 return imageData; 501 return imageData;
603 } 502 }
604 503
605 -#pragma mark - UITableViewDataSource  
606 -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {  
607 - return 1;  
608 -}  
609 -  
610 -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  
611 - return self.dataArray.count+1;  
612 -}  
613 -  
614 -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 504 +#pragma mark - 调用百度SDK识别 !!!!!!!!!!!!!!!!
  505 +- (void)goToBaiDuOrcController:(BOOL)isFront {
615 506
616 - if (indexPath.row < self.dataArray.count) {  
617 - AgreementModel *model = self.dataArray[indexPath.row];  
618 - NSString *shootCellId = [NSString stringWithFormat:@"%zd",indexPath.row];  
619 - ApplyForShootCell *cell = [tableView dequeueReusableCellWithIdentifier:shootCellId];  
620 - if (!cell) {  
621 - cell = [[ApplyForShootCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:shootCellId];  
622 - cell.model = model;  
623 - cell.selectionStyle = UITableViewCellSelectionStyleNone;  
624 - }  
625 - __weak __typeof(self)weakSelf = self;  
626 - cell.clickShootBtnBlock = ^() {  
627 - if (model.isOwn) {  
628 - //拍照||相册  
629 - [weakSelf iconAction];  
630 - } else {  
631 - //身份证  
632 - [weakSelf takePhoto:model.isFront];  
633 - }  
634 - };  
635 - return cell; 507 + self.isHandler = YES;
  508 + AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  509 + if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
  510 + {
  511 + //无权限
  512 + NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
636 513
637 - } else {  
638 - NSString *confirmCellId = [NSString stringWithFormat:@"%zd",indexPath.row];  
639 - ApplyForConfirmCell *cell = [tableView dequeueReusableCellWithIdentifier:confirmCellId];  
640 - if (!cell) {  
641 - cell = [[ApplyForConfirmCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:confirmCellId]; 514 + NSString *appName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  515 + if (appName == nil)
  516 + {
  517 + appName = @"APP";
642 } 518 }
643 - cell.selectionStyle = UITableViewCellSelectionStyleNone;  
644 - AgreementModel *model = [[AgreementModel alloc] init];  
645 - model.confirmTitle = @"下一步";  
646 - cell.model = model;  
647 - __weak __typeof(self)weakSelf = self;  
648 - cell.clickBtnBlock = ^(UIButton *btn){  
649 - [weakSelf submit:btn];  
650 - };  
651 - self.confirmCell = cell;  
652 - return cell;  
653 - } 519 +// NSString *errorStr = @"无相机权限,请在设置中启用";
  520 + NSString *message = [NSString stringWithFormat:@"请在iPhone的“设置-隐私”选项中,允许%@访问你的相机。", appName];
  521 +
  522 + UIAlertController *actionAlert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
  523 +// UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  524 +// // 引导去设置
  525 +// NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  526 +// if ([[UIApplication sharedApplication]canOpenURL:url]) {
  527 +// [[UIApplication sharedApplication]openURL:url];
  528 +// }
  529 +// }];
  530 + UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleCancel handler:NULL];
  531 + [actionAlert addAction:action2];
  532 +// [actionAlert addAction:action1];
  533 + [self presentViewController:actionAlert animated:YES completion:nil];
654 534
  535 +// [QMUITips showError:errorStr inView:self.view hideAfterDelay:1.5f];
  536 + return;
  537 + }
  538 +
  539 + if (isFront) {
  540 + _isFont = YES;
  541 + UIViewController * vc =
  542 + [AipCaptureCardVC ViewControllerWithCardType:CardTypeIdCardFont
  543 + andImageHandler:^(UIImage *image) {
  544 +
  545 + self.fontImage = image;
  546 + [[AipOcrService shardService] detectIdCardFrontFromImage:image
  547 + withOptions:nil
  548 + successHandler:_successHandler
  549 + failHandler:_failHandler];
  550 + }];
  551 +
  552 + [self presentViewController:vc animated:YES completion:nil];
  553 +
  554 + } else if (!isFront) {
  555 +
  556 + _isFont = NO;
  557 + UIViewController * vc =
  558 + [AipCaptureCardVC ViewControllerWithCardType:CardTypeIdCardBack
  559 + andImageHandler:^(UIImage *image) {
  560 +
  561 + self.backImage = image;
  562 + [[AipOcrService shardService] detectIdCardBackFromImage:image
  563 + withOptions:nil
  564 + successHandler:_successHandler
  565 + failHandler:_failHandler];
  566 + }];
  567 + [self presentViewController:vc animated:YES completion:nil];
  568 + }
655 } 569 }
656 570
657 -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {  
658 - if (indexPath.row < self.dataArray.count) {  
659 - if (indexPath.row == 2) {  
660 - return 299; 571 +// 自拍cell点击事件
  572 +- (void)clickedIconImageAction {
  573 + AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  574 + if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS7Later) {
  575 + // 无权限 做一个友好的提示
  576 + [self goPrivacySetting];
  577 + } else if (authStatus == AVAuthorizationStatusNotDetermined) {
  578 + // fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏
  579 + if (iOS7Later) {
  580 + [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
  581 + if (granted) {
  582 + dispatch_sync(dispatch_get_main_queue(), ^{
  583 + [self showBottomSelectView];
  584 + });
  585 + }
  586 + }];
661 } else { 587 } else {
662 - return 256; 588 + [self showBottomSelectView];
663 } 589 }
664 } else { 590 } else {
665 - if (kNavigationBarHeight+256*2+145<KScreenHeight) {  
666 - return KScreenHeight-kNavigationBarHeight-256*2;  
667 - } else {  
668 - return 145;  
669 - } 591 + [self showBottomSelectView];
670 } 592 }
671 } 593 }
672 594
673 -#pragma mark - 自拍  
674 --(void)photoBtnClick { 595 +#pragma mark - 显示下方选择拍照/相册视图
  596 +-(void)showBottomSelectView {
675 597
676 __weak __typeof(self)weakSelf = self; 598 __weak __typeof(self)weakSelf = self;
677 [self.view createAlertViewTitleArray:@[@"拍照",@"从手机相册选择"] subTitleArr:@[@"",@""] textColor:RGBA(76, 170, 252, 1) subTitleColor:[UIColor whiteColor] firstFont:UIFontMake(18.0f) font:UIFontMake(18.0f) subFont:UIFontMake(18.0f) cancelTitle:@"取消" cancelFont:UIFontMake(18.0f) cancelTitleColor:UIColorMake(102, 102, 102) actionBlock:^(UIButton *button, NSInteger didRow) { 599 [self.view createAlertViewTitleArray:@[@"拍照",@"从手机相册选择"] subTitleArr:@[@"",@""] textColor:RGBA(76, 170, 252, 1) subTitleColor:[UIColor whiteColor] firstFont:UIFontMake(18.0f) font:UIFontMake(18.0f) subFont:UIFontMake(18.0f) cancelTitle:@"取消" cancelFont:UIFontMake(18.0f) cancelTitleColor:UIColorMake(102, 102, 102) actionBlock:^(UIButton *button, NSInteger didRow) {
678 switch (didRow) { 600 switch (didRow) {
679 case 0:{ 601 case 0:{
680 - [weakSelf takeToXFPhoto]; 602 + [weakSelf pushXTPhoto];
681 } 603 }
682 break; 604 break;
683 case 1:{ 605 case 1:{
@@ -690,8 +612,8 @@ @@ -690,8 +612,8 @@
690 }]; 612 }];
691 } 613 }
692 614
693 -#pragma mark - 跳转到相机  
694 --(void)takeToXFPhoto { 615 +#pragma mark - 跳转到系统相机
  616 +-(void)pushXTPhoto {
695 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 617 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
696 self.pickerVC.sourceType = UIImagePickerControllerSourceTypeCamera; 618 self.pickerVC.sourceType = UIImagePickerControllerSourceTypeCamera;
697 //设置拍照后的图片可被编辑 619 //设置拍照后的图片可被编辑
@@ -772,29 +694,6 @@ @@ -772,29 +694,6 @@
772 [picker dismissViewControllerAnimated:YES completion:^{}]; 694 [picker dismissViewControllerAnimated:YES completion:^{}];
773 } 695 }
774 696
775 -// 自拍cell点击事件  
776 -- (void)iconAction {  
777 - AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];  
778 - if ((authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied) && iOS7Later) {  
779 - // 无权限 做一个友好的提示  
780 - [self goPrivacySetting];  
781 - } else if (authStatus == AVAuthorizationStatusNotDetermined) {  
782 - // fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏  
783 - if (iOS7Later) {  
784 - [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {  
785 - if (granted) {  
786 - dispatch_sync(dispatch_get_main_queue(), ^{  
787 - [self photoBtnClick];  
788 - });  
789 - }  
790 - }];  
791 - } else {  
792 - [self photoBtnClick];  
793 - }  
794 - } else {  
795 - [self photoBtnClick];  
796 - }  
797 -}  
798 // 隐私设置提醒 697 // 隐私设置提醒
799 - (void)goPrivacySetting { 698 - (void)goPrivacySetting {
800 dispatch_async(dispatch_get_main_queue(), ^{ 699 dispatch_async(dispatch_get_main_queue(), ^{
@@ -811,7 +710,7 @@ @@ -811,7 +710,7 @@
811 }); 710 });
812 } 711 }
813 712
814 -#pragma maek -从相册选择 713 +#pragma mark - 从相册选择
815 - (void)pushTZImagePickerController { 714 - (void)pushTZImagePickerController {
816 __weak typeof(self)weakSelf = self; 715 __weak typeof(self)weakSelf = self;
817 TZImagePickerController *picker = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self]; 716 TZImagePickerController *picker = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
@@ -836,38 +735,130 @@ @@ -836,38 +735,130 @@
836 [self presentViewController:picker animated:YES completion:nil]; 735 [self presentViewController:picker animated:YES completion:nil];
837 } 736 }
838 737
839 -#pragma mark UIAlertViewDelegate  
840 -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {  
841 - [self dismissViewControllerAnimated:YES completion:nil]; 738 +#pragma mark - IDCardAuthAlertViewDelegate
  739 +- (void)IDCardAlertView:(CNLiveIDCardAuthAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  740 +
  741 + [alertView removeFromSuperview];
  742 + alertView = nil;
  743 +}
  744 +
  745 +#pragma mark - 加载页面数据 !!!!!!!!!!!!!!!!!
  746 +- (void)loadData {
  747 +
  748 + NSArray *array = @[
  749 + @{
  750 + @"shootTitle":@"第一步",
  751 + @"shootImage":@"observer_idcard_front",
  752 + @"isFront":@"1",
  753 + @"isOwn":@"0"
  754 + },
  755 + @{
  756 + @"shootTitle":@"第二步",
  757 + @"shootImage":@"observer_idcard_back",
  758 + @"isFront":@"0",
  759 + @"isOwn":@"0"
  760 + },
  761 + @{
  762 + @"shootTitle":@"第三步",
  763 + @"shootImage":@"observer_idcard_own",
  764 + @"isFront":@"0",
  765 + @"isOwn":@"1"
  766 + },
  767 + ];
  768 + NSMutableArray *arrayM = [NSMutableArray array];
  769 + for (NSDictionary *dic in array) {
  770 + AgreementModel *model = [AgreementModel mj_objectWithKeyValues:dic];
  771 + [arrayM addObject:model];
  772 + }
  773 + self.dataArray = arrayM.copy;
  774 + [self.tableView reloadData];
  775 +
842 } 776 }
843 777
  778 +#pragma mark - UITableViewDataSource
  779 +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  780 + return 1;
  781 +}
844 782
845 -#pragma mark - RunTime  
846 -- (void)mockBundlerIdForTest {  
847 -#pragma clang diagnostic push  
848 -#pragma clang diagnostic ignored "-Wundeclared-selector"  
849 - [self mockClass:[NSBundle class] originalFunction:@selector(bundleIdentifier) swizzledFunction:@selector(sapicamera_bundleIdentifier)];  
850 -#pragma clang diagnostic pop 783 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  784 + return self.dataArray.count+1;
851 } 785 }
852 786
853 -- (void)mockClass:(Class)class originalFunction:(SEL)originalSelector swizzledFunction:(SEL)swizzledSelector {  
854 -  
855 - Method originalMethod = class_getInstanceMethod(class, originalSelector);  
856 - Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);  
857 -  
858 - BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); 787 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
859 788
860 - if (didAddMethod) {  
861 - class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); 789 + if (indexPath.row < self.dataArray.count) {
  790 + AgreementModel *model = self.dataArray[indexPath.row];
  791 + NSString *shootCellId = [NSString stringWithFormat:@"%zd",indexPath.row];
  792 + ApplyForShootCell *cell = [tableView dequeueReusableCellWithIdentifier:shootCellId];
  793 + if (!cell) {
  794 + cell = [[ApplyForShootCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:shootCellId];
  795 + cell.model = model;
  796 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  797 + }
  798 + __weak __typeof(self)weakSelf = self;
  799 + cell.clickShootBtnBlock = ^() {
  800 + if (model.isOwn) {
  801 + //自拍cell点击事件
  802 + [weakSelf clickedIconImageAction];
  803 + } else {
  804 + //身份证
  805 + [weakSelf goToBaiDuOrcController:model.isFront];
  806 + }
  807 + };
  808 + return cell;
  809 +
862 } else { 810 } else {
863 - method_exchangeImplementations(originalMethod, swizzledMethod); 811 + NSString *confirmCellId = [NSString stringWithFormat:@"%zd",indexPath.row];
  812 + ApplyForConfirmCell *cell = [tableView dequeueReusableCellWithIdentifier:confirmCellId];
  813 + if (!cell) {
  814 + cell = [[ApplyForConfirmCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:confirmCellId];
  815 + }
  816 + cell.selectionStyle = UITableViewCellSelectionStyleNone;
  817 + AgreementModel *model = [[AgreementModel alloc] init];
  818 + model.confirmTitle = @"下一步";
  819 + cell.model = model;
  820 + __weak __typeof(self)weakSelf = self;
  821 + cell.clickBtnBlock = ^(UIButton *btn){
  822 + [weakSelf submit:btn];
  823 + };
  824 + self.confirmCell = cell;
  825 + return cell;
  826 + }
  827 +
  828 +}
  829 +
  830 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  831 + if (indexPath.row < self.dataArray.count) {
  832 + if (indexPath.row == 2) {
  833 + return 299;
  834 + } else {
  835 + return 256;
  836 + }
  837 + } else {
  838 + if (kNavigationBarHeight+256*2+145<KScreenHeight) {
  839 + return KScreenHeight-kNavigationBarHeight-256*2;
  840 + } else {
  841 + return 145;
  842 + }
864 } 843 }
  844 +}
  845 +
  846 +#pragma mark - 返回 !!!!!!!!!!!!!!!!!!!
  847 +- (void)backAction
  848 +{
  849 + [self.navigationController popViewControllerAnimated:YES];
  850 +}
  851 +
  852 +- (BOOL)shouldPopViewControllerByBackButtonOrPopGesture:(BOOL)byPopGesture {
865 853
  854 + [self backAction];
  855 + return NO;
866 } 856 }
  857 +
867 #pragma mark - SubViews 858 #pragma mark - SubViews
868 -(UITableView *)tableView { 859 -(UITableView *)tableView {
869 if (!_tableView) { 860 if (!_tableView) {
870 - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) style:UITableViewStylePlain]; 861 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-kNavigationBarHeight) style:UITableViewStylePlain];
871 _tableView.backgroundColor = RGB(242, 242, 242); 862 _tableView.backgroundColor = RGB(242, 242, 242);
872 _tableView.delegate = self; 863 _tableView.delegate = self;
873 _tableView.dataSource = self; 864 _tableView.dataSource = self;
@@ -878,49 +869,8 @@ @@ -878,49 +869,8 @@
878 return _tableView; 869 return _tableView;
879 } 870 }
880 871
881 -- (void)didReceiveMemoryWarning {  
882 - [super didReceiveMemoryWarning];  
883 - // Dispose of any resources that can be recreated.  
884 -}  
885 -  
886 - (void)dealloc { 872 - (void)dealloc {
887 NSLog(@"dealloc ==> ApplyForShootController"); 873 NSLog(@"dealloc ==> ApplyForShootController");
888 } 874 }
889 875
890 -// 字典转json字符串方法  
891 -  
892 -- (NSString *)convertToJsonData:(NSDictionary *)dict  
893 -{  
894 - NSError *error;  
895 - NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];  
896 -  
897 - NSString *jsonString;  
898 - if (!jsonData) {  
899 - NSLog(@"%@",error);  
900 - }else{  
901 - jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];  
902 - }  
903 -  
904 - NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];  
905 - NSRange range = {0,jsonString.length};  
906 - //去掉字符串中的空格  
907 - [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];  
908 -  
909 - NSRange range2 = {0,mutStr.length};  
910 - //去掉字符串中的换行符  
911 - [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];  
912 - return mutStr;  
913 -  
914 -}  
915 -  
916 -/*  
917 -#pragma mark - Navigation  
918 -  
919 -// In a storyboard-based application, you will often want to do a little preparation before navigation  
920 -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {  
921 - // Get the new view controller using [segue destinationViewController].  
922 - // Pass the selected object to the new view controller.  
923 -}  
924 -*/  
925 -  
926 @end 876 @end
CNLiveBPersonalVerificationModule/Classes/CNBPersonCardInfo/View/CNLiveIDCardAuthAlertView.h 0 → 100644
  1 +//
  2 +// CNLiveIDCardAuthAlertView.h
  3 +// CNLiveBPersonalVerificationModule
  4 +//
  5 +// Created by cnliveJunBo on 2020/4/24.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +@class CNLiveIDCardAuthAlertView;
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@protocol IDCardAuthAlertViewDelegate <NSObject>
  13 +@optional
  14 +- (void)IDCardAlertView:(CNLiveIDCardAuthAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
  15 +
  16 +@end
  17 +
  18 +@interface CNLiveIDCardAuthAlertView : UIView
  19 +
  20 +@property (nonatomic, assign) BOOL messageLabTextAlignmentLeft;
  21 +
  22 +- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate;
  23 +
  24 +- (void)show;
  25 +
  26 +@end
  27 +
  28 +NS_ASSUME_NONNULL_END
CNLiveBPersonalVerificationModule/Classes/CNBPersonCardInfo/View/CNLiveIDCardAuthAlertView.m 0 → 100644
  1 +//
  2 +// CNLiveIDCardAuthAlertView.m
  3 +// CNLiveBPersonalVerificationModule
  4 +//
  5 +// Created by cnliveJunBo on 2020/4/24.
  6 +//
  7 +
  8 +#import "CNLiveIDCardAuthAlertView.h"
  9 +#import <CNLiveBaseKit/CNLiveBaseKit.h>
  10 +#import <Masonry/Masonry.h>
  11 +
  12 +@interface CNLiveIDCardAuthAlertView ()
  13 +
  14 +@property (nonatomic, strong) UIView *contentBgView;
  15 +@property (nonatomic, strong) UILabel *titleLab;
  16 +@property (nonatomic, strong) UIView *messageBgView;
  17 +@property (nonatomic, strong) UILabel *messageLab;
  18 +@property (nonatomic, strong) UIView *horizontalLine;//水平
  19 +@property (nonatomic, strong) UIView *verticalLine;//垂直
  20 +@property (nonatomic, strong) UIButton *confirmBtn;
  21 +@property (nonatomic, strong) UIButton *cancelBtn;
  22 +
  23 +@property (nonatomic, copy) NSString *title;
  24 +@property (nonatomic, copy) NSString *message;
  25 +
  26 +@property (nonatomic, weak) id <IDCardAuthAlertViewDelegate>delegate;
  27 +
  28 +@end
  29 +
  30 +@implementation CNLiveIDCardAuthAlertView
  31 +
  32 +- (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate
  33 +{
  34 + self = [super init];
  35 + if (self) {
  36 + self.title = title;
  37 + self.message = message;
  38 + self.delegate = delegate;
  39 + [self setupUI];
  40 + }
  41 + return self;
  42 +}
  43 +
  44 +- (void)show {
  45 +
  46 + [[UIApplication sharedApplication].delegate.window addSubview:self];
  47 +}
  48 +
  49 +- (void)setMessageLabTextAlignmentLeft:(BOOL)messageLabTextAlignmentLeft {
  50 + _messageLabTextAlignmentLeft = messageLabTextAlignmentLeft;
  51 +
  52 + _messageLab.textAlignment = NSTextAlignmentLeft;
  53 +}
  54 +
  55 +- (void)setupUI {
  56 +
  57 + self.backgroundColor = RGBA(51, 51, 51, 0.5);
  58 + self.frame = [UIScreen mainScreen].bounds;
  59 + [self addSubview:self.contentBgView];
  60 + [self.contentBgView addSubview:self.titleLab];
  61 + [self.contentBgView addSubview:self.messageBgView];
  62 + [self.messageBgView addSubview:self.messageLab];
  63 + [self.contentBgView addSubview:self.horizontalLine];
  64 + [self.contentBgView addSubview:self.verticalLine];
  65 + [self.contentBgView addSubview:self.confirmBtn];
  66 + [self.contentBgView addSubview:self.cancelBtn];
  67 +
  68 + [self.contentBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  69 + make.top.equalTo(self).offset(200+kStatusHeight);
  70 + make.left.equalTo(self).offset(52.5);
  71 + make.right.equalTo(self).offset(-52.5);
  72 + }];
  73 + [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  74 + make.top.equalTo(self.contentBgView).offset(16);
  75 + make.centerX.equalTo(self.contentBgView);
  76 + }];
  77 + [self.messageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  78 + make.top.equalTo(self.titleLab.mas_bottom).offset(11);
  79 + make.left.equalTo(self.contentBgView).offset(20.5);
  80 + make.right.equalTo(self.contentBgView).offset(-20.5);
  81 + make.height.mas_greaterThanOrEqualTo(30);
  82 + }];
  83 + [self.messageLab mas_makeConstraints:^(MASConstraintMaker *make) {
  84 + make.top.left.equalTo(self.messageBgView).offset(12);
  85 + make.bottom.right.equalTo(self.messageBgView).offset(-12);
  86 + }];
  87 + [self.horizontalLine mas_makeConstraints:^(MASConstraintMaker *make) {
  88 + make.top.equalTo(self.messageBgView.mas_bottom).offset(11);
  89 + make.left.right.equalTo(self.contentBgView);
  90 + make.height.mas_equalTo(0.5);
  91 + }];
  92 + [self.verticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
  93 + make.top.equalTo(self.horizontalLine.mas_bottom);
  94 + make.centerX.equalTo(self.horizontalLine);
  95 + make.width.mas_equalTo(0.5);
  96 + make.height.mas_equalTo(44);
  97 + }];
  98 + [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  99 + make.top.equalTo(self.horizontalLine.mas_bottom);
  100 + make.left.equalTo(self.contentBgView);
  101 + make.right.equalTo(self.verticalLine.mas_left);
  102 + make.height.mas_equalTo(44);
  103 + make.bottom.equalTo(self.contentBgView);
  104 + }];
  105 + [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  106 + make.top.equalTo(self.horizontalLine.mas_bottom);
  107 + make.left.equalTo(self.verticalLine.mas_right);
  108 + make.right.equalTo(self.contentBgView);
  109 + make.height.mas_equalTo(44);
  110 + }];
  111 +
  112 +}
  113 +
  114 +#pragma mark - Action
  115 +- (void)confirmBtnAction:(UIButton *)sender {
  116 +
  117 + [self clickedButtonAtIndex:1];
  118 +}
  119 +
  120 +- (void)cancelBtnAction:(UIButton *)sender {
  121 +
  122 + [self clickedButtonAtIndex:0];
  123 +}
  124 +
  125 +- (void)clickedButtonAtIndex:(NSInteger)index {
  126 +
  127 + if (self.delegate && [self.delegate respondsToSelector:@selector(IDCardAlertView:clickedButtonAtIndex:)]) {
  128 + [self.delegate IDCardAlertView:self clickedButtonAtIndex:index];
  129 + }
  130 +}
  131 +
  132 +#pragma mark - Getter
  133 +- (UIView *)contentBgView {
  134 + if (!_contentBgView) {
  135 + _contentBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
  136 + _contentBgView.backgroundColor = kWhiteColor;
  137 + _contentBgView.layer.cornerRadius = 5;
  138 + _contentBgView.layer.masksToBounds = YES;
  139 + }
  140 + return _contentBgView;
  141 +}
  142 +
  143 +- (UILabel *)titleLab {
  144 + if (!_titleLab) {
  145 + _titleLab = [[UILabel alloc] init];
  146 + _titleLab.text = self.title;
  147 + _titleLab.textColor = KBlack51Color;
  148 + _titleLab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15];
  149 + }
  150 + return _titleLab;
  151 +}
  152 +
  153 +- (UIView *)messageBgView {
  154 + if (!_messageBgView) {
  155 + _messageBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 90)];
  156 + _messageBgView.backgroundColor = RGBA(244, 244, 244, 1);
  157 + _messageBgView.layer.cornerRadius = 5;
  158 + _messageBgView.layer.masksToBounds = YES;
  159 + }
  160 + return _messageBgView;
  161 +}
  162 +
  163 +- (UILabel *)messageLab {
  164 + if (!_messageLab) {
  165 + _messageLab = [[UILabel alloc] init];
  166 + NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:self.message];
  167 + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  168 + paragraphStyle.lineSpacing = 6.0; // 设置行间距
  169 + [attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
  170 + _messageLab.attributedText = attributedStr;
  171 + _messageLab.textColor = RGBA(102, 102, 102, 1);
  172 + _messageLab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
  173 + _messageLab.numberOfLines = 0;
  174 + _messageLab.textAlignment = NSTextAlignmentCenter;
  175 + }
  176 + return _messageLab;
  177 +}
  178 +
  179 +- (UIButton *)confirmBtn {
  180 + if (!_confirmBtn) {
  181 + _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  182 + [_confirmBtn setTitle:@"确定" forState:UIControlStateNormal];
  183 + [_confirmBtn setTitleColor:RGBA(72, 167, 249, 1) forState:UIControlStateNormal];
  184 + _confirmBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:17];
  185 + [_confirmBtn addTarget:self action:@selector(confirmBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  186 + }
  187 + return _confirmBtn;
  188 +}
  189 +
  190 +- (UIButton *)cancelBtn {
  191 + if (!_cancelBtn) {
  192 + _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  193 + [_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  194 + [_cancelBtn setTitleColor:KGray153Color forState:UIControlStateNormal];
  195 + _cancelBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:17];
  196 + [_cancelBtn addTarget:self action:@selector(cancelBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  197 + }
  198 + return _cancelBtn;
  199 +}
  200 +
  201 +- (UIView *)horizontalLine {
  202 + if (!_horizontalLine) {
  203 + _horizontalLine = [[UIView alloc] init];
  204 + _horizontalLine.backgroundColor = RGBA(199, 197, 199, 1);
  205 + _horizontalLine.layer.borderColor = RGBA(199, 197, 199, 1).CGColor;
  206 + }
  207 + return _horizontalLine;
  208 +}
  209 +
  210 +- (UIView *)verticalLine {
  211 + if (!_verticalLine) {
  212 + _verticalLine = [[UIView alloc] init];
  213 + _verticalLine.backgroundColor = RGBA(199, 197, 199, 1);
  214 + _verticalLine.layer.borderColor = RGBA(199, 197, 199, 1).CGColor;
  215 + }
  216 + return _verticalLine;
  217 +}
  218 +
  219 +@end