//
//  Log2ViewController.m
//  Open
//
//  Created by 雷俊博 on 2019/9/11.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "Log2ViewController.h"
#import "Constants.h"


#import "Log2TableViewCell.h"
#import "LogMiddleFunctionTableCell.h"
#import "LogFunctionItemsCell.h"
#import "Log2HeaderView.h"


#import "LoginVC.h"

#import "enterTableViewController.h"
#import "VoucherRecordViewController.h"
#import "SettingViewController.h"
#import "CoinsExchangeVC.h"
#import "CoinsDetailListVC.h"
#import "CoinsDetailListVC2.h"
#import "WithDrawViewController.h"
#import "CoinsCenterViewController.h"

#import "MyPrizeListVC.h"
#import "ShareViewController.h"

#import "UIImageView+WebCache.h"

#import "OnFootEarnCoinsViewController.h"


//比财
#import "AiDaAlertView.h"

#import "regardTableViewController.h"

#import <CoreMotion/CoreMotion.h>

#import "CTAPIBaseManager.h"

#import "StatisticsViewController.h"


#import "WXApi.h"



#import "FeedBackController.h"
#import "KKUserAuthViewController.h"
#import "KKUserAuthSuccessViewController.h"

//#import <YXLaunchAds/YXLaunchAds.h>

#import "KKYQModel.h"
#import "KKLogBannerModel.h"
#import "LogBannerView.h"

#import "MyRankViewController.h"
#import "MyWalletViewController.h"
#import "PersonInfoViewController.h"


//存钱罐
#import "SaveTabBarController.h"
#import "SaveProductListController.h"
#import "MyAssetsController.h"
#import "LittleGoldHouseWebVC.h"
#import "ProductDetailController.h"
#import "KKCLFundViewController.h"

//小满
#import <BXMediaSDK/BXMediaMaterialManager.h>
#import "KKActivityViewController.h"
#import "LogHiddenFunctionItemsCell.h"


#import "CoinsRankViewController.h"
#import "KKTodayProfitViewController.h"


#import "KKRedPackageClickEventModel.h"
#import "LogLeftCell.h"
#import "ScreeningView.h"
@interface Log2ViewController ()<UITableViewDelegate,UITableViewDataSource,LogHeaderViewDelegate,LogBannerViewDelegate,LogFunctionItemsCellDelegate,LogHiddenFunctionItemsCellDelegate,LogMiddleFunctionTableCellDelegate>
{
    NSInteger unreadCount;
}

@property (nonatomic, strong)UITableView *tableView;

@property (nonatomic, strong)NSArray *dataArray;

@property (nonatomic, strong)Log2HeaderView *headerview;

@property(nonatomic,strong)CMPedometer *pedometer;

@property(nonatomic, strong)KKYQModel *yqModel;

@property(nonatomic, strong)BXMMaterialModel *xmModel;

@property(nonatomic, assign)BOOL showBanner;

@property(nonatomic, assign)BOOL showSelfBanner;

@property(nonatomic, strong)NSArray* bannerArray;

@property(nonatomic, strong)UIView *logView;

@property(nonatomic, assign)BOOL showView;

@property (nonatomic, strong)BXMMaterialModel *materialModel;

@property (nonatomic, strong)NSMutableArray *DataArr;

@property (nonatomic, strong)NSMutableArray *midDataArr;
@end

@implementation Log2ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSLog(@"🎁 Log2ViewController viewDidLoad - 我的页面已加载");
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.tableView];
    
                                                                     
    
    [self addFloatingBtn];
  
    //登录成功通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(authStateUpdate) name:KKSBAccountAuthNotificationName object:nil];
    

    [self getMYBannerRequest];
    
    [self hiddenLogViewRequest];
    
    [self requestMidIconsAndTargetEvent];
    
    [self requestIconsAndTargetEvent];
    
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
//    self.navigationController.navigationBar.barTintColor = K_MainColor;
//
//    [self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
//        self.navigationController.navigationBar.barTintColor = K_MainColor;
//    } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
//    }];
    
    [self refreshCoins];
    
    [self getUnreadState];
    
   // [self.headerview refreshData];
    
    [self authStateUpdate];
    
    
    
    [self.navigationController.navigationBar navBarBackGroundColor:K_MainColor image:nil isOpaque:YES];//颜色
      
    [self.navigationController.navigationBar navBarBottomLineHidden:YES];
    
     [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [self hiddenrequest];
    
//    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"showSuspension"]) {
//       //悬浮按钮
//       [[clickEvent instance] SuspensionBtnRooterVC:self];
//    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:KKSBAccountAuthNotificationName object:nil];
}

- (void)addFloatingBtn
{
    NSLog(@"🎁 开始创建红包悬浮按钮");
    
    UIView * floatingView = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth - 120, ScreenHeight - TAB_BAR_HEIGHT - 123, 100, 100)];
    
    floatingView.hidden = YES;
    
    floatingView.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview:floatingView];
    
    NSLog(@"🎁 红包悬浮按钮容器创建完成 - 位置: %@", NSStringFromCGRect(floatingView.frame));
    
    UIImageView *iconImg = [[UIImageView alloc]initWithFrame:CGRectMake(28, 23, 44, 50)];
    iconImg.image = [UIImage imageNamed:@"mine_floating_redPackage"];
    [floatingView addSubview:iconImg];
    
    UILabel *lb_message = [[UILabel alloc]init];
    lb_message.backgroundColor = [UIColor colorWithHex:0xba1f1e];
    lb_message.text = @"可领取";
    lb_message.textColor = [UIColor colorWithHex:0xffdf95];
    lb_message.font = [UIFont systemFontOfSize:10];
    lb_message.textAlignment = NSTextAlignmentCenter;
    lb_message.layer.cornerRadius = 10;
    lb_message.layer.masksToBounds= YES;
    [floatingView addSubview:lb_message];
    [lb_message mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(iconImg);
        make.top.equalTo(iconImg.mas_bottom).offset(-16);
        make.width.offset(55);
        make.height.offset(20);
    }];
    
    UIButton *targetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [targetBtn addTarget:self action:@selector(targetBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [floatingView addSubview:targetBtn];
    [targetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.right.equalTo(floatingView);
    }];
    
    
    
    iconImg.layer.anchorPoint = CGPointMake(0.5, 1);
    
    [self startShowAnimationWithView:iconImg];
    
    NSLog(@"🎁 红包悬浮按钮创建完成 - 图片: %@, 动画已启动", iconImg.image);
    NSLog(@"🎁 按钮点击区域: %@", NSStringFromCGRect(targetBtn.frame));
    
    self.logView = floatingView;
}

