//
//  SearchCollectionViewController.m
//  Open
//
//  Created by gao on 2017/2/6.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "SearchCollectionViewController.h"
#import "NewSCell.h"
#import "BtnCollectionViewCell.h"
#import "telephotoVM.h"
#import "LoginVC.h"

#import "WETianqiController.h"

#import "LMJScrollTextView.h"

#import "VisitCountManager.h"

#import "governmentViewController.h"



#import "CTAPIBaseManager.h"
#import "GTCountSDK.h"

#import "AiDaAlertView.h"
#import "JoinPartnerResultViewController.h"
#import "PartnerModel.h"
#import "PartnerCenterViewController.h"
#import "JoinPartGuideViewController.h"

#import "SearchCollectionReusableView.h"
#import "GovInfoViewController.h"
#import "WETianqiController.h"


//存钱罐
#import "SaveTabBarController.h"
#import "SaveProductListController.h"
#import "MyAssetsController.h"
#import "LittleGoldHouseWebVC.h"
#import "KKUserIdentifyViewController.h"
#import "ApplyStateQueryViewController.h"

//极光小视频
#import "KKTabBarViewController.h"
#import "KKTVViewController.h"
#import "LittleVideoViewController.h"
#import "KKVideoViewController.h"
#import "KKSVideoViewController.h"
//优抚核查
#import "DistrictAuthenticationPersonalInfoController.h"
#import "KKCLFundViewController.h"
#import "GovNewVc.h"


#import "SurplusmVC.h"
@interface SearchCollectionViewController ()<UICollectionViewDelegateFlowLayout>
{
//    NSInteger ingeerr;
    BOOL show;
}
@property (strong, nonatomic) IBOutlet UICollectionView *collectView;

@property(nonatomic,strong)	 NewSCell *viewModel;
//天气
@property (weak, nonatomic) IBOutlet LMJScrollTextView *cityView;
@property (weak, nonatomic) IBOutlet UILabel *strWeather;
@property (weak, nonatomic) IBOutlet UIButton *buttonWeather;


//////////
@property(nonatomic,strong)telephotoVM *telVM;

@property(nonatomic,strong)NSMutableArray *baocun;
@property(nonatomic,strong)PostMessageViewModel*postVM;
@property(nonatomic,strong)NSMutableArray *array_k1;
@property(nonatomic,strong)NSMutableArray *array_k2;
@property(nonatomic,strong)NSMutableArray *array_k3;
@property(nonatomic,strong)NSMutableArray *array_k4;
@property(nonatomic,strong)NSMutableArray *array_k5;

@property (weak, nonatomic) IBOutlet UIView *pushHidel;

@end



@implementation SearchCollectionViewController

//static NSString * const reuseIdentifier = @"collectionCellID";
static NSString *reuseIdentifier = @"collectionCellID";
-(PostMessageViewModel *)postVM
{
    if (!_postVM) {
        _postVM =[PostMessageViewModel new];
    }
    return _postVM;
    
}
-(NSMutableArray *)baocun
{
    if (!_baocun) {
        _baocun=[NSMutableArray new];
    }
    return _baocun;
}
-(NSMutableArray *)array_k1
{
    if (!_array_k1) {
        _array_k1 =[NSMutableArray new];
    }
    return _array_k1;
}
-(NSMutableArray *)array_k2
{
    if (!_array_k2) {
        _array_k2 =[NSMutableArray new];
    }
    return _array_k2;
}
-(NSMutableArray *)array_k3
{
    if (!_array_k3) {
        _array_k3 =[NSMutableArray new];
    }
    return _array_k3;
}
-(NSMutableArray *)array_k4
{
    if (!_array_k4) {
        _array_k4 =[NSMutableArray new];
    }
    return _array_k4;
}
-(NSMutableArray *)array_k5
{
    if (!_array_k5) {
        _array_k5 =[NSMutableArray new];
    }
    return _array_k5;
}



-(telephotoVM *)telVM
{
    if (!_telVM) {
    _telVM =[[telephotoVM alloc]init];
    }
    return _telVM;
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    self.pushHidel.hidden = YES;
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self.navigationController.navigationBar navBarBackGroundColor:K_MainColor image:nil isOpaque:YES];//颜色
      
      [self.navigationController.navigationBar navBarBottomLineHidden:YES];
    
    //导航栏颜色
       self.navigationController.navigationBar.barTintColor = K_MainColor;
       [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor],
                                                                         NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:17]}];
       
       [self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
           self.navigationController.navigationBar.barTintColor = K_MainColor;
       } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
       }];
    
    //tianqi
    //tianqi
    self.pushHidel.hidden = NO;
    //从飞机票开始
    //self.collectView.contentOffset = CGPointMake(0, -55);
    self.collectView.showsVerticalScrollIndicator = NO;
    AppDelegate * app = (AppDelegate*)[[UIApplication sharedApplication]delegate];
    if (app.onLine == NO ) {
          [SVProgressHUD doneShow];
        [SVProgressHUD showErrorWithStatus:@"网络状态不佳"];
        return;
    }
