//
//  AuthB32ViewController.m
//  Open
//
//  Created by weface on 2023/9/1.
//  Copyright © 2023 QXY. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AuthB32ViewController.h"
#import "Constants.h"
#import "UIScrollView+UITouch.h"
#import "UIImage+Custom.h"

#import "GreenChannelImageView.h"

#import "AlertView.h"
#import <ZJAnimationPopView.h>


#import "successViewController.h"
#import "AuthenticationGuideView.h"
#import "CaijiShareAlertView.h"

#import "WXApi.h"
#import "KKUserIdentifyViewController.h"
#import "KKSocialAuthSuccessController.h"
#import "AuthB1ViewController.h"
#import "AuthB40ViewController.h"
#import "AuthenticationFailedController.h"
@interface AuthB32ViewController ()<UIImagePickerControllerDelegate,UINavigationControllerDelegate>
{
    NSInteger _selectIndex;
    
    UIImage *_lastImage;
}
@property (nonatomic, strong)UIScrollView *scrollView;
@property (nonatomic, strong)NSMutableArray *imagesArray;

@property (nonatomic, strong)UIButton *commitBtn;

//scrollview
@property (nonatomic, strong)UIView *topView;
@property (nonatomic, strong)GreenChannelImageView *cardView;

@property (nonatomic, strong)UILabel *lb_title;

@property (nonatomic, strong)UILabel *lb_remind;

@property (nonatomic, strong)UILabel *lb_five;

@property (nonatomic, strong)UIButton *btn_CustomerService;

@property (nonatomic, strong)UIImagePickerController *imagePicker;

@property (nonatomic, strong)AlertView *alertView;

@end

@implementation AuthB32ViewController

#pragma mark - life cycle
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [GTCountSDK trackCountEvent:@"home_SBAuth_greenChannelPage" withArgs:@{}];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.scrollView];
    [self.view addSubview:self.commitBtn];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.imagesArray addObject:self.lastVCImage];
    [self.cardView.btn_left setBackgroundImage:self.lastVCImage forState:UIControlStateNormal];
    _lastImage = self.lastVCImage;
    
    //起点发生变化
    self.edgesForExtendedLayout=UIRectEdgeBottom;
    
    [self configBackBtn];
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.offset(45 * WIDTHRADIU);
    }];
}


