YOUPAILCUploadCameraAuditVC.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // YOUPAILCUploadCameraAuditVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/8/31.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCUploadCameraAuditVC.h"
  9. @interface YOUPAILCUploadCameraAuditVC ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
  10. @property(nonatomic,strong)UIScrollView* youpaipscrollView;
  11. @property(nonatomic,strong)UIImageView* youpaipverifyImgView;
  12. @end
  13. @implementation YOUPAILCUploadCameraAuditVC
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.title = @"上传认证照片";
  17. [self youpaifsetupView];
  18. }
  19. - (void)youpaifsetupView{
  20. UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)];
  21. scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
  22. scrollView.bounces = YES;
  23. scrollView.showsHorizontalScrollIndicator = NO;
  24. scrollView.showsVerticalScrollIndicator = NO;
  25. self.youpaipscrollView = scrollView;
  26. [self.view addSubview:scrollView];
  27. UILabel* topLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 40.0f)];
  28. topLabel.backgroundColor = [HexColorFromRGB(0xFFA68B) colorWithAlphaComponent:0.06f];
  29. topLabel.textColor = HexColorFromRGB(0xFFA68B);
  30. topLabel.textAlignment = NSTextAlignmentCenter;
  31. topLabel.font = [UIFont systemFontOfSize:12];
  32. topLabel.text = @"注:非本人照片/照片模糊/未露全脸均无法通过认证";
  33. [scrollView addSubview:topLabel];
  34. CGFloat wh = (KScreenWidth - 40.0f) / 2.0f;
  35. UIImageView* authImgView = [[UIImageView alloc]initWithFrame:CGRectMake(14.0f, CGRectGetMaxY(topLabel.frame) + 25.0f, wh, wh)];
  36. authImgView.contentMode = UIViewContentModeScaleAspectFill;
  37. authImgView.layer.cornerRadius = 5.0;
  38. authImgView.layer.masksToBounds = YES;
  39. [authImgView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipauthImgUrl]];
  40. [self.youpaipscrollView addSubview:authImgView];
  41. UILabel* authLabel = [[UILabel alloc]initWithFrame:CGRectMake(14.0f, CGRectGetMaxY(authImgView.frame) + 12.0f, wh, 17.0f)];
  42. authLabel.textColor = [UIColor whiteColor];
  43. authLabel.font = [UIFont systemFontOfSize:14];
  44. authLabel.textAlignment = NSTextAlignmentCenter;
  45. authLabel.text = @"示例动作";
  46. [self.youpaipscrollView addSubview:authLabel];
  47. UIImageView* verifyImgView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(authImgView.frame) + 12.0f, CGRectGetMaxY(topLabel.frame) + 25.0f, wh, wh)];
  48. verifyImgView.contentMode = UIViewContentModeScaleAspectFill;
  49. verifyImgView.layer.cornerRadius = 5.0;
  50. verifyImgView.layer.masksToBounds = YES;
  51. verifyImgView.image = self.youpaipcameraImage;
  52. self.youpaipverifyImgView = verifyImgView;
  53. [self.youpaipscrollView addSubview:verifyImgView];
  54. UILabel* verLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(authImgView.frame) + 12.0f, CGRectGetMaxY(verifyImgView.frame) + 12.0f,wh, 17.0f)];
  55. verLabel.textColor = [UIColor whiteColor];
  56. verLabel.font = [UIFont systemFontOfSize:14];
  57. verLabel.textAlignment = NSTextAlignmentCenter;
  58. verLabel.text = @"本人动作";
  59. [self.youpaipscrollView addSubview:verLabel];
  60. UIButton* uploadBtn = [[UIButton alloc]initWithFrame:CGRectMake(40.0f, scrollView.mj_h - 77.0f - SafeHeight, KScreenWidth - 80.0f, 50)];
  61. [uploadBtn setBackgroundImage:[LCTools ColorImage:uploadBtn.mj_size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:(UIControlStateNormal)];
  62. uploadBtn.titleLabel.font = [UIFont systemFontOfSize:17];
  63. [uploadBtn setTitle:@"上传" forState:(UIControlStateNormal)];
  64. [uploadBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  65. uploadBtn.layer.cornerRadius = 25.0;
  66. uploadBtn.layer.masksToBounds = YES;
  67. [uploadBtn addTarget:self action:@selector(youpaifuploadBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  68. [self.youpaipscrollView addSubview:uploadBtn];
  69. UIButton* reCameraBtn = [[UIButton alloc]initWithFrame:CGRectMake(40.0f, uploadBtn.mj_y - 15.0f - 50, KScreenWidth - 80.0f, 50)];
  70. reCameraBtn.backgroundColor = [UIColor clearColor];
  71. reCameraBtn.titleLabel.font = [UIFont systemFontOfSize:17];
  72. [reCameraBtn setTitle:@"重拍" forState:(UIControlStateNormal)];
  73. [reCameraBtn setTitleColor:HexColorFromRGB(0xF4003F) forState:(UIControlStateNormal)];
  74. reCameraBtn.layer.borderColor = HexColorFromRGB(0xF4003F).CGColor;
  75. reCameraBtn.layer.borderWidth = 1.0;
  76. reCameraBtn.layer.cornerRadius = 25.0;
  77. reCameraBtn.layer.masksToBounds = YES;
  78. [reCameraBtn addTarget:self action:@selector(reCameraClick) forControlEvents:(UIControlEventTouchUpInside)];
  79. [self.youpaipscrollView addSubview:reCameraBtn];
  80. }
  81. - (void)reCameraClick{
  82. [UCAuthorityManager cameraAuthority:^{
  83. UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
  84. if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
  85. UIImagePickerController* imgPick = [[UIImagePickerController alloc] init];
  86. imgPick.delegate = self;
  87. imgPick.sourceType = sourceType;
  88. imgPick.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  89. imgPick.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  90. imgPick.allowsEditing = YES;
  91. imgPick.showsCameraControls = YES;
  92. [self presentViewController:imgPick animated:YES completion:nil];
  93. } else {
  94. NSLog(@"模拟器中无法打开照相机,请在真机中使用");
  95. }
  96. } denied:^{
  97. UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
  98. UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  99. [systemAlert addAction:action];
  100. [self presentViewController:systemAlert animated:YES completion:nil];
  101. }];
  102. }
  103. - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  104. [picker dismissViewControllerAnimated:YES completion:nil];
  105. NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
  106. if ([type isEqualToString:@"public.image"]) {
  107. UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
  108. self.youpaipcameraImage = image;
  109. self.youpaipverifyImgView.image = image;
  110. }
  111. }
  112. - (void)youpaifuploadBtnClick{
  113. [ZCHUDHelper showWithStatus:@"上传中..."];
  114. [LCCommonHttp uploadImages:@[self.youpaipcameraImage] type:@"audit" succress:^(NSArray *imageArray) {
  115. NSDictionary* dict = imageArray[0];
  116. if ([[dict objectForKey:@"type"] isEqualToString:@"audit"]) {
  117. NSString* str = [dict objectForKey:@"url"];
  118. [LCHttpHelper requestWithURLString:UploadCameraAudit parameters:@{@"action_type":@(1),@"photo":str} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  119. NSDictionary* dict = (NSDictionary*)responseObject;
  120. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  121. if (code==0) {
  122. [ZCHUDHelper showTitle:@"照片已提交"];
  123. [self.navigationController popViewControllerAnimated:YES];
  124. }
  125. } failure:^(NSError *error) {
  126. [ZCHUDHelper dismiss];
  127. }];
  128. }
  129. }];
  130. }
  131. @end