//            self.strWeather.text=  [[NSUserDefaults standardUserDefaults] objectForKey:@"weatherti1"];
//            self.imageWeather.image = [UIImage imageNamed: [[NSUserDefaults standardUserDefaults] objectForKey:@"weatherti2"]];
    
   
    
    NSString *city = nil;
    NSString *weather = nil;
    NSDictionary *data = [[NSUserDefaults standardUserDefaults]objectForKey:@"TQData"];
    if (![NSString blankString:data[@"cityname"]]) {
         city = [NSString stringWithFormat:@"%@",data[@"cityname"]];
        NSString *low_temp = data[@"today"][@"low_temp"];
        NSString *high_temp = data[@"today"][@"high_temp"];
        if (low_temp.length > 3 && high_temp.length > 3) {
            weather = [NSString stringWithFormat:@"%@  %@~%@",data[@"today"][@"weather"],[low_temp substringFromIndex:2],[high_temp substringFromIndex:2]];
        }
      
    }else {
        city = @"上海市";
        
        weather =@"晴 22℃";
    }
    
   
    CGFloat width  = [city sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:16], NSFontAttributeName, nil]].width;
    if (width >= 100) {
         [_cityView startScrollWithText:city textColor:[UIColor whiteColor] font:[UIFont systemFontOfSize:16]];
    }else {
        [_cityView startShowWithText:city textColor:[UIColor whiteColor] font:[UIFont systemFontOfSize:16]];
    }
    
    self.strWeather.text = weather;

   
    [self changeABC];
    
    [self hiddenrequest];

}
-(void)changeABC{
    AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    if ([delegate.changeProgress isEqualToString:@"开始"]) {
        delegate.changeProgress =@"结束";
        [self searchProgress];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor colorWithHex:0xf4f4f4];
     
    self.collectView.bounces =NO;
      //[self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView"];
    
    if (@available(iOS 11.0, *)) {
        self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    self.collectionView.contentInset = UIEdgeInsetsMake(0, 0, cl_kTabBarHeight - 49, 0);
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"SearchCollectionReusableView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView"];
    
    //发布数据
    [self getSuperData];
    
    [self hiddenrequest];
    
    if (!self.fromHome) {
        self.collectionView.frame = CGRectMake(0, cl_kNavigationBarHeight, ScreenWidth, ScreenHeight - cl_kNavigationBarHeight - cl_kTabBarHeight);
        
        UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 44)];
        label.text = @"发现";
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont fontWithName:@"Hoefler Text" size:18];
        
        UIBarButtonItem*leftItem = [[UIBarButtonItem alloc]initWithCustomView:label];
        
        self.navigationItem.leftBarButtonItem = leftItem;
        
    }else{
        self.collectionView.frame = CGRectMake(0, cl_kNavigationBarHeight, ScreenWidth, ScreenHeight - cl_kNavigationBarHeight);
    }
    
//    self.cityView.hidden = self.fromHome;
//    self.strWeather.hidden = self.fromHome;
//    self.buttonWeather.hidden = self.fromHome;
}


#pragma mark - 隐藏比财请求

- (void)hiddenrequest
{
    NSString * url =[NSString stringWithFormat:@"%@%@",[NetworkConfig ipSwitchConfig],SwitchRequest];
     NSString*version = nil;
     NSString*v = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
     NSArray*vArr = [v componentsSeparatedByString:@"."];
     
     for (int i = 0; i < vArr.count; i++) {
         if (version == nil) {
             version = [NSString stringWithFormat:@"kklife%@",vArr[i]];
         }else{
             version = [version stringByAppendingFormat:@"%@",vArr[i]];
         }
     }
     
     NSDictionary*params = @{
         @"version":version
     };
              
      [NetworkRequest Get:url Params:params Success:^(id _Nonnull responseObject) {
          
          NSString* state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
          if ([state isEqualToString:@"200"]) {
              NSString* result = responseObject[@"result"];
              if ([result isEqualToString:@"0"]) {
                  self->show = YES;
                  
                  [self.collectionView reloadData];
              }
          }
          
          
      } Failure:^(NSError* error) {
         
    }];
}


#pragma mark - 获取访问比财接口的token
- (NSDictionary *)aiDaTokenRequestPara
{
    NSDictionary* params = @{
        @"loginId":[NSNumber numberWithInteger:[getPeopleID PeopleID]].stringValue,
        @"telephone":[getPeopleID PeopleIphoneNmber]
    };
    return params;
}

- (void)aiDaTokenRequest:(void (^)(bool success, NSString*token))response
{
    NSString*url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipAdDaConfig],AiDaTokenRequest];
    NSLog(@"爱达token的url:%@",url);
    
    NSLog(@"params:%@",[self aiDaTokenRequestPara]);
    
    [NetworkRequest Get3:url Params:[self aiDaTokenRequestPara] Success:^(id _Nonnull responseObject) {
        
        NSLog(@"responseObject:%@",responseObject);
        
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
            NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
            if ([state isEqualToString:@"200"]) {
                
                NSString*token = [NSString stringWithFormat:@"%@",responseObject[@"result"]];
                
                response(YES,token);
                
            }else{
                [SVProgressHUD showErrorWithStatus:describe];
            }
            
        }else{
            [SVProgressHUD showErrorWithStatus:@"服务器异常"];
        }
        
    } Failure:^(NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"网络异常"];
    }];
}



#pragma mark - 比财

- (NSDictionary *)getBCRequestParam
{
    NSDictionary *params = @{
        @"phone":[[getPeopleID PeopleIphoneNmber] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]],
        @"id":[NSNumber numberWithInteger:[getPeopleID PeopleID]].stringValue
    };
    return params;
}