#pragma mark - 导航栏返回按钮及点击事件
- (void)configBackBtn
{
    UIButton *backbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backbtn.frame = CGRectMake(-50, 0, 40, 40);
    [backbtn setTitle:@"返回" forState:UIControlStateNormal];
    [backbtn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [backbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [backbtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [backbtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:6];
    
    
    
    if (self.state == GreenRenZheng) {
        UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithCustomView:backbtn];
        
        self.navigationItem.leftBarButtonItem = backItem;
    }
}

- (void)backBtnClick:(UIButton *)btn
{
   // BOOL show = [[NSUserDefaults standardUserDefaults]boolForKey:@"SocialSecurityAuthenticationggreenVC"];
    
    //if (!show) {
        [AuthenticationGuideView showGuideViewWithimgHidden:YES Block:^(BOOL isBack) {
           // [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"SocialSecurityAuthenticationggreenVC"];
            //[[NSUserDefaults standardUserDefaults]synchronize];
            if (isBack) {
                
                
                [self.navigationController popViewControllerAnimated:YES];
            }
        }];
   // }else {
     //   [self.navigationController popViewControllerAnimated:YES];
    //}
    
    
    
}


#pragma mark - event response
- (void)btnClick:(UIButton *)sender
{
    NSLog(@"%ld",sender.tag);
    if (sender == self.commitBtn) {
        if (self.state == GreenRenZheng) {
            [self uploadData];
        }else if(self.state == GreenCaiJi){

            [self uploadData2];
        }
        
    }else {
        if (self.imagesArray.count == 0 && sender == self.cardView.btn_right) {
            [SVProgressHUD showInfoWithStatus:@"请先拍摄第一张照片"];
            return;
        }
        _selectIndex = sender.tag;

        [self getPhoto];
    }
  
   
}

- (void)kehuchatClick:(UIButton *)sender
{
    
    //https://nginx.weface.com.cn/appH5/appoutlink/#/customer
    //tc.title = @"人工客服";
    [[clickEvent instance] clickEventRooterVC:self Content:@"weChatService" menuName:@"weChatService"];
}
#pragma mark 处理自定义视图操作事件
- (void)handleCustomActionEnvent:(ZJAnimationPopView *)popView
{
    
}
#pragma mark - 绿色通道上传图片
- (void)uploadImageData {
    if (self.imagesArray.count < 2) {
        [SVProgressHUD showErrorWithStatus:@"要传2张自拍照片"];
        return;
    }
    NSString *path =@"";
    path =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/greenChannelVerify"];
    NSUserDefaults* userDefault=[NSUserDefaults standardUserDefaults];
    //雷俊博备注:这三个参数,是上个界面传过来,上个开发者将其存到本地;
     NSString *names =[userDefault objectForKey:@"name"];
    NSString *ID =[userDefault objectForKey:@"bak"];
    NSString *identifity =[userDefault objectForKey:@"identityNumber"];
    UIImage *lastImage = [UIImage imageWithCGImage:_lastImage.CGImage scale:1.0 orientation:UIImageOrientationUp];
    lastImage =  [UIImage imageByScalingAndCroppingForSize:CGSizeMake(360, 270) and:lastImage];
    NSData  *dateImage1 =UIImageJPEGRepresentation( lastImage,0.86);
    NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < self.imagesArray.count; i++) {
        NSString * str = [self changeBase64:self.imagesArray[i]];
        [array addObject:str];
     }
    
    NSString *idPara = [Tools isBlankString:ID] ? @"" : ID;
    NSString *namePara = [Tools isBlankString:names] ? @"" : [EnercryTool A:names];
    NSString *identityPara = [Tools isBlankString:identifity] ? @"" : [EnercryTool A:identifity];
    NSString *imagePara = [EnercryTool encryptBase64:dateImage1];
    
    NSString *strPara = [NSString stringWithFormat:@"identityNumber=%@&name=%@&KkweInfo",identityPara,namePara];
    NSLog(@"%@",strPara);
    strPara =  [MyMD5 md5:strPara];
    
    NSString *senderPicPara = nil;
    
    if (array.count <1) {
        senderPicPara = @"";
    }else{
        senderPicPara = [array componentsJoinedByString:@","];
    }
    
    
    NSDictionary *params = @{
        @"flag":@2,
        @"id":idPara,
        @"name":namePara,
        @"identityNumber":identityPara,
        @"image":imagePara,
        @"sign":strPara,
        @"versionflag":@1,
//                             @"phoneNumber":telPhone,
        @"photoLstr":senderPicPara//1周 照片一逗号的形式隔开
    };
    [KKLoadingAnimationView show];
    [NetworkRequest SBAuthPost:path Params:params Success:^(id _Nonnull objc) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"objc:%@",objc);
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
    }];
    
}

