//
//  FindTableTopCell.m
//  Open
//
//  Created by 雷俊博 on 2020/6/1.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "FindTableTopCell.h"
#import "UIView+shadowPath.h"
#import "FindTopCell.h"
#import "FindTop2Cell.h"


@interface FindTableTopCell ()<UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UIView *topView;
@property (nonatomic, strong)UIScrollView*scrollView;

@property (nonatomic, strong)UIImageView*personImg;

@property (nonatomic, strong)UIImageView* packageImg;

@property (nonatomic, strong)UIButton* SuspensionBallBtn;

@property (nonatomic, strong)NSTimer* timer;

@property (nonatomic, strong)UIView* whiteView;

@property (nonatomic, strong)UICollectionView*cardCollectionView;



@property (nonatomic, strong)NSArray* titleArray;

@property (nonatomic, strong)NSArray* iconsArray;

@property (nonatomic, strong)NSArray* title2Array;

@property (nonatomic, strong)NSArray* icons2Array;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topBackHeight;

//@property (nonatomic, strong)NSArray *modelArray;
@property (nonatomic, strong)NSArray *model1Array;
@property (nonatomic, strong)NSArray *model2Array;
//@property (nonatomic, assign)BOOL showBackData;

@property (nonatomic, assign)BOOL showData1;
@property (nonatomic, assign)BOOL showData2;
@end

@implementation FindTableTopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.topView.backgroundColor = K_MainColor;
    self.topBackHeight.constant = cl_kStatusBarHeight;
    
    [self.contentView addSubview:self.scrollView];
    
    [self creatGifImg];
       
    [self.contentView addSubview:self.whiteView];
    
    self.timer = [NSTimer scheduledTimerWithTimeInterval:0.04 target:self selector:@selector(runClick) userInfo:nil repeats:YES];
      
    [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}

- (void)creatGifImg
{
    
    [self.contentView addSubview:self.progressView];
    
    UILabel*lb1 = [UILabel new];
    lb1.text = @"1W";
    lb1.textColor = [UIColor whiteColor];
    lb1.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:lb1];
    UILabel*lb2 = [UILabel new];
    lb2.text = @"5K";
    lb2.textColor = [UIColor whiteColor];
    lb2.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:lb2];
    UILabel*lb3 = [UILabel new];
    lb3.text = @"0";
    lb3.textColor = [UIColor whiteColor];
    lb3.font = [UIFont systemFontOfSize:10];
   [self.contentView addSubview:lb3];
    [lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.progressView);
        make.left.equalTo(self.progressView.mas_right).offset(8);
    }];
    [lb2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.progressView);
        make.left.equalTo(self.progressView.mas_right).offset(8);
    }];
    [lb3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.progressView);
        make.left.equalTo(self.progressView.mas_right).offset(8);
    }];
    
    
    UIImageView*img = [[UIImageView alloc]init];
    img.image = [JobUtil changeImageToGit:@"person.gif"];
    [self.contentView addSubview:img];
    
    self.personImg = img;
    
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.scrollView.mas_bottom).offset(-50* WIDTHRADIU);
        make.width.offset(39.5 * WIDTHRADIU * 0.75);
        make.height.offset(57 * WIDTHRADIU * 0.75);
    }];
    
    
    
    UILabel*lb_stepCount = [[UILabel alloc]init];
    [self.contentView addSubview:lb_stepCount];
    NSString* str = @"0步";
    NSMutableAttributedString*attributedStr = [[NSMutableAttributedString alloc]initWithString:str];
    [attributedStr addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:40],NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, str.length - 1)];
    [attributedStr addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(str.length - 1, 1)];
    lb_stepCount.attributedText = attributedStr;
    self.lb_count = lb_stepCount;
    [lb_stepCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.offset(cl_kStatusBarHeight + 20 * WIDTHRADIU);
    }];
    
    [self.contentView addSubview:self.packageImg];
    [self.packageImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(lb_stepCount.mas_bottom).offset(20 * WIDTHRADIU);
        make.left.equalTo(lb_stepCount.mas_right).offset(0 * WIDTHRADIU);
        make.width.height.offset(32 * WIDTHRADIU);
    }];
    
    
    [self.contentView addSubview:self.SuspensionBallBtn];
    
    [self.SuspensionBallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(cl_kStatusBarHeight + 20 * WIDTHRADIU);
        make.left.equalTo(self.packageImg.mas_right).offset(5 * WIDTHRADIU);
        make.width.offset(60 * WIDTHRADIU);
        make.height.offset(50 * WIDTHRADIU);
    }];
    
    [self.contentView addSubview:self.whiteView];
    
    [self.contentView addSubview:self.top2CollectionView];
    
    [self.top2CollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.whiteView.mas_bottom).offset(15 * WIDTHRADIU);
        make.left.offset(15 * WIDTHRADIU);
        make.right.offset(-15 * WIDTHRADIU);
        make.height.offset(70 * WIDTHRADIU);
    }];
    
