ios之系统相机和相册上传图片,相机拍照,相册选择图片

#import "Reachability.h"
#import <Photos/Photos.h>
#import <AVFoundation/AVCaptureDevice.h>
#import <AVFoundation/AVMediaFormat.h>
@interface LYMyrealnameVC ()<UITableViewDelegate,UITableViewDataSource,LYMyrealnamecellDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
@property(nonatomic,strong)UITableView *tab;
@property(nonatomic,strong)UIView *bottomv;
@property(nonatomic,strong)UIImage *headerImage;
@property(nonatomic,strong)NSArray *cellTitleArr;
@property(nonatomic,strong)UIImageView *headimageV;

@property(nonatomic,copy)NSString *mobile;//手机
@property(nonatomic,copy)NSString *realname;//实名
@property(nonatomic,copy)NSString *idcard;//身份证
@property(nonatomic,copy)NSString *headeric;//头像url

@property(nonatomic,strong)UIButton *sureBtn;
@property(nonatomic,assign)NSInteger index;//标记哪个身份证按钮
@property(nonatomic,copy)NSString *positiveIDCardImg;//身份证正面
@property(nonatomic,copy)NSString *negtiveIDCardImg;//身份证反面
@property(nonatomic,copy)NSString *positiveBankCardImg;//银行卡正面
@property(nonatomic,copy)NSString *positiveIDCardAndBankCardImg;//身份证和银行卡正面

@property(nonatomic,strong)UILabel *haveverifyLabel;//已验证的标识

@property(nonatomic,strong)UIButton *sfcfrontbtn;//身份证正面
@property(nonatomic,strong)UIButton *sfcbackbtn;//身份证反面
@property(nonatomic,strong)UIButton *sfcandbankbtn;//身份证正面和银行卡正面
@property(nonatomic,strong)UIButton *bankfrontbtn;//银行卡正面
@property(nonatomic,strong)UIButton *suresendImagebtn;//提交按钮
@end
static NSString *identifier=@"realnamecell";

@implementation LYMyrealnameVC

-(instancetype)init{
    if(self==[super init]){
        self.hidesBottomBarWhenPushed=YES;
    }
    return self;
}


-(UIImage *)headerImage{
    if(nil==_headerImage){
    _headerImage=[UIImage imageNamed:@"icon_avatar"];
    }
    return _headerImage;
}
-(NSArray *)cellTitleArr{
    if(nil==_cellTitleArr){
    
        _cellTitleArr=@[@"手机号",@"姓名",@"身份证"];
    }
    return _cellTitleArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets=NO;
self.title=@"实名认证";
   
    [self setTab];

    [self.tab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
    }];
    
}

-(void)viewWillAppear:(BOOL)animated{
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];//标题颜色
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];//导航背景颜色
[self initDatasss];
    
}

-(void)initDatasss{
    if([LYCommanManager sharedManager].headerImageStrurl && ![[LYCommanManager sharedManager].headerImageStrurl isEqualToString:@""] &&![[LYCommanManager sharedManager].headerImageStrurl isEqualToString:@"null"]){
        self.headeric=[LYCommanManager sharedManager].headerImageStrurl;
         NSString *urlstr=self.headeric;
        NSLog(@"从网络获取头像--0011 -%@",urlstr);
        
        [self.headimageV  sd_setImageWithURL:[NSURL URLWithString:urlstr] placeholderImage:[UIImage imageNamed:@"icon_avatar"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            
        }];

    }
}