//认证
- (void)uploadData
{
    if (self.imagesArray.count < 2) {
        [SVProgressHUD showErrorWithStatus:@"要传2张自拍照片"];
        return;
    }
    Boolean type=[getPeopleID getpeopleLimited];
    int accountType;
    if(type){
        accountType=0;
    }else{
        accountType=1;
    }
    NSString *path =@"https://h5.weface.com.cn/renshe/multichannel/auth/compare";
    //姓名AES加密
    NSString *aesName =  [EnercryTool AES256Encrypt:self.auth_name key:MZAESKEY];
    //身份证号AES加密
    NSString *aesId = [EnercryTool AES256Encrypt:self.auth_id key:MZAESKEY];
    //处理图片
    NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
    for (int i = 0; i < self.imagesArray.count; i++) {
        NSString * str = [self changeBase64:self.imagesArray[i]];
        [array addObject:str];
     }
    NSDictionary *params = @{
        @"fromModel":@"4",
        @"fromApp":@"kksh",
        @"accountType":[NSNumber numberWithInteger:accountType],
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"name":aesName,
                             @"idCard":aesId,
                             @"telPhone":[EnercryTool AES256Encrypt:[getPeopleID PeopleIphoneNmber] key:MZAESKEY],
        @"nowAddress":self.auth_nowAddress,
        @"addressRelation":self.auth_addressRelation,
        @"verifyInterfaceType":self.auth_result[@"verifyInterfaceType"],
        @"idCardFrontImage":self.auth_card,
        @"idCardFaceImage":self.auth_head,
        @"images":array
                             };
    [KKLoadingAnimationView show];
    [NetworkRequest PostNo:path Params:params Success:^(id _Nonnull obj) {
        [KKLoadingAnimationView dismiss];
        NSString *state=obj[@"state"];
        if([state isEqualToString:@"200100"]||[state isEqualToString:@"200005"]){//认证成功和当日已经认证成功
            AuthB40ViewController *blueVC = [AuthB40ViewController new];
            blueVC.imageView1 = self.imagesArray[0];
            blueVC.name = self.auth_name;
            blueVC.idNumber = self.auth_id;
            blueVC.auth_type=self.auth_result[@"verifyType"];
            [self.navigationController pushViewController:blueVC animated:YES];
        }else if([state isEqualToString:@"200300"]){//认证审核中
            UIAlertController *alertCon =[UIAlertController alertControllerWithTitle:@"信息正在审核中,请耐心等待!" message:nil preferredStyle:UIAlertControllerStyleAlert];
            [alertCon addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                NSLog(@"%@",@"确定了!!!!!");
                for (UIViewController*vc in self.navigationController.viewControllers) {
                    if ([vc isKindOfClass:[AuthB1ViewController class]]) {
                        AuthB1ViewController*currentVC  = (AuthB1ViewController *)vc;
                        [currentVC clearText];
                        [self.navigationController popToViewController:currentVC animated:YES];
                        break;
                    }
                }
             self.navigationController.navigationBar.translucent = YES;
                    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:27/255.0 green:132/255.0 blue:208/255.0 alpha:1.0]];
                if ([UIScreen mainScreen].bounds.size.height == 480) {
                    [self.navigationController setNavigationBarHidden:NO animated:YES];
                }
            }]];
            [self presentViewController:alertCon animated:YES completion:nil];
            return;
        }else if([state isEqualToString:@"200001"]){//照片不合格
            [SVProgressHUD showErrorWithStatus:@"照片不合格,请重新拍摄!"];
        }else if([state isEqualToString:@"200200"]){//人脸比对失败可去审核
            //todo
            NSString *verifyInterfaceType=self.auth_result[@"verifyInterfaceType"];
            if([verifyInterfaceType isEqualToString:@"2"]){//社保的
                // 1.初始化
                ZJAnimationPopView *popView = [[ZJAnimationPopView alloc] initWithCustomView:self.alertView popStyle:ZJAnimationPopStyleScale dismissStyle:ZJAnimationDismissStyleScale];
                [self handleCustomActionEnvent:popView];
                __weak typeof(popView) weakPopView = popView;
                __weak typeof(self) weakSelf = self;
                self.alertView.canceSureActionBlock = ^(NSInteger tag) {
                    
                    [weakPopView dismiss];
                    
                    if (tag == 201) {
                        [weakSelf.cardView.btn_left setBackgroundImage:nil forState:UIControlStateNormal];
                        [weakSelf.cardView.btn_right setBackgroundImage:nil forState:UIControlStateNormal];
                        [weakSelf.imagesArray removeAllObjects];
                       self -> _lastImage = nil;
                        
                        [weakSelf btnClick:weakSelf.cardView.btn_left];
                    }else if (tag == 200){
                        NSLog(@"进入人工审核界面");
                        UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                        artificalViewController *artVC=[sb instantiateViewControllerWithIdentifier:@"artificalViewController"];
                        //留着
                        // artVC.failurePic = nil;
                        UIImage *image =weakSelf.imagesArray[0];
                       artVC.failurePic = image;
                        artVC.auth_id=self.auth_id;
                        NSDictionary *result=obj[@"result"];
                        artVC.sqId=result[@"recordId"];
                        [weakSelf.navigationController pushViewController:artVC animated:YES];
                    }
                    
                };
                // 2.显示弹框
                [popView pop];
            }else{
                AuthenticationFailedController *vc = [Storyboard instantiateViewControllerWithIdentifier:@"AuthenticationFailedController"];
                                       vc.title = @"认证失败";
                vc.type=@"";
                [self.navigationController pushViewController:vc animated:YES];
            }
            
        }else{
            NSString* describe = [NSString stringWithFormat:@"%@",obj[@"describe"]];
            [SVProgressHUD showErrorWithStatus:describe];
        }
    } Failure:^(NSError* error) {
        NSLog(@"error:%@",error);
        [KKLoadingAnimationView dismiss];
        [SVProgressHUD showErrorWithStatus:@"服务器异常!"];
    }];
    
}
//采集
- (void)uploadData2{

}