- (void)startShowAnimationWithView:(UIView *)view{
    
    NSLog(@"🎁 开始启动红包悬浮按钮摇摆动画");
    
//    CABasicAnimation *displacementYAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
//    displacementYAnimation.fromValue = @(view.layer.position.y);
//    displacementYAnimation.toValue = @(view.layer.position.y-5);
//    displacementYAnimation.duration = 0.01;
//    displacementYAnimation.removedOnCompletion = NO;
//    displacementYAnimation.fillMode = kCAFillModeForwards;
    
    
    CABasicAnimation* startAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    startAnimation.toValue = [NSNumber numberWithFloat:-(M_PI/11) ];
    startAnimation.duration = 0.2;
    //startAnimation.beginTime = 0.01;
    startAnimation.cumulative = NO;
    startAnimation.removedOnCompletion = NO;
    startAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];;
    startAnimation.fillMode = kCAFillModeForwards;
 
    
    CABasicAnimation *backCenterAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    backCenterAnimation.toValue = [NSNumber numberWithFloat:0];
    backCenterAnimation.duration = 0.2;
    backCenterAnimation.beginTime = 0.2;
    backCenterAnimation.removedOnCompletion = NO;
    backCenterAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];;
    backCenterAnimation.fillMode = kCAFillModeForwards;
    
    
    CABasicAnimation *endAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    endAnimation.toValue = [NSNumber numberWithFloat:(M_PI/11) ];
    endAnimation.duration = 0.2;
    endAnimation.beginTime = 0.4;
    endAnimation.removedOnCompletion = NO;
    endAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];;
    endAnimation.fillMode = kCAFillModeForwards;
 
 
    CABasicAnimation *backAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    backAnimation.toValue = [NSNumber numberWithFloat:0];
    backAnimation.duration = 0.2;
    backAnimation.beginTime = 0.6;
    backAnimation.removedOnCompletion = NO;
    backAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];;
    backAnimation.fillMode = kCAFillModeForwards;
    
    
    CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
    animationGroup.animations = @[startAnimation,backCenterAnimation,endAnimation,backAnimation];
    animationGroup.duration = 0.8f;
    animationGroup.repeatCount = MAXFLOAT;
    animationGroup.removedOnCompletion = NO;
    animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];;
    [view.layer addAnimation:animationGroup forKey:@"rotationAnimationZ"];
    
    NSLog(@"🎁 红包悬浮按钮摇摆动画已启动 - 动画组包含 %lu 个动画", (unsigned long)animationGroup.animations.count);
    
}
//-(void)viewWillDisappear:(BOOL)animated
//{
//
//    [super viewWillDisappear:YES];
//
//    //雷俊博
//    //取消隐藏导航栏
//    if (!(self.presentedViewController || self.presentingViewController )) {
//          [self.navigationController setNavigationBarHidden:NO animated:animated];
//      }
//}
#pragma mark - 隐藏接口请求

- (void)hiddenrequest
{
    NSLog(@"🎁 开始请求红包悬浮按钮显示控制接口");
    
    NSString * url =[NSString stringWithFormat:@"%@%@",[NetworkConfig ipSwitchConfig],SwitchRequest];
    NSLog(@"🎁 请求URL: %@", url);
    
    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.headerview.showBtn = YES;
                  self.showView = YES;
                  [self.tableView reloadData];
                  [self.headerview refreshData];
              }
          }
          
          
      } Failure:^(NSError* error) {
         
    }];
}


- (void)hiddenLogViewRequest{
    
    NSString*version = [Tools getVersionCode];
    NSString *url = [NSString stringWithFormat:@"%@dynamic/menu/get",[NetworkConfig ipYinShuConfig]];
    //NSString *url = @"http://172.16.10.18:8017/dynamic/menu/get";
    
    NSDictionary *params = @{
        @"configName":@"WoDeXuanFuKuang",
        @"appName":@"kksh",
        @"version":version,
        @"systemType":@"iOS"
    };
    
    [NetworkRequest Post15:url Params:params Success:^(id _Nonnull objc) {
        
        NSLog(@"🎁 红包悬浮按钮显示控制请求返回: %@",objc);
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
            NSLog(@"🎁 服务器返回状态: %@", state);
            
            if ([state isEqualToString:@"200"]) {
                self.logView.hidden = NO;
                NSLog(@"🎁 红包悬浮按钮显示 - 服务器允许显示");
            }else{
                self.logView.hidden = YES;
                NSLog(@"🎁 红包悬浮按钮隐藏 - 服务器不允许显示，状态: %@", state);
            }
        }
 
    } Failure:^(NSError *error) {
        NSLog(@"🎁 红包悬浮按钮显示控制请求失败: %@",error);
        NSLog(@"🎁 红包悬浮按钮保持隐藏状态 - 网络请求失败");
        
    }];
    
}

#pragma mark - 账户实名通知
- (void)authStateUpdate {
    
    [self.headerview refreshData];
    [self.tableView reloadData];
    
}
#pragma mark - call api
- (void)refreshCoins
{
    
    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];
        [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
            
            if (error) {
                [SVProgressHUD showInfoWithStatus:@"无网络"];
                return ;
            }
            if (responseObj) {
                NSString *code = [responseObj[@"code"] stringValue];
                if ([code isEqualToString:@"0"]) {
                    [getPeopleID getTotalCoins:responseObj[@"result"]];
                   
                    [self.headerview refreshData];
                    
                    return ;
                }
            }
            
        
        }];
    }
}