//    [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(img.mas_bottom).offset(15 * WIDTHRADIU);
//        make.left.offset(20 * WIDTHRADIU);
//        make.right.offset(-20 * WIDTHRADIU);
//        make.height.offset(70 * WIDTHRADIU);
//    }];
    
    //[_whiteView viewShadowPathWithColor:K_MainColor shadowOpacity:0.5 shadowRadius:5 shadowPathType:LeShadowPathBottom shadowPathWidth:10];
}


- (void)runClick
{
    CGFloat x = self.scrollView.contentOffset.x;
    x = x + 1.5;
    
    if ((x - 875* WIDTHRADIU*2 ) >= 0) {
        x =0;
    }
    
    self.scrollView.contentOffset = CGPointMake(x, 0);
}
//刷新数据
- (void)refreshDataWithArray1:(NSArray *)model1Array andArray2:(NSArray *)model2Array;
{
//    if (model1Array.count == 5) {
//        self.modelArray = model1Array;
//        self.showBackData = YES;
//    }
    self.packageImg.hidden = self.btnHidden;
    if (!self.btnHidden) {
        if (model1Array.count > 0) {
            
            self.showData1 = YES;
            self.model1Array = model1Array;
            int index1 = (model1Array.count % 4 == 0) ? (int)(model1Array.count / 4) : (int)(model1Array.count / 4) + 1;
            _whiteView.frame = CGRectMake(20 * WIDTHRADIU,   cl_kStatusBarHeight +155 * WIDTHRADIU, ScreenWidth - 40 * WIDTHRADIU, 75 * WIDTHRADIU * index1);
        }else{
            _iconsArray = @[@"live_coins",@"live_lottery",@"daka_icon.gif",@"live_invite"];
            _titleArray = @[@"我的金币",@"金币抽奖",@"打卡领钱",@"邀请好友"];
        }
        if (model2Array.count > 0) {
            self.showData2 = YES;
            self.model2Array = model2Array;
            int index2 = (model2Array.count % 5 == 0) ? (int)(model2Array.count / 5) : (int)(model2Array.count / 5) + 1;
            [self.top2CollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.offset(70 * WIDTHRADIU * index2);
            }];
        }else{
//            _title2Array = @[@"极速义诊",@"平价药房",@"广场舞",@"天气",@"更多功能"];
//            _icons2Array = @[@"live_freeMedical",@"live_yaofang",@"live_squaredance",@"live_weather",@"live_moreIcons"];
            _title2Array = @[@"极速义诊",@"平价药房",@"广场舞",@"AI照相馆",@"更多功能"];
            _icons2Array = @[@"live_freeMedical",@"live_yaofang",@"live_squaredance",@"live_Photostudio",@"live_moreIcons"];
        }
    }else{
        _iconsArray = @[@"live_coins",@"live_lottery",@"live_prize",@"live_invite"];
        _titleArray = @[@"我的金币",@"金币抽奖",@"我的奖品",@"邀请好友"];
        
        _title2Array = @[@"快递查询",@"火车票",@"万年历",@"天气",@"更多功能"];
        _icons2Array = @[@"live_kuaidi",@"live_train",@"live_calendar",@"live_weather",@"live_moreIcons"];
        
    }
    
    [self.cardCollectionView reloadData];
    
    [self.top2CollectionView reloadData];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    if (collectionView == self.cardCollectionView) {
        if (self.showData1) {
            return self.model1Array.count;
        }
        return self.titleArray.count;
    }
    if (self.btnHidden || self.showData2 == NO) {
        return self.title2Array.count;
    }
    
    return self.model2Array.count;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (collectionView == self.cardCollectionView) {
       
        FindTopCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FindTopCell" forIndexPath:indexPath];
        if (self.showData1) {
            KKRedPackageClickEventModel *model = self.model1Array[indexPath.item];
            cell.lb_title.attributedText = [[NSMutableAttributedString alloc] initWithString:model.menuName attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 16],NSForegroundColorAttributeName: [UIColor colorWithHex:0x4c4c4c]}];
            [cell.img sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",KKFindPackageIP,model.menuIcon]]];
            cell.gifImageView.hidden = YES;
            cell.gifImageView2.hidden = YES;
            if (model.gifIcon.length > 0) {
                cell.gifImageView2.hidden = NO;
                [cell.gifImageView2 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",KKFindPackageIP,model.gifIcon]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
                           
                }];
            }else{
                cell.gifImageView2.hidden = YES;
            }