-(void)setTab{
    UITableView *tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 400) style:UITableViewStylePlain];
    self.tab=tab;
    [self.view addSubview:tab];
    
    tab.delegate=self;
    tab.dataSource=self;
    tab.tableFooterView=[[UIView alloc]init];
    UINib *nib=[UINib nibWithNibName:@"LYMyrealnamecell" bundle:nil];
    [tab registerNib:nib forCellReuseIdentifier:identifier];
   
        //tabviewheader
    UIView *v=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 150)];
    UIImageView *headerImageV=[[UIImageView alloc]init];
    headerImageV.bounds=CGRectMake(0, 0, 100, 100);
    headerImageV.center=v.center;
    headerImageV.backgroundColor=[UIColor redColor];
    
    headerImageV.layer.masksToBounds = YES;
   headerImageV.layer.cornerRadius = 50;
   headerImageV.layer.borderWidth = 0.5;
    headerImageV.layer.borderColor=[UIColor blackColor].CGColor;

    self.headimageV=headerImageV;
    headerImageV.image=self.headerImage;
    [v addSubview:headerImageV];
    tab.tableHeaderView=v;
    
     UIView *tabfootview;
    if([LYCommanManager sharedManager].positiveIDCardImg&& ![[LYCommanManager sharedManager].positiveIDCardImg isEqualToString:@""]&& ![[LYCommanManager sharedManager].positiveIDCardImg isEqualToString:@"<null>"]){//如果有身份证
        tabfootview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 100)];
        UILabel *tipLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WIDTH/2, 30)];
        tipLabel.text=@"  证件和银行卡照片";
        [tabfootview addSubview:tipLabel];
        UILabel *haveverifyLabel=[[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2, 0, WIDTH/2, 30)];
        haveverifyLabel.text=@"已认证        ";
        self.haveverifyLabel=haveverifyLabel;
        haveverifyLabel.textColor=[UIColor colorWithRed:103.0/255 green:158.0/255 blue:247.0/255 alpha:1];
        haveverifyLabel.textAlignment=NSTextAlignmentRight;
        [tabfootview addSubview:haveverifyLabel];
        
    }else{
    //底部
        tabfootview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 500)];
    UILabel *tipLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, WIDTH/2, 30)];
    tipLabel.text=@"  证件和银行卡照片";
    [tabfootview addSubview:tipLabel];
        UILabel *haveverifyLabel=[[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2, 0, WIDTH/2, 30)];
        haveverifyLabel.text=@"";
        self.haveverifyLabel=haveverifyLabel;
        haveverifyLabel.textColor=[UIColor colorWithRed:103.0/255 green:158.0/255 blue:247.0/255 alpha:1];
        haveverifyLabel.textAlignment=NSTextAlignmentRight;
        [tabfootview addSubview:haveverifyLabel];
        
    UIView *sfcfrontview=[[UIView alloc]initWithFrame:CGRectMake(0, 30, WIDTH/2, 120)];
    UIButton *sfcfrontbtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, WIDTH/2,85)];
    self.sfcfrontbtn=sfcfrontbtn;
    [sfcfrontbtn setImage:[UIImage imageNamed:@"sfzfront"] forState:UIControlStateNormal];
    [sfcfrontbtn addTarget:self action:@selector(sfzfrontbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [sfcfrontview addSubview:sfcfrontbtn];
    UILabel *sfcfrontlbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 85, WIDTH/2, 30)];
    sfcfrontlbl.text=@"身份证正面";
    sfcfrontlbl.font=[UIFont systemFontOfSize:12];
    sfcfrontlbl.textAlignment=NSTextAlignmentCenter;
    [sfcfrontview addSubview:sfcfrontlbl];
    [tabfootview addSubview:sfcfrontview];
    