- (void)getUnreadState
{
//    WeakSelf
    if ([getPeopleID PeopleID])
    {
        NSDictionary *params = @{
                                 @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                                 @"appType":FeedAppType
                                 };
        NSString *url =[NSString stringWithFormat:@"%@/socialsecurity/kankan/getUnreadState",IPDIZHI];
        
        [NetworkRequest SBAuthPost:url Params:params Success:^(id _Nonnull responseObj) {
            
            if ([responseObj isKindOfClass:[NSDictionary class]]) {
                NSString *code = [responseObj[@"code"] stringValue];
                if ([code isEqualToString:@"0"]) {
                    NSDictionary *dic = responseObj[@"result"];
                    if ([dic[@"newUnread"] isKindOfClass:[NSNumber class]] ) {
                        NSNumber *newUnread = dic[@"newUnread"];
                        
                        self->unreadCount = newUnread.integerValue;
                        [self.tableView reloadData];
                        if (self->unreadCount) {
                            [self.tabBarController.tabBar showBadgeOnItemIndex:3];
                        }else{
                            [self.tabBarController.tabBar hideBadgeOnItemIndex:3];
                        }
 
                    }

                    return ;
                }
            }
            
        } 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],BCMyAccountRuqest];
    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:[Log2ViewController 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 *)judgeAccountAuthRequestParams {
    NSString*tel =  [getPeopleID PeopleIphoneNmber];
    
    tel = [EnercryTool AES256Encrypt:tel key:DESKEY];
    NSDictionary *dic = @{
           @"tel":tel
       };
    
    return dic;
}

- (void)judgeAccountAuthStateRequest {
    
    NSString *urlString = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipESSCConfig],KKCheckAccountStateRequest];
    NSLog(@"判断账户是否已实名url:%@",urlString);
    NSLog(@"params:%@",[self judgeAccountAuthRequestParams]);
    [KKLoadingAnimationView show];
    [NetworkRequest SBAuthPost:urlString Params:[self judgeAccountAuthRequestParams] Success:^(id _Nonnull objc) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"objc:%@",objc);
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString* code = [NSString stringWithFormat:@"%@",objc[@"state"]];
            NSString* describe = [NSString stringWithFormat:@"%@",objc[@"describe"]];
            if ([code isEqualToString:@"200"]) {
                
                if ([objc[@"result"] isKindOfClass:[NSDictionary class]]) {
                    NSString* idcard = [NSString stringWithFormat:@"%@",objc[@"result"][@"idcard"]];
                    NSString* name = [NSString stringWithFormat:@"%@",objc[@"result"][@"name"]];
                    if ([self isKindOfClass:[Log2ViewController class]]) {
                        KKUserAuthSuccessViewController* vc = [KKUserAuthSuccessViewController new];
                        vc.nameTT = name;
                        vc.numTT = idcard;
                        vc.type = KKUserAuthFromVCTypeAccount;
                        vc.title = @"实名认证";
                        vc.hidesBottomBarWhenPushed = YES;
                        [self.navigationController pushViewController:vc animated:YES];
                    }
                   
                }
                
            }else if ([code isEqualToString:@"204"]) {
                KKUserAuthViewController* vc = [KKUserAuthViewController new];
                vc.title = @"实名认证";
                vc.type = KKUserAuthFromVCTypeAccount;
                vc.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:vc animated:YES];
            }else {
                [self alertShowMessage:describe];
            }
        }else{
            [self alertShowMessage:@"服务器异常"];
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [self alertShowMessage:@"网络异常"];
        
    }];
}

#pragma mark - 提示
- (void)alertShowMessage:(NSString *)msg
{
    if (@available(iOS 9.0,*)) {
        
        UIAlertController * alertV = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alertV addAction:confirm];
        
        [self presentViewController:alertV animated:YES completion:nil];
        
    }else{
        UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertV show];
    }
}


#pragma mark - 获取步数
//获取计步数
- (void)getStepCount
{
    
//    WeakSelf
    NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDate *now = [NSDate date];
    NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now];
    // 开始日期
    NSDate *startDate = [calendar dateFromComponents:components];
    // 结束日期
    NSDate *endDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:startDate options:0];
   
    //判断记步功能
    if ([CMPedometer isStepCountingAvailable]) {
        [self.pedometer queryPedometerDataFromDate:startDate toDate:endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
            if (error) {
                NSLog(@">>>error====%@",error);
                dispatch_async(dispatch_get_main_queue(), ^{
                     [Tools showMessage:@"请开启运动权限"];
                });
                
            }else {
                
                //self->open = YES;
                
                NSLog(@"步数====%@",pedometerData.numberOfSteps);
                NSLog(@"距离====%@",pedometerData.distance);
                NSInteger stepCount = pedometerData.numberOfSteps.integerValue;
                
                


                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    
                    
                    if([[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"]){
                         [self getstepRequest:stepCount distance:pedometerData.distance];
                    }
                    
                   
                });
            }
        }];
    }else{
        NSLog(@"记步功能不可用");
    }
}

- (NSDictionary *)getstepRequestPara:(NSInteger)step
{
    NSDictionary *dic = @{      @"userid":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                                @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                                @"stepNum":@(step),
                                @"reqStamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                                };
    NSArray *result = [dic.allKeys sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
              
              NSLog(@"%@~%@",obj1,obj2); //3~4 2~1 3~1 3~2
              
              return [obj1 compare:obj2]; //升序
              
          }];
          NSString *sign = nil;
          for (int i = 0; i < result.count; i++) {
              NSString *key = result[i];
              if (i==0) {
                  sign = [NSString stringWithFormat:@"%@=%@",key,dic[key]];
              }else{
                  
                  sign = [NSString stringWithFormat:@"%@&%@=%@",sign,key,dic[key]];
              }
          }
          
          sign = [NSString stringWithFormat:@"%@&Kanwf574",sign];
          
          NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithDictionary:dic];
          
          NSString *signString = [[MyMD5 md5:sign] lowercaseString];
          [params setObject:signString forKey:@"sign"];
    return params;
}