- (void)getBCRequest:(NSString *)token
{
   NSString*url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipAdDaUrlConfig],BCUrlRequest];
    NSLog(@"比财url的url:%@",url);
    
    NSLog(@"params:%@",[self getBCRequestParam]);
    
    [NetworkRequest Get2:url Params:[self getBCRequestParam] Token:token Success:^(id  _Nonnull responseObject) {
        
         NSLog(@"responseObject:%@",responseObject);
                
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
            NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
            if ([state isEqualToString:@"200"]) {
                
                NSString*url = [NSString stringWithFormat:@"%@&appBarHide=hide",responseObject[@"result"]];
                
//                NSMutableCharacterSet *lastSet = [[NSMutableCharacterSet alloc] init];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"-_.!~*;/?:@&=$,#"]];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet letterCharacterSet]];
//                   [lastSet formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]];
//
//                url = [url stringByAddingPercentEncodingWithAllowedCharacters:lastSet];
                
                if ([self.navigationController.visibleViewController isKindOfClass:[SearchCollectionViewController class]]) {
                    Web2ViewController * vc = [Web2ViewController new];
                    vc.title= @"存钱罐";
                    vc.skipUrl = [NSURL URLWithString:url];
                    vc.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:vc animated:YES];
                }
                
              
                
                
            }else{
                [SVProgressHUD showErrorWithStatus:describe];
            }
            
        }else{
            [SVProgressHUD showErrorWithStatus:@"服务器异常"];
        }
        
        
    } Failure:^(NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"网络异常"];
    }];
}


#pragma mark -合伙人查询
- (NSDictionary *)getPartnerQueryRequestPara
{
    NSDictionary*params = @{
         @"tel":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]
    };
    return params;
}

- (void)getPartnerQuery
{
//    WeakSelf
    NSString *urlString = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipPartnerConfig],PartnetQueryRequest];
    NSLog(@"合伙人查询url:%@",urlString);
    NSLog(@"params:%@",[self getPartnerQueryRequestPara]);
    
    
    [NetworkRequest Get3:urlString Params:[self getPartnerQueryRequestPara] Success:^(id _Nonnull responseObject) {
        NSLog(@"responseObject:%@",responseObject);
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
             NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
             NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
             

            
            if ([state isEqualToString:@"202"]) {
                JoinPartnerResultViewController* vc = [JoinPartnerResultViewController new];
                vc.type = @"loading";
                vc.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:vc animated:YES];
            }else if ([state isEqualToString:@"200"]){
                    PartnerModel*model = [PartnerModel mj_objectWithKeyValues:responseObject[@"result"]];
                    PartnerCenterViewController*vc = [PartnerCenterViewController new];
                    vc.title = @"合伙人中心";
                    vc.model = model;
                    vc.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:vc animated:YES];
                
                    return;
            }else if ([state isEqualToString:@"203"]){
                JoinPartnerResultViewController* vc = [JoinPartnerResultViewController new];
                vc.type = @"fail";
                vc.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:vc animated:YES];
            }else if ([state isEqualToString:@"201"]){
                
                JoinPartGuideViewController *vc = [JoinPartGuideViewController new];
                vc.title = @"加入合伙人";
                vc.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:vc animated:YES];
                   
                
                    return;
            }else{
                [SVProgressHUD showErrorWithStatus:describe];
            }
        }else{
            [SVProgressHUD showErrorWithStatus:@"服务器异常"];
        }
        
    } Failure:^(NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        [SVProgressHUD showErrorWithStatus:@"网络异常"];
    }];
    
    
}


//#pragma mark - 判断是否有存款
//- (void)judgeSaveAmountRequest
//{
//    NSString* url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipYinShuConfig],BCGetSaveAmountRequest];
//    NSLog(@"获取乌当和比财账户存款金额总数量url:%@",url);
//
////    NSString *province = [Tools isBlankString:[UserDefault objectForKey:@"locationProvince"]] ? @"" : [UserDefault objectForKey:@"locationProvince"];
////    NSString *city = [Tools isBlankString:[UserDefault objectForKey:@"locationCity"]] ? @"" : [UserDefault objectForKey:@"locationCity"];
////    NSString *county = [Tools isBlankString:[UserDefault objectForKey:@"locationCounty"]] ? @"" : [UserDefault objectForKey:@"locationCounty"];
//
//    NSMutableDictionary *params = [NetworkPublicParams getBCPublicParams];
//    [params setObject:[getPeopleID PeopleIphoneNmber] forKey:@"loginPhoneNum"];
//
//
////    [params setObject:[getPeopleID PeopleIphoneNmber] forKey:@"tel"];
////    [params setObject:@([getPeopleID PeopleID]) forKey:@"uid"];
////    [params setObject:province forKey:@"province"];
////    [params setObject:city forKey:@"city"];
////    [params setObject:county forKey:@"county"];
//
//
//
//    NSLog(@"params:%@",params);
//    [KKLoadingAnimationView show];
//    [NetworkRequest Post6:url Params:params Success:^(id _Nonnull objc) {
//        [KKLoadingAnimationView dismiss];
//        NSLog(@"objc:%@",objc);
//        NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
//        NSString *describe = [NSString stringWithFormat:@"%@",objc[@"describe"]];
//        if ([state isEqualToString:@"200"]) {
//            NSDictionary *result = objc[@"result"];
//            if ([result isKindOfClass:[NSDictionary class]]) {
//                NSString *sumAmount = [NSString stringWithFormat:@"%@",result[@"sumAmount"]];
//
//
//                if (sumAmount.doubleValue > 0) {
//
//                    UITabBarController*tabVC = [self getTabVC:sumAmount.doubleValue > 0];
//                    [tabVC.navigationController setNavigationBarHidden:YES];
//                    tabVC.hidesBottomBarWhenPushed = YES;
//                    [self.navigationController pushViewController:tabVC animated:YES];
//
//                }else{
//
////                    LittleGoldHouseWebVC *oneVC = [[LittleGoldHouseWebVC alloc] init];
////                    oneVC.title = @"小金库";
////                    oneVC.view.backgroundColor = [UIColor whiteColor];
////                    oneVC.fromHome = YES;
////                    oneVC.hidesBottomBarWhenPushed = YES;
////                    [self.navigationController pushViewController:oneVC animated:YES];
//
//                    SaveTabBarController*tabVC = (SaveTabBarController*)[self getTabVC2];
//
//                    [tabVC.navigationController setNavigationBarHidden:YES];
//                    tabVC.hidesBottomBarWhenPushed = YES;
//                    [self.navigationController pushViewController:tabVC animated:YES];
//
//                }
//
//
//
//
//            }
//
//        }else{
//            [Tools showMessage:describe];
//        }
//
//    } Failure:^(NSError* error) {
//        [KKLoadingAnimationView dismiss];
//        NSLog(@"error:%@",error);
//
//        [Tools showMessage:@"网络出小差了,请稍后重试"];
//
//    }];
//}

