//
//  ViewController.m
//  Open
//
//  Created by 黄江涛  on 16/9/7.
//  Copyright © 2016年 黄江涛 . All rights reserved.
//




#import "ViewController.h"
#import "PhotoViewController.h"
#import "SDCycleScrollView.h"
#import "MJExtension.h"
#import "ShowPicker.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import "MyPickerViewController.h"

#import <AddressBookUI/AddressBookUI.h>
#import <Contacts/Contacts.h>
#import "CLMarkButton.h"
#import "WebViewController.h"
#import "homePageNewsModel.h"
#import "weatherNetModel.h"
#import "LoginViewController.h"
#import "LoginVC.h"
#import "AppDelegate.h"
#import "NewSCell.h"
#import "newsViewModel.h"
#import "UIImageView+WebCache.h"
#import "uitableViewController.h"
#import "myJDCell.h"
#import "socialAssistant.h"
#import "fontFZ.h"
#import "NewEditionTestManager.h"
#import "TYImageCache.h"
#import "UIImage+GIF.h"
#import "MyTableViewCell_d.h"


//雷俊博
#import "LittleProcedureTableViewCell.h"
#import "WXApi.h"

#import "CTAPIBaseManager.h"

#import "DeathProveViewController.h"
#import "SSTerminationViewController.h"
#import "SSPaymenyViewController.h"
#import "SSTerminationViewController.h"
#import "tabViewController.h"
#import "WebViewco.h"





#import "VideoVC.h"
#define MHSafeString(str) (str == nil ? @"" : str)
#define  NUMBERFORHEIGHT 84.1
#define  NUMBERFORHEIGHT_2 168

#define statusRect  [[UIApplication sharedApplication] statusBarFrame]
@import AVKit;

@interface ViewController ()<SDCycleScrollViewDelegate,MKMapViewDelegate,CLLocationManagerDelegate,UITableViewDelegate,UITableViewDataSource>{
    BOOL hiddenStatusBar;
}

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

@property(nonatomic,strong)	 CLLocationManager *manager;
@property (weak, nonatomic) IBOutlet UILabel *loactionText;
@property (weak, nonatomic) IBOutlet UIView *viewLine;
@property(nonatomic,strong)UIViewController *vm;

@property (weak, nonatomic) IBOutlet UIButton *socialSecurity;
@property (weak, nonatomic) IBOutlet UIButton *waterPay;//2
@property (weak, nonatomic) IBOutlet UIButton *nongzi;//3
@property (weak, nonatomic) IBOutlet UIButton *shenghuojifei;//4
@property (weak, nonatomic) IBOutlet UIButton *searchExpressage;//5
@property (weak, nonatomic) IBOutlet UIButton *mianfeifabu;//6
@property (weak, nonatomic) IBOutlet UIButton *searchTrafficViolation;//7
@property (weak, nonatomic) IBOutlet UIButton *medcine;
@property (weak, nonatomic) IBOutlet UIButton *zhiwuxinxi;

@property (weak, nonatomic) IBOutlet UIButton *pai_er_one;

@property (weak, nonatomic) IBOutlet UIButton *pai_er_two;

@property (weak, nonatomic) IBOutlet UIButton *pai_er_three;

@property (weak, nonatomic) IBOutlet UIButton *pai_er_four;

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

@property(nonatomic,strong)NSMutableArray *arrayP;
@property(nonatomic,strong)NSMutableArray *arrayT;

@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(nonatomic,strong)NSArray *arr111;

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

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

@property(nonatomic,strong)NSString *longtitudeAndLatitude;
@property(nonatomic,strong)NSString *GPS;


@property (weak, nonatomic) IBOutlet UILabel *weather_label;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollViewNews;

@property (weak, nonatomic) IBOutlet UIImageView *weather_image;

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

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


//雷俊博
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *BannerScrollViewtopConstraints;

//雷俊博



@property (weak, nonatomic) IBOutlet UITableView *tableViewNews;
@property(nonatomic,strong)	 newsViewModel *viewModel;

@property(nonatomic,strong)NSArray *newsArray;


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

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIImageView *loadingImageView;

@property (weak, nonatomic) IBOutlet UIImageView *moneyCount;


@end

@implementation ViewController
{
    int ingeerr;
    
}

#pragma mark - cycle
- (void)viewDidLoad {
    
    [super viewDidLoad];  
    [self locationDisplay];
    [self getOCR];

    [NewEditionTestManager checkNewEditionWithAppID:@"1227583739" ctrl:self]; //1种用法，系统Alert
    self.scrollViewNews.bounces =NO;
    self.scrollViewNews.showsVerticalScrollIndicator = NO;
    self.tableViewNews.bounces = NO;
    self.tableViewNews.sectionFooterHeight = 6;
  self.tableViewNews.contentInset = UIEdgeInsetsMake(0, 0,5, 0);
       self.KKtableHeight.constant = 663+114-208-20-75-75-10+6 + 34 + 10+30;
    
    //修改banner约束
    self.BannerScrollViewtopConstraints.constant = -statusRect.size.height;
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(skipCoinDetailVC:) name:@"authenticationCoinsSkip" object:nil];
    
    //观察跳转广告页
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToAd:) name:@"ZLPushToAdvert" object:nil];
    
}

-(void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:YES];
     self.pushHidel.hidden = YES;
    
    //雷俊博
    //取消隐藏导航栏
    self.navigationController.navigationBarHidden = NO;
  
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    //雷俊博
    //隐藏导航栏
    //self.navigationController.navigationBarHidden = YES;
   
   
    self.pushHidel.hidden = NO;
 __block   AppDelegate * app = (AppDelegate*)[[UIApplication sharedApplication]delegate];
    self.navigationController.navigationBar.translucent = YES;
    [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWWAN:
            case AFNetworkReachabilityStatusReachableViaWiFi:
                app.onLine = YES;
                break;
            case AFNetworkReachabilityStatusNotReachable:
                
            default:
                  [self NETWORKing];//添加本地图片
                app.onLine = NO;
                [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"networkCantUse"];
                if (app.onLine == NO ) {
                         [SVProgressHUD doneShow];
                    [SVProgressHUD showErrorWithStatus:@"网络状态不佳"];
                    return;
                }        
                break;
        }
    }];
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"networkCantUse"] == NO) {
        self.weather_label.text =@"天气:晴";
     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"networkCantUse"];
    }

    
    
    if ([[UIScreen mainScreen]bounds].size.height  == 736 ) {

        self.heighForIphone6Plus.constant = NUMBERFORHEIGHT;
        self.heightForIphone6plus_2.constant = NUMBERFORHEIGHT_2;
    }else if ([[UIScreen mainScreen]bounds].size.height  == 568){
        self.heighForIphone6Plus.constant = NUMBERFORHEIGHT;
        self.heightForIphone6plus_2.constant = NUMBERFORHEIGHT_2;
        self.controllerForTopheight.constant =160.426;
    }else{
    self.heighForIphone6Plus.constant = NUMBERFORHEIGHT;
        self.heightForIphone6plus_2.constant = NUMBERFORHEIGHT_2;
    }
    
    