- (void)getstepRequest:(NSInteger)step distance:(NSNumber *)distance
{
    NSString *url = [NSString stringWithFormat:@"%@walkservice/getstep",CoinsBaseUrl];
    NSLog(@"获取指定用户的走路步数url:%@",url);
    NSLog(@"params:%@",[self getstepRequestPara:step]);
//    WeakSelf
    
    [CTAPIBaseManager POST:url params:[self getstepRequestPara:step] completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        if (error) {
            NSLog(@"error:%@",error);
            [SVProgressHUD showErrorWithStatus:@"无网络"];
        }
        
        if (responseObject) {
            NSLog(@"responseObject:%@",responseObject);
            
            if ([responseObject isKindOfClass:[NSDictionary class]]) {
                NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
                NSString *des = [NSString stringWithFormat:@"%@",responseObject[@"des"]];
                if ([code isEqualToString:@"0"] || [code isEqualToString:@"2006"]) {
//                    NSDictionary*result = responseObject[@"result"];
//                    NSNumber*num1 = result[@"stepNum"];
//                    NSNumber*num2 = result[@"shareNum"];
//                    NSInteger stepNum = num1.integerValue + num2.integerValue;
                    
                    StatisticsViewController*vc = [StatisticsViewController new];

                    vc.hidesBottomBarWhenPushed = YES;
                      
                    vc.title = @"健康统计";
                    vc.stepCount = [NSNumber numberWithInteger:step];
                    vc.distance = distance;

                    [self.navigationController pushViewController:vc animated:YES];
                    return;
            
                    
                    
                    
                }else if ([code isEqualToString:@"2002"]){
                    [SVProgressHUD showErrorWithStatus:@"当前时间与网络时间不一致!!!"];
                }else if ([code isEqualToString:@"1001"] || [code isEqualToString:@"9999"]){
                    [SVProgressHUD showErrorWithStatus:@"服务器繁忙,请稍等!!!"];
                }else if ([code isEqualToString:@"1009"]){
                    [SVProgressHUD showErrorWithStatus:@"服务器繁忙,请稍等!!"];
                } else{
                    [SVProgressHUD showErrorWithStatus:des];
                }
            }else{
               [SVProgressHUD showErrorWithStatus:@"服务器异常"];
            }
        }
        
        
    }];
}
#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    //return self.dataArray.count;
    
    if (self.showBanner) {
        return 4;
    }
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
//    NSArray *array = self.dataArray[section];
//    return array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.showBanner) {
        if (indexPath.section == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"registerCell"];
            if (cell == nil) {
                //确保它是simpleTableIdentifier创建的
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"registerCell"];
            }
            for (UIView *view in cell.contentView.subviews) {
                if ([view isKindOfClass:[UIView class]]) {
                    if (view.tag == 200) {
                        [view removeFromSuperview];
                    }
                }
            }
            if (self.showSelfBanner == NO) {
                UIImageView *iconImage = [[UIImageView alloc]init];
                iconImage.tag = 200;
                [cell.contentView addSubview:iconImage];
                if (self.yqModel) {
                    [iconImage sd_setImageWithURL:[NSURL URLWithString:self.yqModel.material_path]];
                }
                if (self.xmModel) {
                    [iconImage sd_setImageWithURL:[NSURL URLWithString:self.xmModel.materialPath]];
                }
                [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.center.equalTo(cell.contentView);
                    make.width.offset(ScreenWidth);
                    make.height.offset(75 * WIDTHRADIU);
                }];
            }else{
                if (self.bannerArray.count == 1) {
                    KKLogBannerModel *model = self.bannerArray[0];
                    UIImageView *iconImage = [[UIImageView alloc]init];
                    iconImage.userInteractionEnabled = YES;
                    iconImage.tag = 200;
                    [cell.contentView addSubview:iconImage];
                    [iconImage sd_setImageWithURL:[NSURL URLWithString:model.imagepath]];
                    [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.center.equalTo(cell.contentView);
                        make.width.offset(ScreenWidth);
                        make.height.offset(75 * WIDTHRADIU);
                    }];
                    //添加点击手势
                    UITapGestureRecognizer *tapTouch = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bannerTap)];
                    [iconImage addGestureRecognizer:tapTouch];
                }else if (self.bannerArray.count > 1){
                   LogBannerView *bannerView = [[LogBannerView alloc]initWithDataArray:self.bannerArray];
                   bannerView.delegate = self;
                   [cell.contentView addSubview:bannerView];
                    bannerView.tag = 200;
                    [bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.center.equalTo(cell.contentView);
                        make.width.offset(ScreenWidth);
                        make.height.offset(75 * WIDTHRADIU);
                    }];
                }
            }
            return cell;
            
        }else if (indexPath.section == 1){
            LogMiddleFunctionTableCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LogMiddleFunctionTableCell"];
            if (self.midDataArr.count > 0) {
                [cell refreshWithData:self.midDataArr];
            }
            cell.delegate = self;
            return cell;
        }else if (indexPath.section == 2){
            LogLeftCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LogLeftCell"];
            
            cell.delegate = self;
            return cell;
        }
        if (self.showView) {
            LogFunctionItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LogFunctionItemsCell"];
            cell.selectionStyle =  UITableViewCellSelectionStyleNone;
            if (self.DataArr.count > 0) {
                [cell refreshWithData:self.DataArr];
            }
            cell.delegate = self;
            return cell;
        }else{
            LogHiddenFunctionItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LogHiddenFunctionItemsCell"];
            cell.selectionStyle =  UITableViewCellSelectionStyleNone;
            cell.delegate = self;
            return cell;
        }
    }
    if (indexPath.section == 0){
        LogMiddleFunctionTableCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LogMiddleFunctionTableCell"];
        cell.delegate = self;
        return cell;
    }
    if (self.showView) {
        LogFunctionItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LogFunctionItemsCell"];
        cell.selectionStyle =  UITableViewCellSelectionStyleNone;
        cell.delegate = self;
        return cell;
    }else{
        LogHiddenFunctionItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LogHiddenFunctionItemsCell"];
        cell.selectionStyle =  UITableViewCellSelectionStyleNone;
        cell.delegate = self;
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.showBanner) {
        if (indexPath.section == 0) {
            return 75 * WIDTHRADIU;
        }else if (indexPath.section == 1){
            return  102 * WIDTHRADIU;
        }else if (indexPath.section == 2){
            return  105 * WIDTHRADIU;
        }
        if (self.showView) {
            return  257 * WIDTHRADIU;
        }
        return  175 * WIDTHRADIU;
    }
    if (indexPath.section == 0) {
        return  102 * WIDTHRADIU;
    }
    if (self.showView) {
        return  257 * WIDTHRADIU;
    }
    return  175 * WIDTHRADIU;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
//    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 5)];
//    view.backgroundColor = [UIColor redColor];
//    return view;
    
    return  nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (self.showBanner) {
        if (section == 1||section == 2) {
            return 10 * WIDTHRADIU;
        }
        return 0.0;
    }
    if (section == 0) {
        return 10 * WIDTHRADIU;
    }
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (self.showBanner ) {
        if (indexPath.section == 0) {
            if (self.showSelfBanner ) {
                if (self.bannerArray.count == 1) {
                    [self didClickScrollViewWithModel:self.bannerArray[0]];
                }
            }else{
                if (self.yqModel) {
                   [self getH52TaskWebViewWithPostID:@"kksh-wd-banner"];
                }else if (self.xmModel){
//                    6668
                    [NetworkRequest statisticsWithEventName:@"dialog_Mine_TigerSendMoney"];
//                    NSString*adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
                    [BXMediaMaterialManager entranceClickEventTrackingWithPlaceId:@"9193" userId:@"" materialModel:self.xmModel];
                    
                    KKActivityViewController *vc = [KKActivityViewController new];
                    vc.title = @"猛虎送财";
                    vc.placeId = @"9193";
//                    vc.buId = @"947689995";
//                    vc.gdtAdId = @"2082218177897738";
                    vc.hidesBottomBarWhenPushed = YES;
                    [self.navigationController pushViewController:vc animated:YES];
                }
            }
        }
    }
}


