//
//  SPBackgroundCell.m
//  Open
//
//  Created by 看看智能 on 2017/11/29.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "SPBackgroundCell.h"

@implementation SPBackgroundCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


-(void)setSPmodel:(SearchProgressResult *)SPmodel
{
    _SPmodel =SPmodel;
    self.nameL.text =[EnercryTool desA:SPmodel.name];
    NSString *numberString = [[EnercryTool desA:SPmodel.identityNumber]stringByReplacingCharactersInRange:NSMakeRange(10, 4) withString:@"****"];
    self.identityL.text = numberString;
    
    
searchViewModel *searchModel =     [[searchViewModel  alloc]init];
    
    WeakSelf
    [searchModel getDataFromName:[EnercryTool desA:SPmodel.name] andID:[EnercryTool desA:SPmodel.identityNumber] NetCompleteHandle:^(NSError *error) {
        [weakSelf initALlCEll];
        
        switch (searchModel.codeZ){
                case 1015://未采集
                [self weicaiji_weicaiji];
                break;
                case 28://采集审核中
                [self weicaiji_caijizhong];
               break;
                            case 29://采集审核失败
                [self weicaiji_caijishibai];
                                break;
                            case 32://采集成功但未认证
                [self weicaiji_weiyanzheng];
                                break;
                            case 34://认证审核中
                [self weicaiji_renzhengshenghezhong];
                                break;
                            case 35://认证失败
   [self weicaiji_renzhengshibai:35];
                                break;
                         case 33://认证成功
   [self weicaiji_renzhengshibai:33];
                               break;
                           case 30://此身份证已停止发放社保金
   [self weicaiji_renzhengshibai:30];
                             break;
                       default:
                 [self initALlCEll];
                          break;
                
        }
//
////                [self viewChange:1 and:0];
//
//                //第一种
//                break;
        
        
        weakSelf.lb_startdate.text =  [NSString blankString:searchModel.model.reviewTime] ? @"" :searchModel.model.reviewTime;
        weakSelf.lb_endDate.text = [NSString blankString:searchModel.model.recordTime] ? @"" :searchModel.model.recordTime;

    }];
    
   
   
}