//            if ([cell.lb_title.text isEqualToString:@"优惠充值"]) {
//                cell.gifImageView2.hidden = NO;
//                cell.gifImageView2.image = [JobUtil changeImageToGit:@"find95.gif"];
//            }
        }else{
            NSString*title = self.titleArray[indexPath.item];
            NSString*imageName = self.iconsArray[indexPath.item];
            cell.lb_title.attributedText = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 16],NSForegroundColorAttributeName: [UIColor colorWithHex:0x4c4c4c]}];
            if ( indexPath.item == 2) {
                if (self.btnHidden) {
                    cell.img.image = [UIImage imageNamed:imageName];
                    cell.gifImageView.hidden = YES;
                    
                }else{
                    cell.img.image = [JobUtil changeImageToGit:imageName];
                    cell.gifImageView.hidden = NO;
                    cell.gifImageView.image = [JobUtil changeImageToGit:@"haveMoney.gif"];
                }
                cell.gifImageView2.hidden = YES;
                
            }else if (indexPath.item == 0){
                if (self.btnHidden) {
                    cell.img.image = [UIImage imageNamed:imageName];
                    cell.gifImageView2.hidden = YES;
                }else{
                    //cell.img.image = [JobUtil changeImageToGit:@"find_freeFruit.gif"];
                    cell.img.image = [UIImage imageNamed:@"live_freeCharge"];
                    cell.gifImageView2.hidden = NO;
                    cell.gifImageView2.image = [JobUtil changeImageToGit:@"find95.gif"];
                    cell.lb_title.text = @"优惠充值";
                }
                cell.gifImageView.hidden = YES;
                
            } else{
                cell.img.image = [UIImage imageNamed:imageName];
                cell.gifImageView.hidden = YES;
                cell.gifImageView2.hidden = YES;
            }
            
            for (UIView *view in cell.contentView.subviews) {
                if ([view isKindOfClass:[NativeAdCustomView class]]) {
                    [view removeFromSuperview];
                }
            }
            
            if (indexPath.section == 0 && indexPath.row == 0) {
                
                if (!self.btnHidden) {
                    if (self.model && self.rootViewController) {
                        [cell setupCellWithModel:self.model delegate:self.dhcDelegate loca:self.dhcLocaDelegate rootViewController:self.rootViewController];
                    }
                }
                
                
               
                
            }
        }
        
        
        
        return cell;
    }
    
    FindTop2Cell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FindTop2Cell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor clearColor];
    
    if (self.btnHidden || self.showData2 == NO) {
        NSString*title = self.title2Array[indexPath.item];
        NSString*imageName = self.icons2Array[indexPath.item];
        cell.lb_title.attributedText = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 15],NSForegroundColorAttributeName: [UIColor colorWithHex:0x404040]}];
        cell.img.image = [UIImage imageNamed:imageName];
    }else{
        KKRedPackageClickEventModel *model = self.model2Array[indexPath.item];
        
        cell.lb_title.attributedText = [[NSMutableAttributedString alloc] initWithString:model.menuName attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFang SC" size: 15],NSForegroundColorAttributeName: [UIColor colorWithHex:0x404040]}];

        if ([Tools isBlankString:model.menuIcon]) {
            cell.img.image = [UIImage imageNamed:[self getBtnImageNameWithmenuTag:model.menuTag]];
        }else{
            [cell.img sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",KKFindPackageIP,model.menuIcon]]];
        }
        cell.GiFimg.hidden = YES;
        if (model.gifIcon.length > 0) {
            cell.GiFimg.hidden = NO;
            [cell.GiFimg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",KKFindPackageIP,model.gifIcon]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
                       
            }];
        }else{
            cell.GiFimg.hidden = YES;
        }
       
    }

    return cell;
}

/**
 cell的大小
 */
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat kHeight = 0.0;
    CGFloat kWidth = 0.0;
    CGFloat width = 0.0;