//
//#pragma mark - 跳转到子视图tabcontroller
//- (UITabBarController *)getTabVC:(BOOL)showBC
//{
//    //2.设置窗口的根控制器
//      SaveTabBarController *tabBarVC = [[SaveTabBarController alloc] init];
//      tabBarVC.showBC = showBC;
//      //添加子控制器
//      //默认显示的第一个添加的子控制器的View
//      //tabBarVC里面有多少个子控制器,tabBar当中就有多少个平分的按钮
//
//      //UITabBarController中的tabBar的内容是有对应按钮的控制器来决定的.
//      //tabBar的内容是有对应按钮的控制器的tabBarItem来决定
//
////    if (showBC) {
////
////        SaveProductListController *oneVC = [[SaveProductListController alloc] init];
////        oneVC.title = @"产品列表";
////        oneVC.view.backgroundColor = [UIColor whiteColor];
////        oneVC.tabBarItem = [self getCustomItemWithTitle:@"产品列表" image:@"product_unselected" selectedImage:@"product_selected"];
////        UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:oneVC];
////        [tabBarVC addChildViewController:nav1];
////
////    }else{
////        LittleGoldHouseWebVC *oneVC = [[LittleGoldHouseWebVC alloc] init];
////        oneVC.title = @"小金库";
////        oneVC.view.backgroundColor = [UIColor whiteColor];
////        oneVC.url = @"https://lc.jr.jd.com/ck/xjkHold/index/?channel=a00308";
////        oneVC.tabBarItem = [self getCustomItemWithTitle:@"小金库" image:@"product_unselected" selectedImage:@"product_selected"];
////        UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:oneVC];
////        [tabBarVC addChildViewController:nav1];
////    }
//
//
//    KKCLFundViewController *oneVC = [[KKCLFundViewController alloc]init];
//    oneVC.title = @"存钱罐";
//    oneVC.view.backgroundColor = [UIColor whiteColor];
//    oneVC.tabBarItem = [self getCustomItemWithTitle:@"存钱罐" image:@"product_unselected" selectedImage:@"product_selected"];
//    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:oneVC];
//    [tabBarVC addChildViewController:nav1];
//
//
//
//    LittleGoldHouseWebVC *twoVC = [[LittleGoldHouseWebVC alloc] init];
//    twoVC.title = @"小金库";
//    twoVC.view.backgroundColor = [UIColor whiteColor];
//    twoVC.url = @"https://lc.jr.jd.com/ck/xjkHold/index/?channel=a00308";
//    twoVC.tabBarItem = [self getCustomItemWithTitle:@"小金库" image:@"xiaojinku_unselected" selectedImage:@"xiaojinku_selected"];
//    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:twoVC];
//    [tabBarVC addChildViewController:nav2];
//
//
//      MyAssetsController *threeVC = [[MyAssetsController alloc] init];
//    threeVC.title = @"其他资产";
//    threeVC.view.backgroundColor = [UIColor whiteColor];
//    threeVC.tabBarItem = [self getCustomItemWithTitle:@"其他资产" image:@"myAssets_unselected" selectedImage:@"myAssets_selected"];
//      UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:threeVC];
//      [tabBarVC addChildViewController:nav3];
//
//
//
//
//      //修改主题的颜色
//      tabBarVC.tabBar.tintColor = [UIColor colorWithHex:0x137ef6];
//
//
//
//    return tabBarVC;
//}
//
//- (UITabBarController *)getTabVC2
//{
//    SaveTabBarController *tabBarVC = [[SaveTabBarController alloc] init];
//
//    KKCLFundViewController *oneVC = [[KKCLFundViewController alloc]init];
//    oneVC.title = @"存钱罐";
//    oneVC.view.backgroundColor = [UIColor whiteColor];
//    oneVC.tabBarItem = [self getCustomItemWithTitle:@"存钱罐" image:@"product_unselected" selectedImage:@"product_selected"];
//    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:oneVC];
//    [tabBarVC addChildViewController:nav1];
//
//
//
//    LittleGoldHouseWebVC *twoVC = [[LittleGoldHouseWebVC alloc] init];
//    twoVC.title = @"小金库";
//    twoVC.view.backgroundColor = [UIColor whiteColor];
//    twoVC.url = @"https://lc.jr.jd.com/ck/xjkHold/index/?channel=a00308";
//    twoVC.tabBarItem = [self getCustomItemWithTitle:@"小金库" image:@"xiaojinku_unselected" selectedImage:@"xiaojinku_selected"];
//    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:twoVC];
//    [tabBarVC addChildViewController:nav2];
//
//    //修改主题的颜色
//    tabBarVC.tabBar.tintColor = [UIColor colorWithHex:0x137ef6];
//
//
//
//
//    return tabBarVC;
//
//}

//- (UITabBarItem *)getCustomItemWithTitle:(NSString *)title image:(NSString *)imageName selectedImage:(NSString *)selectedImageName
//{
//    UIImage *image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage* selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//     UITabBarItem *tabbarItem = [[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
//    [tabbarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHex:0x137ef6], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
//    [tabbarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHex:0x7a7a7a], NSForegroundColorAttributeName,[UIFont systemFontOfSize:15],NSFontAttributeName, nil] forState:UIControlStateNormal];
//
//    return tabbarItem;
//}



