123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- //
- // YOUPAILCUploadCameraAuditVC.m
- // LiveChat
- //
- // Created by 张灿 on 2018/8/31.
- // Copyright © 2018年 caicai. All rights reserved.
- //
- #import "YOUPAILCUploadCameraAuditVC.h"
- @interface YOUPAILCUploadCameraAuditVC ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
- @property(nonatomic,strong)UIScrollView* youpaipscrollView;
- @property(nonatomic,strong)UIImageView* youpaipverifyImgView;
- @end
- @implementation YOUPAILCUploadCameraAuditVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"上传认证照片";
- [self youpaifsetupView];
-
- }
- - (void)youpaifsetupView{
- UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)];
- scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
- scrollView.bounces = YES;
- scrollView.showsHorizontalScrollIndicator = NO;
- scrollView.showsVerticalScrollIndicator = NO;
- self.youpaipscrollView = scrollView;
- [self.view addSubview:scrollView];
-
-
- UILabel* topLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 40.0f)];
- topLabel.backgroundColor = [HexColorFromRGB(0xFFA68B) colorWithAlphaComponent:0.06f];
- topLabel.textColor = HexColorFromRGB(0xFFA68B);
- topLabel.textAlignment = NSTextAlignmentCenter;
- topLabel.font = [UIFont systemFontOfSize:12];
- topLabel.text = @"注:非本人照片/照片模糊/未露全脸均无法通过认证";
- [scrollView addSubview:topLabel];
-
- CGFloat wh = (KScreenWidth - 40.0f) / 2.0f;
-
- UIImageView* authImgView = [[UIImageView alloc]initWithFrame:CGRectMake(14.0f, CGRectGetMaxY(topLabel.frame) + 25.0f, wh, wh)];
- authImgView.contentMode = UIViewContentModeScaleAspectFill;
- authImgView.layer.cornerRadius = 5.0;
- authImgView.layer.masksToBounds = YES;
- [authImgView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipauthImgUrl]];
- [self.youpaipscrollView addSubview:authImgView];
-
- UILabel* authLabel = [[UILabel alloc]initWithFrame:CGRectMake(14.0f, CGRectGetMaxY(authImgView.frame) + 12.0f, wh, 17.0f)];
- authLabel.textColor = [UIColor whiteColor];
- authLabel.font = [UIFont systemFontOfSize:14];
- authLabel.textAlignment = NSTextAlignmentCenter;
- authLabel.text = @"示例动作";
- [self.youpaipscrollView addSubview:authLabel];
-
-
- UIImageView* verifyImgView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(authImgView.frame) + 12.0f, CGRectGetMaxY(topLabel.frame) + 25.0f, wh, wh)];
- verifyImgView.contentMode = UIViewContentModeScaleAspectFill;
- verifyImgView.layer.cornerRadius = 5.0;
- verifyImgView.layer.masksToBounds = YES;
- verifyImgView.image = self.youpaipcameraImage;
- self.youpaipverifyImgView = verifyImgView;
- [self.youpaipscrollView addSubview:verifyImgView];
-
- UILabel* verLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(authImgView.frame) + 12.0f, CGRectGetMaxY(verifyImgView.frame) + 12.0f,wh, 17.0f)];
- verLabel.textColor = [UIColor whiteColor];
- verLabel.font = [UIFont systemFontOfSize:14];
- verLabel.textAlignment = NSTextAlignmentCenter;
- verLabel.text = @"本人动作";
- [self.youpaipscrollView addSubview:verLabel];
-
-
- UIButton* uploadBtn = [[UIButton alloc]initWithFrame:CGRectMake(40.0f, scrollView.mj_h - 77.0f - SafeHeight, KScreenWidth - 80.0f, 50)];
- [uploadBtn setBackgroundImage:[LCTools ColorImage:uploadBtn.mj_size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:(UIControlStateNormal)];
- uploadBtn.titleLabel.font = [UIFont systemFontOfSize:17];
- [uploadBtn setTitle:@"上传" forState:(UIControlStateNormal)];
- [uploadBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- uploadBtn.layer.cornerRadius = 25.0;
- uploadBtn.layer.masksToBounds = YES;
- [uploadBtn addTarget:self action:@selector(youpaifuploadBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [self.youpaipscrollView addSubview:uploadBtn];
-
- UIButton* reCameraBtn = [[UIButton alloc]initWithFrame:CGRectMake(40.0f, uploadBtn.mj_y - 15.0f - 50, KScreenWidth - 80.0f, 50)];
- reCameraBtn.backgroundColor = [UIColor clearColor];
- reCameraBtn.titleLabel.font = [UIFont systemFontOfSize:17];
- [reCameraBtn setTitle:@"重拍" forState:(UIControlStateNormal)];
- [reCameraBtn setTitleColor:HexColorFromRGB(0xF4003F) forState:(UIControlStateNormal)];
- reCameraBtn.layer.borderColor = HexColorFromRGB(0xF4003F).CGColor;
- reCameraBtn.layer.borderWidth = 1.0;
- reCameraBtn.layer.cornerRadius = 25.0;
- reCameraBtn.layer.masksToBounds = YES;
- [reCameraBtn addTarget:self action:@selector(reCameraClick) forControlEvents:(UIControlEventTouchUpInside)];
- [self.youpaipscrollView addSubview:reCameraBtn];
-
-
- }
- - (void)reCameraClick{
- [UCAuthorityManager cameraAuthority:^{
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
- if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
- UIImagePickerController* imgPick = [[UIImagePickerController alloc] init];
- imgPick.delegate = self;
- imgPick.sourceType = sourceType;
- imgPick.cameraDevice = UIImagePickerControllerCameraDeviceFront;
- imgPick.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- imgPick.allowsEditing = YES;
- imgPick.showsCameraControls = YES;
- [self presentViewController:imgPick animated:YES completion:nil];
- } else {
- NSLog(@"模拟器中无法打开照相机,请在真机中使用");
- }
- } denied:^{
- UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
- [systemAlert addAction:action];
- [self presentViewController:systemAlert animated:YES completion:nil];
- }];
- }
- - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
- [picker dismissViewControllerAnimated:YES completion:nil];
- NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
- if ([type isEqualToString:@"public.image"]) {
- UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
- self.youpaipcameraImage = image;
- self.youpaipverifyImgView.image = image;
- }
- }
- - (void)youpaifuploadBtnClick{
- [ZCHUDHelper showWithStatus:@"上传中..."];
- [LCCommonHttp uploadImages:@[self.youpaipcameraImage] type:@"audit" succress:^(NSArray *imageArray) {
- NSDictionary* dict = imageArray[0];
- if ([[dict objectForKey:@"type"] isEqualToString:@"audit"]) {
- NSString* str = [dict objectForKey:@"url"];
- [LCHttpHelper requestWithURLString:UploadCameraAudit parameters:@{@"action_type":@(1),@"photo":str} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- [ZCHUDHelper showTitle:@"照片已提交"];
- [self.navigationController popViewControllerAnimated:YES];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper dismiss];
- }];
- }
- }];
-
- }
- @end
|