//    NSString *path=[[NSBundle mainBundle] pathForResource:@"socialNews" ofType:@"plist"];
//
//
//    self.newsArray = [[NSArray alloc]init];
//    self.newsArray = [NSArray arrayWithContentsOfFile:path];
//
//


    
    
 self.navigationController.toolbarHidden=YES;
    
   
    getPeopleID *pi = [[getPeopleID alloc]init];
  

     self.arr111 =[[pi readPlist] copy];

    if(_arr111.count ==0){
        [self.mianfeifabu setBackgroundImage:[UIImage imageNamed:@"菜谱2"] forState:UIControlStateNormal];
        [self.searchTrafficViolation setBackgroundImage:[UIImage imageNamed:@"电台2"] forState:UIControlStateNormal];
        [self.medcine setBackgroundImage:[UIImage imageNamed:@"万年历2"] forState:UIControlStateNormal];
        [self.zhiwuxinxi setBackgroundImage:[UIImage imageNamed:@"免费发布2"] forState:UIControlStateNormal];
      
    }else{

       [self.mianfeifabu setImage:[UIImage imageNamed:@"万年历2"]  forState:normal];
         [self.mianfeifabu setTitle:@"万年历" forState:normal];
        [self.searchTrafficViolation setImage:[UIImage imageNamed:[self.arr111[2] stringByAppendingString:@"2"]]  forState:normal];

        if([getPeopleID LimmitedToBanbana] == YES){
            [self.searchTrafficViolation setImage:[UIImage imageNamed:@"短视频2"]  forState:normal];
        [self.searchTrafficViolation setTitle:@"短视频" forState:normal];

        }else{
          [self.searchTrafficViolation setTitle:self.arr111[2] forState:normal];
        }
        
        
        if([getPeopleID LimmitedToBanbana] == YES){
            [self.medcine setImage:[UIImage imageNamed:@"抢红包2"] forState:normal];
            self.moneyCount.image = [JobUtil changeImageToGit:@"haveMoney.gif"];
          [self.medcine setTitle:@"抢红包" forState:normal];
        }else{
             [self.searchTrafficViolation setImage:[UIImage imageNamed:[self.arr111[1] stringByAppendingString:@"2"]]  forState:normal];

              [self.medcine setTitle:self.arr111[1] forState:normal];

        }
        
        [self.zhiwuxinxi  setImage:[UIImage imageNamed:[self.arr111[0] stringByAppendingString:@"2"]]  forState:normal];
        [self.zhiwuxinxi  setTitle:self.arr111[0] forState:normal];
    }
    if ([getPeopleID LimmitedToBanbana] == YES) {

        
        [self.pai_er_three setImage:[UIImage imageNamed:@"水滴互助"] forState:UIControlStateNormal];
        [self.pai_er_three  setTitle:@"互助宝" forState:normal];
        
    }else{
        [self.pai_er_three setImage:[UIImage imageNamed:@"智慧出行20"] forState:UIControlStateNormal];
        [self.pai_er_three  setTitle:@"智慧出行" forState:normal];
    }
    
   
    
    
    [self.socialSecurity setTitle:@"电子社保卡" forState:UIControlStateNormal];
    NSURL * alipay_app_url = [NSURL URLWithString:@"alipay://"];
    
    BOOL ali = [[UIApplication sharedApplication] canOpenURL:alipay_app_url];
    if (ali) {
        [self.socialSecurity setImage:[UIImage imageNamed:@"home_Electronicsocialsecuritycard_normal"] forState:UIControlStateNormal];
    }
    [self initButton:self.socialSecurity];
    [self initButton:self.waterPay];
    [self initButton:self.nongzi];
    [self initButton:self.shenghuojifei];
    [self initButton:self.searchExpressage];
    [self initButton:self.mianfeifabu];
    [self initButton:self.searchTrafficViolation];
    [self initButton:self.medcine];
    [self initButton:self.zhiwuxinxi];
    [self initButton:self.pai_er_one];
    [self initButton:self.pai_er_two];
    [self initButton:self.pai_er_three];
    [self initButton:self.pai_er_four];
//    [self.tableViewNews reloadData];
    
    [self changeABC];
}



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

- (void)dealloc
{
    NSLog(@"首页被销毁了");
    [[NSNotificationCenter defaultCenter ]removeObserver:self name:@"authenticationCoinsSkip" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"ZLPushToAdvert" object:nil];
}

-(void)searchProgress{
    
    
    [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)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    NSLog(@"内存不够了");
}