//    UIView *sfcbackview=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2, 30, WIDTH/2, 120)];
//    UIButton *sfcbackbtn=[[UIButton alloc]initWithFrame:CGRectMake(WIDTH/2, 0, WIDTH/2, 85)];
//    self.sfcbackbtn=sfcbackbtn;
//    [sfcbackbtn setImage:[UIImage imageNamed:@"sfzback"] forState:UIControlStateNormal];
//    [sfcbackbtn addTarget:self action:@selector(sfcbackbtnclicks) forControlEvents:UIControlEventTouchUpInside];
//    [sfcfrontview addSubview:sfcbackbtn];
//    UILabel *sfcbacklbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 85, WIDTH/2, 30)];
//    sfcbacklbl.text=@"身份证反面";
//    sfcbacklbl.font=[UIFont systemFontOfSize:12];
//     sfcbacklbl.textAlignment=NSTextAlignmentCenter;
//    [sfcbackview addSubview:sfcbacklbl];
//    [tabfootview addSubview:sfcbackview];
    UIButton *sfcbackbtn=[[UIButton alloc]initWithFrame:CGRectMake(WIDTH/2, 30, WIDTH/2, 85)];
    self.sfcbackbtn=sfcbackbtn;
    [sfcbackbtn setImage:[UIImage imageNamed:@"sfzback"] forState:UIControlStateNormal];
    [sfcbackbtn addTarget:self action:@selector(sfcbackbtnclicks) forControlEvents:UIControlEventTouchUpInside];
    [tabfootview addSubview:sfcbackbtn];
    UILabel *sfcbacklbl=[[UILabel alloc]initWithFrame:CGRectMake(WIDTH/2, 30+85, WIDTH/2, 30)];
        sfcbacklbl.text=@"身份证反面";
        sfcbacklbl.font=[UIFont systemFontOfSize:12];
         sfcbacklbl.textAlignment=NSTextAlignmentCenter;
        [tabfootview addSubview:sfcbacklbl];
    
    UIView *sfcandbankview=[[UIView alloc]initWithFrame:CGRectMake(0, 150, WIDTH/2, 150)];
    UIButton *sfcandbankbtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, WIDTH/2, 85)];
    self.sfcandbankbtn=sfcandbankbtn;
    [sfcandbankbtn setImage:[UIImage imageNamed:@"sfcandbank"] forState:UIControlStateNormal];
    [sfcandbankbtn addTarget:self action:@selector(sfcandbankbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [sfcandbankview addSubview:sfcandbankbtn];
    UILabel *sfcandbanklbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 85, WIDTH/2, 30)];
    sfcandbanklbl.text=@"手持身份证和银行卡正面";
    sfcandbanklbl.font=[UIFont systemFontOfSize:12];
    sfcandbanklbl.textAlignment=NSTextAlignmentCenter;
    [sfcandbankview addSubview:sfcandbanklbl];
    UILabel *sfcandbanklbldtail=[[UILabel alloc]initWithFrame:CGRectMake(0, 110, WIDTH/2, 20)];
    sfcandbanklbldtail.text=@"左手身份证右手银行卡";
    sfcandbanklbldtail.textColor=[UIColor colorWithHexString:@"#54a0fe" alpha:1];
    sfcandbanklbldtail.font=[UIFont systemFontOfSize:10];
    sfcandbanklbldtail.textAlignment=NSTextAlignmentCenter;
    [sfcandbankview addSubview:sfcandbanklbldtail];
    [tabfootview addSubview:sfcandbankview];
    
    UIView *bankfrontview=[[UIView alloc]initWithFrame:CGRectMake(WIDTH/2, 150, WIDTH/2, 120)];
    UIButton *bankfrontbtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, WIDTH/2, 85)];
    self.bankfrontbtn=bankfrontbtn;
    [bankfrontbtn setImage:[UIImage imageNamed:@"bankfront"] forState:UIControlStateNormal];
    [bankfrontbtn addTarget:self action:@selector(bankfrontbtnclick) forControlEvents:UIControlEventTouchUpInside];
    [bankfrontview addSubview:bankfrontbtn];
    UILabel *bankfrontlbl=[[UILabel alloc]initWithFrame:CGRectMake(0, 85, WIDTH/2, 30)];
    bankfrontlbl.text=@"银行卡正面";
    bankfrontlbl.font=[UIFont systemFontOfSize:12];
    bankfrontlbl.textAlignment=NSTextAlignmentCenter;
    [bankfrontview addSubview:bankfrontlbl];
    [tabfootview addSubview:bankfrontview];
    
    UIButton *suresendImagebtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 300,345*WIDTH/375, 50*HEIGHT/667)];
        self.suresendImagebtn=suresendImagebtn;
      suresendImagebtn.layer.cornerRadius=25*HEIGHT/667;
    [suresendImagebtn setCenterX:WIDTH/2];
    [suresendImagebtn setTitle:@"立即上传" forState:UIControlStateNormal];
    [suresendImagebtn setBackgroundColor:[UIColor colorWithRed:103.0/255 green:158.0/255 blue:247.0/255 alpha:1]];
    [suresendImagebtn addTarget:self action:@selector(suresendImagebtnclick) forControlEvents:UIControlEventTouchUpInside];
    [tabfootview addSubview:suresendImagebtn];
    }
    
     tab.tableFooterView=tabfootview;
}