#pragma mark - LogHeaderViewDelegate
- (void)selectedItemButton:(NSInteger)index
{
    NSLog(@"我的界面点击按钮索引%ld",index);
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {
        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        return;
    }
    if (index == 200){
        [self goToCoinCenterVC];
     }else if (index == 201){
        // [self goToCoinsListVC];
         [self goToCoinRankVC];//金币累计排名
     }else if (index == 203){//养老钱包
         //[self goToMyWalletVC];
         [[clickEvent instance]clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/KK_WALLET" menuName:@"养老钱包"];//养老金
     }else if (index == 202){//我的收益
         //[self goToTodayProfitVC];
         //[[clickEvent instance]clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/KK_WALLET" menuName:@"养老钱包"];
         NSString *url=[NSString stringWithFormat:@"https://nginx.weface.com.cn/appH5/kk_wallet/#/?userId=%ld&phone=%@&from=incomerecord",(long)[getPeopleID PeopleID],[getPeopleID PeopleIphoneNmber]];
         WebVC *webvc = [[WebVC alloc]init];
         webvc.url = url;
         webvc.title = @"看看生活";
         webvc.hidesBottomBarWhenPushed = YES;
         [self.navigationController pushViewController:webvc animated:YES];
     }else if (index == 204){
         [self judgeAccountAuthStateRequest];
     }
    
    
}
#pragma mark - banner 单张图片点击
- (void)bannerTap{
    if (self.bannerArray.count > 0) {
        KKLogBannerModel *model = self.bannerArray[0];
        switch (model.eventflag.integerValue) {
            case 101:{
                [[clickEvent instance] clickEventRooterVC:self Content:model.targeturl menuName:model.title];
            }
                break;
            case 102:{
                
            }
                break;
            case 103:{
                if (![WXApi isWXAppInstalled]){
                    [Tools showMessage:@"请安装微信APP后重试"];
                    return;
                }
                if (model.title.length > 0 && model.targeturl.length > 0) {
                    NSString *userName = model.title;
                    NSString *path = model.targeturl;
                    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                    launchMiniProgramReq.userName = userName; //拉起的小程序的username
                    launchMiniProgramReq.path = path; //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                    [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {

                    }];
                }
            }
                break;
            case 104:{
                WebVC * vc = [WebVC new];
                vc.title= model.title;
                vc.url = model.targeturl;
                vc.hidesBottomBarWhenPushed = YES;
                [self.navigationController pushViewController:vc animated:YES];
            }
                break;
            default:
                break;
        }
    }
}
-(void) LogLeftClickWithIndex:(NSInteger)index{
    if (index==0) {//打卡领钱
        [[clickEvent instance] clickEventRooterVC:self Content:@"homeThree2" menuName:@"homeThree2"];
    }else{
        [[clickEvent instance]clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/JinBiShangChengUrl" menuName:@"金币商城"];
    }
    
}

#pragma mark - LogBannerViewDelegate
-(void)didClickScrollViewWithModel:(KKRedPackageClickEventModel *)model{
    switch (model.type.integerValue) {
            //原生跳转
        case 1001:{
            [[clickEvent instance] clickEventRooterVC:self model:model];
        }
            break;
        case 1002:
            //h5跳转
        {
            WebVC *vc = [[WebVC alloc]init];
            vc.title = model.menuName;
            vc.url = model.content;
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1003:
            //微信小程序
        {
            if (![WXApi isWXAppInstalled]){
                [Tools showMessage:@"请安装微信APP后重试"];
                return;
            }
            
            NSDictionary *resourceInfoDic = [self dictionaryWithJsonString:model.content];
            if (resourceInfoDic&& resourceInfoDic.allKeys.count > 1) {
                NSString *userName = resourceInfoDic[@"userId"];
                NSString *path = resourceInfoDic[@"path"];
                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                launchMiniProgramReq.userName = userName; //拉起的小程序的username
                launchMiniProgramReq.path = path; //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                    
                }];
            }
           
        }
            break;
//        case 1004:
//            //其他
//        {
//            NSDictionary *dic = [self dictionaryWithJsonString:model.content];
//            if (dic) {
//                [self push:dic model:model];
//            }
//        }
//            break;
        case 1005:
        {
            [self getFederatedLoginRequestWithModel:model];
        }
            break;
        default:
            break;
    }
}
- (void)setStatusBarBackgroundColor:(UIColor *)color
{
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = color;
    }
}

