YOUPAILCCameraAuditVC.m 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // LCCameraAduitVC.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/8/31.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCameraAuditVC.h"
  9. #import "YOUPAILCUploadCameraAuditVC.h"
  10. @interface YOUPAILCCameraAuditVC ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
  11. @property(nonatomic,strong)NSString* youpaipauthimg;//认证的示例图片
  12. @property(nonatomic,assign)NSInteger youpaipstatus;//认证状态
  13. @property(nonatomic,strong)UIScrollView* youpaipscrollView;
  14. @property(nonatomic,strong)UIImageView* youpaipauthImgView;
  15. @property(nonatomic,strong)UIButton* youpaipopenCameraBtn;
  16. @property(nonatomic,strong)NSString* youpaipaction_type;
  17. @property(nonatomic,strong)NSString* youpaipaction_image;
  18. @property(nonatomic,strong)NSString* youpaipaudit_remark;
  19. @property(nonatomic,assign)NSInteger youpaipaudit_status;
  20. @end
  21. @implementation YOUPAILCCameraAuditVC
  22. - (void)viewWillAppear:(BOOL)animated{
  23. [super viewWillAppear:animated];
  24. [self youpaifinitData];
  25. }
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. self.title = @"自拍认证";
  29. [self youpaifsetupView];
  30. }
  31. - (void)youpaifinitData{
  32. [LCHttpHelper requestWithURLString:CameraAudit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  33. NSDictionary* dict = (NSDictionary*)responseObject;
  34. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  35. if (code==0) {
  36. NSInteger action_type=[[[dict objectForKey:@"data"]objectForKey:@"action_type"]integerValue];
  37. self.youpaipaction_type =[NSString stringWithFormat:@"%zd",action_type] ;
  38. self.youpaipaction_image = [[dict objectForKey:@"data"]objectForKey:@"action_image"];
  39. self.youpaipaudit_remark = [[dict objectForKey:@"data"]objectForKey:@"audit_remark"];
  40. self.youpaipaudit_status = [[[dict objectForKey:@"data"]objectForKey:@"audit_status"]integerValue];
  41. [self youpaifupdateView];
  42. }
  43. } failure:^(NSError *error) {
  44. }];
  45. }
  46. - (void)youpaifsetupView{
  47. UIScrollView* scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight)];
  48. scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-NavBarHeight+1);
  49. scrollView.bounces = YES;
  50. scrollView.showsHorizontalScrollIndicator = NO;
  51. scrollView.showsVerticalScrollIndicator = NO;
  52. self.youpaipscrollView = scrollView;
  53. [self.view addSubview:scrollView];
  54. UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(14.0f,25.0f,KScreenWidth-28.0f,427.0f)];
  55. baseView.layer.cornerRadius = 6.0f;
  56. baseView.layer.masksToBounds = YES;
  57. baseView.backgroundColor = HexColorFromRGB(0x2A2935);
  58. [self.youpaipscrollView addSubview:baseView];
  59. UILabel* tipLabel = [[UILabel alloc]initWithFrame:CGRectMake(14.0f,25, 200, 20)];
  60. tipLabel.textAlignment = NSTextAlignmentLeft;
  61. tipLabel.textColor = [UIColor whiteColor];
  62. tipLabel.font = [UIFont boldSystemFontOfSize:14];
  63. tipLabel.text = @"温馨提示";
  64. [baseView addSubview:tipLabel];
  65. UILabel* tipLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(14.0f,CGRectGetMaxY(tipLabel.frame) + 8.0f, KScreenWidth-28-28, 17.0f)];
  66. tipLabel1.textAlignment = NSTextAlignmentLeft;
  67. tipLabel1.textColor = [UIColor whiteColor];
  68. tipLabel1.font = [UIFont systemFontOfSize:14];
  69. tipLabel1.text = @"1.认证照片必须为本人正面全脸清晰露出照";
  70. [baseView addSubview:tipLabel1];
  71. UILabel* tipLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(14.0f,CGRectGetMaxY(tipLabel1.frame), KScreenWidth-28-28, 17.0f)];
  72. tipLabel2.textAlignment = NSTextAlignmentLeft;
  73. tipLabel2.textColor = [UIColor whiteColor];
  74. tipLabel2.font = [UIFont systemFontOfSize:14];
  75. tipLabel2.text = @"2.本照片仅用于认证,官方将对照片保密";
  76. [baseView addSubview:tipLabel2];
  77. UIImageView* authImgView = [[UIImageView alloc]initWithFrame:CGRectMake((baseView.mj_w - 230.0f) / 2.0f, CGRectGetMaxY(tipLabel2.frame) + 25.0f, 230,230)];
  78. authImgView.backgroundColor = LCBkgColor;
  79. authImgView.contentMode = UIViewContentModeScaleAspectFill;
  80. authImgView.layer.cornerRadius = 5.0;
  81. authImgView.layer.masksToBounds = YES;
  82. self.youpaipauthImgView = authImgView;
  83. [baseView addSubview:authImgView];
  84. UILabel *topLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(authImgView.frame) + 14.0f, baseView.mj_w,15)];
  85. topLabel.textColor = HexColorFromRGB(0x9F9DA5);
  86. topLabel.font = [UIFont systemFontOfSize:12];
  87. topLabel.textAlignment = NSTextAlignmentCenter;
  88. topLabel.text = @"(请模仿示例动作否则不会通过认证)";
  89. [baseView addSubview:topLabel];
  90. UIButton* openCameraBtn = [[UIButton alloc]initWithFrame:CGRectMake(40.0f, scrollView.mj_h - 77.0f - SafeHeight, KScreenWidth-80.0f,48)];
  91. openCameraBtn.backgroundColor = HexColorFromRGB(0x4F4B5B);
  92. openCameraBtn.titleLabel.font = [UIFont systemFontOfSize:17];
  93. [openCameraBtn setTitle:@"马上自拍" forState:(UIControlStateNormal)];
  94. [openCameraBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  95. openCameraBtn.layer.cornerRadius = 24.0;
  96. openCameraBtn.layer.masksToBounds = YES;
  97. [openCameraBtn addTarget:self action:@selector(openCameraClick) forControlEvents:(UIControlEventTouchUpInside)];
  98. openCameraBtn.userInteractionEnabled = NO;
  99. self.youpaipopenCameraBtn = openCameraBtn;
  100. [scrollView addSubview:openCameraBtn];
  101. }
  102. - (void)youpaifupdateView{
  103. [self.youpaipauthImgView sd_setImageWithURL:[LCTools getImageUrlWithAddress:self.youpaipaction_image]];
  104. if (self.youpaipaudit_status == 0 || self.youpaipaudit_status == 3) {
  105. [self.youpaipopenCameraBtn setBackgroundImage:[LCTools ColorImage:self.youpaipopenCameraBtn.mj_size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:GradientLeftToRight] forState:(UIControlStateNormal)];
  106. self.youpaipopenCameraBtn.userInteractionEnabled = YES;
  107. if (self.youpaipaudit_status == 0) {
  108. [self.youpaipopenCameraBtn setTitle:@"马上自拍" forState:(UIControlStateNormal)];
  109. }else{
  110. [self.youpaipopenCameraBtn setTitle:@"审核未通过,再次自拍" forState:(UIControlStateNormal)];
  111. }
  112. }else{
  113. [self.youpaipopenCameraBtn setBackgroundImage:nil forState:(UIControlStateNormal)];
  114. self.youpaipopenCameraBtn.userInteractionEnabled = NO;
  115. if (self.youpaipaudit_status == 1) {
  116. [self.youpaipopenCameraBtn setTitle:@"人工审核中..." forState:(UIControlStateNormal)];
  117. }else{
  118. [self.youpaipopenCameraBtn setTitle:@"已通过自拍认证" forState:(UIControlStateNormal)];
  119. }
  120. }
  121. }
  122. - (void)openCameraClick{
  123. [UCAuthorityManager cameraAuthority:^{
  124. UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
  125. if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
  126. dispatch_async(dispatch_get_main_queue(), ^{
  127. UIImagePickerController* imgPick = [[UIImagePickerController alloc] init];
  128. imgPick.delegate = self;
  129. imgPick.sourceType = sourceType;
  130. imgPick.cameraDevice = UIImagePickerControllerCameraDeviceFront;
  131. imgPick.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  132. imgPick.allowsEditing = YES;
  133. imgPick.showsCameraControls = YES;
  134. [self presentViewController:imgPick animated:YES completion:nil];
  135. });
  136. } else {
  137. NSLog(@"模拟器中无法打开照相机,请在真机中使用");
  138. }
  139. } denied:^{
  140. UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
  141. UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  142. [systemAlert addAction:action];
  143. [self presentViewController:systemAlert animated:YES completion:nil];
  144. }];
  145. }
  146. - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  147. [picker dismissViewControllerAnimated:YES completion:nil];
  148. NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
  149. if ([type isEqualToString:@"public.image"]) {
  150. UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
  151. YOUPAILCUploadCameraAuditVC* uploadAudit = [[YOUPAILCUploadCameraAuditVC alloc]init];
  152. uploadAudit.youpaipcameraImage = image;
  153. uploadAudit.youpaipauthImgUrl = self.youpaipaction_image;
  154. uploadAudit.youpaipaction_type = self.youpaipaction_type;
  155. [self.navigationController pushViewController:uploadAudit animated:YES];
  156. }
  157. }
  158. @end