//吊起相册或相机
-(void)gotocameraOrLibrary{
    __weak typeof(self)weakself=self;
    UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"打开相机或相册" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *libraray=[UIAlertAction actionWithTitle:@"打开相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [weakself opencameraAndlibrayWith:0];
    }];
    UIAlertAction *camera=[UIAlertAction actionWithTitle:@"打开相机" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [weakself opencameraAndlibrayWith:1];
    }];
    UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [weakself opencameraAndlibrayWith:2];
    }];
    [controller addAction:libraray];
    [controller addAction:camera];
    [controller addAction:cancel];
    [self presentViewController:controller animated:YES completion:nil];
    
}
//打开相机或相册
-(void)opencameraAndlibrayWith:(NSInteger)index{
     NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    if(index==0){
    if([UIImagePickerController  isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
        //我的相册
        sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        
        //获取相册访问权限
        
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            dispatch_async(dispatch_get_main_queue(), ^{
                switch (status) {
                    case PHAuthorizationStatusAuthorized: //已获取权限
                    {
                        // 跳转到相机或相册页面
                        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
                        imagePickerController.delegate = self;
                        imagePickerController.allowsEditing = YES;
                        imagePickerController.sourceType = sourceType;
                        //弹出相册页面或相机
                        [self presentViewController:imagePickerController animated:YES completion:^{
                            
                        }];
                        
                        break;
                    }
                    case PHAuthorizationStatusDenied: {//用户已经明确否认了这一照片数据的应用程序访问
                        [self gotoSetAuthor];//去设置权限
                        
                        break;
                    }
                    case PHAuthorizationStatusRestricted://此应用程序没有被授权访问的照片数据。
                        [self gotoSetAuthor];
                        break;
                        
                    default://其他。。。
                        break;
                }
            });
        }];
    }
    }else if(index==1){//打开相机
        if([UIImagePickerController  isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
            //相机
            sourceType = UIImagePickerControllerSourceTypeCamera;
            
            [AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
                
                AVAuthorizationStatus status =[AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
                if (status == AVAuthorizationStatusAuthorized){
                    //获取权限
                    // 跳转到相机或相册页面
                    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
                    imagePickerController.delegate = self;
                    imagePickerController.allowsEditing = YES;
                    imagePickerController.sourceType = sourceType;
                    //弹出相册页面或相机
                    [self presentViewController:imagePickerController animated:YES completion:^{
                        
                    }];
                    
                }else if(status == AVAuthorizationStatusDenied ||status ==AVAuthorizationStatusRestricted){//拒绝了权限
                    [self gotoSetAuthor];
                    
                }
            }];
        }
    }else if(index==2){//取消
        
    }
}
-(void)gotoSetAuthor{
    UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"去设置页面->2号情报->照片、相机" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *sure=[UIAlertAction actionWithTitle:@"去开启权限" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        dispatch_async(dispatch_get_main_queue(), ^{
            if( [[UIApplication sharedApplication] canOpenURL:url]){
                [[UIApplication sharedApplication] openURL:url];
            }
        });
    }];
    UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"暂不" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [controller addAction:sure];
    [controller addAction:cancel];
    [self presentViewController:controller animated:YES completion:^{
        
    }];
}
//选中相册的代理方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    
    NSLog(@"选择照片");
    [picker dismissViewControllerAnimated:YES completion:^{
        
    }];
    
    //从相册获取到的头像
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    //缩小图片
    CGSize newSize=CGSizeMake(130, 85);
    UIGraphicsBeginImageContext(newSize);
    
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    
    UIImage*
    newImage = UIGraphicsGetImageFromCurrentImageContext();//从图形上下文获取新的图片
    UIGraphicsEndImageContext();
    
    
        
    
    //*************吧头像上传到服务器
    
    //加密解秘都是对二进制进行处理
    NSData *data =UIImagePNGRepresentation(newImage);
    
    //指定编码方式.默认0
    NSString *base64String= [data base64EncodedStringWithOptions:0];
     base64String=[@"data:image/png;base64," stringByAppendingString:base64String];///php服务器上面要加上@"data:image/png;base64,"
    //    //解密
    //    //二进制
    //    NSData *datas = [[NSData alloc]initWithBase64EncodedString:base64String options:0];
    //
    //    UIImage *image=[UIImage imageWithData:datas];
    //    [UIImage imageWithData:datas scale:0.8];
    
    if(self.index==0){
        self.positiveIDCardImg=base64String;
        [self.sfcfrontbtn setImage:newImage forState:UIControlStateNormal];//吧要上传的图片显示出来
    }else  if(self.index==1){
        self.negtiveIDCardImg=base64String;
         [self.sfcbackbtn setImage:newImage forState:UIControlStateNormal];
    }else  if(self.index==2){
        self.positiveBankCardImg=base64String;
         [self.sfcandbankbtn setImage:newImage forState:UIControlStateNormal];
    }else  if(self.index==3){
        self.positiveIDCardAndBankCardImg=base64String;
         [self.bankfrontbtn setImage:newImage forState:UIControlStateNormal];
    }
    
}
//省份证正面
-(void)sfzfrontbtnclick{
    self.index=0;
    [self gotocameraOrLibrary];
}
//身份证反面
-(void)sfcbackbtnclicks{
    self.index=1;
     [self gotocameraOrLibrary];
}
//身份证和银行卡正面
-(void)sfcandbankbtnclick{
    self.index=2;
     [self gotocameraOrLibrary];
}
//银行卡正面
-(void)bankfrontbtnclick{
    self.index=3;
     [self gotocameraOrLibrary];
}