#pragma mark - LogFunctionItemsCellDelegate
- (void)LogFunctionItemsCellClickWithIndex:(NSInteger)index
{
    
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        
        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        
        return;

    }

    switch (index) {
        case 0:
        {
            [self goToPersonInfoVC];//个人信息
        }
            break;
        case 1:
        {
            [self judgeAccountAuthStateRequest];//实名认证
        }
            break;
        case 2:
        {
            [[clickEvent instance] clickEventRooterVC:self Content:@"homeThree4" menuName:@"存钱罐"];//我的资产
        }
            break;
        case 3:
        {
            [self goToAssetsRankVC];//收益排行榜
        }
            break;
        case 4:
        {
            [self goToSheBaoAuthListVC];//社保认证记录
        }
            break;
//        case 5:
//        {
//            [self goToSheBaoCollectionListVC];//社保采集记录
//        }
//            break;
        case 5:
        {
            [self jumpToHTML5:@"https://nginx.weface.com.cn/appH5/workApp/#/home" andJAnalytics:@"找工作"];
        }
            break;
        case 6:
        {
            [self goToInviteFriendsVC];//邀请好友
        }
            break;
        case 7:
        {
            [self goToSuggestionFeedBackVC];//意见反馈
        }
            break;
        case 8:
        {
            [self goToSettingVC];//设置
        }
            break;
        case 9:
        {
            [self goToAboutVC];//关于
        }
            break;
        default:
            break;
    }
}
- (void)goToClickRedPackageVCWithModel:(KKRedPackageClickEventModel *)model
{
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        
        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        
        return;

    }
    [NetworkRequest statisticsWithEventName:[NSString stringWithFormat:@"%@",model.ID]];
    switch (model.type.integerValue) {
        case 1001:
            //原生跳转
        {
            [[clickEvent instance] clickEventRooterVC:self Content:model.content menuName:model.menuName];
        }
            break;
        case 1002:
            //h5跳转
        {
            WebVC *vc = [[WebVC alloc]init];
            vc.title = model.menuName;
            vc.url = model.content;
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1003:
            //小程序
        {
            if (![WXApi isWXAppInstalled]){
                [Tools showMessage:@"请安装微信APP后重试"];
                return;
            }
            
            NSDictionary *resourceInfoDic = [self dictionaryWithJsonString:model.content];
            
            if (resourceInfoDic&& resourceInfoDic.allKeys.count > 1) {
                NSString *userName = resourceInfoDic[@"userId"];
                NSString *path = resourceInfoDic[@"path"];
                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                launchMiniProgramReq.userName = userName; //拉起的小程序的username
                launchMiniProgramReq.path = path; //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                    
                }];
            }
           
        }
            break;
        case 1004:
            //其他 反定向
        {
//            NSDictionary *dic = [self dictionaryWithJsonString:model.content];
//            if (dic) {
//                [self push:dic model:model];
//            }
            
        }
            break;
        case 1005:
        {
            [self getFederatedLoginRequestWithModel:model];
        }
            break;
        default:
            break;
    }

}
#pragma mark - LogHiddenFunctionItemsCellDelegate
- (void)LogHiddenFunctionItemsCellClickWithIndex:(NSInteger)index
{
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        
        return;

    }

    switch (index) {
        case 0:
        {
            [self goToPersonInfoVC];//个人信息
        }
            break;
        case 1:
        {
            NSLog(@"12424324");
            
            [self judgeAccountAuthStateRequest];//实名认证
        }
            break;
        case 2:
        {
            [self goToSheBaoAuthListVC];//社保认证记录
        }
            break;
//        case 3:
//        {
//            [self goToSheBaoCollectionListVC];//社保采集记录
//        }
//            break;
        case 3:
        {
            [self goToInviteFriendsVC];//邀请好友
        }
            break;
        case 4:
        {
            [self goToSuggestionFeedBackVC];//意见反馈
        }
            break;
        case 5:
        {
            [self goToSettingVC];//设置
        }
            break;
        case 6:
        {
            [self goToAboutVC];//关于
        }
            break;
            
        default:
            break;
    }
}
#pragma mark - 获取联合登录链接
- (void)getFederatedLoginRequestWithModel:(KKRedPackageClickEventModel *)model
{
    NSString *url = [NSString stringWithFormat:@"%@",model.content];
    
    url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet  URLQueryAllowedCharacterSet]];
    
    NSDictionary *params = @{
        @"uid":@([getPeopleID PeopleID]),
        @"tel":[getPeopleID PeopleIphoneNmber]
    };
    [KKLoadingAnimationView show];
    [NetworkRequest Get: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"]) {
            NSString *url = [NSString stringWithFormat:@"%@",objc[@"result"]];
//            url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet  URLQueryAllowedCharacterSet]];
            WebVC *webvc = [[WebVC alloc]init];
            webvc.url =  url;
            webvc.title = model.menuName;
            webvc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:webvc animated:YES];
            
        }else{
            [self alertShowMessage:describe];
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [self alertShowMessage:@"网络异常"];
    }];
    
}
#pragma mark - LogMiddleFunctionTableCellDelegate
- (void)LogMiddleFunctionTableCellClickWithIndex:(NSInteger)index
{
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        
        return;
    }
    
    switch (index) {
        case 0:
        {
            [self goToHeathStatisticsVC];//健康统计
        }
            break;
        case 1:
        {
            [self goToCoinLuckDrawVC];//金币抽奖
        }
            break;
        case 2:
        {
            [self goToMyPrizeListVC];//我的奖品
        }
            break;
        case 3:
        {
            //[self goToInviteFriendsVC];//邀请好友
            [self goToHuaFeeChargeVC];//话费充值
        }
            break;
            
        default:
            break;
    }
    
}
- (void)LogMiddleFunctionTableCellClickWithModel:(KKRedPackageClickEventModel *)model{
    NSInteger loginState = [UserDefault integerForKey:@"appleLoginState"];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"firstlog"] && loginState == 1031) {

        NSString* uid = [UserDefault objectForKey:@"appleId"];
        NSString* userId = [NSString stringWithFormat:@"%ld",[getPeopleID PeopleID]];
        NSString* cus_name = [getPeopleID Peopletitle];
        NSString* photoUrl = [getPeopleID PeoplePhoto].absoluteString;
        
        BPViewController *bpVC = [[BPViewController alloc]init];
        bpVC.UID = uid;
        bpVC.Id = userId;
        bpVC.wxName = [NSString blankString:cus_name] ? @"" :cus_name;
        bpVC.wxPhotoUrl = photoUrl;
        bpVC.title = @"绑定手机号";
        bpVC.from = @"other";
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:bpVC];
        [self presentViewController:nav animated:YES completion:nil];
        
        return;

    }
    [NetworkRequest statisticsWithEventName:[NSString stringWithFormat:@"%@",model.ID]];
    switch (model.type.integerValue) {
        case 1001:
            //原生跳转
        {
            [[clickEvent instance] clickEventRooterVC:self Content:model.content menuName:model.menuName];
        }
            break;
        case 1002:
            //h5跳转
        {
            WebVC *vc = [[WebVC alloc]init];
            vc.title = model.menuName;
            vc.url = model.content;
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1003:
            //小程序
        {
            if (![WXApi isWXAppInstalled]){
                [Tools showMessage:@"请安装微信APP后重试"];
                return;
            }
            NSDictionary *resourceInfoDic = [self dictionaryWithJsonString:model.content];
            
            if (resourceInfoDic&& resourceInfoDic.allKeys.count > 1) {
                NSString *userName = resourceInfoDic[@"userId"];
                NSString *path = resourceInfoDic[@"path"];
                WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
                launchMiniProgramReq.userName = userName; //拉起的小程序的username
                launchMiniProgramReq.path = path; //拉起小程序页面的可带参路径，不填默认拉起小程序首页
                launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
                [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                    
                }];
            }
           
        }
            break;
        case 1004:
            //其他
        {
//            NSDictionary *dic = [self dictionaryWithJsonString:model.content];
//            if (dic) {
//                [self push:dic model:model];
//            }
            
        }
            break;
        case 1005:
        {
            [self getFederatedLoginRequestWithModel:model];
        }
            break;
        default:
            break;
    }
}
#pragma mark - json 转字典
- (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString
{
    if (jsonString == nil) {
        return nil;
    }
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err)
    {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}
#pragma mark - 个人信息
- (void)goToPersonInfoVC
{
    PersonInfoViewController *pfVC = [PersonInfoViewController new];
    pfVC.title = @"个人信息";
    pfVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:pfVC animated:YES];
}

#pragma mark - 我的奖品
- (void)goToMyPrizeListVC
{
    MyPrizeListVC *vc = [[MyPrizeListVC alloc]init];
    vc.title = @"我的奖品";
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    return;
}

#pragma mark - 金币明细
- (void)goToCoinsListVC
{
    CoinsDetailListVC *vc = [[CoinsDetailListVC alloc]init];
    vc.title = @"金币明细";
    vc.type = ListVCTypeCoinsDetail;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 金币排名
- (void)goToCoinRankVC
{
    CoinsRankViewController *coinVC = [CoinsRankViewController new];
    coinVC.title = @"我的金币";
    coinVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:coinVC animated:YES];
    
    return;
}