#pragma mark - event response

- (IBAction)WeatherBtnClick:(UIButton *)sender {
     NSDictionary *data = [[NSUserDefaults standardUserDefaults]objectForKey:@"TQData"];
    
    if (![NSString blankString:data[@"cityname"]]) {
        NSString *lat = [NSString stringWithFormat:@"%@",data[@"lat"]];
        NSString *lng = [NSString stringWithFormat:@"%@",data[@"lng"]];
        WETianqiController *controlltr = [[WETianqiController alloc] init];
        [controlltr fetchWeatherDataLocationLat:[lat doubleValue] LocationLng:[lng doubleValue]];
        [self presentViewController:controlltr animated:YES completion:NULL];
    }else{
        WETianqiController *controlltr = [[WETianqiController alloc] init];
        [controlltr fetchWeatherDataLocationLat:31.22 LocationLng:121.48];
        [self presentViewController:controlltr animated:YES completion:NULL];
    }
   
}




-(void)getSuperData
{
    
    [postMessageMNet getSuperCatalogcompletionHandle:^(postMessageModel *model, NSError *error) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            //              [self.baocun addObjectsFromArray:model.Result];
            [self.baocun removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [self.baocun addObject:models.categoryname];
                    NSLog(@"_superData:%@",self.baocun);
                }
            }
            
        });
    }];
    
    __weak __typeof(self)weakSelf = self;
    [postMessageMNet getChildCatalog:1 completionHandle:^(postMessageModel *model, NSError *error) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [weakSelf.array_k1 removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [weakSelf.array_k1 addObject:models.categoryname];
                    NSLog(@"_superData:%@",weakSelf.array_k1);
                }
                
            }
            
        });
    }];
    [postMessageMNet getChildCatalog:2 completionHandle:^(postMessageModel *model, NSError *error) {
        [self.array_k2 removeAllObjects];
        if (model.Result.count >0) {
            for (postMessageResultModel *models in model.Result) {
                
                [self.array_k2 addObject:models.categoryname];
            }
        }
        
    }];
    [postMessageMNet getChildCatalog:3 completionHandle:^(postMessageModel *model, NSError *error) {
        [self.array_k3 removeAllObjects];
        if (model.Result.count >0) {
            for (postMessageResultModel *models in model.Result) {
                
                [self.array_k3 addObject:models.categoryname];
            }
        }
        
    }];
    [postMessageMNet getChildCatalog:4 completionHandle:^(postMessageModel *model, NSError *error) {
        [self.array_k4 removeAllObjects];
        if (model.Result.count >0) {
            for (postMessageResultModel *models in model.Result) {
                
                [self.array_k4 addObject:models.categoryname];
            }
        }
        
    }];
    [postMessageMNet getChildCatalog:5 completionHandle:^(postMessageModel *model, NSError *error) {
        [self.array_k5 removeAllObjects];
        if (model.Result.count >0) {
            for (postMessageResultModel *models in model.Result) {
                
                [self.array_k5 addObject:models.categoryname];
            }
        }
        
    }];
    
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
//3->4
    if (show) {
        return 4;
    }
    return 3;
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    switch (section) {
        case 0:
            return 7;
        case 1:{
            if (show) {
                return 11;
            }else{
                return 9;
            }
        }
        case 2:{
            if (show) {
                return 3;
            }else{
                return 4;
            }
        }
        default:
            return 4;
    }
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    //注释了
    static NSString *collectionCellID = @"myCollectionCell";
    BtnCollectionViewCell *cell = (BtnCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:collectionCellID forIndexPath:indexPath];
    NewSCell *cellView=[[NewSCell alloc]init];
    if (indexPath.section == 0) {
        
        cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item show:show]];
        
    }else if(indexPath.section == 1){
    
       cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+7 show:show]];
        
    }else{
        if (show) {
            if (indexPath.section == 2) {
                cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+21 show:show]];
            }else{
                cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+24 show:show]];
            }
        }else{
            cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+16 show:show]];
        }
    }
    
//    if (indexPath.section == 0) {
//       cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item show:show]];
//    }
//    else if(indexPath.section == 1)
//    {
//
//       cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+7 show:show]];
//
//    }
//    else
//    {
//        if (show) {
//            cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+21 show:show]];
//        }else{
//            cell.image2.image=[UIImage imageNamed:[cellView arraypppp:indexPath.item+16 show:show]];
//        }
//
//    }

     return cell;
}