-(void)NETWORKing{
                dispatch_async(dispatch_get_main_queue(), ^{
                    UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"005.jpg"]];
                    backgroundView.frame = self.view.bounds;
                    [self.view addSubview:backgroundView];
                    int g = 180;
                    if ([[UIScreen mainScreen]bounds].size.height  == 568){

                        g =152.42;
                    }
                    UIScrollView *demoContainerView = [[UIScrollView alloc] initWithFrame:CGRectMake(self.scrollViewNews.bounds.origin.x, 0, self.view.bounds.size.width, g)];
                    demoContainerView.contentSize = CGSizeMake(self.view.frame.size.width, 300);
                    [self.scrollViewNews addSubview:demoContainerView];
                    CGFloat w = self.view.bounds.size.width;
                    SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, w, g) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
                    demoContainerView.bounces=NO;
                    demoContainerView.scrollEnabled=NO;
                    cycleScrollView2.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
                    cycleScrollView2.autoScrollTimeInterval = 3.0;
           cycleScrollView2.titlesGroup = @[@"看看社保",@"智慧人设 服务民生",@"社保新局面"];
                    cycleScrollView2.currentPageDotColor = [UIColor whiteColor];
                    
       __block  NSMutableArray *array2 =[NSMutableArray new];
                        [array2 removeAllObjects];
                        [array2 addObject:[UIImage imageNamed:@"shouye0.jpg"]];
                        [array2 addObject:[UIImage imageNamed:@"shouye1.jpg"]];
                        [array2 addObject:[UIImage imageNamed:@"shouye2.jpg"]];
                        cycleScrollView2.localizationImageNamesGroup = array2;
                    [demoContainerView addSubview:cycleScrollView2];
                    
                   
                });
}
-(void)acquirePicture:(CLPlacemark*)placeMark andL:(CLLocation *)location
{

     [self NETWORKing];
    
     NSDictionary *addressDic = placeMark.addressDictionary;
      NSString *subLocality=[addressDic objectForKey:@"SubLocality"];

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    [NewsNetModel acquirePicture:MHSafeString(subLocality)  andlocationCoordinate:[NSString stringWithFormat:@"%ld,%ld",(long)location.coordinate.latitude,(long)location.coordinate.longitude] andint:1 complete:^(homePageNewsModel* model, NSError *error) {
        
        if (error) {
               [self NETWORKing];
            return ;
        }
        
    __block  NSMutableArray *array1 =[NSMutableArray new];
     __block  NSMutableArray *array2 =[NSMutableArray new];
 
       // [self.arrayT addObjectsFromArray:model.Result];
        [self.arrayT removeAllObjects];
        for (int i = 0; i < model.Result.count; i++) {
            NSArray *retArray = (NSArray *)model.Result;
            [self.arrayT addObject:retArray[i]];
        }

        [array1 removeAllObjects];
        [array2 removeAllObjects];
        for ( homePageNewsResultModel*str1 in model.Result) {
            [array1 addObject:(NSString*)str1.title];
              [array2 addObject:(NSString*)str1.KKImage];
            NSLog(@"%@",str1.title);
            NSLog(@"%@",array1);
             NSLog(@"%@",array2);
        }


        
        

        dispatch_async(dispatch_get_main_queue(), ^{

            UIImageView *backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"005.jpg"]];
            backgroundView.frame = self.view.bounds;
            [self.view addSubview:backgroundView];
            int g = 180;
            if ([[UIScreen mainScreen]bounds].size.height  == 568){
                
                g =152.42;
            }
            
        
            
            
            UIScrollView *demoContainerView = [[UIScrollView alloc] initWithFrame:CGRectMake(self.scrollViewNews.bounds.origin.x, 0, self.view.bounds.size.width, g)];
            demoContainerView.contentSize = CGSizeMake(self.view.frame.size.width, 300);
            [self.scrollViewNews addSubview:demoContainerView];
            CGFloat w = self.view.bounds.size.width;
            SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, w, g) delegate:self placeholderImage:[UIImage imageNamed:@"shouye1.jpg"]];
            demoContainerView.bounces=NO;
            demoContainerView.scrollEnabled=NO;
            cycleScrollView2.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
            cycleScrollView2.autoScrollTimeInterval = 3.0;
            if (array1.count>0) {
                cycleScrollView2.titlesGroup = array1;
            }else{
                   cycleScrollView2.titlesGroup = @[@"看看社保",@"智慧人设 服务民生",@"社保新局面"];
            }
            cycleScrollView2.currentPageDotColor = [UIColor whiteColor]; // 自定义分页控件小圆标颜色
            self.isgetter =TRUE;//我改动的地方
            
            if (array2.count>0) {
                if (![array2[0] containsString:@"05"]) {
                    self.isgetter =FALSE;
                }
                if (![array2[1] containsString:@"13"]) {
                    self.isgetter =FALSE;
                }
                if (![array2[2] containsString:@"20"]) {
                    self.isgetter =FALSE;
                }
            }
            
            
            
            if ( self.isgetter ==FALSE) {

                 cycleScrollView2.imageURLStringsGroup =array2;
            }else{
                [array2 removeAllObjects];
               
                [array2 addObject:[UIImage imageNamed:@"shouye0.jpg"]];
                [array2 addObject:[UIImage imageNamed:@"shouye1.jpg"]];
                [array2 addObject:[UIImage imageNamed:@"shouye2.jpg"]];
                cycleScrollView2.localizationImageNamesGroup = array2;
            }
            
            
            [demoContainerView addSubview:cycleScrollView2];
            
         });
   }];
      });
}


-(void)drawALine
{

}

-(void)locationDisplay
{
    
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"weatherti1"]==nil) {
        self.weather_label.text=  @"天气:晴";
        self.weather_image.image = [UIImage imageNamed:@"W0"];
    }
    
       [self acquirePicture:nil andL:0];
    
    
    
    
    [[XWLocationManager sharedXWLocationManager] getCurrentLocation:^(CLLocation *location, CLPlacemark *placeMark, NSString *error) {
        
        
        
        
        
        
        
        if (error) {
            self.loactionText.text = MHSafeString(@"当前无法定位");
            NSLog(@"定位出错,错误信息:%@",error);
            [SVProgressHUD showErrorWithStatus:@"当前网络状态不佳"];
            return;
        }else{
            NSLog(@"     定位成功:经度:%f 纬度:%lf 当前地址:%@  \n location详细信息:%@ \n ",location.coordinate.latitude, location.coordinate.longitude, placeMark.name, location);
             AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
            delegate.jin =[NSString stringWithFormat:@"%f",location.coordinate.latitude];
            delegate.wei =[NSString stringWithFormat:@"%f",location.coordinate.longitude];
            
            //雷俊博注释,该接口已失效
           // weatherObject *weaher =[weatherObject new];
            /*[weaher weathermessage:^(NSError *error) {
 dispatch_async(dispatch_get_main_queue(), ^{
                if ([weaher.haveSomeThing isEqualToString:@"have"]) {
                    [[NSUserDefaults standardUserDefaults] setObject:weaher.strWeather  forKey:@"weatherti1"];
                    [[NSUserDefaults standardUserDefaults]synchronize];
                    [[NSUserDefaults standardUserDefaults] setObject:weaher.imageWeather forKey:@"weatherti2"];
                    [[NSUserDefaults standardUserDefaults]synchronize];
                }

         self.weather_label.text=  [[NSUserDefaults standardUserDefaults] objectForKey:@"weatherti1"];
         self.weather_image.image = [UIImage imageNamed: [[NSUserDefaults standardUserDefaults] objectForKey:@"weatherti2"]];
     
     

                 });

             }];*/
            NSString *url = @"http://ttsbapi.tianqistatic.com/weather.html";
            AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
            manager.requestSerializer = [AFHTTPRequestSerializer serializer];
            manager.responseSerializer = [AFHTTPResponseSerializer serializer];
            manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
            //默认:application/x-www-form-urlencoded
            [manager.requestSerializer setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
            
            manager.requestSerializer.timeoutInterval = 20;
            [manager POST:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              
                if (responseObject) {
                    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                    NSLog(@"%@",dic);
                    
                    [[NSUserDefaults standardUserDefaults]setObject:dic forKey:@"TQData"];
                    [[NSUserDefaults standardUserDefaults]synchronize];
                }
                
                
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
               
            }];
            
          
                
                
                NSDictionary *addressDic = placeMark.addressDictionary;
                //NSString *state=[addressDic objectForKey:@"State"];
                NSString *city=[addressDic objectForKey:@"City"];
               // NSString *subLocality=[addressDic objectForKey:@"SubLocality"];
               // NSString *street=[addressDic objectForKey:@"Street"];
            AppDelegate *dele=(AppDelegate*)[[UIApplication sharedApplication]delegate];
            [getPeopleID getAppleyPay:MHSafeString(city)];
            if ([getPeopleID applePaycity]) {
                dele.isLogin=YES;
            }else{
                dele.isLogin=NO;
            }
            
            [self.loactionText setText:[NSString stringWithFormat:@"%@%@%@",
                                        MHSafeString(placeMark.administrativeArea),
                                        MHSafeString(placeMark.thoroughfare),
                                        MHSafeString(placeMark.name)
                                        ]];
          
            self.GPS =self.loactionText.text;

        }
    } onViewController:self];

}