//    CGFloat realWidth = 0.0;
    
    if (collectionView == self.cardCollectionView) {
//        kWidth = ScreenWidth - 50 * WIDTHRADIU;
//        kHeight = 75 * WIDTHRADIU;
//        width =  kWidth  / self.titleArray.count ;
//        realWidth = kWidth   - floor(width)*(self.titleArray.count - 1);
        kWidth = ScreenWidth - 50 * WIDTHRADIU;
        kHeight = 75 * WIDTHRADIU;
        width =  kWidth  / 4;
    }else{
//        kWidth = ScreenWidth - 30 * WIDTHRADIU;
//        kHeight = 76 * WIDTHRADIU;
//        width = kWidth / self.title2Array.count;
//        realWidth = kWidth   - floor(width)*(self.title2Array.count - 1);
        kWidth = ScreenWidth - 30 * WIDTHRADIU;
        kHeight = 70 * WIDTHRADIU;
        width = kWidth / 5;
    }
  
        // CGFloat itemW = K_ScreenWidth/array.count;
//        if (indexPath.item == 0) {
//            return CGSizeMake(realWidth, kHeight);
//        }

       return CGSizeMake(floor(width), kHeight);
    
   
}

/**
 每个分区的内边距（上左下右）
 */
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    
    return UIEdgeInsetsMake(0, 0, 0, 0);
}
/**
 分区内cell之间的最小行间距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{

    return 0;
}
/**
 分区内cell之间的最小列间距
 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    
    return 0;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    return nil;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
   
        return CGSizeZero;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (collectionView == self.cardCollectionView) {
        FindTableTopCellType type = FindTableTopCellTypeUNKnow;
        if (self.showData1) {
            KKRedPackageClickEventModel *model = self.model1Array[indexPath.item];
            if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithModel:)]) {
                [self.delegate TopCellClickWithModel:model];
            }
        }else{
            if (indexPath.row == 0) {
                if (self.btnHidden) {
                    type = FindTableTopCellTypeCoins;
                }else{
                    type = FindTableTopCellTypeHuaFees;
                }
            }else if (indexPath.row == 1){
                type = FindTableTopCellTypeDraw;
            }else if (indexPath.row == 2){
                if (self.btnHidden) {
                    type = FindTableTopCellTypePrize;
                }else{
                    type = FindTableTopCellTypeCoinCenter;
                }
            }else if (indexPath.row == 3){
                type = FindTableTopCellTypeInvite;
            }
            if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithType:)]) {
                [self.delegate TopCellClickWithType:type];
            }
        }
    }else if (collectionView == self.top2CollectionView){
        FindTableTopCellType type = FindTableTopCellTypeUNKnow;
        if (self.showData2) {
            KKRedPackageClickEventModel *model = self.model2Array[indexPath.item];
            if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithModel:)]) {
                [self.delegate TopCellClickWithModel:model];
            }
        }else{
            if (indexPath.row == 0) {
                if (self.btnHidden) {
                    type = FindTableTopCellTypeExpress;
                }else{
                    type = FindTableTopCellTypeFreeMedical;
                }
                
            }else if (indexPath.row == 1){
                if (self.btnHidden) {
                    type = FindTableTopCellTypeTrain;
                }else{
                    type = FindTableTopCellTypeInterrogation;
                }
                
            }else if (indexPath.row == 2){
                if (self.btnHidden) {
                    type = FindTableTopCellTypeCalendar;
                }else{
                    type = FindTableTopCellTypeYaoFang;
                    
                }
            }else if (indexPath.row == 3){
                if (self.btnHidden) {
                    type = FindTableTopCellTypeWeather;
                }else{
                    type = FindTableTopCellTypePhotostudio;
                    
                }
            }else if (indexPath.row == 4){
                type = FindTableTopCellTypeMore;
            }
            if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithType:)]) {
                [self.delegate TopCellClickWithType:type];
            }
        }
    }
    
}

-(void) collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
//设置选中时的颜色
    UICollectionViewCell *cell = (UICollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
    
    
    [cell setBackgroundColor:[UIColor colorWithHex:0xe5e5e5]];
}
 
- (void)collectionView:(UICollectionView *)colView  didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath
{
//恢复颜色
    UICollectionViewCell *cell = (UICollectionViewCell*)[colView cellForItemAtIndexPath:indexPath];
    [cell setBackgroundColor:[UIColor clearColor]];
    
}

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
}


- (void)setupCellWithModel:(DHCWNativeAdDataObject *)model
                  delegate:(id<DHCWNativeAdViewDelegate>)delegate loca:(id<DHCWNativeLocaVideoAdDelegate>)localDelegate
        rootViewController:(UIViewController *)rootViewController
{
    self.model = model;
    self.dhcDelegate = delegate;
    self.dhcLocaDelegate = localDelegate;
    self.rootViewController = rootViewController;
    //[self.collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:2]]];
    [self.cardCollectionView reloadData];
}

#pragma mark - 图片和title匹配
- (NSString *)getBtnImageNameWithmenuTag:(NSString *)menuTag
{
    if ([menuTag isEqualToString:@"quick_diagnose"]) {
        return @"live_freeMedical";
    }else if ([menuTag isEqualToString:@"parity_pharmacies"]){
        return @"live_yaofang";
    }else if ([menuTag isEqualToString:@"square_dancing"]){
        return @"live_squaredance";
    }else if ([menuTag isEqualToString:@"weather_report"]){
        return @"live_weather";
    }else if ([menuTag isEqualToString:@"more_menu"]){
        return @"live_moreIcons";
    }
    
    return @"";
}



#pragma mark - event response
- (void)packageClick:(UITapGestureRecognizer *)tap
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithType:)]) {
        [self.delegate TopCellClickWithType:FindTableTopCellTypePackage];
    }
}

- (void)suspensionBallBtnClick:(UIButton *)sender
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(TopCellClickWithType:)]) {
        [self.delegate TopCellClickWithType:FindTableTopCellTypeBall];
    }
}

#pragma mark - getters and setters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, cl_kStatusBarHeight, ScreenWidth, 190* WIDTHRADIU)];
        _scrollView.contentSize = CGSizeMake(3 * 875* WIDTHRADIU, 190 * WIDTHRADIU);
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.showsVerticalScrollIndicator = NO;
        _scrollView.scrollEnabled = NO;
        _scrollView.contentOffset = CGPointMake(0, 0);
        _scrollView.backgroundColor = [UIColor whiteColor];
        _scrollView.delegate = self;
        UIImageView*leftImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 875* WIDTHRADIU, 190*WIDTHRADIU)];
        leftImageView.contentMode = UIViewContentModeScaleAspectFit;
        leftImageView.image = [UIImage imageNamed:@"findHomebg"];
        [_scrollView addSubview:leftImageView];
        
        UIImageView*middleImageView = [[UIImageView alloc]initWithFrame:CGRectMake(875* WIDTHRADIU, 0, 875* WIDTHRADIU, 190*WIDTHRADIU)];
        middleImageView.image = [UIImage imageNamed:@"findHomebg"];
        middleImageView.contentMode = UIViewContentModeScaleAspectFit;
        [_scrollView addSubview:middleImageView];
        
        UIImageView*rightImageView = [[UIImageView alloc]initWithFrame:CGRectMake(875* WIDTHRADIU * 2, 0, 875* WIDTHRADIU, 190*WIDTHRADIU)];
        rightImageView.image = [UIImage imageNamed:@"findHomebg"];
        rightImageView.contentMode = UIViewContentModeScaleAspectFit;
        [_scrollView addSubview:rightImageView];
        
        [_scrollView setContentOffset:CGPointMake(875* WIDTHRADIU, 0)];
        
    }
    return _scrollView;
}

- (LineProcessView *)progressView
{
    if (!_progressView) {
        _progressView = [[LineProcessView alloc]initWithFrame:CGRectMake( 20 * WIDTHRADIU, cl_kStatusBarHeight + 30 * WIDTHRADIU, 8, 95 * WIDTHRADIU)];
        //_progressView.backgroundColor = [UIColor redColor];
        
        
        
    }
    return _progressView;
}


- (UIView *)whiteView
{
    if (!_whiteView) {
        _whiteView = [[UIView alloc]initWithFrame:CGRectMake(20 * WIDTHRADIU,   cl_kStatusBarHeight +155 * WIDTHRADIU, ScreenWidth - 40 * WIDTHRADIU, 75 * WIDTHRADIU)];
        _whiteView.backgroundColor = [UIColor whiteColor];
        _whiteView.layer.cornerRadius = 10 * WIDTHRADIU;
        
        //[self addShadowToView:_whiteView withColor:K_MainColor];
        
        _whiteView.layer.shadowColor=K_MainColor.CGColor;
        _whiteView.layer.shadowOffset=CGSizeMake(0, 0);
        _whiteView.layer.shadowOpacity=0.5;
        _whiteView.layer.shadowRadius=2.5;

        
        //_whiteView.layer.masksToBounds = NO;
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
         // 设置item的行间距和列间距
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        
        UICollectionView*collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        collectionView.backgroundColor = [UIColor whiteColor];
        collectionView.showsVerticalScrollIndicator = NO;   //是否显示滚动条
        collectionView.scrollEnabled = YES;  //滚动使能
        collectionView.delegate = self;
        collectionView.dataSource = self;
        [collectionView registerNib:[UINib nibWithNibName:@"FindTopCell" bundle:nil] forCellWithReuseIdentifier:@"FindTopCell"];
        [_whiteView addSubview:collectionView];
        collectionView.layer.cornerRadius = 10 * WIDTHRADIU;
        self.cardCollectionView = collectionView;
        
        [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.offset(0);
            make.left.offset( 5 * WIDTHRADIU);
            make.right.offset(- 5 * WIDTHRADIU);
        }];
        
    }
    return _whiteView;
}

- (UICollectionView *)top2CollectionView
{
    if (!_top2CollectionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        // 设置item的行间距和列间距
        layout.minimumInteritemSpacing = 0;
        layout.minimumLineSpacing = 0;
        
        _top2CollectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        _top2CollectionView.backgroundColor = [UIColor whiteColor];
        _top2CollectionView.showsVerticalScrollIndicator = NO;   //是否显示滚动条
        _top2CollectionView.scrollEnabled = NO;  //滚动使能
        _top2CollectionView.delegate = self;
        _top2CollectionView.dataSource = self;
        [_top2CollectionView registerNib:[UINib nibWithNibName:@"FindTop2Cell" bundle:nil] forCellWithReuseIdentifier:@"FindTop2Cell"];
    }
    return _top2CollectionView;
}

- (UIImageView *)packageImg
{
    if (!_packageImg) {
        _packageImg = [[UIImageView alloc]init];
        _packageImg.image = [UIImage imageNamed:@"suspensionPackage"];
        _packageImg.userInteractionEnabled = YES;
        UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(packageClick:)];
        [_packageImg addGestureRecognizer:tap];
        _packageImg.hidden = YES;
    }
    return _packageImg;
}

- (UIButton *)SuspensionBallBtn
{
    if (!_SuspensionBallBtn) {
        _SuspensionBallBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_SuspensionBallBtn setImage:[UIImage imageNamed:@"SuspensionBall"] forState:UIControlStateNormal];
        [_SuspensionBallBtn setTitle:@"健康能量" forState:UIControlStateNormal];
        [_SuspensionBallBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _SuspensionBallBtn.titleLabel.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
        [_SuspensionBallBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleTop imageTitleSpace:3];
        [_SuspensionBallBtn addTarget:self action:@selector(suspensionBallBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _SuspensionBallBtn;
}

- (NSArray *)titleArray
{
    if (!_titleArray) {
        _titleArray = @[@"我的金币",@"金币抽奖",@"打卡领钱",@"邀请好友"];
    }
    return _titleArray;
}

- (NSArray *)title2Array
{
   if (!_title2Array) {
        _title2Array = @[@"快递查询",@"智能问诊",@"万年历",@"天气",@"医院挂号"];
    }
    return _title2Array;
}

- (NSArray *)iconsArray
{
    if (!_iconsArray) {
        _iconsArray = @[@"live_coins",@"live_lottery",@"daka_icon.gif",@"live_invite"];
    }
    return _iconsArray;
}

- (NSArray *)icons2Array
{
    if (!_icons2Array) {
        _icons2Array = @[@"live_kuaidi",@"live_wenzhen",@"live_calendar",@"live_weather",@"live_guahao"];
    }
    return _icons2Array;
}


- (void)addShadowToView:(UIView *)theView withColor:(UIColor *)theColor {
    
    theView.layer.shadowColor = theColor.CGColor;
    theView.layer.shadowOffset = CGSizeMake(0,0);
    theView.layer.shadowOpacity = 0.15;
    theView.layer.shadowRadius = 1;
    // 单边阴影 顶边
    float shadowPathWidth = theView.layer.shadowRadius;
    CGRect shadowRect = CGRectMake(-shadowPathWidth/2.0,  shadowPathWidth/2.0, theView.bounds.size.width + shadowPathWidth , theView.bounds.size.height);
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:shadowRect];
    theView.layer.shadowPath = path.CGPath;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