#pragma mark - 健康统计
- (void)goToHeathStatisticsVC
{
    [self getStepCount];
}

#pragma mark - 金币抽奖
- (void)goToCoinLuckDrawVC
{
    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];
           [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
               
               if (error) {
                   [SVProgressHUD showInfoWithStatus:@"无网络"];
                   return ;
               }
               if (responseObj) {
                   NSString *code = [responseObj[@"code"] stringValue];
                   if ([code isEqualToString:@"0"]) {
                       [getPeopleID getTotalCoins:responseObj[@"result"]];
                      
                       [self.headerview refreshData];
                       
                       
                          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.hidesBottomBarWhenPushed =YES;
                            [self.navigationController pushViewController:webVC animated:YES];
                       return ;
                   }
               }
               
           
           }];
       }
}

#pragma mark - 金币中心
- (void)goToCoinCenterVC
{
    CoinsCenterViewController *vc = [[CoinsCenterViewController alloc]init];
    vc.title = @"金币中心";
    vc.hidesBottomBarWhenPushed = YES;
    vc.Completeblock = ^(BOOL isSuccess) {
        if (isSuccess) {
            self.tabBarController.selectedIndex = 2;
        }
    };
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 我的钱包
- (void)goToMyWalletVC
{
    MyWalletViewController *vc = [MyWalletViewController new];
    vc.title = @"我的钱包";
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];

}

#pragma mark - 今日收益
- (void)goToTodayProfitVC
{
    KKTodayProfitViewController *vc = [KKTodayProfitViewController new];
    vc.title = @"今日收益";
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    return;
}

#pragma mark - 收益排行榜
- (void)goToAssetsRankVC
{
    MyRankViewController *vc = [MyRankViewController new];
    vc.title = @"收益排行榜";
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 社保认证记录
- (void)goToSheBaoAuthListVC
{
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    socialRecord*vc=[sb instantiateViewControllerWithIdentifier:@"socialRecord"];
    vc.isHomeVC = YES;
    vc.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 就业采集记录
- (void)goToEmploymentCollectionListVC
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    chooseAddressViewController*once  = [sb instantiateViewControllerWithIdentifier:@"chooseAddressViewController"];
    once.isSearch = YES;
    once.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:once animated:YES];
}

#pragma mark - 社保采集记录
- (void)goToSheBaoCollectionListVC
{
    UIStoryboard *sb  =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
    socialRecord*vc=[sb instantiateViewControllerWithIdentifier:@"socialRecord"];
    vc.isHomeVC = YES;
    vc.record = 1;
    vc.hidesBottomBarWhenPushed =YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - 邀请好友
- (void)goToInviteFriendsVC
{
    ShareViewController *shareVC = [[ShareViewController alloc]init];
    shareVC.title = @"邀请好友";
    shareVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:shareVC animated:YES];
}

#pragma mark - 话费充值
- (void)goToHuaFeeChargeVC
{
//    WebVC *webvc = [[WebVC alloc]init];
//    NSString  *phone = [getPeopleID PeopleIphoneNmber];
//    if (phone.length > 0) {
//        webvc.url = [NSString stringWithFormat:@"http://www.qld02.com/t/blackcard/callFee/callFeeForH5.html?channel=shebao&mobile=%@",[getPeopleID PeopleIphoneNmber]];
//    }else{
//        webvc.url = @"http://www.qld02.com/t/blackcard/callFee/callFeeForH5.html?channel=shebao";
//    }
//    webvc.title = @"话费劵";
//    webvc.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:webvc animated:YES];
    [[clickEvent instance] clickEventRooterVC:self getFederatedLoginRequestWithUrl:@"https://web.kanface.com:444/common/forward/FamilyChargeForwardUrl" menuName:@"话费充值"];
}

#pragma mark - 意见反馈
- (void)goToSuggestionFeedBackVC
{
    FeedBackController*vc = [FeedBackController new];
    vc.title = @"意见反馈";
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    return;
}

#pragma mark - 设置
- (void)goToSettingVC
{
    SettingViewController *settingVC = [SettingViewController new];
    settingVC.title = @"设置";
    settingVC.block = ^(BOOL isSuccess){
        if (isSuccess) {
            self.tabBarController.selectedIndex = 0;
        }
    };
    settingVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:settingVC animated:YES];
}

#pragma mark - 关于
- (void)goToAboutVC
{
    regardTableViewController *vc =[regardTableViewController sharedInstance];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - event response
- (void)targetBtnClick:(UIButton*)sender{
    
    NSLog(@"🎁 右下角红包悬浮按钮被点击 - 开始跳转到任务页面");
    NSLog(@"🎁 按钮信息: %@", sender);
    NSLog(@"🎁 当前时间: %@", [NSDate date]);
    
//    [YXAdSDKManager defaultManager].channelID = @"kksh-ios";
//    [YXAdSDKManager defaultManager].vuid = [NSString stringWithFormat:@"kksh_%@",@([getPeopleID PeopleID])];//渠道号前缀+_+用户ID
   
    [self getH52TaskWebViewWithPostID:@"kksh-wd-icon"];
}
#pragma mark - 获取自己的banner的接口
- (void)getMYBannerRequest
{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *version=[Tools getVersionCode];
    NSString * centerUrl = [NSString stringWithFormat:@"%@dynamic/menu/get",[NetworkConfig ipYinShuConfig]];
    NSDictionary *centerParam = @{
        @"uid":@([getPeopleID PeopleID]),
        @"configName":@"MineCenterPager",
        @"appName":@"kksh",
        @"version":version,
        @"systemType":@"iOS"
    };
    [NetworkRequest Post15:centerUrl Params:centerParam Success:^(id _Nonnull objc) {
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
            if ([state isEqualToString:@"200"]) {
                if ([objc[@"result"] isKindOfClass:[NSArray class]]) {
                    self.bannerArray = [KKRedPackageClickEventModel mj_objectArrayWithKeyValuesArray:objc[@"result"]];
                    if(self.bannerArray!=nil&&self.bannerArray.count>0){
                        self.showBanner = YES;
                        self.showSelfBanner = YES;
                    }
                }
                [self.tableView reloadData];
            }
        }
    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
    NSDictionary *params = @{
        @"userId":@([getPeopleID PeopleID]),
        @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
        @"fromApp":@"kksh",
        @"versionNo":version,
        @"fromModel":@"2",
        @"category":@"6001"
    };
}

- (void)getH52TaskWebViewWithPostID:(NSString *)postID {
}

#pragma mark -网页分享
//网页分享
- (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType
{
    if (![WXApi isWXAppInstalled]) {
        [Tools showMessage:@"请先安装微信!!!"];
        return;
    }
//    WeakSelf
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    
    //创建网页内容对象
//    NSString* thumbURL =  UMS_THUMB_IMAGE;
    //UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"安全认证 轻松领钱" descr:@"邀您一起拿金币,赢大奖" thumImage:[UIImage imageNamed:@"login_icon"]];
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"安全认证 轻松领钱" descr:@"限时抢购补贴口罩，就差你啦！" thumImage:[UIImage imageNamed:@"login_icon"]];
    //设置网页地址
    NSString *url = [NSString stringWithFormat:@"http://nginx.weface.com.cn/lesson/award/share/index.html?userid=%ld&telephone=%@",[getPeopleID PeopleID],[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]];//外网
    //NSString *url = [NSString stringWithFormat:@"http://172.16.10.144/projects/html-nginx/html-nginx/lesson/award/share/index.html?userid=%ld&telephone=%@",(long)[getPeopleID PeopleID],[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]];//内网
    shareObject.webpageUrl = url;
    
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
                
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
            
        }
        
    }];
}