- (void)getPhoto
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请选择获取图片操作" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    // 使用前置还是后置摄像头
    
//    UIAlertAction *photos = [UIAlertAction actionWithTitle:@"从相册中" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        self.imagePicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
//        [self presentViewController:self.imagePicker animated:YES completion:nil];
//
//    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    UIAlertAction *makePhotos = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        self.imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera;
        self.imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
        [self presentViewController: self.imagePicker animated:YES completion:nil];
     
    }];
    //[alert addAction:photos];
    [alert addAction:makePhotos];
    [alert addAction:cancel];
    
    [self presentViewController:alert animated:YES completion:^{
        
    }];
}



#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController: (UIImagePickerController *)picker
didFinishPickingMediaWithInfo: (NSDictionary *)info
{
    
    dispatch_async(dispatch_get_main_queue(), ^{
        UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
          if (self.imagesArray.count == 2) {
              if (self->_selectIndex == 200) {
                  self->_lastImage = image;
                  [self.imagesArray replaceObjectAtIndex:0 withObject:image];
              }else if (self->_selectIndex == 201){
                  [self.imagesArray replaceObjectAtIndex:1 withObject:image];
              }
          }else if (self.imagesArray.count == 1){
              if (self->_selectIndex == 200) {
                  self->_lastImage = image;
                  [self.imagesArray replaceObjectAtIndex:0 withObject:image];
              }else if (self->_selectIndex == 201){
                  [self.imagesArray addObject:image];
              }
          }else if (self.imagesArray.count == 0){
              if (self->_selectIndex == 200) {
                  self->_lastImage = image;
                  [self.imagesArray addObject:image];
              }
          }
          
          
        if (self->_selectIndex == 200) {
              [self.cardView.btn_left setBackgroundImage:image forState:UIControlStateNormal];
          }else{
              [self.cardView.btn_right setBackgroundImage:image forState:UIControlStateNormal];
          }
          [self dismissViewControllerAnimated:YES completion:nil];
    });
  
}

// 用户选择取消
- (void) imagePickerControllerDidCancel: (UIImagePickerController *)picker
{
   [self dismissViewControllerAnimated:YES completion:nil];
   
}


#pragma mark - 分享
//网页分享
- (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType
{
    if (![WXApi isWXAppInstalled]) {
        [Tools showMessage:@"请先安装微信!!!"];
        return;
    }
    
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    //创建网页内容对象
    NSString* thumbURL =  UMS_THUMB_IMAGE;
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:UMS_Title descr:UMS_Text thumImage:thumbURL];
    //设置网页地址
    shareObject.webpageUrl = UMS_WebLink;
    
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
                
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
        [self alertWithError:error];
    }];
}


- (void)alertWithError:(NSError *)error
{
    NSString *result = nil;
    if (!error) {
        result = [NSString stringWithFormat:@"分享成功"];
    }
    else{
        NSMutableString *str = [NSMutableString string];
        if (error.userInfo) {
            for (NSString *key in error.userInfo) {
                [str appendFormat:@"%@ = %@\n", key, error.userInfo[key]];
            }
        }
        if (error) {
            result = [NSString stringWithFormat:@"Share fail with error code: %d\n%@",(int)error.code, str];
            result = [NSString stringWithFormat:@"分享失败"];
        }
        else{
            result = [NSString stringWithFormat:@"Share fail"];
        }
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
                                                    message:result
                                                   delegate:nil
                                          cancelButtonTitle:NSLocalizedString(@"确定", @"确定")
                                          otherButtonTitles:nil];
    [alert show];
}