#pragma mark <UICollectionViewDelegate>
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    if (kind == UICollectionElementKindSectionHeader) {
        SearchCollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView" forIndexPath:indexPath];
        if (show) {
            if (indexPath.section == 0) {
                headerView.lb_title.text = @"  政务便民";
            }else if(indexPath.section == 1){
                headerView.lb_title.text =@"  生活便利";
            }else if(indexPath.section == 2){
                headerView.lb_title.text =@"  金融理财";
            }else{
                headerView.lb_title.text =@"  交通出行";
            }
        }else{
            if (indexPath.section == 0) {
                headerView.lb_title.text = @"  政务便民";
            }else if(indexPath.section == 1){
                headerView.lb_title.text =@"  生活便利";
            }else{
                headerView.lb_title.text =@"  交通出行";
            }
        }
        return headerView;
    }else{
        return (id)[UIView new];
    }
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
//   106
    return CGSizeMake( [UIScreen mainScreen].bounds.size.width/4-10, [UIScreen mainScreen].bounds.size.width/4+10);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(5, 5, 5, 5);
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    CGSize size ={320,45};
    return size;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    //hang
    return 10;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
  //lie
    return 0;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell =[collectionView cellForItemAtIndexPath:indexPath];
    [cell setBackgroundColor:[UIColor whiteColor]];
    if (indexPath.section == 0) {
        
        if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]) {
            [self unLoginTap];
            return;
        }
        switch (indexPath.row ) {
                
            case 0:
                [self social];
                break;
            case 1:

                //[self searchProgress];
                [[clickEvent instance] clickEventRooterVC:self Content:@"moreRZCX" menuName:@"moreRZCX"];
                break;
            case 2:
             
                [self goToZhengWuVC];
                
                break;
            case 3:
            {
                DistrictAuthenticationPersonalInfoController* vc = [DistrictAuthenticationPersonalInfoController new];
                vc.title = @"优抚认证";
                [self.navigationController pushViewController:vc animated:YES];
                return;
            }
                break;
             
            case 4:
                
                [self dataGatherViewController];
                
                break;
            case 5:
                
               
                [self senderWK];
                
                break;
            case 6:
            ZHINENGKEFU
            break;
            default:

                break;
        }
    }else if(indexPath.section == 1){
        switch (indexPath.row ) {
            case 0:
                
                [self jumpToHTML5:@"http://m.zhuge.com/city/house/?ad_source=cpc_kankanshebao&spread=sem_cpc_kankanshebao" andJAnalytics:@"诸葛找房"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"诸葛找房" imageName:@"诸葛找房-home" url:@"http://m.zhuge.com/city/house/?ad_source=cpc_kankanshebao&spread=sem_cpc_kankanshebao"];
                break;
            case 1:
                [self jumpToHTML5:@"http://nginx.weface.com.cn/appH5/calendar/#/"andJAnalytics:@"万年历"];
                break;
            case 2:
                
                [[clickEvent instance] clickEventRooterVC:self Content:@"homeThree3" menuName:@"抢红包"];
                
                break;
            case 3:
                
                [self jumpToHTML5:@"https://m.rilishipu.com/indexnew.html?Authorize=97d0eb43e3c43b9b3574606e4fd825d" andJAnalytics:@"菜谱"];
                [getPeopleID changePlistContentand:@"菜谱"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"菜谱" imageName:@"home_Menu" url:@"https://m.rilishipu.com/indexnew.html?Authorize=97d0eb43e3c43b9b3574606e4fd825d"];
                
                break;
            case 4:
                [self jumpToHTML5:@"https://m.kuaidi100.com/index_all.html"andJAnalytics:@"快递"];
                [getPeopleID changePlistContentand:@"快递查询"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"快递查询" imageName:@"快递查询2" url:@"https://m.kuaidi100.com/index_all.html"];
                break;
            case 5:
                [self jumpToHTML5:@"https://www.ctrip.com/" andJAnalytics:@"周边游"];
                [getPeopleID changePlistContentand:@"周边游"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"周边游" imageName:@"home_Travel" url:@"https://www.ctrip.com/"];
                break;
            case 6:
                [self goToTVVC:YES];
                break;
            case 7:
                [self jumpToHTML5:@"https://www.ilaw66.com/jasmine/?channel=kkss" andJAnalytics:@"问律师"];
                break;
            case 8:{
                //AI照相馆
                [[clickEvent instance] clickEventRooterVC:self Content:@"lifeZJZ" menuName:@"AI照相馆"];
                return;
            }
                break;
            case 9:
            {
                //快速问诊
                [[clickEvent instance] clickEventRooterVC:self Content:@"homeKSWZ" menuName:@"首页"];
            }
                break;
            case 10:
            {
                //免费发布
                [[clickEvent instance] clickEventRooterVC:self Content:@"freePublishH5" menuName:@"免费发布"];
              
            }
                break;
                
            case 11:
            {
                //免费果园
                [[clickEvent instance] clickEventRooterVC:self Content:@"homeThree1" menuName:@"免费果园"];
              
            }
                break;
//            case 12:
//            {
//                //优惠充值
//                //[[clickEvent instance] clickEventRooterVC:self Content:@"goToFruitVC" menuName:@"优惠充值"];
//                [[clickEvent instance] clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/FamilyChargeForwardUrl" menuName:@"优惠充值"];
//              
//            }
//                break;
//            case 13:
//            {
//                //电费便宜
//                //[[clickEvent instance] clickEventRooterVC:self Content:@"goToFruitVC" menuName:@"电费便宜"];
//                [[clickEvent instance] clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/electric/get/url" menuName:@"电费便宜"];
//            }
//                break;
            
        }
    }else{
        if (show) {
            if (indexPath.section == 2) {
                switch (indexPath.row ) {
                    case 0:{
                        //小金库
//                        LittleGoldHouseWebVC *twoVC = [[LittleGoldHouseWebVC alloc] init];
//                        twoVC.url = @"https://lc.jr.jd.com/ck/xjkHold/index/?channel=a00308";
//                        twoVC.title = @"小金库";
//                        twoVC.view.backgroundColor = [UIColor whiteColor];
//                        twoVC.fromHome = YES;
//                        [self.navigationController pushViewController:twoVC animated:YES];
                        
                        WebVC *webvc = [[WebVC alloc]init];
                        webvc.url = @"https://lc.jr.jd.com/ck/xjkHold/index/?channel=a00308";
                        webvc.title = @"小金库";
                        webvc.fromName = self.title;
                        webvc.hidesBottomBarWhenPushed = YES;
                        [self.navigationController pushViewController:webvc animated:YES];
                    }
                        break;
                    case 1:{
                        //盈米基金
                        SurplusmVC *oneVC = [[SurplusmVC alloc]init];
                        oneVC.hidesBottomBarWhenPushed = YES;
                        oneVC.title = @"理财";
                        oneVC.fromHome = YES;
                        oneVC.view.backgroundColor = [UIColor whiteColor];
                        [self.navigationController pushViewController:oneVC animated:YES];
                    }
                        break;
                    case 2:{
                        //常量基金
                        KKCLFundViewController *oneVC = [[KKCLFundViewController alloc]init];
                        oneVC.title = @"理财";
                        oneVC.view.backgroundColor = [UIColor whiteColor];
                        oneVC.from = @"home";
                        [self.navigationController pushViewController:oneVC animated:YES];
                    }
                        break;
                }
                return;
            }
        }
        switch (indexPath.row ) {
            case 0:
                [self jumpToHTML5:@"https://m.ctrip.com/webapp/train/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close&hiderecommapp=1"andJAnalytics:@"火车票"];
                [getPeopleID changePlistContentand:@"火车票"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"火车票" imageName:@"home_Train" url:@"https://m.ctrip.com/webapp/train/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close&hiderecommapp=1"];
                break;
            case 1:
                [self jumpToHTML5:@"https://m.ctrip.com/webapp/bus/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close" andJAnalytics:@"汽车票"];
                [getPeopleID changePlistContentand:@"汽车票"];
                [[VisitCountManager shareInstance]updateDataWithTitle:@"汽车票" imageName:@"home_busTicket" url:@"https://m.ctrip.com/webapp/bus/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close"];
                break;
            case 2:
                [self jumpToHTML5:@"https://m.ctrip.com/html5/Flight/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close"andJAnalytics:@"飞机票"];
                [getPeopleID changePlistContentand:@"飞机票"];
                 [[VisitCountManager shareInstance]updateDataWithTitle:@"飞机票" imageName:@"home_airPlane" url:@"https://m.ctrip.com/html5/Flight/?allianceid=452800&sid=949980&sourceid=2055&popup=close&autoawaken=close"];
                break;
            case 3:
                [self jumpToHTML5:@"http://m.ctrip.com/webapp/Hotel/?allianceid=452800&sid=949980&sourceid=xx&popup=close&autoawaken=close"andJAnalytics:@"酒店"];
                [getPeopleID changePlistContentand:@"酒店"];
                 [[VisitCountManager shareInstance]updateDataWithTitle:@"酒店" imageName:@"home_Hotel" url:@"http://m.ctrip.com/webapp/Hotel/?allianceid=452800&sid=949980&sourceid=xx&popup=close&autoawaken=close"];
                break;
        }
    }
}
-(void)senderDW{
//    WKSuperViewController *tc=[[WKSuperViewController alloc]init];
//    tc.titleStr=@"短视频";
////    tc.pathStr=@"https://h5.kuaiyinshi.com";
//     tc.pathStr=@"http://www.pearvideo.com/?from=intro";
//    tc.hidesBottomBarWhenPushed =YES;
//    [self.navigationController pushViewController:tc animated:YES];
    
//    VideoVC *vc = [[VideoVC alloc]init];
//    vc.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:vc animated:YES];
}
-(void)senderWK{
    
     [self jumpToHTML5:@"http://www.wodeshebao.com/calc/index.html" andJAnalytics:@"社保计算器"];
    
//    WKSuperViewController *tc=[[WKSuperViewController alloc]init];
//    tc.titleStr=@"社保计算器";
//    tc.pathStr=@"http://www.wodeshebao.com/calc/index.html";
//    tc.hidesBottomBarWhenPushed =YES;
//    [self.navigationController pushViewController:tc animated:YES];
}
-(void)searchProgress{

    
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]) {
        
        [self unLoginTap];
        return;
    }
    
    [SearchProgressNet getgetBindIdCardsListHandle:^(SearchProgress *model, NSError *error) {
        if (model.code ==0) {
            
            if (model.result.count == 0) {
                UIStoryboard *sbs =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                startProgressViewcontroller *tc=[sbs instantiateViewControllerWithIdentifier:@"startProgressViewcontroller"];
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
            }else{
                UIStoryboard *sbs =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                SearchProgressViewController *tc=[sbs instantiateViewControllerWithIdentifier:@"SearchProgressViewController"];
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
                
            }
        }else
        {
            codeSelected *code = [codeSelected MustTakeReturn:model.code];
            [code returnCodeMethod];
        }
    }];
    
    
    
}