-(void)inWeather{
    waterViewController *waterV = [[waterViewController alloc]init];
    [self presentViewController:waterV animated:YES completion:^{
        
    }];
    
}



- (IBAction)buttonForSocialAll:(UIButton *)sender {
    if(sender == self.socialSecurity){

        

        
   if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
       
       
       NSURL * alipay_app_url = [NSURL URLWithString:@"alipay://"];
       
       BOOL ali = [[UIApplication sharedApplication] canOpenURL:alipay_app_url];
       if (ali) {
           [self skipToAliSSCard];
           //[self jumpToHTML5:@"https://ur.alipay.com/383cSU" andJAnalytics:@"电子社保卡"];
           return;
       }
       
       governmentViewController *gVC   =   [[governmentViewController alloc]init];gVC.hidesBottomBarWhenPushed =YES;if ([getPeopleID getpeopleLimited]  ==YES) gVC.personPrivate =1; else gVC.personPrivate =0;[self.navigationController pushViewController:gVC  animated:YES];}else{
       
//       LoginViewController *logVC =    [LoginViewController sharedInstance];logVC.hidesBottomBarWhenPushed =YES;
//       if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//               [self.navigationController pushViewController:logVC animated:YES];
//       }
       LoginVC *loginVC = [[LoginVC alloc]init];
       UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
       [self presentViewController:nav animated:YES completion:nil];
   }
     
    }else if(sender == self.waterPay){

if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
    [self performSegueWithIdentifier:@"socialSecurity" sender:self];}else{
//    LoginViewController *logVC =    [LoginViewController sharedInstance];
//    logVC.hidesBottomBarWhenPushed =YES;
//    if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//        [self.navigationController pushViewController:logVC animated:YES];
//    }
        LoginVC *loginVC = [[LoginVC alloc]init];
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
        [self presentViewController:nav animated:YES completion:nil];
    
}
    
    
    
    }else if(sender == self.mianfeifabu){

      
        if (self.arr111.count == 0)
            [self functionAllAnd:@"菜谱"];
        else

         [self functionAllAnd:@"万年历"];
        
    }else if (sender ==self.zhiwuxinxi){
      if (self.arr111.count == 0)
            [self functionAllAnd:@"快递查询"];
        else
          [self functionAllAnd:self.arr111[0]];
 
    }else if (sender ==self.searchTrafficViolation)
    {

        
        if (self.arr111.count == 0)
            [self functionAllAnd:@"电台"];
        else

            [self functionAllAnd:@"短视频"];

        
        
    }else if(sender==self.nongzi){

       

        
 
        NSDate*date = [NSDate date];
        NSCalendar*calendar = [NSCalendar currentCalendar];
        NSDateComponents*comps;

        comps =[calendar components:(NSCalendarUnitWeekOfYear | NSCalendarUnitWeekday |NSCalendarUnitWeekdayOrdinal)
                           fromDate:date];
        NSInteger week = [comps weekOfYear]; // 今年的第几周
        if(week > 0){
            if (week %2 == 0) {
         NONGZI
            }else{

                
                WKSuperViewController *tc=[[WKSuperViewController alloc]init];
                tc.titleStr=@"民政信息";
                tc.pathStr=@"http://www.mca.gov.cn/wap/";
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
  
            }

        }
        
        
    }else if (sender==self.shenghuojifei){

        [self searchProgress];
       
        
        
       
        
    }else if(sender == self.medcine){


        if (self.arr111.count == 0){
            [self functionAllAnd:@"万年历"];
    }else{
        ingeerr ++;
        if ([getPeopleID LimmitedToBanbana] == YES) {
            

            
            if(ingeerr % 2 == 0){

                WKSuperViewController *tc=[[WKSuperViewController alloc]init];
                tc.titleStr=@"支付宝抢红包";
                tc.pathStr=@"https://render.alipay.com/p/f/jfxb4alj/pages/receive-redpacket/index.html?partnerId=&sharedUserId=&shareUserId=2088331168368991&__webview_options__=ttb%253Dauto&shareChannel=QRCode&sceneCode=KF_DYW04";
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
                
                
               
                
            }else{
           
                WKSuperViewController *tc=[[WKSuperViewController alloc]init];
                tc.titleStr=@"银联抢红包";
                tc.pathStr=@"https://wallet.95516.com/s/wl/webV3/activity/vInvite/html/snsIndex.html?code=bdyx&from=groupmessage&isappinstalled=0";
                tc.hidesBottomBarWhenPushed =YES;
                [self.navigationController pushViewController:tc animated:YES];
                
            }

            
            
        }else{
     [self functionAllAnd:self.arr111[1]];
        }
        

        
        
    }

            
            
            
            
        
    }else if(sender ==self.pai_er_one){
      

                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];
                }

    }else if(sender ==self.pai_er_two){
        
        //以前人写的
      //MIANFIFABU
        
        //雷俊博
        NSString * strA = @"https://kksb.wy.guahao.com/ask/entry/introduce?pageFrom=10020";
        
        
        [self jumpToHTML5:strA andJAnalytics:@"快速问诊"];
        
    }else if(sender ==self.pai_er_three){
        NSString * strA = @"https://www.shuidihuzhu.com/toufang/throwIn?typeFrom=external&channel=sdhzkksb";
        
        
        [self jumpToHTML5:strA andJAnalytics:@"水滴互助"];

//
//        if ([getPeopleID LimmitedToBanbana] == YES) {
//
//
//            if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
//
//                [weatherNetModel findJobInfoLoginID:0 handle:^(verifyAdressModel *model, NSError *error) {
//                    if (error) {
//                        return;
//                    }
//
//                    if (model.state == 404 ) {
//                        FiveEightCityViewController *moasd =[[FiveEightCityViewController alloc]init];
//                        moasd.hidesBottomBarWhenPushed =YES;
//                        [self.navigationController pushViewController:moasd animated:YES];
//                    }else{
//                        if (model.state  == 200 ) {
//                            if (model.RESULT) {
//                                NSString * pathNew1 =  [model.RESULT stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//                                NSLog(@"%@",model.RESULT);
//
//                                [self jumpToHTML5:pathNew1 andJAnalytics:@"58速聘"];
//                            }
//                        }
//                    }
//
//                }];
//
//            }else{
//                    LoginViewController *logVC =    [LoginViewController sharedInstance];
//                    logVC.hidesBottomBarWhenPushed =YES;
//                    if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//                        [self.navigationController pushViewController:logVC animated:YES];
//                    }
//
//                }
//
//
//
//
//
//
//
//        }else{
//
//
//        }
 
        
    }else if(sender ==self.pai_er_four){
        ZHINENGKEFU
    
    }
    

    
    
    
}
-(void)jumpToHTML5:(NSString*)url andJAnalytics:(NSString*)janalytics
{
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    WebViewController *tc=[sb instantiateViewControllerWithIdentifier:@"webViewController"];
    tc.URL =[NSURL URLWithString:url];
            tc.hidesBottomBarWhenPushed =YES;
    tc.janalytics = janalytics;
    [self.navigationController pushViewController:tc animated:YES];

}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"socialSecurity"]) {
        PhotoViewController *cvc =segue.destinationViewController;
        cvc.hidesBottomBarWhenPushed =YES;
    }
    
    
    if ([segue.identifier isEqualToString:@"postMessage"])  {
        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)getSuperData
{
    __weak typeof(self) weakSelf = self;
    dispatch_group_t group = dispatch_group_create();
 
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getSuperCatalogcompletionHandle:^(postMessageModel *model, NSError *error) {
                [weakSelf.baocun removeAllObjects];
                if (model.Result.count >0) {
                    for (postMessageResultModel *models in model.Result) {
                        
                        [weakSelf.baocun addObject:models.categoryname];
                        NSLog(@"_superData:%@",weakSelf.baocun);
                    }
                }
                
             dispatch_group_leave(group);
        }];
        
 
    });
    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getChildCatalog:1 completionHandle:^(postMessageModel *model, NSError *error) {
   
                [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);
                    }
                    
                }
                
                     dispatch_group_leave(group);
        }];

  
    });
    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getChildCatalog:2 completionHandle:^(postMessageModel *model, NSError *error) {
            [self.array_k2 removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [weakSelf.array_k2 addObject:models.categoryname];
                }
            }
                  dispatch_group_leave(group);
        }];

        
    });
    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getChildCatalog:3 completionHandle:^(postMessageModel *model, NSError *error) {
            [weakSelf.array_k3 removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [weakSelf.array_k3 addObject:models.categoryname];
                }
            }
                dispatch_group_leave(group);
        }];
  
        
    });
    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getChildCatalog:4 completionHandle:^(postMessageModel *model, NSError *error) {
            [weakSelf.array_k4 removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [weakSelf.array_k4 addObject:models.categoryname];
                }
            }
                 dispatch_group_leave(group);
        }];
 
        
    });
    dispatch_group_async(group, queue, ^{
        dispatch_group_enter(group);
        [postMessageMNet getChildCatalog:5 completionHandle:^(postMessageModel *model, NSError *error) {
            [weakSelf.array_k5 removeAllObjects];
            if (model.Result.count >0) {
                for (postMessageResultModel *models in model.Result) {
                    
                    [weakSelf.array_k5 addObject:models.categoryname];
                }
            }
            
              dispatch_group_leave(group);
        }];
      
        
    });
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    });
    
    
    








    
}