#pragma mark - private methods
-(NSString *)changeBase64:(UIImage*)image
{
    CGSize imagesize = image.size;
    NSLog(@"%lf",image.size.height);
    NSLog(@"%lf",image.size.width);
    imagesize.height =50;
    imagesize.width =50;
    //对图片大小进行压缩--
    
    //    UIImage *image1=   [SecondSocialViewController imageCompressFitSizeScale:image targetSize:CGSizeMake(image.size.width/4, image.size.height/4)];
    
    UIImage *image1=    [UIImage imageByScalingAndCroppingForSize:CGSizeMake(483, 644) and:image];
    //照片是对的完全没有问题,如果想加快速度必须让戴海峰配合的去弄,否则毫无办法,因为把他放在网上转base64是可以转出来的,如果想提速只要调用上面的这个方法即可.否则毫无办法,上面两个方法都是可以的
    //这里的0.3决定了照片认证的精确值
    //mage1 =   [SecondSocialViewController image:image1 rotation:UIImageOrientationLeft];
    NSData *str2=UIImageJPEGRepresentation(image1, 0.4);
    
   
    NSString *str3=[EnercryTool encryptBase64:str2];

   
    return str3;
    
}




#pragma mark - getters and setters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - cl_kNavigationBarHeight - 45 * WIDTHRADIU)];
        _scrollView.backgroundColor = [UIColor whiteColor];
        _scrollView.contentSize = CGSizeMake(ScreenWidth, ScreenHeight - cl_kNavigationBarHeight - 45 * WIDTHRADIU);
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        [_scrollView addSubview:self.topView];
        [_scrollView addSubview:self.cardView];
        [_scrollView addSubview:self.lb_title];
        [_scrollView addSubview:self.lb_remind];
        [_scrollView addSubview:self.lb_five];
        [_scrollView addSubview:self.btn_CustomerService];
        [self setupUI];
    }
    return _scrollView;
}

- (void)setupUI
{
    [self.lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.cardView.mas_bottom).offset(35 * WIDTHRADIU);
        make.left.offset(20 * WIDTHRADIU);
        make.height.offset(16 * WIDTHRADIU);
    }];
    [self.lb_remind mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lb_title.mas_bottom).offset(18 * WIDTHRADIU);
        make.left.equalTo(self.lb_title);
        make.right.equalTo( self.cardView);
    }];
    [self.lb_five mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lb_remind.mas_bottom).offset(10 * WIDTHRADIU);
        make.left.equalTo(self.lb_remind);
        make.height.offset(14 * WIDTHRADIU);
    }];
    [self.btn_CustomerService mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.lb_five);
        make.left.equalTo(self.lb_five.mas_right).offset(10);
    }];
}
- (UIView *)topView
{
    if (!_topView) {
        _topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.scrollView.frame.size.width, 125 * WIDTHRADIU)];
        _topView.backgroundColor = K_MainColor;
    }
    return _topView;
}