-(void)weicaiji_weicaiji
{
    //未采集
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >6 && self.progressCircle.count ==0){
        return;
    }
     //圆形

    UIImageView *imageCircle =  (UIImageView*)self.progressCircle[0];
    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
    //字体
    UILabel *textLabel =  (UILabel*)self.pregressLabel[0];
    textLabel.text =@"未采集";
    textLabel.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
}
-(void)weicaiji_caijizhong
{
  //  采集审核中
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >6 && self.progressCircle.count ==0){
        return;
    }

    for (int i = 1 ;  i < 3; i ++) {
        //线条
   
        if (i == 2) {
     
             UIImageView *imageCircle =  (UIImageView*)self.progressCircle[1];    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
        }else if (i <2){
            UIImageView *imageLine =  (UIImageView*)self.progressLine[0];    imageLine.image = [UIImage imageNamed:@"进度实线"];
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[0];    imageCircle.image = [UIImage imageNamed:@"进度白圈"];
                UILabel *textLabel =  (UILabel*)self.pregressLabel[i-1];  textLabel.textColor =[UIColor whiteColor];
        }
    }
        UILabel *textLabel =  (UILabel*)self.pregressLabel[1];    textLabel.text =@"采集审核中";    textLabel.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
}
-(void)weicaiji_caijishibai
{
    //采集审核失败
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >6 && self.progressCircle.count ==0){
        return;
    }
    
    for (int i = 1 ;  i < 4; i ++) {
        //线条
                   //type ==2 的时候就采集失败 type /= 2 采集成功
            if (i == 3) {
                UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
            }else if (i <3){
                UIImageView *imageLine =  (UIImageView*)self.progressLine[i-1];    imageLine.image = [UIImage imageNamed:@"进度实线"];
                UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度白圈"];
              UILabel *textLabel =  (UILabel*)self.pregressLabel[i-1];  textLabel.textColor =[UIColor whiteColor];
                
            }
    }
    UILabel *textLabel =  (UILabel*)self.pregressLabel[2];    textLabel.text =@"采集审核失败";    textLabel.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
}
-(void)weicaiji_weiyanzheng
{
    //采集成功但未认证
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >6 && self.progressCircle.count ==0){
        return;
    }
    
    for (int i = 1 ;  i < 5; i ++) {
        //线条
        //type ==2 的时候就采集失败 type /= 2 采集成功
        if (i == 4) {
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
        }else if (i <4){
            UIImageView *imageLine =  (UIImageView*)self.progressLine[i-1];    imageLine.image = [UIImage imageNamed:@"进度实线"];
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度白圈"];
        UILabel *textLabel =  (UILabel*)self.pregressLabel[i-1];  textLabel.textColor =[UIColor whiteColor];
        }
        
        
        
    }
    UILabel *textLabel =  (UILabel*)self.pregressLabel[2];    textLabel.text =@"采集成功";    textLabel.textColor =[UIColor whiteColor];
      UILabel *textLabel_ =  (UILabel*)self.pregressLabel[3];    textLabel_.text =@"待认证";    textLabel_.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
}
-(void)weicaiji_renzhengshenghezhong
{
    //认证审核中
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >6 && self.progressCircle.count ==0){
        return;
    }
    
    for (int i = 1 ;  i < 6; i ++) {
        //线条
        //type ==2 的时候就采集失败 type /= 2 采集成功
        if (i == 5) {
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
        }else if (i <5){
            UIImageView *imageLine =  (UIImageView*)self.progressLine[i-1];    imageLine.image = [UIImage imageNamed:@"进度实线"];
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度白圈"];
            UILabel *textLabel =  (UILabel*)self.pregressLabel[i-1];  textLabel.textColor =[UIColor whiteColor];
        }
        
        
        
    }
    UILabel *textLabel =  (UILabel*)self.pregressLabel[2];    textLabel.text =@"采集成功";    textLabel.textColor =[UIColor whiteColor];
    UILabel *textLabel_ =  (UILabel*)self.pregressLabel[4];    textLabel_.text =@"认证审核中";    textLabel_.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
 
}
-(void)weicaiji_renzhengshibai:(NSInteger)type
{
    //认证失败/认证成功
//此身份证已停止发放社保金
    if(self.progressCircle.count >7 && self.progressCircle.count ==0 && self.progressLine.count >7 && self.progressCircle.count ==0){
        return;
    }
    
    for (int i = 1 ;  i < 7; i ++) {
        //线条
        //type ==2 的时候就采集失败 type /= 2 采集成功
        if (i == 6) {
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度异常圈"];
        }else if (i <6){
            UIImageView *imageLine =  (UIImageView*)self.progressLine[i-1];    imageLine.image = [UIImage imageNamed:@"进度实线"];
            UIImageView *imageCircle =  (UIImageView*)self.progressCircle[i-1];    imageCircle.image = [UIImage imageNamed:@"进度白圈"];
            UILabel *textLabel =  (UILabel*)self.pregressLabel[i-1];  textLabel.textColor =[UIColor whiteColor];
        }
        
        
        
    }
    UILabel *textLabel =  (UILabel*)self.pregressLabel[2];    textLabel.text =@"采集成功";    textLabel.textColor =[UIColor whiteColor];
    UILabel *textLabel_ =  (UILabel*)self.pregressLabel[5];
    switch (type ) {
        case 33:
      textLabel_.text =@"认证成功";
            break;
            case 35:
                   textLabel_.text =@"认证失败";
            break;
        case 30:
           textLabel_.text =@"此身份证已停止发放社保金";
            break;
        default:
            textLabel_.text =@"认证失败";
            break;
    }
    textLabel_.textColor =[UIColor colorWithRed:255/255.0 green:180/255.0 blue:0/255.0 alpha:1.0];
}





//-(void)viewChange:(NSInteger)ing and:(NSInteger)type{
//
//
//
//
//
//
//    for (int i =0 ; i < self.progressCircle.count; i ++) {
//        if (i < ing) {
//
//
//        }
//
//
//        for (UIImageView * images  in  self.progressLine) {
//
//            if (i == ing) {
//                <#statements#>
//            }
//
//
//
//
//        }
//        for (UIImageView * images  in  self.progressCircle) {
//            UIImage * imagea  =[UIImage imageNamed:@"进度无操作"];
//            images.image = imagea;
//        }
//        for (UILabel * textLabel  in  self.pregressLabel) {
//            textLabel.textColor =[UIColor colorWithRed:110/255.0 green:110/255.0 blue:110/255.0 alpha:0.5];
//        }
//
//
//
//
//
//
//
//
//
//    }
//
//
//
// }
-(void)initALlCEll{
    for (UIImageView * images  in  self.progressLine) {
        UIImage * imagea  =[UIImage imageNamed:@"进度虚线"];
        images.image = imagea;
    }
    for (UIImageView * images  in  self.progressCircle) {
        UIImage * imagea  =[UIImage imageNamed:@"进度无操作-暗圈"];
        images.image = imagea;
    }
    for (UILabel * textLabel  in  self.pregressLabel) {
        textLabel.textColor =[UIColor colorWithWhite:1 alpha:0.5];
    }
    
    
    
}


@end