#pragma mark - 跳转电子社保卡
- (void)skipToAliSSCard
{
    SSTerminationViewController *vc = [[SSTerminationViewController alloc]init];
    vc.title = @"电子社保卡";
    
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 跳转广告业
- (void)pushToAd:(NSNotification *)noti
{
    
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    WebViewController *tc=[sb instantiateViewControllerWithIdentifier:@"webViewController"];
    
    
    //urlPath
    NSDictionary *dict = noti.userInfo;
    tc.URL =[NSURL URLWithString: dict[@"url"]];
    tc.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:tc animated:YES];
}



#pragma mark - UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   return   1;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    //雷俊博
    if(indexPath.section == 1) {
        static NSString *cellIdentifier = @"littleProcedure";
        LittleProcedureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        
        if (cell == nil) {
            cell = [[[NSBundle mainBundle]loadNibNamed:@"LittleProcedureTableViewCell" owner:self options:nil]objectAtIndex:0];
        }
        
        return cell;
    }
    //雷俊博
    if (  indexPath.section == 2) {
        static NSString *CellIdentifier =@"myJDCell";
        myJDCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myJDCell"];
        if (cell == nil) {
            cell = [[myJDCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            
        }
     
        switch (indexPath.section) {
            case 1:
                cell.ASSName.text =nil;
                cell.ASSImage.image = [UIImage imageNamed:@""];
                if ([getPeopleID LimmitedToBanbana] == YES) {
                    //s正确
                   cell.ASSBackGuardImage.image =[UIImage imageNamed:@"国庆出行01"];
                }else{
                    
                    //错误
                   cell.ASSBackGuardImage.image =[UIImage imageNamed:@"国庆出行"];
                    
                }
                break;
                
            default:
                cell.ASSName.text =@"保险服务";
                cell.ASSImage.image = [UIImage imageNamed:@"保险服务9.4"];
                cell.ASSBackGuardImage.image =[UIImage imageNamed:@"保险9.4"];
                break;
        }
        
        return cell;
    }else if(indexPath.section == 0){
        static NSString *CellIdentifier =@"socialAssistant";
        socialAssistant *cell = [tableView dequeueReusableCellWithIdentifier:@"socialAssistant"];
     
        if (cell == nil) {
            cell = [[socialAssistant alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }
     __block  NSString *address = nil;
            [CityNetManager phonenumberAndCompletionHandle:^(resulTModel *model, NSError *error) {
                if (model.result  != nil) {
                    address = model.result;
                      NSLog(@"%@",address);
                    
                    if ([getPeopleID socialSate] == 0) {
                         if ([getPeopleID LimmitedToBanbana] == YES) {
                        cell.KKHide.text =@"足不出户,安全认证,放心领钱";
                         }else{
                        cell.KKHide.text =@"足不出户,安全认证,放心领钱";

                         }
                        cell.AAReccord.text =@"";
                        cell.AAImage.image= nil;
                        
                        cell.AAName.text =@"";
                        cell.AAId.text = @"";
                        cell.AATime.text =@"";
                        
                        
                    }else if ([getPeopleID socialSate] == 1 ){
                        //rengzhi
                        //我改动的地方
                        NSString *       path = [IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/myCertificationRecord"];
                        NSString *  cityAddressResult = @"";
                    NSString *CityAddress=    [[NSUserDefaults standardUserDefaults]objectForKey:@"provinceAABBCC"];

                        if([MHSafeString(CityAddress) isEqualToString:@""] || !CityAddress ){
                            cityAddressResult =MHSafeString(model.result);
                        }else{
                            cityAddressResult =MHSafeString(CityAddress);
                        }
                        
                        [CityNetManager myCertificationUserID:[getPeopleID PeopleID] andPage:1 province:MHSafeString(cityAddressResult) andPath:path completionHandle:^(socialModelRecord *model, NSError *error) {
                            if (error) {
                                return;
                            }
                            if (!model.result) {
                            }else{
                                //

                                if (model.result.count == 0) {
                                    return;
                                }else{
                                    socialResultModel *models =(socialResultModel*)model.result[0];
                                    NSLog(@"%@",models.createTime);
                                    cell.record =1;
                                    cell.socModel = models;

                                }



                            }


                        }];
                        
 
                        
                    }else{
                        
                        cell.KKHide.text =@"足不出户,安全认证,放心领钱";//我改动的地方
                        
                        
                        
                        cell.AAReccord.text =@"";
                        cell.AAImage.image= nil;
                        
                        cell.AAName.text =@"";
                        cell.AAId.text = @"";
                        cell.AATime.text =@"";
                    }
                }
                
            }];
        return cell;
    }else{
          //创建静态标识符
         static NSString *CellIdentifier =@"MyCell";
        
         //根据标识符从重用池取得cell
        MyTableViewCell_d *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
        
         //没有则创建新的cell
        if (cell == nil) {
            cell = [[MyTableViewCell_d alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }
        
        
UITapGestureRecognizer * tag = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
UITapGestureRecognizer * tag1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
        UITapGestureRecognizer * tag2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
        UITapGestureRecognizer * tag3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
                        switch (indexPath.section) {
                            case 3:

                                cell.imageleft.image =[UIImage imageNamed:@"大病求助"];
                                cell.imageright.image =[UIImage imageNamed:@"微医挂号"];
                                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                                cell.imageleft.tag = 1;
                                cell.imageright.tag =2;
                                cell.imageleft.userInteractionEnabled = YES;
                                cell.imageright.userInteractionEnabled = YES;
                            
                                [cell.imageleft addGestureRecognizer:tag];
                                [cell.imageright addGestureRecognizer:tag1];
                                
                               
                                

                                break;
                            case 4:
                                cell.imageleft.image =[UIImage imageNamed:@"在线问诊"];
                                cell.imageright.image =[UIImage imageNamed:@"海外医疗"];
                                cell.selectionStyle=UITableViewCellSelectionStyleNone;
                                cell.imageleft.tag = 3;
                                cell.imageright.tag =4;
                                cell.imageleft.userInteractionEnabled = YES;
                                cell.imageright.userInteractionEnabled = YES;
                                
                                [cell.imageleft addGestureRecognizer:tag2];
                                [cell.imageright addGestureRecognizer:tag3];
                                
                                
                                
                                break;

//
//                            case 5:
//        cell.newsTitle.text =self.newsArray[2][@"bigTitleNews"];
//                                [cell.imageNews sd_setImageWithURL:self.newsArray[2][@"imageNews"] placeholderImage:[UIImage imageNamed:@"shebao_3"]];
//                                cell.textNews.text =self.newsArray[2][@"titleNews"];
//
//                                break;
//                            case 6:
//        cell.newsTitle.text =self.newsArray[3][@"bigTitleNews"];
//                                [cell.imageNews sd_setImageWithURL:self.newsArray[3][@"imageNews"] placeholderImage:[UIImage imageNamed:@"shebao_4"]];
//                                cell.textNews.text =self.newsArray[3][@"titleNews"];
//                                break;
//                            case 7:
//                 cell.newsTitle.text =self.newsArray[4][@"bigTitleNews"];
//                                [cell.imageNews sd_setImageWithURL:self.newsArray[4][@"imageNews"] placeholderImage:[UIImage imageNamed:@"shebao_5"]];
//                                cell.textNews.text =self.newsArray[4][@"titleNews"];
//                                break;
                            default:
                                break;
                        }

                return cell;
        
        
        
    
    }
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    
    if (indexPath.section == 0) {
        return 110;
    }else if ( indexPath.section == 1){
    
        UIImage *image = [UIImage imageNamed:@"190123-微保乘驾险-V2.png"];
        float width = image.size.width;
        float height = image.size.height;
        float widthProportion = self.view.bounds.size.width / width;
        return  height * widthProportion;

    }else if (indexPath.section == 2){
        
        return  0;
        
    }else if (indexPath.section == 6){
        
          return  0;
        
    }else if (indexPath.section == 7){
        
           return  0;
        
    }else{
        
       UIImage *image = [UIImage imageNamed:@"大病求助"];
        CGFloat scale = image.size.height / image.size.width;
         return  (ScreenWidth - 30)/2 *scale;
        
    }
 
    
    

    
    
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    //不要显示
    if (section == 2 || section == 6 || section == 7) {
        return 0.00000000001;
    }else{
    
        return 10;
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.00001;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headView = [[UIView alloc]init];
    headView.backgroundColor = [UIColor clearColor];
    return headView;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return UITableViewAutomaticDimension;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    if (indexPath.section == 0) {
        
        SSPaymenyViewController *vc  = [[SSPaymenyViewController alloc]init];
        vc.title = @"社保自助缴纳";
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
        return;
        
        switch ([getPeopleID socialSate]) {
            case 1:
                if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
                    
                  
                    
                    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];



                    socialRecord*vc=[sb instantiateViewControllerWithIdentifier:@"socialRecord"];
                    vc.hidesBottomBarWhenPushed =YES;
                    [self.navigationController pushViewController:vc animated:YES];
                }else
                {
//                    LoginViewController *logVC =    [LoginViewController sharedInstance];
//                    logVC.hidesBottomBarWhenPushed =YES;
//                    if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//                        [self.navigationController pushViewController:logVC animated:YES];
//                    }
                    LoginVC *loginVC = [[LoginVC alloc]init];
                    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
                    [self presentViewController:nav animated:YES completion:nil];
                }
                break;
            case 2:
                if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
                    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
                    
                   
                    
                    socialRecord*vc=[sb instantiateViewControllerWithIdentifier:@"socialRecord"];
                    vc.record = 1;
                    vc.hidesBottomBarWhenPushed =YES;
                    [self.navigationController pushViewController:vc animated:YES];
                }else
                {
//                    LoginViewController *logVC =    [LoginViewController sharedInstance];
//                    logVC.hidesBottomBarWhenPushed =YES;
//                    if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//                        [self.navigationController pushViewController:logVC animated:YES];
//                    }
                    LoginVC *loginVC = [[LoginVC alloc]init];
                    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
                    [self presentViewController:nav animated:YES completion:nil];
                }
                
                break;
        }
        
    }else if (indexPath.section == 3 || indexPath.section == 4 || indexPath.section == 5 || indexPath.section == 6 || indexPath.section == 7  ){
        NSString *strURL  =@"";
        switch (indexPath.section) {
            case 3:
                
                //                http://politics.people.com.cn/n1/2017/0730/c1001-29436837.html
                //                strURL =@"https://mp.weixin.qq.com/s/d5m6gTS9M6qhccIBmJuI2w";
                break;
            case 4:
                
                //
                //                strURL =@"https://mp.weixin.qq.com/s/ZSQxoYi0UfcG3FYa6o2xtQ";
                break;
            case 5:
                
                //                strURL =@"https://mp.weixin.qq.com/s/urK_x8JrwbRAYac2WVWOrQ";
                break;
            case 6:
                
                //                strURL =@"https://mp.weixin.qq.com/s/dT-wxr-uR3sTXrXgBIP8AA";
                
                break;
            case 7:
                
                //           strURL=@"https://mp.weixin.qq.com/s/48YXQjhCIjIOk3swZe4Zag";
                break;
            default:
                break;
        }
        
        //        [self jumpToHTML5:strURL andJAnalytics:@"政务信息"];
        
    }else if(indexPath.section == 1){
        
        WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
        launchMiniProgramReq.userName = @"gh_f8a0e531525d";  //拉起的小程序的username
        launchMiniProgramReq.path = @"WXMiniPro://gh_f8a0e531525d/pages/base/redirect/index?routeKey=PH04_PRODUCT_TRANSFER_CY&wtagid=118.4.2";    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
        launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
        [WXApi sendReq:launchMiniProgramReq];
        
        
    }else if(indexPath.section == 2){
        
    }
    
    
    
    
}


#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", (long)index);
    
    if (self.arrayT) {
        homePageNewsResultModel *model = self.arrayT[index];
        if (model.targetUrl && ![model.targetUrl isEqualToString:@""]) {
            UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
            WebViewController *tc=[sb instantiateViewControllerWithIdentifier:@"webViewController"];
            tc.URL =[NSURL URLWithString:model.targetUrl];
              tc.janalytics = model.title;
            tc.hidesBottomBarWhenPushed =YES;
            tc.title = model.title;
            [self.navigationController pushViewController:tc animated:YES];

        }
    }
    
}

-(void)vcJumpOtherVc:(NSInteger)row
{
    
    governmentNewsViewController *gVC   =   [[governmentNewsViewController alloc]init];
    gVC.index = row;
    gVC.hidesBottomBarWhenPushed =YES;
    gVC.titleNews = self.newsArray[row][@"titleNews"];
    [self.navigationController pushViewController:gVC  animated:YES];
    
}





-(void)tapImageView
{

}

- (IBAction)jiazaigengduoxinwen:(id)sender {
    
   
}

#pragma mark - event response
-(void)skipCoinDetailVC:(NSNotification *)notif
{
    dispatch_async(dispatch_get_main_queue(), ^{
        
         //self.navigationController.toolbarHidden=NO;
        
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        UIViewController *vc = appDelegate.window.rootViewController;
      if ([vc isKindOfClass:[uitableViewController class]]){
            uitableViewController *tabvc = (uitableViewController *)vc;
            
            tabvc.selectedIndex = 3;
        }else if ([vc isKindOfClass:[tabViewController class]]){
            tabViewController *tabVC = (tabViewController*)vc;
            
            if ([tabVC.selectedViewController isKindOfClass:[uitableViewController class]]) {
                uitableViewController *myTabVC = (uitableViewController *)tabVC.selectedViewController;
                myTabVC.tabBar.hidden = NO;
                myTabVC.selectedIndex = 3;
            }
        }
        
    });
   
}
-(void)onClick:(UITapGestureRecognizer *)sender{
    
    if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
       
    
   
    long t = sender.view.tag;
    
    if (t == 1) {
        NSString * strA = @"https://www.shuidichou.com/tf/ads/business/register?channel=BD_cooperation_index_kankanshebao";
       
       
       [self jumpToHTML5:strA andJAnalytics:@"大病筹款"];
        
        
    }else if (t == 2){
        
        
          [self jumpToHTML5:@"https://qudao-1.wy.guahao.com/booking" andJAnalytics:@"医疗服务"];
        
        
    }else if(t == 3){
//        NSString * strA;
//        long i = [getPeopleID PeopleID];
//        NSString *s= [NSString stringWithFormat:@"%ld",i];
//        NSString *str = @"https://healthapi.axzchou.com/medicine/index?channel=kankan&loginId=";
//        strA = [str stringByAppendingString:s];
        
       // [self jumpToHTML5:@"https://kksb.wy.guahao.com/standard/index" andJAnalytics:@"在线问诊"];
        [self jumpToHTML5:@"https://kksb.wy.guahao.com/ask/entry/introduce?pageFrom=10020" andJAnalytics:@"在线问诊"];
        
    }else if (t == 4){
        NSString * strA;
        long i = [getPeopleID PeopleID];
        NSString *s= [NSString stringWithFormat:@"%ld",i];
        NSString *str = @"http://www.zhonghuijia.cn?cha?channel=kankan&loginId=";
        strA = [str stringByAppendingString:s];
        
        [self jumpToHTML5:strA andJAnalytics:@"海外医疗"];
        
    }
    }else{
//        LoginViewController *logVC =    [LoginViewController sharedInstance];
//        logVC.hidesBottomBarWhenPushed =YES;
//        if(![self.navigationController.topViewController isKindOfClass:[logVC class]]) {
//            [self.navigationController pushViewController:logVC animated:YES];
//        }
        LoginVC *loginVC = [[LoginVC alloc]init];
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:loginVC];
        [self presentViewController:nav animated:YES completion:nil];
        
    }
}
-(void)functionAllAnd:(NSString*)all
{
    
    if(![all isEqualToString:@"智慧出行"]){
        [getPeopleID changePlistContentand:all];
    }
    
    
    
    if ([all isEqualToString:@"火车票"]) {
        HUOCHEPIAO
    }else if([all isEqualToString:@"汽车票"]){
        
        QICHIPIAO
        
    }else if([all isEqualToString:@"飞机票"]){
        
        FEIJIPIAO
        
    }else if([all isEqualToString:@"电台"]){
        DIANTAI
        
        
    }else if([all isEqualToString:@"菜谱"]){
        
        
        CAIPU
    }else if([all isEqualToString:@"酒店"]){
        
        JIUDIAN
        
    }else if([all isEqualToString:@"万年历"]){
        RILI
    }else if([all isEqualToString:@"周边游"]){
        
        ZHOUBIANYOU
    }else if([all isEqualToString:@"运动"]){
        YUNDONG
    }else if([all isEqualToString:@"智慧出行"]){
        
    }else if([all isEqualToString:@"快递查询"]){
        KUAIDI
    }else if([all isEqualToString:@"抢红包"]){
        QIANGHONGBAO
    }else if([all isEqualToString:@"短视频"]){
        
        VideoVC *vc = [[VideoVC alloc]init];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}


#pragma mark - private methods
-(void)initButton:(UIButton*)button{
    
    CGFloat offset = 15.0f;
    button.titleEdgeInsets = UIEdgeInsetsMake(0, -button.imageView.frame.size.width, -button.imageView.frame.size.height-offset/2, 0);
    
    button.imageEdgeInsets = UIEdgeInsetsMake(-button.titleLabel.intrinsicContentSize.height-offset/2, 0, 0, -button.titleLabel.intrinsicContentSize.width);
    
}
- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize and:(UIImage*)imageKs
{
    UIImage *sourceImage = imageKs;
    UIImage *newImage = nil;
    CGSize imageSize = sourceImage.size;
    CGFloat width = imageSize.width;
    CGFloat height = imageSize.height;
    CGFloat targetWidth = targetSize.width;
    CGFloat targetHeight = targetSize.height;
    CGFloat scaleFactor = 0.0;
    CGFloat scaledWidth = targetWidth;
    CGFloat scaledHeight = targetHeight;
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
    
    if (CGSizeEqualToSize(imageSize, targetSize) == NO)
    {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;
        
        if (widthFactor > heightFactor)
            scaleFactor = widthFactor;
        else
            scaleFactor = heightFactor;
        scaledWidth= width * scaleFactor;
        scaledHeight = height * scaleFactor;
        
        
        if (widthFactor > heightFactor)
        {
            thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
        }
        else if (widthFactor < heightFactor)
        {
            thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
        }
    }
    
    UIGraphicsBeginImageContext(targetSize);
    
    CGRect thumbnailRect = CGRectZero;
    thumbnailRect.origin = thumbnailPoint;
    thumbnailRect.size.width= scaledWidth;
    thumbnailRect.size.height = scaledHeight;
    
    [sourceImage drawInRect:thumbnailRect];
    
    newImage = UIGraphicsGetImageFromCurrentImageContext();
    if(newImage == nil)
        NSLog(@"could not scale image");
    
    
    UIGraphicsEndImageContext();
    return newImage;
}

+ (UIImage *)thumbnailWithImage:(UIImage *)originalImage size:(CGSize)size
{
    
    CGSize originalsize = [originalImage size];
    
    //原图长宽均小于标准长宽的，不作处理返回原图
    
    if (originalsize.width<size.width && originalsize.height<size.height)
        
    {
        
        return originalImage;
        
    }
    
    
    
    //原图长宽均大于标准长宽的，按比例缩小至最大适应值
    
    else if(originalsize.width>size.width && originalsize.height>size.height)
        
    {
        
        CGFloat rate = 1.0;
        
        CGFloat widthRate = originalsize.width/size.width;
        
        CGFloat heightRate = originalsize.height/size.height;
        
        
        
        rate = widthRate>heightRate?heightRate:widthRate;
        
        
        
        CGImageRef imageRef = nil;
        
        
        
        if (heightRate>widthRate)
            
        {
            
            imageRef = CGImageCreateWithImageInRect([originalImage CGImage], CGRectMake(0, originalsize.height/2-size.height*rate/2, originalsize.width, size.height*rate));//获取图片整体部分
            
        }
        
        else
            
        {
            
            imageRef = CGImageCreateWithImageInRect([originalImage CGImage], CGRectMake(originalsize.width/2-size.width*rate/2, 0, size.width*rate, originalsize.height));//获取图片整体部分
            
        }
        
        UIGraphicsBeginImageContext(size);//指定要绘画图片的大小
        
        CGContextRef con = UIGraphicsGetCurrentContext();
        
        
        
        CGContextTranslateCTM(con, 0.0, size.height);
        
        CGContextScaleCTM(con, 1.0, -1.0);
        
        
        
        CGContextDrawImage(con, CGRectMake(0, 0, size.width, size.height), imageRef);
        
        
        
        UIImage *standardImage = UIGraphicsGetImageFromCurrentImageContext();
        
        
        
        UIGraphicsEndImageContext();
        
        CGImageRelease(imageRef);
        
        
        
        return standardImage;
        
    }
    
    
    
    
    else if(originalsize.height>size.height || originalsize.width>size.width)
        
    {
        
        CGImageRef imageRef = nil;
        
        
        
        if(originalsize.height>size.height)
            
        {
            
            imageRef = CGImageCreateWithImageInRect([originalImage CGImage], CGRectMake(0, originalsize.height/2-size.height/2, originalsize.width, size.height));
            
        }
        
        else if (originalsize.width>size.width)
            
        {
            
            imageRef = CGImageCreateWithImageInRect([originalImage CGImage], CGRectMake(originalsize.width/2-size.width/2, 0, size.width, originalsize.height));
            
        }
        
        
        
        UIGraphicsBeginImageContext(size);
        
        
        
        CGContextRef con = UIGraphicsGetCurrentContext();
        
        CGContextTranslateCTM(con, 0.0, size.height);
        
        CGContextScaleCTM(con, 1.0, -1.0);
        
        
        
        CGContextDrawImage(con, CGRectMake(0, 0, size.width, size.height), imageRef);
        
        
        
        UIImage *standardImage = UIGraphicsGetImageFromCurrentImageContext();
        
        NSLog(@"改变后图片的宽度为%f,图片的高度为%f",[standardImage size].width,[standardImage size].height);
        
        
        
        UIGraphicsEndImageContext();
        
        CGImageRelease(imageRef);
        
        
        
        return standardImage;
        
    }
    
    
    
    
    else
        
    {
        
        return originalImage;
        
    }
    
    
    
}

-(UIImage *)LoadingImageViews:(NSString *)baseImageName
{
    
    NSString  *name = baseImageName;
    NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];
    NSData  *imageData = [NSData dataWithContentsOfFile:filePath];
    
    if (!self.loadingImageView) {
        self.loadingImageView = [[UIImageView alloc]init];
    }
    self.loadingImageView.backgroundColor = [UIColor clearColor];
    
    self.loadingImageView.image = [UIImage sd_animatedGIFWithData:imageData];
    
    return self.loadingImageView.image;
    
}

-(void)getOCR
{
    
#if TARGET_IPHONE_SIMULATOR
    
#else
    Gint ret = 0;
    Gint vaule = 1;
    ret = TREC_StartUP(TREC_GetEngineTimeKEY());
    if (ret == 100) {
        return;
    }
    if (ret == 100) {
        return;
    }if (ret == 101) {
        return;
    }
    
    ret = TREC_SetParam(T_SET_HEADIMG, &vaule);
    ret = TREC_SetSupportEngine(TIDCARD2);// 演示使用身份证，其他证件以此类推
    if (ret != 1) {
        
        TREC_ClearUP();
        return;
    }
    
    ret = TREC_ClearUP();
#endif
    
}

#pragma mark - getters and setters

-(newsViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel =[newsViewModel new ];
    }
    return _viewModel;
}

-(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;
}

-(PostMessageViewModel *)postVM
{
    if (!_postVM) {
        _postVM =[PostMessageViewModel new];
    }
    return _postVM;
    
}

-(NSMutableArray *)arrayP
{
    if (_arrayP) {
        _arrayP =[NSMutableArray new];
    }
    return  _arrayP;
}
-(NSMutableArray *)arrayT
{
    if (!_arrayT) {
        _arrayT=[NSMutableArray new];
    }
    return _arrayT;
}











@end