-(void)social
{
    
    if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
        KKUserIdentifyViewController*vc = [[KKUserIdentifyViewController alloc]init];
        vc.title = @"社保认证";
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }else{
        
        [self unLoginTap];
    }
    
 

}
-(void)tel
{
    if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){

        [self.telVM getTelNumber:[getPeopleID PeopleIphoneNmber] Handle:^(NSError *error) {
            if (error) {
                return;
            }
            UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
            telephoneViewController *tc=[sb instantiateViewControllerWithIdentifier:@"telephoneViewController"];
            tc.hidesBottomBarWhenPushed =YES;
            tc.photoModel =[self.telVM.dataArr copy];
            [self.navigationController pushViewController:tc animated:YES];
          
        }];
         }else
    {

        [self unLoginTap];
    }


}


-(void)jumpToHTML5:(NSString*)url andJAnalytics:(NSString*)janalytics
{
    if ([janalytics isEqualToString:@"0元购"]) {
        WebVC *webvc = [[WebVC alloc]init];
        webvc.url = url;
        webvc.title = janalytics;
        webvc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webvc animated:YES];
        return;
    }
    
  
    
    
    Web2ViewController*tc = [Web2ViewController new];
    tc.skipUrl =[NSURL URLWithString:url];
    tc.hidesBottomBarWhenPushed =YES;
    tc.title = janalytics;
    [self.navigationController pushViewController:tc animated:YES];
    
    
    
    
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 
    if ([segue.identifier isEqualToString:@"postMessageThree"])  {
        postMessgaeTotal *blueVC = segue.destinationViewController;
        if (self.baocun.count >0) {
            blueVC.superData = [self.baocun copy];
        }
        if (self.array_k1.count >0) {
            blueVC.superChildData_1 =[self.array_k1 copy];
        }
        if (self.array_k2.count >0) {
            blueVC.superChildData_2 =[self.array_k2 copy];
        }
        if (self.array_k3.count >0) {
            blueVC.superChildData_3 =[self.array_k3 copy];
        }
        if (self.array_k4.count >0) {
            blueVC.superChildData_4 =[self.array_k4 copy];
        }
        if (self.array_k5.count >0) {
            blueVC.superChildData_5 =[self.array_k5 copy];
        }
        blueVC.hidesBottomBarWhenPushed=YES;
    }
}
-(void)dataGatherViewController
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    dataGatherViewController*dataG=[sb instantiateViewControllerWithIdentifier:@"dataGatherViewController"];
    dataG.hidesBottomBarWhenPushed =YES;
    if(![self.navigationController.topViewController isKindOfClass:[dataG class]]) {
        [self.navigationController pushViewController:dataG animated:YES];
    }
    
}


