123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- //
- // KXUserIdentificationContronller.m
- // QBCS
- //
- // Created by qianbodong on 2017/7/30.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXUserIdentificationContronller.h"
- #import <MobileCoreServices/MobileCoreServices.h>
- #import <AVFoundation/AVFoundation.h>
- #import <MediaPlayer/MediaPlayer.h>
- @interface KXUserIdentificationContronller ()<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
- @property (nonatomic,assign)NSUInteger tag;
- @property (nonatomic,strong)UIImagePickerController *picker;
- @property (nonatomic,assign)BOOL haveImageA;
- @property (nonatomic,assign)BOOL haveImageB;
- @end
- @implementation KXUserIdentificationContronller
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self initNavBar];
- [self initUIview];
- }
- -(void)initNavBar
- {
- self.navigationController.navigationBar.hidden=NO;
- self.name=@"身份认证";
- [self addLeftBarButtonItemWithImageName:@"main_back" title:nil target:self selector:@selector(beforeAction)];
- }
- -(void)beforeAction
- {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"离开" message:@"现在离开将不会保存所填写信息,确认离开吗?" preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [self.navigationController popViewControllerAnimated:YES];
-
- }]];
- [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- -(void)initUIview{
- _tag=997;
- UIImageView *imageView=[[UIImageView alloc]init];
- //WithFrame:CGRectMake(0, 44*SCREEN_MUTI, SCREEN_WIDTH, 130*SCREEN_MUTI)];
-
- imageView.image=[UIImage imageNamed:@"main_identification_a"];
- imageView.userInteractionEnabled = YES;
- UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapAction:)];
- imageView.tag=997;
- [imageView addGestureRecognizer:singleTap];
- [self.view addSubview:imageView];
- [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view.mas_top).offset(44*SCREEN_MUTI);
- make.centerX.equalTo(self.view);
- make.size.mas_equalTo([imageView.image size]);
- }];
-
- UIImageView *imageView1=[[UIImageView alloc]init];
- imageView1.image=[UIImage imageNamed:@"main_identification_b"];
- imageView1.userInteractionEnabled = YES;
- singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapAction1:)];
- [imageView1 addGestureRecognizer:singleTap];
- imageView1.tag=998;
- [self.view addSubview:imageView1];
- [imageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(imageView.mas_bottom).offset(32*SCREEN_MUTI);
- make.centerX.equalTo(self.view);
- make.size.mas_equalTo([imageView1.image size]);
- }];
-
-
- UIButton *next=[UIButton buttonWithType:UIButtonTypeCustom];
- next.layer.cornerRadius=3;
- next.tag=999;
- next.layer.masksToBounds=YES;
- [next setBackgroundImage:[self imageWithColor:[UIColor baseColor]] forState:UIControlStateHighlighted |UIControlStateNormal];
- [next setBackgroundImage:[self imageWithColor:[UIColor KXColorWithHex:0xd5d5d5]]forState:UIControlStateDisabled];
- next.backgroundColor=[UIColor baseColor];
- next.titleLabel.font=FONT_SYS(16);
- [next setTitle:@"提交" forState:UIControlStateNormal];
- [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [next addTarget:self action:@selector(submitAction:) forControlEvents:UIControlEventTouchUpInside];
- next.enabled=NO;
- [self.view addSubview:next];
- [next mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(imageView1.mas_bottom).offset(30*SCREEN_MUTI);
- make.left.equalTo(self.view.mas_left).offset(14*SCREEN_MUTI);
- make.right.equalTo(self.view.mas_right).offset(-14*SCREEN_MUTI);
- make.height.mas_equalTo(44*SCREEN_MUTI);
- }];
- }
- -(UIImage *)imageWithColor:(UIColor *)color {
- CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
- UIGraphicsBeginImageContext(rect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- CGContextSetFillColorWithColor(context, [color CGColor]);
- CGContextFillRect(context, rect);
-
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
-
- return image;
- }
- -(void)singleTapAction:(UIGestureRecognizer*) g
- {
- _tag=997;
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
- {
- [self presentViewController:self.picker animated:YES completion:nil];
- }
-
- }
- -(void)singleTapAction1:(UIGestureRecognizer*) g
- {
- _tag=998;
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
- {
- [self presentViewController:self.picker animated:YES completion:nil];
- }
- }
- #pragma mark UIImagePickerControllerDelegate
- //该代理方法仅适用于只选取图片时
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo {
- if (image){
- UIImageView* imageView=[self.view viewWithTag:_tag];
- imageView.image = image;
- if(_tag==997){
- _haveImageA=YES;
- if(_haveImageB){
- UIButton* button=[self.view viewWithTag:999];
- button.enabled=YES;
- }
- }else {
- _haveImageB=YES;
- if(_haveImageA){
- UIButton* button=[self.view viewWithTag:999];
- button.enabled=YES;
- }
- }
-
- }
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- {
- [self dismissViewControllerAnimated:YES completion:nil];
-
- }
- -(void)submitAction:(UIButton*) button{
- button.enabled=NO;
- [button setTitle:@"提交中..." forState:UIControlStateNormal];
-
- NSString *urlS=[NSString stringWithFormat:@"%@/user/iosApply",URL];
- // NSDictionary *paraDict=@{@"amount":@(_amount),@"term":@(_term),@"name":nameTF.text,@"age":ageTF.text,@"cell_num":cell_numTF.text,@"occupation":careerBtn.titleLabel.text,@"monthly_income":incomeBtn.titleLabel.text};
- NSLog(@"%@",_paraDict);
- [KXHTTP post:urlS params:_paraDict success:^(id json) {
- // [[NSNotificationCenter defaultCenter]postNotificationName:KXWAITING object:nil userInfo:nil];
- [self.navigationController popToRootViewControllerAnimated:YES];
- } failure:^(NSError *error) {
- button.enabled=YES;
- }];
-
- }
- -(UIImagePickerController*)picker{
- if(!_picker){
- self.picker= [[UIImagePickerController alloc] init];
- _picker.delegate = self;
- // picker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
- _picker.allowsEditing = YES;
- _picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- }
- return _picker;
- }
- @end
|