#pragma mark - h5跳转
-(void)jumpToHTML5:(NSString*)url andJAnalytics:(NSString*)janalytics
{
    if ([janalytics isEqualToString:@"0元购"]  || [janalytics isEqualToString:@"找工作"]) {
        WebVC *webvc = [[WebVC alloc]init];
        webvc.url = url;
        webvc.title = janalytics;
        webvc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webvc animated:YES];
        return;
    }
    
    
    WebViewController *tc=[WebViewController new];
    tc.URL =[NSURL URLWithString:url];
            tc.hidesBottomBarWhenPushed =YES;
    tc.janalytics = janalytics;
    [self.navigationController pushViewController:tc animated:YES];

}

#pragma mark - private methods
-(NSInteger )getNowTimeTimestamp3{
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss SSS"]; // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    //设置时区,这个对于时间的处理有时很重要
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    NSDate *datenow = [NSDate date];//现在时间,你可以输出来看下是什么格式
    
    NSInteger timeSp = [datenow timeIntervalSince1970]*1000;
    
    return timeSp;
}

#pragma mark - getters and setters
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, -cl_kStatusBarHeight , ScreenWidth, ScreenHeight +cl_kStatusBarHeight    - cl_kTabBarHeight) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerNib:[UINib nibWithNibName:@"Log2TableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        [_tableView registerNib:[UINib nibWithNibName:@"LogLeftViewCell" bundle:nil] forCellReuseIdentifier:@"LogLeftViewCell"];
        [_tableView registerClass:[LogFunctionItemsCell class] forCellReuseIdentifier:@"LogFunctionItemsCell"];
        [_tableView registerClass:[LogMiddleFunctionTableCell class] forCellReuseIdentifier:@"LogMiddleFunctionTableCell"];
        [_tableView registerClass:[LogHiddenFunctionItemsCell class] forCellReuseIdentifier:@"LogHiddenFunctionItemsCell"];
        [_tableView registerClass:[LogLeftCell class] forCellReuseIdentifier:@"LogLeftCell"];
        _tableView.tableHeaderView = self.headerview;
        _tableView.backgroundColor = [UIColor colorWithHex:0xf4f4f4];
    }
    return _tableView;
}

- (NSArray *)dataArray
{
    if (self.showBanner) {
        _dataArray = @[@[@"账户实名认证"],@[@"账户实名认证",@"社保认证记录",@"就业采集记录"],@[@"推荐有礼",@"意见反馈",@"设置",@"关于"]];
    }else{
        _dataArray = @[@[],@[@"账户实名认证",@"社保认证记录",@"就业采集记录"],@[@"推荐有礼",@"意见反馈",@"设置",@"关于"]];
    }
    return _dataArray;
}

- (Log2HeaderView *)headerview
{
    if (!_headerview) {
        _headerview = [[Log2HeaderView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 185 + cl_kStatusBarHeight )];
        _headerview.backgroundColor = [UIColor whiteColor];
        _headerview.delegate = self;
    }
    return _headerview;
}

- (CMPedometer *)pedometer
{
    if (!_pedometer) {
        _pedometer = [[CMPedometer alloc]init];
    }
    return _pedometer;
}
#pragma mark - 后台获取底部图
- (void)requestIconsAndTargetEvent{
    NSString*version = [Tools getVersionCode];
    NSString *url1 = [NSString stringWithFormat:@"%@dynamic/menu/get",[NetworkConfig ipYinShuConfig]];
    NSDictionary *params1 = @{
        @"configName":@"MineBottom",
        @"appName":@"kksh",
        @"version":version,
        @"systemType":@"iOS"
    };
    typeof(self) wSelf = self;
    [NetworkRequest Post15:url1 Params:params1 Success:^(id _Nonnull objc) {
        
        NSLog(@"objc:%@",objc);
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];

            if ([state isEqualToString:@"200"]) {
                if ([objc[@"result"] isKindOfClass:[NSArray class]]) {
                    wSelf.DataArr = [NSMutableArray array];
                    for (NSDictionary *dic in objc[@"result"]) {
                        KKRedPackageClickEventModel *model = [KKRedPackageClickEventModel mj_objectWithKeyValues:dic];
                      
                        [wSelf.DataArr addObject:model];
                    }
//                    wSelf.DataArr = [KKRedPackageClickEventModel mj_objectArrayWithKeyValuesArray:objc[@"result"]];
                    [wSelf.tableView reloadData];
                }
            }


        }

    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
}
#pragma mark - 后台获取中部图
- (void)requestMidIconsAndTargetEvent{
    NSString*version = [Tools getVersionCode];
    NSString *url1 = [NSString stringWithFormat:@"%@dynamic/menu/get",[NetworkConfig ipYinShuConfig]];
    
    NSDictionary *params1 = @{
        @"configName":@"WoDeZhongJianMenu",
        @"appName":@"kksh",
        @"version":version,
        @"systemType":@"iOS"
    };
    typeof(self) wSelf = self;
    [NetworkRequest Post15:url1 Params:params1 Success:^(id _Nonnull objc) {
        
        NSLog(@"objc:%@",objc);
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];

            if ([state isEqualToString:@"200"]) {
                if ([objc[@"result"] isKindOfClass:[NSArray class]]) {
                    wSelf.midDataArr = [NSMutableArray array];
                    for (NSDictionary *dic in objc[@"result"]) {
                        KKRedPackageClickEventModel *model = [KKRedPackageClickEventModel mj_objectWithKeyValues:dic];
                      
                        [wSelf.midDataArr addObject:model];
                    }
                    [wSelf.tableView reloadData];
                }
            }
        }

    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