//确定发送图片的按钮
-(void)suresendImagebtnclick{
    NSString *url=[TESTBASEURL stringByAppendingString:@"extraImg"];
    NSDictionary *params=@{@"positiveIDCardImg":self.positiveIDCardImg?self.positiveIDCardImg:@"",
                           @"negtiveIDCardImg":self.negtiveIDCardImg?self.negtiveIDCardImg:@"",
                           @"positiveBankCardImg":self.positiveBankCardImg?self.positiveBankCardImg:@"",
                        @"positiveIDCardAndBankCardImg":self.positiveIDCardAndBankCardImg?self.positiveIDCardAndBankCardImg:@""
                           };
    [LYMyRequesthttp realnnameshenfenzhengAndbankWithUrl:url params:params successBlock:^(NSURLSessionDataTask *task, id responseObject) {
        if(responseObject){
            if([[responseObject allKeys]containsObject:@"result"]){
               
            }
            if([[responseObject allKeys]containsObject:@"state"]){
                if([responseObject[@"status"] integerValue]==1){
                    [LYCommanManager sharedManager].positiveIDCardImg=@"身份证正面";//只是用来标识是否已提交图片,无其他作用
                    self.haveverifyLabel.text=@"已认证        ";
                    self.sfcandbankbtn.alpha=0;
                    self.sfcbackbtn.alpha=0;
                    self.sfcfrontbtn.alpha=0;
                    self.bankfrontbtn.alpha=0;
                    [self.tab reloadData];
                     [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"操作成功" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];
                }else {
                    [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"操作失败" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];
                }
            }
            
        }
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
        
    }];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.cellTitleArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LYMyrealnamecell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.delegate=self;
    [cell setcellWithname:self.cellTitleArr[indexPath.row] row:indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *sheader=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 10)];
    
    sheader.backgroundColor=[UIColor clearColor];
    
    return  sheader;

}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}

//代理
-(void)LYMyrealnamecell:(LYMyrealnamecell*)LYMyrealnamecell textf:(NSString *)textf row:(NSInteger)row{
    if(row==0){
       
        self.mobile= textf;
    }else if (row==1){
    self.realname=textf;
       
    }else if(row==2){
       self.idcard=textf;
    }
    NSLog(@"代理执行0000");
 }

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}
//请求一下接口更新数据
-(void)initDatas{
    
    NSString  *url=[TESTBASEURL stringByAppendingString:@"api/user/userInfo"];
    
    NSDictionary *params=@{};
    [LYWofubaoHttpRequest getUserinforequestWithUrl:url params:params  successBlock:^(NSURLSessionDataTask *task, id responseObject) {
        if(responseObject){
            LYMyUserinfoModal *infoomodal=responseObject;
        
            NSString *leveimgaeurl=infoomodal.head_pic;
            NSLog(@"level--img---%@",leveimgaeurl);
            self.headeric=leveimgaeurl;
           
            if(leveimgaeurl && ![leveimgaeurl isEqualToString:@""] &&![leveimgaeurl isEqualToString:@"null"]){
//            NSString *urlstr=[TESTBASEURL stringByAppendingString:self.headeric];
          NSString *urlstr=self.headeric;
            NSLog(@"从网络获取头像--quanlujing -%@",urlstr);
            
            [self.headimageV  sd_setImageWithURL:[NSURL URLWithString:urlstr] placeholderImage:[UIImage imageNamed:@"icon_avatar"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                
            }];
            }
            }
        [self.tab reloadData];
        
    } failureBlock:^(NSURLSessionDataTask *task, NSError *error) {
         [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"网络连接失败" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];
    }];
    
}
- (void)reachabilityChanged:(NSNotification *)noti {
    Reachability * reach = [noti object];
    if([reach isReachable]) {
        [self initDatasss];
    } else {
        
        
    }
}



@end

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值