////抢红包
//- (void)goToPackageVC
//{
//
////    [self refreshCoins];
////
////    return;
//    if (ingeerr % 2 == 0) {
//        [self refreshCoins];
//        //[self refreshCoins];
//    }else if (ingeerr % 2 == 1){
//
//        [self goToTVVC:NO];
////        NSString*version = nil;
////        NSString*v = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
////        NSArray*vArr = [v componentsSeparatedByString:@"."];
////
////        for (int i = 0; i < vArr.count; i++) {
////            if (version == nil) {
////                version = [NSString stringWithFormat:@"%@",vArr[i]];
////            }else{
////                version = [version stringByAppendingFormat:@"%@",vArr[i]];
////            }
////        }
////
////        NSString* url = [NSString stringWithFormat:@"%@?userId=%@&phone=%@&version=%@&appName=kksh",@"http://nginx.weface.com.cn/appH5/Piggybank/activity/lib/home.html",@([getPeopleID PeopleID]),[getPeopleID PeopleIphoneNmber],version];
////
////        [self jumpToUrl:url andTitle:@"存钱罐活动"];
//    }
//
//
//    ingeerr ++;
//
//
//}

-(void)jumpToUrl:(NSString*)url andTitle:(NSString*)title
{
    
    WebVC *webvc = [[WebVC alloc]init];
    webvc.url = url;
    webvc.title = title;
    webvc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:webvc animated:YES];
}

//去政务信息
- (void)goToZhengWuVC
{
    
    if (show) {
        GovNewVc* govVC = [[GovNewVc alloc]init];
        
        govVC.title = @"政务便民";
        govVC.hidesBottomBarWhenPushed = YES;

        [self.navigationController pushViewController:govVC animated:YES];
    }else{
        ApplyStateQueryViewController* vc = [ApplyStateQueryViewController new];
        vc.title = @"登记进度查询";
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        return;
    }
    
    
}

#pragma mark - 跳转到小视频
- (void)goToTVVC:(BOOL)fromHome {


    if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){


        [self unLoginTap];

     return;
     }

    KKSVideoViewController *oneVC = [[KKSVideoViewController alloc]initWithType:fromHome];
    oneVC.title = fromHome ?@"看视频" :@"红包视频";
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.hidesBottomBarWhenPushed = YES;

    [self.navigationController pushViewController:oneVC animated:YES];
}

#pragma mark - 未登录跳转

- (void)unLoginTap {
    [[NSNotificationCenter defaultCenter]postNotificationName:KKSBJumpLoginVCNotificationName object:nil];
}


//#pragma mark - 抽奖
//- (void)refreshCoins
//{
//
//    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]) {
//        if ([getPeopleID PeopleID] && [getPeopleID PeopleIphoneNmber])
//        {
//            NSDictionary *params = @{
//                                     @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
//                                     @"telephone": [EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]
//                                     };
//            NSString *url =[NSString stringWithFormat:@"%@score/getpersonintegrals",CoinsBaseUrl];
//
//            WeakSelf;
//            [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
//
//                if (responseObj) {
//                    NSString *code = [responseObj[@"code"] stringValue];
//                    if ([code isEqualToString:@"0"]) {
//                        [getPeopleID getTotalCoins:responseObj[@"result"]];
//                        WebVC *webVC = [[WebVC alloc]init];
//                        webVC.title = @"金币抽奖";
//                        //外网http://nginx.weface.com.cn/lesson/award/src/award.html
//                        //内网@"http://172.16.10.121/projects/html-nginx/html-nginx/lesson/award/src/award.html"
//                      // webVC.url = @"http://nginx.weface.com.cn/lesson/award/src/award.html";
//                         webVC.url = CoinsRewardedUrl;
//                        webVC.type = @"home";
//                        webVC.hidesBottomBarWhenPushed =YES;
//                        [weakSelf.navigationController pushViewController:webVC animated:YES];
//                    }
//                }
//            }];
//        }
//    }else {
//
//
//        [self unLoginTap];
//
//    }
//
//
//
//}

//检测是否安装了支付宝
-(BOOL)ALIisLogin{
    
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"alipay://"]]) {
        return YES;
    }
    else {
        //        NSLog(@"未安装");
        return NO;
    }
}


@end