- (UIButton *)commitBtn
{
    if (!_commitBtn) {
        _commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _commitBtn.backgroundColor = [UIColor colorWithHex:0x11a480];
        [_commitBtn setTitle:@"确认提交" forState:UIControlStateNormal];
        _commitBtn.titleLabel.font = [UIFont systemFontOfSize:15 * WIDTHRADIU];
        [_commitBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _commitBtn;
}

- (GreenChannelImageView *)cardView
{
    if (!_cardView) {
        _cardView = [[GreenChannelImageView alloc]initWithFrame:CGRectMake(10 * WIDTHRADIU, 20 * WIDTHRADIU, ScreenWidth - 20 * WIDTHRADIU, 237 * WIDTHRADIU)];
        _cardView.backgroundColor = [UIColor whiteColor];
        _cardView.layer.cornerRadius = 10 * WIDTHRADIU;
        _cardView.layer.shadowColor = RGBCOLOR(23, 123, 205).CGColor;
        _cardView.layer.shadowOffset = CGSizeMake(0, 0);
        _cardView.layer.shadowOpacity = 0.25;
        _cardView.layer.shadowRadius = 2.0;
        [_cardView.btn_left addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_cardView.btn_right addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cardView;
}

- (UILabel *)lb_title
{
    if (!_lb_title) {
        _lb_title = [[UILabel alloc]init];
        _lb_title.text = @"绿色通道:";
        _lb_title.font = [UIFont systemFontOfSize:16 * WIDTHRADIU];
        _lb_title.textColor = [UIColor colorWithHex:0x808080];
        _lb_title.numberOfLines = 0;
    }
    return _lb_title;
}

- (UILabel *)lb_remind
{
    if (!_lb_remind) {
        _lb_remind = [[UILabel alloc]init];
        NSString *text1 = @"1、生病人群（如：卧床不起、重大疾病）等其他特殊人群;\n";
        NSString *text2 = @"2、80岁以上老人、退伍军人;\n";
        NSString *text3 = @"3、正视摄像头，注意光线和角度，确保人脸清晰度;\n";
        NSString *text4 = @"4、拍摄两张正面照片;";
        
        NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:10 * WIDTHRADIU];
        
        NSMutableAttributedString *attributedString1 = [[NSMutableAttributedString alloc] initWithString:text1 attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
        NSMutableAttributedString *attributedString2 = [[NSMutableAttributedString alloc] initWithString:text2 attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
        NSMutableAttributedString *attributedString3 = [[NSMutableAttributedString alloc] initWithString:text3 attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
         NSMutableAttributedString *attributedString4 = [[NSMutableAttributedString alloc] initWithString:text4 attributes:@{NSParagraphStyleAttributeName: paragraphStyle}];
        [attributedString1 appendAttributedString:attributedString2];
        [attributedString1 appendAttributedString:attributedString3];
        [attributedString1 appendAttributedString:attributedString4];
        
        NSRange range = [[[[text1 stringByAppendingString:text2] stringByAppendingString:text3] stringByAppendingString:text4] rangeOfString:[[[text1 stringByAppendingString:text2] stringByAppendingString:text3] stringByAppendingString:text4]];
        [attributedString1 addAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x999999],
                                           NSFontAttributeName:[UIFont systemFontOfSize:14 * WIDTHRADIU]} range:range];
        _lb_remind.attributedText = attributedString1;
        _lb_remind.numberOfLines = 0;
    }
    return _lb_remind;
}
- (UILabel *)lb_five
{
    if (!_lb_five) {
        _lb_five = [[UILabel alloc]init];
        _lb_five.text = @"5、有疑问请联系人工客服。";
        _lb_five.font = [UIFont systemFontOfSize:14 * WIDTHRADIU
                         ];
        _lb_five.textColor = [UIColor colorWithHex:0x999999];
    }
    return _lb_five;
}

- (UIButton *)btn_CustomerService
{
    if (!_btn_CustomerService) {
        _btn_CustomerService = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btn_CustomerService setImage:[UIImage imageNamed:@"Greenchannel_customerserviceicon_normal"] forState:UIControlStateNormal];
        [_btn_CustomerService setTitle:@"转人工咨询" forState:UIControlStateNormal];
        _btn_CustomerService.titleLabel.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
        [_btn_CustomerService setTitleColor:K_MainColor forState:UIControlStateNormal];
        [_btn_CustomerService layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:4 * WIDTHRADIU];
        [_btn_CustomerService addTarget:self action:@selector(kehuchatClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn_CustomerService;
}

- (UIImagePickerController *)imagePicker
{
    if (!_imagePicker) {
        _imagePicker = [[UIImagePickerController alloc]init];
        _imagePicker.delegate = self;
        _imagePicker.allowsEditing = YES;
        
        
    }
    
    return _imagePicker;
}

- (NSMutableArray *)imagesArray
{
    if (!_imagesArray) {
        _imagesArray = [[NSMutableArray alloc]initWithCapacity:2];
        
    }
    return _imagesArray;
}

- (AlertView *)alertView
{
    if (!_alertView) {
        _alertView = [[AlertView alloc]initWithFrame:CGRectMake(0, 0, 230 * WIDTHRADIU, 161 * WIDTHRADIU)];
    }
    return _alertView;
}

@end
