//
//  CoinsCenterViewController.m
//  Open
//
//  Created by 雷俊博 on 2019/8/6.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "CoinsCenterViewController.h"
#import <UICountingLabel.h>

#import "Constants.h"
#import "ExchangeMoneyBtn.h"

#import "SignInSuccessView.h"
#import "RetroactiveView.h"
#import "RedPackageSuccessView.h"

#import "SignInCollectionViewCell.h"
#import "LineCollectionReusableView.h"

#import "CoinCenterTableViewCell.h"
#import "CoinCenterHeaderView.h"

#import "ShareViewController.h"
#import "CTAPIBaseManager.h"

#import "CoinsDetailListVC.h"


//签到弹框
#import "SignInSuccessView.h"
//公众号弹框
#import "OfficialAccountsAlertView.h"
//弹框动画
#import <ZJAnimationPopView.h>
#import <Toast.h>
#import "KKTaskModel.h"
#import "KKBubbleTaskModel.h"


//红包弹框
#import "RedPackageView.h"
#import "RedPackageOpenedView.h"
#import "CoinCenterCoinRewardAlertView.h"

//穿山甲
#import <BUAdSDK/BUAdSDK.h>



//极光小视频
#import "KKTabBarViewController.h"
#import "LittleVideoViewController.h"
#import "KKVideoViewController.h"
#import "KKSVideoViewController.h"

#import <WXApi.h>

#import "PrizeInfoCommitSuccessAlertView.h"


//tip
#import <JDFTooltips.h>

//补签弹框
#import "SuppleSignAlertView.h"

#import "LittleGoldHouseWebVC.h"

#import "KKInsuranceModel.h"
#import "KKInsuranceTabBarController.h"
#import "KKInsuranceViewController.h"
#import "KKInsuranceContainerController.h"


//变现猫
#import "DHCWNativeRenderAd.h"
#import "LocalPlayerVideoManager.h"

//快手
#import <KSAdSDK/KSAdSDK.h>
#import "KSFeedAdCell.h"


//签到弹框
#import "ClickOnForCoinsAlertView.h"

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

#import "PersonInfoViewController.h"

//免费果园
#import "MyFruitViewController.h"

#import "InviteRegulationView.h"

#import "GoldBottomView.h"
@interface CoinsCenterViewController ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UIScrollViewDelegate,CoinCenterSignTableViewCellDelegate,BUNativeExpressRewardedVideoAdDelegate,BUNativeExpressAdViewDelegate,DHCWNativeRenderAdDelegate,DHCWNativeAdViewDelegate,DHCWNativeLocaVideoAdDelegate,KSFeedAdsManagerDelegate,KSFeedAdDelegate,GoldBottomViewDelegate>{
    
    id _customView;
    
    KKBubbleTaskModel* currentModel;
    UIButton* currentBtn;
    
    CGFloat brightness;
    
}


//导航栏
@property (nonatomic, strong)UIButton *rightBtn;

//@property (nonatomic, strong)UIView *headerView;
@property (nonatomic, strong)CoinCenterHeaderView *headerView;

@property (nonatomic, strong)UIView *cardView;

//card view
@property (nonatomic, strong)UICountingLabel *lb_coinsNum;

@property (nonatomic, strong)UILabel *lb_coinsNumTitle;

@property (nonatomic, strong)ExchangeMoneyBtn *btn_exchangeMoney;

@property (nonatomic, strong)UIButton *btn_arrow;


@property (nonatomic, strong)UICollectionView *collectionView;

@property (nonatomic, strong)UIButton *btn_signIn;

@property (nonatomic, strong)UITableView *tableView;

@property (nonatomic, strong)NSMutableArray *dateArray;

@property (nonatomic, strong)NSMutableArray *dataArray;

@property (nonatomic, strong)NSArray *bubbleTaskArray;

@property (nonatomic, assign)NSInteger weekIndex;

@property (nonatomic, assign)BOOL isrefresh;

//穿山甲
@property (nonatomic, strong)BUNativeExpressRewardedVideoAd* rewardedAd;


//变现猫
@property (nonatomic, strong) DHCWNativeRenderAd *nativeAd;
@property (nonatomic, strong) NSMutableArray *adDataArray;



@property (strong, nonatomic) BUNativeExpressAdManager *nativeExpressAdManager;


@property (strong, nonatomic) BUNativeExpressAdManager *nativeExpressAd2Manager;

@property (strong, nonatomic) BUNativeExpressAdManager *nativeExpressAd3Manager;

@property (strong, nonatomic) NSMutableArray<__kindof BUNativeExpressAdView *> *expressAdViews;

@property (nonatomic, strong)UIView* adView;

@property (nonatomic, strong) JDFSequentialTooltipManager *tooltipManager;


@property (nonatomic, copy)NSString* type;

@property (nonatomic, strong) JDFTooltipView *tipsView;

@property (nonatomic, strong) KSFeedAdsManager *feedAdsManager;

@property (nonatomic, strong)UIView* xmADView;

@property (nonatomic, strong) NSDictionary *ShareDic;
@end

@implementation CoinsCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //[self navConfig];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.tableView];
    [self bottomView];
    
    if (@available(iOS 11.0, *)) {
           self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
       } else {
           self.automaticallyAdjustsScrollViewInsets = NO;
       }
    
    
    [self refreshHeaderViewData];

   // [self loadData];
    
    [self signAndMakeCoinsInTasksRequest];
    
    [self getBubbleTasksRequest];
    
    //获取签到提醒状态
    [self RequestSignRemind];
    
    //获取分享地址
    [self getShareUrl];
    
    //获取分享用户
    [self getshredusers];
    
    //self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:self.rightBtn];
    
    //init
    //[BUAdSDKManager setAppID:@"5109638"];
    self.expressAdViews = [NSMutableArray array];
    
    //变现猫
    
    brightness = [UIScreen mainScreen].brightness;
    
    //6791
//    NSString*adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    [BXMediaMaterialManager entranceShowEventTrackingWithPlaceId:@"9193" userId:@"" materialModel:nil];
    
    NSString *appId = @"603000003";
    [KSAdSDKManager setAppId:appId];
    
    
    NSDate *oldDate = [NSDate date];
    [[NSUserDefaults standardUserDefaults]setObject:oldDate forKey:@"CoinCenterShowLastTime"];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
-(void)bottomView{
//    UIView *bottomGroup = [[UIView alloc]init];
//    bottomGroup.backgroundColor=[UIColor whiteColor];
//    [self.view addSubview:bottomGroup];
//    [bottomGroup mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.tableView.mas_bottom).offset(10*WIDTHRADIU);
//        make.width.offset(ScreenWidth);
//        make.height.offset(180*WIDTHRADIU);
//        make.centerX.equalTo(self.view);
//    }];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [self.navigationController.navigationBar navBarBackGroundColor:[UIColor colorWithHex:0xf98505] image:nil isOpaque:YES];//颜色
         
    [self.navigationController.navigationBar navBarBottomLineHidden:YES];
    
//    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHex:0xf98505];
//
//    [self.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
//        self.navigationController.navigationBar.barTintColor = [UIColor colorWithHex:0xf98505];
//         [self.navigationController.navigationBar setBackgroundImage:[UIImage  imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
//    } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
//    }];
//
    
    NSString *pushStr = [[NSUserDefaults standardUserDefaults]objectForKey:@"pushKey"];
    if ([pushStr isEqualToString:@"unOpenPush"] && [self isUserNotificationEnable]) {
         [self increaseScoreWithType:@"1006"];
    }
    
    [self refreshCoins];
    
    //self.navigationController.navigationBar.translucent = NO;
    [GTCountSDK trackCountEvent:@"life_coinCenter" withArgs:@{}];//个推统计
    
    if ([UIScreen mainScreen].brightness !=  brightness) {
      [UIScreen mainScreen].brightness = brightness;
    }
    
    //取消所有延迟的操作
    //[NSObject cancelPreviousPerformRequestsWithTarget:self];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.translucent = YES;
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [JANALYTICSService startLogPageView:@"金币中心"];
    [MobClick beginLogPageView:@"金币中心"];
}
-(void)viewDidDisappear:(BOOL)animated{
    
    [super viewDidDisappear:animated];
    [JANALYTICSService stopLogPageView:@"金币中心"];
    [MobClick endLogPageView:@"金币中心"];
    
}



- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
//    [self.lb_coinsNum mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.top.offset(20 * WIDTHRADIU);
//        make.centerX.equalTo(self.cardView);
//        make.height.offset(25 * WIDTHRADIU);
//    }];
//    [self.lb_coinsNumTitle mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.lb_coinsNum.mas_bottom).offset(10 * WIDTHRADIU);
//        make.centerX.equalTo(self.cardView);
//        make.height.offset(13 * WIDTHRADIU);
//    }];
    
//    [self.btn_exchangeMoney mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.offset(38 * WIDTHRADIU);
//        make.right.offset(0);
//        make.width.offset(80 * WIDTHRADIU);
//        make.height.offset(30 * WIDTHRADIU);
//    }];
//
//    [self.btn_arrow mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(self.cardView);
//        make.right.offset(0);
//        make.width.offset(80 * WIDTHRADIU);
//        make.height.offset(30 * WIDTHRADIU);
//    }];
    
}

- (void)navConfig
{
    UIView*navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cl_kNavigationBarHeight)];
    navView.backgroundColor = [UIColor colorWithHex:0xf98505];
    //返回按钮
    UIButton* backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [backBtn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [backBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backBtn.frame = CGRectMake(10, cl_kStatusBarHeight, 60, 44);
    [backBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:4];
    [backBtn addTarget:self action:@selector(backClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UILabel* lb_title = [UILabel new];
    lb_title.text = self.title;
    lb_title.font = [UIFont boldSystemFontOfSize:17];
    lb_title.textAlignment = NSTextAlignmentCenter;
    lb_title.textColor = [UIColor whiteColor];
    [navView addSubview:backBtn];
    [navView addSubview:lb_title];
    [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(cl_kStatusBarHeight);
        make.centerX.equalTo(navView);
        make.height.offset(44);
    }];

    [self.view addSubview:navView];
}
- (void)btnClick:(UIButton *)button{
    [self showDeclareAlertView];
}


#pragma mark - loadData
//获取金币数
- (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];
        WeakSelf
        [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
            
            weakSelf.isrefresh = YES;
           
            if (responseObj) {
                NSString *code = [responseObj[@"code"] stringValue];
                if ([code isEqualToString:@"0"]) {
                    [getPeopleID getTotalCoins:responseObj[@"result"]];
                    NSDictionary *dic = [getPeopleID totalCoins];
                    NSNumber *num = dic[@"totalScore"];
                    [weakSelf.lb_coinsNum countFrom:self.lb_coinsNum.text.integerValue  to:num.integerValue];
                }
            }
            
        }];
    }
}

//获取签到列表
- (void)loadData
{
    //[KKLoadingAnimationView show];
    NSString *url = [NSString stringWithFormat:@"%@score/getuserTaskStatus",CoinsBaseUrl];
    
    NSDictionary *dic = @{
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                             @"fromModel":@"2"
                             };
    
    
    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"];
   
    [params setObject:[NSNumber numberWithInt:172] forKey:@"verflag"];
    
    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        
       
        //[KKLoadingAnimationView dismiss];
        
       
        if (responseObject) {
            NSNumber *code = responseObject[@"code"];
            if (code.integerValue == 0) {
                
                
                self.tableView.hidden = NO;
                self.dateArray = [[NSMutableArray alloc]initWithArray:responseObject[@"result"][@"dateTaskStatus"]];
                self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"taskstatus"]];
                
                //获取今天是周几
                
                NSNumber *index = responseObject[@"result"][@"currentDayofWeek"];
                self.weekIndex = index.integerValue - 1;
                
                if (self.dateArray.count == 7) {
                    NSDictionary *dic = self.dateArray[self.weekIndex];
                    NSNumber *status = dic[@"status"];
                    if (status.integerValue == 302) {
                        //[self setSignBtnInterace:NO];
                        [self.headerView setSignBtnInterace:NO];
                    }else if(status.integerValue == 303){
                        //[self setSignBtnInterace:YES];
                        [self.headerView setSignBtnInterace:YES];
                    }
                }
                
                
               
                
                //[self.collectionView reloadData];
                [self.tableView reloadData];
                [self reloadHeaderCollectionViewWithData:self.dateArray currentIndex:self.weekIndex];
                
                //[self loadBXMADViews];
                
                [self refreshCoins];
                return ;
            }
        }
        
       
        
        
        
    }];
}


#pragma mark - 获取签到任务和其他任务

- (void)signAndMakeCoinsInTasksRequest {
    
    
    
    //[KKLoadingAnimationView show];
    dispatch_group_t group = dispatch_group_create();
    
    dispatch_group_enter(group);
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSString *urlString = [NSString stringWithFormat:@"%@taskservice/initTaskQuery",[NetworkConfig ipCoinsConfig]];
        NSDictionary *params = @{
            @"userId":@([getPeopleID PeopleID]),
            @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
            @"fromAPP":@"kklife",
            @"fromModel":@"2",
            @"version": KKLifeVersionCode,
            @"reqstamp":[Tools getNowTimeTimestamp],
            @"isOpenPush":[self isUserNotificationEnable] ? @(1) :@(0)
        };
        [NetworkRequest Post14:urlString Params:params Success:^(id _Nonnull responseObject) {
            NSLog(@"responseObject:%@",responseObject);
            if ([responseObject isKindOfClass:[NSDictionary class]]) {
                NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
                if ([code isEqualToString:@"0"]) {
                    self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"]];
                }
            }
            dispatch_group_leave(group);
        } Failure:^(NSError* error) {
            NSLog(@"error:%@",error);
            dispatch_group_leave(group);
        }];
    });
    dispatch_group_enter(group);
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        NSString *url = [NSString stringWithFormat:@"%@score/getuserTaskStatus",[NetworkConfig ipCoinsConfig]];
        NSDictionary *dic = @{
                                 @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                                 @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                                 @"fromModel":@"2"
                                 };
        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"];
        [params setObject:[NSNumber numberWithInt:172] forKey:@"verflag"];
        [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
            if (responseObject) {
                NSNumber *code = responseObject[@"code"];
                if (code.integerValue == 0) {
                    self.dateArray = [[NSMutableArray alloc]initWithArray:responseObject[@"result"][@"dateTaskStatus"]];
                    //self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"taskstatus"]];
                    //获取今天是周几
                    NSNumber *index = responseObject[@"result"][@"currentDayofWeek"];
                    self.weekIndex = index.integerValue - 1;
                }
            }
           dispatch_group_leave(group);
        }];
   });
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        //[KKLoadingAnimationView dismiss];
        if (self.dateArray.count == 7) {
            self.tableView.hidden = NO;
            NSDictionary *dic = self.dateArray[self.weekIndex];
            NSNumber *status = dic[@"status"];
            if (status.integerValue == 302) {
                [self.headerView setSignBtnInterace:NO];
            }else if(status.integerValue == 303){
                [self.headerView setSignBtnInterace:YES];
                [self showSignTipsAlertView];
            }
        }
        [self.tableView reloadData];
        [self reloadHeaderCollectionViewWithData:self.dateArray currentIndex:self.weekIndex];
        [self refreshCoins];
        
        //[self loadBXMADViews];
        
        if (self.dataArray.count > 4) {
            //[self loadKSFeedADs];
            //[self loadBUADData2];
        }
        
    });
   
 
}
- (void)sign2AndMakeCoinsInTasksRequest {
    
    
    
    dispatch_group_t group = dispatch_group_create();
    
    dispatch_group_enter(group);
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        NSString *urlString = [NSString stringWithFormat:@"%@taskservice/initTaskQuery",[NetworkConfig ipCoinsConfig]];
        
        NSDictionary *params = @{
            @"userId":@([getPeopleID PeopleID]),
            @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
            @"fromAPP":@"kklife",
            @"fromModel":@"2",
            @"version": KKLifeVersionCode,
            @"reqstamp":[Tools getNowTimeTimestamp],
            @"isOpenPush":[self isUserNotificationEnable] ? @(1) :@(0)
        };
        
        [NetworkRequest Post14:urlString Params:params Success:^(id _Nonnull responseObject) {
            
            NSLog(@"responseObject:%@",responseObject);
            
            if ([responseObject isKindOfClass:[NSDictionary class]]) {
                NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
                if ([code isEqualToString:@"0"]) {
                    self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"]];
                }
            }
            
            dispatch_group_leave(group);
            
        } Failure:^(NSError* error) {
            
            NSLog(@"error:%@",error);
            
            dispatch_group_leave(group);
            
        }];
        
    });
    
    dispatch_group_enter(group);
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
           
        
        NSString *url = [NSString stringWithFormat:@"%@score/getuserTaskStatus",[NetworkConfig ipCoinsConfig]];
        
        NSDictionary *dic = @{
                                 @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                                 @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                                 @"fromModel":@"2"
                                 };
        
        
        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"];
       
        [params setObject:[NSNumber numberWithInt:172] forKey:@"verflag"];
        
        [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
            
           
            if (responseObject) {
                NSNumber *code = responseObject[@"code"];
                if (code.integerValue == 0) {
                    
                    
                   
                    self.dateArray = [[NSMutableArray alloc]initWithArray:responseObject[@"result"][@"dateTaskStatus"]];
                    //self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"taskstatus"]];
                    
                    //获取今天是周几
                    
                    NSNumber *index = responseObject[@"result"][@"currentDayofWeek"];
                    self.weekIndex = index.integerValue - 1;
                    
                  
                }
            }
        
           dispatch_group_leave(group);
        }];
   });

    
    
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        if (self.dateArray.count == 7) {
            self.tableView.hidden = NO;
            
            NSDictionary *dic = self.dateArray[self.weekIndex];
            NSNumber *status = dic[@"status"];
            if (status.integerValue == 302) {
                [self.headerView setSignBtnInterace:NO];
            }else if(status.integerValue == 303){
                [self.headerView setSignBtnInterace:YES];
            }
        }
        
        [self.tableView reloadData];
        [self reloadHeaderCollectionViewWithData:self.dateArray currentIndex:self.weekIndex];
        
        [self refreshCoins];
        
        if (self.dataArray.count > 4) {
            //[self loadKSFeedADs];
            //[self loadBUADData2];
        }
        
    });

}


#pragma mark - 任务得金币接口
- (void)increaseScoreWithType:(NSString *)type
{
    NSString *url = [NSString stringWithFormat:@"%@score/increateScore",CoinsBaseUrl];
    NSDictionary *dic = @{
                          @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                          @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                          @"scoreType":type,
                          @"reqTimesTamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                          
                          @"fromModel":@"2"
                          };
    
    
    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"];
    
//    WeakSelf
   
    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        if (responseObject) {
            NSNumber *code = responseObject[@"code"];
            if (code.integerValue == 1006) {
                
                if ([type isEqualToString:@""]) {
                    
                }
                  [[NSUserDefaults standardUserDefaults]setObject:@"openedPush" forKey:@"pushKey"];
                [[NSUserDefaults standardUserDefaults]synchronize];
                
                //[weakSelf loadData];
                

                NSString*score = [NSString stringWithFormat:@"+%@",responseObject[@"result"][@"score"]];
                
                
                //(ScreenHeight - 288) / 2 - 20
                //299, 288
                WeakSelf
                [PrizeInfoCommitSuccessAlertView showReceiveViewWithVC:self Number:score block:^(CTShareType type) {
                    if (weakSelf.xmADView.superview) {
                        [weakSelf.xmADView removeFromSuperview];
                    }
                }];
                
//               [PrizeInfoCommitSuccessAlertView showReceiveViewWithVC:self Number:score block:^(CTShareType type) {
//                   if (weakSelf.xmADView.superview) {
//                       [weakSelf.xmADView removeFromSuperview];
//                   }
//               } ExchangBlock:^{
//                   //兑换
//                   [[clickEvent instance] clickEventRooterVC:weakSelf Content:@"JBDH" menuName:@"金币兑换" ID:@"0"];
//                   [NetworkRequest statisticsWithEventName:@"dialog_Task_JBDH"];
//               }];
                

                //[self loadKSFeedADs];

                [self loadBUADData3];
                
                [weakSelf sign2AndMakeCoinsInTasksRequest];
                
                return ;
                
            }
        }
       
        
    }];
}

#pragma mark - 任务得金币接口弹框2

//领取的时候需要弹框
- (void)increase2ScoreWithType:(NSString *)type
{
    NSString *url = [NSString stringWithFormat:@"%@/score/increateScore",CoinsBaseUrl];
    
    NSDictionary *dic = @{
                          @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                          @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                          @"scoreType":type,
                          @"reqTimesTamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                          
                          @"fromModel":@"2"
                          };
    
    
    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"];
    
    WeakSelf
    
    //[KKLoadingAnimationView show];
    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        if (responseObject) {
            NSNumber *code = responseObject[@"code"];
            if (code.integerValue == 1006) {
                
                if ([type isEqualToString:@"1004"]) {
                    
                    if (self.signBlock) {
                        self.signBlock(YES);
                    }
                    
                }
                [weakSelf loadHttpData:[NSString stringWithFormat:@"%@",responseObject[@"result"][@"score"]]];
                return ;
                
            }
        }
        
        
        //[KKLoadingAnimationView dismiss];
        
        
    }];
}


#pragma mark - 补签任务请求
- (void)suppleTaskRequestWithBlock:(void (^)(bool result))success {
    
    
    NSString *url = [NSString stringWithFormat:@"%@/score/increateScore",CoinsBaseUrl];
    
    NSDictionary *dic = @{
                          @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                          @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                          @"scoreType":@"1050",
                          @"reqTimesTamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                          
                          @"fromModel":@"2"
                          };
    
    
    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"];
    
    WeakSelf
    //[KKLoadingAnimationView show];
    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        if (responseObject) {
            NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
            if ([code isEqualToString:@"1006"]) {
                
                
                //[KKLoadingAnimationView dismiss];
                success(YES);
                NSString *score = [NSString stringWithFormat:@"%@",responseObject[@"result"][@"score"]];
                
                [SignInSuccessView showSuccessViewWithVC:self Title:@"补签成功" message:@"偷偷告诉你，满签奖励多多" num:score block:^(BOOL hidden) {
                    if (hidden) {
                        [weakSelf refreshCoins];
                    }
                }];
                
                return ;
                
            }
        }
        
        
        //[KKLoadingAnimationView dismiss];
        
        success(NO);
        
        
    }];
    
}




- (void)setSignBtnInterace:(BOOL)Interace
{
    if (Interace) {
        [_btn_signIn setTitle:@"打卡领金币" forState:UIControlStateNormal];
        [_btn_signIn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn_signIn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
        _btn_signIn.backgroundColor = [UIColor colorWithHex:0xed8b0b];
        _btn_signIn.layer.cornerRadius = 22 * WIDTHRADIU;
        _btn_signIn.userInteractionEnabled = YES;
    }else{
        [_btn_signIn setTitle:@"已打卡" forState:UIControlStateNormal];
        [_btn_signIn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn_signIn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
        _btn_signIn.backgroundColor = [UIColor colorWithHex:0xffd28e];
        _btn_signIn.layer.cornerRadius = 22 * WIDTHRADIU;
        _btn_signIn.userInteractionEnabled = NO;
    }
}

- (void)refreshHeaderViewData
{

    NSDictionary *dic = [getPeopleID totalCoins];
    self.lb_coinsNum.text =  [NSString stringWithFormat:@"%@",[dic[@"totalScore"] stringValue]];
    
}


//签到请求
- (void)loadHttpData:(NSString *)str
{
    
     dispatch_group_t group = dispatch_group_create();
    
     dispatch_queue_t searialQueue = dispatch_queue_create("com.hmc.www", DISPATCH_QUEUE_SERIAL);
    
     dispatch_group_enter(group);
    dispatch_group_async(group, searialQueue, ^{
        //网络请求1
        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) {
                dispatch_group_leave(group);
                if (responseObj) {
                    NSString *code = [responseObj[@"code"] stringValue];
                    if ([code isEqualToString:@"0"]) {
                        [getPeopleID getTotalCoins:responseObj[@"result"]];
                        
                    }
                }
                
            }];
        }
    });
    dispatch_group_enter(group);
    dispatch_group_async(group, searialQueue, ^{
        //网络请求2
        NSString *url = [NSString stringWithFormat:@"%@/score/getuserTaskStatus",CoinsBaseUrl];
        
        NSDictionary *dic = @{
                              @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                              @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                              @"fromModel":@"2"
                              };
        
        
        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"];
        [params setObject:[NSNumber numberWithInt:172] forKey:@"verflag"];
        [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
            
           dispatch_group_leave(group);
            if (responseObject) {
                NSNumber *code = responseObject[@"code"];
                if (code.integerValue == 0) {
                    NSNumber *index = responseObject[@"result"][@"currentDayofWeek"];
                    self.weekIndex =index.integerValue - 1;
                    self.dateArray = [[NSMutableArray alloc]initWithArray:responseObject[@"result"][@"dateTaskStatus"]];
                    //self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"taskstatus"]];
                    

                }
            }
            
            
            
        }];
    });
    //2个网络请求结束后,刷新UI
    dispatch_group_notify(group, searialQueue, ^{
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            dispatch_async(dispatch_get_main_queue(), ^{
               
                
                //[KKLoadingAnimationView dismiss];
                
                //[self.collectionView reloadData];
                [self.tableView reloadData];
                [self reloadHeaderCollectionViewWithData:self.dateArray currentIndex:self.weekIndex];
               
                
                if (self.dateArray.count == 7) {
                    NSDictionary *dic = self.dateArray[self.weekIndex];
                    NSNumber *status = dic[@"status"];
                    if (status.integerValue == 302) {
                        //[self setSignBtnInterace:NO];
                        [self.headerView setSignBtnInterace:NO];
                    }else if(status.integerValue == 303){
                        //[self setSignBtnInterace:YES];
                        [self.headerView setSignBtnInterace:YES];
                    }
                }
                
                
                
                NSDictionary *dic = [getPeopleID totalCoins];
                NSNumber *num = dic[@"totalScore"];
                
                
                //刷新UI
                WeakSelf
                [SignInSuccessView showSuccessViewWithVC:self Title:@"签到成功" message:@"偷偷告诉你，满签奖励多多" num:str block:^(BOOL hidden) {
                    if (hidden) {
                        [weakSelf.lb_coinsNum countFrom:self.lb_coinsNum.text.integerValue  to:num.integerValue];
                    }
                }];
                
            });
        });
    });
    
}

//领取奖励
- (void)loadHttp2Data:(NSString *)str
{
    dispatch_group_t group = dispatch_group_create();
    
    dispatch_queue_t searialQueue = dispatch_queue_create("com.hmc2.www", DISPATCH_QUEUE_SERIAL);
    
    dispatch_group_enter(group);
    dispatch_group_async(group, searialQueue, ^{
        //网络请求1
        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) {
                dispatch_group_leave(group);
                if (responseObj) {
                    NSString *code = [responseObj[@"code"] stringValue];
                    if ([code isEqualToString:@"0"]) {
                        [getPeopleID getTotalCoins:responseObj[@"result"]];
                        
                    }
                }
                
            }];
        }
    });
    dispatch_group_enter(group);
    dispatch_group_async(group, searialQueue, ^{
        //网络请求2
        NSString *url = [NSString stringWithFormat:@"%@score/getuserTaskStatus",CoinsBaseUrl];
        
        NSDictionary *dic = @{
                              @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                              @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                              @"fromModel":@"2"
                              };
        
        
        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"];
        [params setObject:[NSNumber numberWithInt:172] forKey:@"verflag"];
        [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
            
            dispatch_group_leave(group);
            if (responseObject) {
                NSNumber *code = responseObject[@"code"];
                if (code.integerValue == 0) {
                    NSNumber *index = responseObject[@"result"][@"currentDayofWeek"];
                    self.weekIndex =index.integerValue - 1;
                    self.dateArray = [[NSMutableArray alloc]initWithArray:responseObject[@"result"][@"dateTaskStatus"]];
                    //self.dataArray = [KKTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"][@"taskstatus"]];
                    
                    
                }
            }
            
            
            
        }];
    });
    //2个网络请求结束后,刷新UI
    dispatch_group_notify(group, searialQueue, ^{
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
                
                
                //[self.collectionView reloadData];
                [self.tableView reloadData];
                [self reloadHeaderCollectionViewWithData:self.dateArray currentIndex:self.weekIndex];
                
                
                if (self.dateArray.count == 7) {
                    NSDictionary *dic = self.dateArray[self.weekIndex];
                    NSNumber *status = dic[@"status"];
                    if (status.integerValue == 302) {
                        //[self setSignBtnInterace:NO];
                        [self.headerView setSignBtnInterace:NO];
                    }else if(status.integerValue == 303){
                        //[self setSignBtnInterace:YES];
                        [self.headerView setSignBtnInterace:YES];
                    }
                }
                
                
                
                NSDictionary *dic = [getPeopleID totalCoins];
                NSNumber *num = dic[@"totalScore"];
                
                
                //刷新UI
                WeakSelf
                
                [SignInSuccessView showSuccessViewWithVC:self Title:@"任务完成" message:@"看新闻也可以赚金币啦!!" num:str block:^(BOOL hidden) {
                    if (hidden) {
                        [weakSelf.lb_coinsNum countFrom:self.lb_coinsNum.text.integerValue  to:num.integerValue];
                    }
                }];
                
            });
        });
    });
}

#pragma mark - 获取悬浮奖励接口
- (void)getBubbleTasksRequest {
    
    NSString *url = [NSString stringWithFormat:@"%@taskservice/initTask",CoinsBaseUrl];
    
    NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];  //获取本地版本号
    currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSDictionary*params = @{
        @"uid":@([getPeopleID PeopleID]),
        @"frommodel":@(2),
        @"versionCode":currentVersion,
        @"termalInfo":@"kksh"
    };
    
    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        NSLog(@"responseObject:%@\nerror:%@",responseObject,error);
        if (responseObject) {
            NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
            if ([code isEqualToString:@"0"]) {
                
                self.bubbleTaskArray = [KKBubbleTaskModel mj_objectArrayWithKeyValuesArray:responseObject[@"result"]];
                
                if (self.bubbleTaskArray.count == 4) {
                    [self.headerView refreshBtnStateWithArray:self.bubbleTaskArray];
                }

            }
        }
        
        
        
    }];
    
    
    
}

#pragma mark - 看视频得金币
- (void)getCoinsByWhatVideos:(KKBubbleTaskModel *)model{
    NSString *url = [NSString stringWithFormat:@"%@score/increateScore",CoinsBaseUrl];
    NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];  //获取本地版本号
    currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSDictionary *dic = @{
                          @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                          @"telephone": [EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                          @"scoreType":model.taskId,
                          @"reqTimesTamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                          @"fromModel":@"2"
                          };
    
    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"];
    [params setObject:currentVersion forKey:@"versionCode"];
    [params setObject:@"kksh" forKey:@"termalInfo"];
    
    
    
//     WeakSelf
    //[KKLoadingAnimationView show];
       [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
           //[KKLoadingAnimationView dismiss];
           if (responseObject) {
               NSNumber *code = responseObject[@"code"];
               if ([code isKindOfClass:[NSNumber class]]) {
                   if (code.integerValue == 1006) {
                       //@1缩放s动画
                       self->currentBtn.hidden = YES;
                       
                       [self refreshCoins];
                       NSNumber *score = responseObject[@"result"][@"score"];
                       NSString *recordId = [NSString stringWithFormat:@"%@",responseObject[@"result"][@"recordId"]];
                       
                       self->currentModel.recordId = recordId;
                       if ([score isKindOfClass:[NSNumber class]]) {
                           NSString *number = [NSString stringWithFormat:@"%@",score];
//                           [CoinCenterCoinRewardAlertView showViewWithVC:self coin:number block:^(BOOL success) {
//
//                               if (success) {
//                                   [self loadBURewardedVideoAD];
//                                   //self->currentModel.recordId = recordId;
//                               }
//
//
//                           }];
                           
                           
                           [self showDoubleAlertView:recordId number:number];
                           return;
                            
      
                       }
                       
                       
                       
                   }
                   
                  
                   
               }
               
              
           }
       }];
    
}



#pragma mark - 获取看视频得红包
- (void)getPackageByWhatVideos:(KKBubbleTaskModel *)model{
    NSString *url = [NSString stringWithFormat:@"%@news/readVideoMoney",CoinsBaseUrl];
    NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];  //获取本地版本号
    currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSDictionary *dic = @{
                          @"userId":@([getPeopleID PeopleID]),
                          @"telephone": [EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
                          @"taskId":model.taskId,
                          @"reqStamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
                          @"fromModel":@"2"
                          };
    
    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"];
    
    [params setObject:currentVersion forKey:@"versionCode"];
    [params setObject:@"kksh" forKey:@"termalInfo"];
    
    //[KKLoadingAnimationView show];
       [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
           //[KKLoadingAnimationView dismiss];
           
           currentModel = nil;
           if (responseObject) {
               NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
               NSString *des = [NSString stringWithFormat:@"%@",responseObject[@"des"]];
               if ([code isEqualToString:@"0"]) {

                self->currentBtn.hidden = YES;
                NSDictionary* dic = responseObject[@"result"];
                NSString *packageMoney = dic[@"packageMoney"];

                NSString*money = [NSString stringWithFormat:@"%0.2f",packageMoney.doubleValue];
//                [RedPackageView showMoneyWithVC:self money:money type:KKRedPackageTypeMoney from:RedPackageFromWatchTV  block:^(BOOL success) {
//                    if (success) {
//
//                    }
//                }];
                   WeakSelf
                   [RedPackageOpenedView showAlertViewWithVC:self number:money btnTitle:@"看视频送红包" type:KKRedPackageTypeMoney block:^(BOOL success) {
                       if (success) {
                           [weakSelf goToTVVC:NO];
                       }
                   }];
                   

                   [self refreshCoins];

               }else{
                   [SVProgressHUD showErrorWithStatus:des];
               }


           }
       }];
    
}


#pragma mark - 获取双倍奖励
- (void)getdoubleExchargeRequest:(KKBubbleTaskModel *)model
{
    NSString *url = [NSString stringWithFormat:@"%@exchargeservice/doubleExcharge",CoinsBaseUrl];
    NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];  //获取本地版本号
    currentVersion = [currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSDictionary *params = @{
                          @"userId":@([getPeopleID PeopleID]),
                          @"recordId": model.recordId ? model.recordId :@"",
                          @"taskid":model.taskId,
                          @"reqstamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]]
                          };
    //[KKLoadingAnimationView show];
       [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
           //[KKLoadingAnimationView dismiss];
           self->currentModel = nil;
           if (responseObject) {
               NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
               NSString *des = [NSString stringWithFormat:@"%@",responseObject[@"des"]];
               if ([code isEqualToString:@"1006"]) {
                   [self refreshCoins];
               }else{
                   [SVProgressHUD showErrorWithStatus:des];
               }


           }
       }];
    
    
    
}


#pragma mark - 0元领
- (void)getZeroInsuranceRequestWithType:(NSString *)type
{
        
    NSString *url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipYinShuConfig],KKInsuranceForwardRequest];
    
    NSLog(@"获取0元领url:%@",url);
    
    NSString *province = [Tools isBlankString:[UserDefault objectForKey:@"locationProvince"]] ? @"" : [UserDefault objectForKey:@"locationProvince"];
    NSString *city = [Tools isBlankString:[UserDefault objectForKey:@"locationCity"]] ? @"" : [UserDefault objectForKey:@"locationCity"];
    NSString *county = [Tools isBlankString:[UserDefault objectForKey:@"locationCounty"]] ? @"" : [UserDefault objectForKey:@"locationCounty"];
    
    NSMutableDictionary *params = [NetworkPublicParams getBCPublicParams];
    
    
    [params setObject:[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY] forKey:@"tel"];
    [params setObject:@([getPeopleID PeopleID]) forKey:@"uid"];
    [params setObject:province forKey:@"province"];
    [params setObject:city forKey:@"city"];
    [params setObject:county forKey:@"county"];
    [params setObject:@"kksh" forKey:@"fromApp"];
    [params setObject:type forKey:@"type"];
   
   
    NSLog(@"params:%@",params);
//    WeakSelf
    //[KKLoadingAnimationView show];
    [NetworkRequest Post15: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 *result = objc[@"result"];
            if ([result isKindOfClass:[NSArray class]]) {
                
                NSArray *array = [KKInsuranceModel mj_objectArrayWithKeyValuesArray:result];
                
                if (array.count == 1) {
                    KKInsuranceModel* model = array[0];
                    [self jump2ToHTML5:model.path andJAnalytics:model.title];
                    
//                    if ([model.pageName isEqualToString:@"重疾险"]) {
//                        [self makeInsuranceStatisticsRequestWithType:@"100104"];
//                    }else if ([model.pageName isEqualToString:@"综合险"]){
//                        [self makeInsuranceStatisticsRequestWithType:@"100105"];
//                    }
                    
                }else if (array.count == 2){
                    [self goToInsurnceVC:array];
                }
               
                
                
            }
           
        }else{
            [Tools showMessage:describe];
        }

    } Failure:^(NSError* error) {
        //[KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        
        [Tools showMessage:@"网络出小差了,请稍后重试"];
        
    }];
    
    
    
}
#pragma mark - 保险统计
/**
 * 请求类型
 * 100101保险_banner入口
 * 100102保险_菜单入口
 * 100103保险_任务入口
 * 100104保险_重疾险
 * 100105保险_综合险
 */
- (void)makeInsuranceStatisticsRequestWithType:(NSString *)type
{
    NSString *url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipYinShuConfig],KKInsuranceStatisticsRequest];
    
    NSString *province = [Tools isBlankString:[UserDefault objectForKey:@"locationProvince"]] ? @"" : [UserDefault objectForKey:@"locationProvince"];
    NSString *city = [Tools isBlankString:[UserDefault objectForKey:@"locationCity"]] ? @"" : [UserDefault objectForKey:@"locationCity"];
    NSString *county = [Tools isBlankString:[UserDefault objectForKey:@"locationCounty"]] ? @"" : [UserDefault objectForKey:@"locationCounty"];
    
    NSMutableDictionary *params = [NetworkPublicParams getBCPublicParams];
    
    
    [params setObject:[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY] forKey:@"tel"];
    [params setObject:@([getPeopleID PeopleID]) forKey:@"uid"];
    [params setObject:province forKey:@"province"];
    [params setObject:city forKey:@"city"];
    [params setObject:county forKey:@"county"];
    [params setObject:@"kksh" forKey:@"fromApp"];
    [params setObject:type forKey:@"type"];
   
   
    NSLog(@"params:%@",params);
    
    
    [NetworkRequest Post15:url Params:params Success:^(id _Nonnull objc) {
    
        NSLog(@"objc:%@",objc);
        

    } Failure:^(NSError* error) {
       
        NSLog(@"error:%@",error);
        
       
        
    }];
    
}



#pragma mark - 显示加倍弹框
- (void)showDoubleAlertView:(NSString *)recordId number:(NSString *)number {
    
    [CoinCenterCoinRewardAlertView showViewWithVC:self coin:number block:^(BOOL success) {
        
        if (success) {
            //[self loadBURewardedVideoAD];
            [self loadABURewardedVideoAD];
            self->currentModel.recordId = recordId;
        }
        
        [self.adView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [obj removeFromSuperview];
        }];
        [self.adView removeFromSuperview];
    }];
    
    
    if (!self.adView) {
        self.adView = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth - 243 * WIDTHRADIU)/2, (ScreenHeight - 489 * WIDTHRADIU) / 2 + 269 * WIDTHRADIU, 243 * WIDTHRADIU , 220 * WIDTHRADIU)];
        
        self.adView.backgroundColor = [UIColor whiteColor];
        
        self.adView.layer.cornerRadius = 10 * WIDTHRADIU;
        
    }
    
//    UIWindow* keyWindow = self.view.window;
//
//    if (keyWindow == nil) {
//        keyWindow = [UIApplication sharedApplication].keyWindow;
//    }

    [self.view addSubview:self.adView];
    
    
    [self loadADData];
    
}

#pragma mark - 提示签到弹框
- (void)showSignTipsAlertView
{
//    NSDate *oldTime = [[NSUserDefaults standardUserDefaults]objectForKey:@"showSignTipsAlertView"];
//
//    if (oldTime && [self isSameDay:[NSDate date] date2:oldTime]) {
//        return;
//    }
//
//    NSDate *oldDate = [NSDate date];
//    [[NSUserDefaults standardUserDefaults]setObject:oldDate forKey:@"showSignTipsAlertView"];
//    [[NSUserDefaults standardUserDefaults]synchronize];
    
    
    WeakSelf
    [ClickOnForCoinsAlertView showViewWithBlock:^{
       //签到
        [weakSelf increase2ScoreWithType:@"1004"];
    } ExchangBlock:^{
//        //兑换
//        [[clickEvent instance] clickEventRooterVC:weakSelf Content:@"JBDH" menuName:@"金币兑换" ID:@"0"];
//        [NetworkRequest statisticsWithEventName:@"dialog_Signin_JBDH"];
    }];
}



#pragma mark - CoinCenterSignTableViewCellDelegate
- (void)clickWithBtn:(UIButton *)btn type:(BtnType)type{
    switch (type) {
        case BtnTypeBack:
        {
//            [self AlertListenNovel];
            [self.navigationController popViewControllerAnimated:YES];
        }
            break;
        case BtnTypeSign:
        {
            [self signBtnClick:btn];
        }
            break;
        case BtnTypePackage1:
        {
            currentBtn = btn;
            [self showMyAd:0];
        }
            break;
        case BtnTypeLuckyCoins:
        {
//            currentBtn = btn;
//            [self showMyAd:1];
            //6791
            [NetworkRequest statisticsWithEventName:@"dialog_ConinsCenter_TigerSendMoney"];
//            NSString*adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
            [BXMediaMaterialManager entranceClickEventTrackingWithPlaceId:@"9193" userId:@"" materialModel:nil];
            
            KKActivityViewController *vc = [KKActivityViewController new];
            vc.title = @"猛虎送财";
            vc.placeId = @"9193";
//            vc.buId = @"947689995";
//            vc.gdtAdId = @"2032212226213072";
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:YES];
            
        }
            break;
        case BtnTypePackage2:
        {
            currentBtn = btn;
            [self showMyAd:2];
        }
            break;
        case BtnTypeGiftBox:
        {
            currentBtn = btn;
            [self showMyAd:3];
        }
            break;
        case BtnTypeSignRuler:
        {
            //签到规则
            [self showDeclareAlertView];
        }
            break;
        case BtnTypeSignShare:
        {
            //签到分享
            [self SignShare];
        }
            break;
        default:
            break;
    }
}


- (void)clickWithCell:(SignInCollectionViewCell *)cell model:(NSDictionary *)model tipView:(JDFTooltipView *)tipView
{
    
    self.tipsView = tipView;
    WeakSelf
    [SuppleSignAlertView showWithTitle:@"兑换补签卡" message:@"观看视频可获得补签卡" btnTitle:@"立即补签" block:^{
       weakSelf.type = @"buqian";
       [weakSelf loadABURewardedVideoAD];
    } ExchangBlock:^{
       //兑换
//       [[clickEvent instance] clickEventRooterVC:weakSelf Content:@"JBDH" menuName:@"金币兑换" ID:@"0"];
//        [NetworkRequest statisticsWithEventName:@"dialog_Retroactive_JBDH"];
    }];

}

- (void)showMyAd:(int)index{
    if (self.bubbleTaskArray.count == 4) {
        currentModel = self.bubbleTaskArray[index];
        
        if ([currentModel.taskproperty isEqualToString:@"71"]) {
            [self loadBURewardedVideoAD];
            //[self loadABURewardedVideoAD];
        }else if ([currentModel.taskproperty isEqualToString:@"70"]){
            [self getCoinsByWhatVideos:currentModel];
        }
        
        
    }else{
        [self getBubbleTasksRequest];
    }
}


#pragma mark - 加载广告

//加载穿山甲聚合激励视频广告
- (void)loadABURewardedVideoAD {
    
   // gdt和穿山甲激励服务端校验需要赋值ABURewardedVideoModel
    BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];
    model.userId = @"123"; //用户Id
    
//    SlotID: 视频广告位Id  945132252 仅为demo示例使用
    self.rewardedAd = [[BUNativeExpressRewardedVideoAd alloc] initWithSlotID:@"946080781" rewardedVideoModel:model];
    self.rewardedAd.delegate = self;
    [self.rewardedAd loadAdData];
    
   //ABURewardedVideoModel *model = [[ABURewardedVideoModel alloc] init];
   //model.userId = @"123";
   //self.rewardedVideoAd = [[ABURewardedVideoAd alloc] initWithAdUnitID:@"946080781" rewardedVideoModel:model];
   //self.rewardedVideoAd.delegate = self;
   //self.rewardedVideoAd.mutedIfCan = YES;//静音
   
   // v2700开始原生广告支持自渲染和模板类型混出，如果开发者在平台配置了对应代码位的该属性则无需设置；否则开发者需要设置getExpressAdIfCan属性来告知SDK当前广告位下配置的是否为模板类型；平台配置优先于getExpressAdIfCan设置
   // self.rewardedVideoAd.getExpressAdIfCan = YES;
   
       //该逻辑用于判断配置是否拉取成功。如果拉取成功，可直接加载广告，否则需要调用setConfigSuccessCallback，传入block并在block中调用加载广告。SDK内部会在配置拉取成功后调用传入的block
   __weak typeof(self) weakself = self;
   //当前配置拉取成功，直接loadAdData
//   if(self.rewardedVideoAd.hasAdConfig){
//       [self.rewardedVideoAd loadAdData];
//   }else{
//       //当前配置未拉取成功，在成功之后会调用该callback
//       [self.rewardedVideoAd setConfigSuccessCallback:^{
//           [weakself.rewardedVideoAd loadAdData];
//       }];
//   }
    
}

//加载穿山甲激励视频广告
- (void)loadBURewardedVideoAD {
    BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];
    model.userId = @"tag123";
    self.rewardedAd = [[BUNativeExpressRewardedVideoAd alloc] initWithSlotID:@"945539143" rewardedVideoModel:model];

    self.rewardedAd.delegate = self;
   [self.rewardedAd loadAdData];
}


#pragma mark - 穿山甲信息流广告 加倍弹框
//加载
- (void)loadADData {
    
    BUAdSlot *slot1 = [[BUAdSlot alloc] init];
    slot1.ID = @"945759461";
    slot1.AdType = BUAdSlotAdTypeFeed; //required
    slot1.supportRenderControl = YES;
    slot1.adSize = CGSizeMake(243 * WIDTHRADIU, 220 * WIDTHRADIU);
    slot1.position = BUAdSlotPositionFeed;
    
    self.nativeExpressAdManager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:CGSizeMake(243 * WIDTHRADIU, 220 * WIDTHRADIU)];
    
    self.nativeExpressAdManager.delegate = self;

    [self.nativeExpressAdManager loadAdDataWithCount:1];

}

#pragma mark - 穿山甲信息流广告
- (void)loadBUADData2
{
//    BUAdSlot *slot1 = [[BUAdSlot alloc] init];
//    slot1.ID = @"946265855";
//    slot1.AdType = BUAdSlotAdTypeFeed; //required
//    slot1.supportRenderControl = YES;
//    slot1.adSize = CGSizeMake(ScreenWidth, 80 * WIDTHRADIU);
//    slot1.position = BUAdSlotPositionFeed;
//
//    BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Feed228_150];
//    slot1.imgSize = imgSize;
//    slot1.position = BUAdSlotPositionFeed;
//
//    self.nativeExpressAd2Manager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:CGSizeMake(ScreenWidth, 80 * WIDTHRADIU)];
//
//    self.nativeExpressAd2Manager.delegate = self;
//
//    [self.nativeExpressAd2Manager loadAdDataWithCount:1];
    
    
    BUAdSlot *slot1 = [[BUAdSlot alloc] init];
    slot1.adSize = CGSizeMake(ScreenWidth, 123.5 * WIDTHRADIU);
    slot1.ID = @"946421253";
    slot1.AdType = BUAdSlotAdTypeFeed;
    
    BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Feed228_150];
    slot1.imgSize = imgSize;
    slot1.position = BUAdSlotPositionFeed;
    
    
    self.nativeExpressAd2Manager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:CGSizeMake(ScreenWidth, 123.5 * WIDTHRADIU)];
    self.nativeExpressAd2Manager.delegate = self;
    
    [self.nativeExpressAd2Manager loadAdDataWithCount:1];
    
}


#pragma mark - 穿山甲广告 任务弹框
- (void)loadBUADData3
{
    BUAdSlot *slot1 = [[BUAdSlot alloc] init];
    slot1.adSize = CGSizeMake(300, 300/375.0 * 123.5 + 30 + 25);
    slot1.ID = @"946421253";
    slot1.AdType = BUAdSlotAdTypeFeed;
    
    BUSize *imgSize = [BUSize sizeBy:BUProposalSize_Feed228_150];
    slot1.imgSize = imgSize;
    slot1.position = BUAdSlotPositionFeed;
    
    
    self.nativeExpressAd3Manager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:CGSizeMake(300, 300/375.0 * 123.5 +25)];
    self.nativeExpressAd3Manager.delegate = self;
    
    [self.nativeExpressAd3Manager loadAdDataWithCount:1];
}


#pragma mark - 加载快手信息流广告
- (void)loadKSFeedADs
{
//    self.feedAdsManager = [[KSFeedAdsManager alloc] initWithPosId:@"6030000153" size:CGSizeMake(ScreenWidth, 0)];
//    self.feedAdsManager.delegate = self;
//    [self.feedAdsManager loadAdDataWithCount:1];
    
    self.feedAdsManager = [[KSFeedAdsManager alloc] initWithPosId:@"6030000153" size:CGSizeMake(300, 300/375.0 * 123.5 )];
    self.feedAdsManager.delegate = self;
    [self.feedAdsManager loadAdDataWithCount:1];
    
    
}



#pragma mark -  UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.tableView) {
        CGFloat offsetY = scrollView.contentOffset.y;
        NSLog(@"%f",offsetY);
        
        if (offsetY <= 0) {
            scrollView.contentOffset = CGPointMake(scrollView.contentOffset.x, 0);
        }
    }
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    id model = self.dataArray[indexPath.row];
    
    if ([model isKindOfClass:[BUNativeExpressAdView class]]) {

        BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)model;
        
        UIView* line = [UIView new];
        line.backgroundColor = [UIColor colorWithHex:0xcccccc];
        line.tag = 100;
        
        expressView.tag = 1000;
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nativeexpresscell" forIndexPath:indexPath];
        cell.selectionStyle =  UITableViewCellSelectionStyleNone;
        for (UIView* view in cell.contentView.subviews) {
            [view removeFromSuperview];
        }
                
        [cell.contentView addSubview:expressView];
        [cell.contentView addSubview:line];
        
        
        [expressView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.offset(0);
        }];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.offset(0);
            make.left.offset(15);
            make.right.offset(-15);
            make.height.offset(0.5);
        }];
        
        return cell;
        
    }
    
    
    KKTaskModel *tempModel = (KKTaskModel *)model;
    CoinCenterTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
    
    [cell.btn_right addTarget:self action:@selector(btn_Click:) forControlEvents:UIControlEventTouchUpInside];
    
    cell.btn_right.tag = indexPath.row + 200;
    
    
    
    [cell refreshUIWithModel:tempModel];
    
    
    [cell.adView removeFromSuperview];
    if (self.adDataArray.count > 0) {
        DHCWNativeAdDataObject *adModel = self.adDataArray[0];
        if ([tempModel.eventTitle isEqual:@"免费果园"]) {
            [cell setupCellWithModel:adModel delegate:self local:self rootViewController:self];
        }
    }
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    id model = self.dataArray[indexPath.row];
    
    if ([model isKindOfClass:[BUNativeExpressAdView class]]) {
        UIView* view = (UIView *)model;
        
        CGFloat height = view.bounds.size.height + 0.5;
    
        return height;
        //KSFeedAd *ad = (KSFeedAd *)model;
        
        //return ad.feedView.size.height * (ScreenWidth / ad.feedView.size.width) + 6 * WIDTHRADIU + 2;
    }
    
    return 67 * WIDTHRADIU + 0.5;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headView = [[UIView alloc]init];
    headView.backgroundColor = [UIColor colorWithHex:0xf4f4f4];
    return headView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10 * WIDTHRADIU;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    
}


#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return self.dateArray.count;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 1;
}
//这是正确的方法
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    SignInCollectionViewCell * cell  = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    [cell refreshUIWithData:self.dateArray[indexPath.section] index:indexPath.section currentIndex:self.weekIndex view:self.view];

    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(33 * WIDTHRADIU, 49 * WIDTHRADIU);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

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


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.item != (self.dateArray.count - 1) ) {
        LineCollectionReusableView *lineView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"lineCell" forIndexPath:indexPath];
        lineView.backgroundColor = [UIColor whiteColor];
        return lineView;
    }
   
    return nil;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    if (section == (self.dateArray.count - 1)) {
        return CGSizeZero;
    }
    
    CGFloat width = (ScreenWidth - (self.dateArray.count * 33 * WIDTHRADIU) - 40 * WIDTHRADIU)/(self.dateArray.count - 1);
    return CGSizeMake( width > 0 ? width : 17.5 * WIDTHRADIU , 49 * WIDTHRADIU);
}


//#pragma mark - ABURewardedVideoAdDelegate
///**
// This method is called when video ad material loaded successfully.
// */
//- (void)rewardedVideoAdDidLoad:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//}
//
///**
// This method is called when video ad materia failed to load.
// @param error : the reason of error
// */
//- (void)rewardedVideoAd:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd didFailWithError:(NSError *_Nullable)error
//{
//    ABUD_LogCallback(@"%s", __func__);
//}
//
///**
// This method is called when cached successfully.
// */
//- (void)rewardedVideoAdDidDownLoadVideo:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//    [self showABURewardVideoAd];
//}
//
///**
// This method is called when video ad slot has been shown.
// */
//- (void)rewardedVideoAdDidVisible:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//}
//
///**
// This method is called when video ad is clicked.
// */
//- (void)rewardedVideoAdDidClick:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//}
//
///**
// This method is called when video ad is skiped.
// */
//- (void)rewardedVideoAdDidSkip:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//}
//
///**
// This method is called when video ad is closed.
// */
//- (void)rewardedVideoAdDidClose:(ABURewardedVideoAd *_Nonnull)rewardedVideoAd
//{
//    ABUD_LogCallback(@"%s", __func__);
//}

/******** 激励广告回调处理 *********/
#pragma mark - BUMNativeExpressRewardedVideoAdDelegate
// 广告加载成功
- (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    // 广告加载成功之后，可以调用展示方法，按照实际需要调整代码位置
    [rewardedVideoAd showAdFromRootViewController:self];
}

// 广告加载失败
- (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error {
    
}

// 广告素材加载完成
- (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {

}

// 广告展示失败
- (void)nativeExpressRewardedVideoAdDidShowFailed:(BUNativeExpressRewardedVideoAd *_Nonnull)rewardedVideoAd error:(NSError *_Nonnull)error {
    
}

// 广告已经展示
- (void)nativeExpressRewardedVideoAdDidVisible:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    /*
    //  (注意: getShowEcpmInfo 需要在当前广告展示之后调用, 展示之前调用该方法会返回 nil)
    BUMRitInfo *info = [rewardedVideoAd.mediation getShowEcpmInfo];
    NSLog(@"ecpm:%@", info.ecpm);
    NSLog(@"platform:%@", info.adnName);
    NSLog(@"ritID:%@", info.slotID);
    NSLog(@"requestID:%@", info.requestID ?: @"None");
    */
}

// 广告已经关闭
- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    
}

// 广告被点击
- (void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    
}

// 广告被点击跳过
- (void)nativeExpressRewardedVideoAdDidClickSkip:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    
}

// 广告视频播放完成
- (void)nativeExpressRewardedVideoAdDidPlayFinish:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error {
    if (error == nil) {
        if (currentModel && currentBtn) {
            if ([currentModel.taskproperty isEqualToString:@"71"]) {
                [self getPackageByWhatVideos:currentModel];
            }else if ([currentModel.taskproperty isEqualToString:@"70"]){
                [self getdoubleExchargeRequest:currentModel];
            }
            
            
        }
        
        WeakSelf
        if ([self.type isEqualToString:@"buqian"]) {
            [self suppleTaskRequestWithBlock:^(bool result) {

                if (result) {
                    [weakSelf.tipsView removeFromSuperview];
                    [weakSelf sign2AndMakeCoinsInTasksRequest];
                    weakSelf.tipsView = nil;
                }

            }];
        }
    }
    
    //currentModel = nil;
    self.type = nil;
}

// 广告奖励下发
- (void)nativeExpressRewardedVideoAdServerRewardDidSucceed:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd verify:(BOOL)verify {
    if (verify) {
        if (currentModel && currentBtn) {
            if ([currentModel.taskproperty isEqualToString:@"71"]) {
                [self getPackageByWhatVideos:currentModel];
            }else if ([currentModel.taskproperty isEqualToString:@"70"]){
                [self getdoubleExchargeRequest:currentModel];
            }
            
            
        }
        
        WeakSelf
        if ([self.type isEqualToString:@"buqian"]) {
            [self suppleTaskRequestWithBlock:^(bool result) {

                if (result) {
                    [weakSelf.tipsView removeFromSuperview];
                    [weakSelf sign2AndMakeCoinsInTasksRequest];
                    weakSelf.tipsView = nil;
                }

            }];
        }
    }
}

// 广告奖励下发失败
- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error {

}





/**
 This method is called when video ad is about to close.
 */
- (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd
{
    
}






/**
 Server verification which is requested asynchronously is failed.
 Return value is not 2000.
 */
- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd
{
    
}
-(BOOL)shouldAutorotate{
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

#pragma mark - 穿山甲显示广告
// important: show的时候会进行WKWebview的渲染，建议一次最多展示三个广告，如果超过3个会很大概率导致WKWebview渲染失败。当然一般情况下激励视频一次只会show一个
- (void)showRewardVideoAd {
    if (self.rewardedAd) {
        [self.rewardedAd showAdFromRootViewController:self];
    }
}

- (void)showExpressAdView {
    if (self.expressAdViews.count) {
        BUNativeExpressAdView*expressView = (BUNativeExpressAdView *)self.expressAdViews[0];
        
        [self.adView addSubview:expressView];
        
        [expressView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.offset(10);
            make.bottom.right.offset(-10);
        }];
    }
   
}

#pragma mark - BUNativeExpressAdViewDelegate
- (void)nativeExpressAdSuccessToLoad:(BUNativeExpressAdManager *)nativeExpressAd views:(NSArray<__kindof BUNativeExpressAdView *> *)views {
    
    if (nativeExpressAd == self.nativeExpressAdManager) {
        [self.expressAdViews removeAllObjects];//【重要】不能保存太多view，需要在合适的时机手动释放不用的，否则内存会过大
        if (views.count) {

            [self.expressAdViews addObjectsFromArray:views];
            
            
    //        [self.expressAdViews addObject:views.firstObject];
            [views enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)obj;
                expressView.rootViewController = self;
                // important: 此处会进行WKWebview的渲染，建议一次最多预加载三个广告，如果超过3个会很大概率导致WKWebview渲染失败。
                [expressView render];
    //            *stop = YES;
            }];
            [self showExpressAdView];
            
        }
    }else if (nativeExpressAd == self.nativeExpressAd2Manager){
        
        if (views.count > 0) {
            [self.dataArray insertObject:views[0] atIndex:4];
            [views enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                        BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)obj;
                        expressView.rootViewController = self;
                        // important: 此处会进行WKWebview的渲染，建议一次最多预加载三个广告，如果超过3个会很大概率导致WKWebview渲染失败。
                        [expressView render];
            }];
        }
        
        
        
        [self.tableView reloadData];
        
    }else if (nativeExpressAd == self.nativeExpressAd3Manager){
        if (views.count > 0) {
            [views enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                        BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)obj;
                        expressView.rootViewController = self;
                        // important: 此处会进行WKWebview的渲染，建议一次最多预加载三个广告，如果超过3个会很大概率导致WKWebview渲染失败。
                        [expressView render];
            }];
            
            UIView * containerView = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20 + 288 + 20, 299, 300/375.0 * 123.5  + 25)];

            containerView.backgroundColor = [UIColor whiteColor];

            containerView.layer.cornerRadius = 10 * WIDTHRADIU;
            containerView.layer.masksToBounds = YES;

            [self.view addSubview:containerView];

            self.xmADView = containerView;
            
            
            BUNativeExpressAdView *adView = views[0];
            [self.xmADView addSubview:adView];
            [adView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.left.bottom.right.offset(0);
            }];
        }
    }
    
   
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdFailToLoad:(BUNativeExpressAdManager *)nativeExpressAd error:(NSError *)error {
    
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"error:%@", error]];
    
    if (nativeExpressAd == self.nativeExpressAd3Manager) {
        [self.xmADView removeFromSuperview];
    }
    
}

- (void)nativeExpressAdViewRenderSuccess:(BUNativeExpressAdView *)nativeExpressAdView {
    //[self.tableView reloadData];
    
}


- (void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView stateDidChanged:(BUPlayerPlayState)playerState {
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"playerState:%ld", (long)playerState]];
}

- (void)nativeExpressAdViewRenderFail:(BUNativeExpressAdView *)nativeExpressAdView error:(NSError *)error {
    [self pbud_logWithSEL:_cmd msg:[NSString stringWithFormat:@"error:%@  此广告将会从列表中移除", error]];
    
    if (nativeExpressAdView.size.width == ScreenWidth) {
        
        
            [self.dataArray removeObjectAtIndex:3];
            [self.tableView reloadData];
        
    }else{
        [nativeExpressAdView.superview removeFromSuperview];
    }
    
   
    
//    [self.expressAdViews removeObject:nativeExpressAdView];
//    [self.tableView reloadData];
    
}

- (void)nativeExpressAdViewWillShow:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidClick:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewPlayerDidPlayFinish:(BUNativeExpressAdView *)nativeExpressAdView error:(NSError *)error {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterWords {
    
    
    if (nativeExpressAdView.size.width == ScreenWidth) {
        
        
            [self.dataArray removeObject:nativeExpressAdView];
            [self.tableView reloadData];
        
    }else{
        [self.expressAdViews removeAllObjects];
        
        [nativeExpressAdView.superview removeFromSuperview];
    }
    
    
   
    
    //【重要】需要在点击叉以后 在这个回调中移除视图，否则，会出现用户点击叉无效的情况
//    [self.expressAdViews removeObject:nativeExpressAdView];
//
//    NSUInteger index = [self.expressAdViews indexOfObject:nativeExpressAdView];
//    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:index inSection:0];
//    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
//    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidClosed:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewWillPresentScreen:(BUNativeExpressAdView *)nativeExpressAdView {
    [self pbud_logWithSEL:_cmd msg:@""];
}

- (void)nativeExpressAdViewDidCloseOtherController:(BUNativeExpressAdView *)nativeExpressAdView interactionType:(BUInteractionType)interactionType {
    NSString *str;
    if (interactionType == BUInteractionTypePage) {
        str = @"ladingpage";
    } else if (interactionType == BUInteractionTypeVideoAdDetail) {
        str = @"videoDetail";
    } else {
        str = @"appstoreInApp";
    }
    [self pbud_logWithSEL:_cmd msg:str];
}


- (void)pbud_logWithSEL:(SEL)sel msg:(NSString *)msg {
    //BUD_Log(@"SDKDemoDelegate BUNativeExpressFeedAdView In VC (%@) extraMsg:%@", NSStringFromSelector(sel), msg);
}






#pragma mark - 刷新签到周期表
- (void)reloadHeaderCollectionViewWithData:(NSArray *)dataArray currentIndex:(NSInteger)currentIndex {
    [self.headerView reloadDataWithData:dataArray currentIndex:currentIndex view:self.view];
}


#pragma mark - BXMNativeAdDelegate

/// 广告加载成功
-(void)nativeRendAdsSuccessToLoad:(NSArray<DHCWNativeAdDataObject *> *)nativeAdDataArray nativeAd:(DHCWNativeRenderAd *)nativeAd
{
    NSLog(@"______自渲染加载成功");
    self.adDataArray = [NSMutableArray arrayWithArray:nativeAdDataArray];
    
    
    if (self.adDataArray.count > 0) {
        //DHCWNativeAdDataObject *model = self.adDataArray[0];
//        NSIndexPath *indexPath1 = [NSIndexPath indexPathForRow:0 inSection:0];
        //HomeCollectionCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
        //[cell setupCellWithModel:model delegate:self loca:self rootViewController:self];
        [self.tableView reloadData];
        
    }
}

/// 广告加载失败
-(void)nativeRendAdsLoadFailWithError:(NSError *)error nativeAd:(DHCWNativeRenderAd *)nativeAd
{
    NSString *toast = [NSString stringWithFormat:@"广告加载失败，code：%ld，%@", error.code, error.localizedDescription];
    NSLog(@"变现猫error:%@",toast);
}

#pragma mark - BXMNativeAdViewDelegate

/// 广告被点击
 - (void)nativeAdDidClick
{
    NSLog(@"______自渲染点击");
    
    for (int i = 0; i < self.dataArray.count; i++) {
        KKTaskModel *model = self.dataArray[i];
        if ([model.eventTitle isEqualToString:@"免费果园"] && model.taskStatus == 305) {
            [self increaseScoreWithType:model.taskId];
            break;
        }
    }
}

/// 广告详情页关闭
- (void)nativeAdDetailViewDidClosed
{
    NSLog(@"______关闭详情页");
}
#pragma mark ---------BXMNativeLocaVideoAdDelegate
/**
    加载视频
 */
-(void)loadNativeVideoWithAdId:(NSString *)adId loadVideoType:(DWLocalVideoType)videoType localVideoAd:(nonnull DHCWNativeLocalVideoAd *)localVideoAd
{
    [[LocalPlayerVideoManager manager]localVideoAd:localVideoAd];
}

/**
        展示视频
 */
-(void)showNativeVideoFromController:(UIViewController *)controller localVideoAd:(DHCWNativeLocalVideoAd *)localVideoAd
{
    
    [[LocalPlayerVideoManager manager] showVideoFromController:controller];
}

#pragma mark - 加载变现猫广告
- (void)loadBXMADViews
{
    self.nativeAd = [[DHCWNativeRenderAd alloc] initWithAdId:@"807696003001" imageSize:DWAdImageSize_Feed690_388];
    self.nativeAd.delegate = self;
    [self.nativeAd loadRendAdWithCount:1];
}

#pragma mark - KSFeedAdsManagerDelegate
- (void)feedAdsManagerSuccessToLoad:(KSFeedAdsManager *)adsManager nativeAds:(NSArray<KSFeedAd *> *_Nullable)feedAdDataArray {
    
    if (feedAdDataArray.count > 0) {
//        [self.dataArray insertObject:feedAdDataArray[0] atIndex:4];

        for (KSFeedAd *feedAd in feedAdDataArray) {
            feedAd.delegate = self;
        }

        KSFeedAd *ad = feedAdDataArray[0];

        [self.xmADView addSubview:ad.feedView];
        [ad.feedView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.bottom.right.offset(0);
        }];
    }
    
    [self.tableView reloadData];
}

- (void)feedAdsManager:(KSFeedAdsManager *)adsManager didFailWithError:(NSError *_Nullable)error {
    
    [self.xmADView removeFromSuperview];
}


#pragma mark - KSFeedAdDelegate
- (void)feedAdViewWillShow:(KSFeedAd *)feedAd {
   
}

- (void)feedAdDidClick:(KSFeedAd *)feedAd {
    
}

- (void)feedAdDislike:(KSFeedAd *)feedAd {
    
//    [self.dataArray removeObjectAtIndex:3];
//    [self.tableView reloadData];
    
    [self.xmADView removeFromSuperview];
}

- (void)feedAdDidShowOtherController:(KSFeedAd *)nativeAd interactionType:(KSAdInteractionType)interactionType {
    
}

- (void)feedAdDidCloseOtherController:(KSFeedAd *)nativeAd interactionType:(KSAdInteractionType)interactionType {
    
}
#pragma mark - event response
- (void)backClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
//#pragma mark - 听小说
//- (void)AlertListenNovel{
//    NSDate *oldTime = [[NSUserDefaults standardUserDefaults]objectForKey:@"ListenNovel"];
//
//    if (oldTime && [self isSameDay:[NSDate date] date2:oldTime]) {
//        [self.navigationController popViewControllerAnimated:YES];
//        return;
//    }
//
//    NSDate *oldDate = [NSDate date];
//    [[NSUserDefaults standardUserDefaults]setObject:oldDate forKey:@"ListenNovel"];
//    [[NSUserDefaults standardUserDefaults]synchronize];
//
//
////    @"userId":@([getPeopleID PeopleID]),
////    @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
////    @"fromAPP":@"kklife",
////    @"fromModel":@"2",
////    @"version": KKLifeVersionCode,
////    @"reqstamp":[Tools getNowTimeTimestamp],
////    @"isOpenPush":[self isUserNotificationEnable] ? @(1) :@(0)
//
//    [NetworkRequest statisticsWithEventName:@"show_CoinsCentre_ListenNovel"];
//    [GuideAlertView showInWindowWithImageName:@"ListenNovel" Block:^(BOOL success) {
//        NSString *url = [NSString stringWithFormat:@"http://content.ivoicead.com/index.html?mid=cb639a7c3f962f86e7bfdafe6c479861&content_id=57e419c365b17bb9db34b1512a00d8ef&buddle=:com.weface.kankanlife&dt=1&uid=%ld&ver=%@&os=1&carrier=[carrier]&ct=[connection_type]&make=[make]&model=[model]&oaid=[oaid]&imei=[imei]&idfa=[idfa]&aid=[android_id]&mac=[mac]&lat=[lat]&lon=[lon]&sw=[screen_width]&sh=[screen_height]",[getPeopleID PeopleID],KKLifeVersionCode];
//
//        [self jumpToHTML5:url andJAnalytics:@"听小说"];
//        [NetworkRequest statisticsWithEventName:@"dialog_CoinsCentre_ListenNovel"];
//    }];
//}
- (void)exchangeMoneyClick:(UIButton *)sender{
    //[SignInSuccessView showSuccessViewWithTitle:@"+30"];
    //[RetroactiveView showSuccessView];
   // [RedPackageSuccessView showSuccessViewWithType:RedPackageTypeNoMultiple];
    
   
    
    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 = CoinsRewardedUrl;
    //webVC.url = @"http://172.16.10.144/projects/html-nginx/html-nginx/lesson/award/src/award.html";
    [self.navigationController pushViewController:webVC animated:YES];
}


//签到
- (void)signBtnClick:(UIButton *)sender
{
    
    
    sender.userInteractionEnabled = NO;
    
    [self increase2ScoreWithType:@"1004"];
    
    
    sender.userInteractionEnabled = YES;
    
    

    
    
    
    
//    NSString *url = [NSString stringWithFormat:@"%@/score/increateScore",CoinsBaseUrl];
//
//    NSDictionary *dic = @{
//                          @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
//                          @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
//                          @"scoreType":@"1004",
//                        @"reqTimesTamp":[NSNumber numberWithInteger:[self getNowTimeTimestamp3]],
//                          @"fromModel":@"2"
//                          };
//
//
//    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"];
//
//    WeakSelf
//    [CTAPIBaseManager POST:url params:params completionHandler:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
//        if (responseObject) {
//            NSNumber *code = responseObject[@"code"];
//            if (code.integerValue == 1006) {
//
//
//                [weakSelf loadHttpData:[NSString stringWithFormat:@"%@",responseObject[@"result"][@"score"]]];
//                return ;
//
//            }
//        }
//
//
//    }];
}

#pragma mark - 去完成任务
- (void)btn_Click:(UIButton *)sender
{
    NSInteger index = sender.tag - 200;
    KKTaskModel* model = self.dataArray[index];

    switch (model.eventFlag.intValue) {
        case 101:{
            
            [self handelOriginalTaskWithModel:model taskDone:model.taskStatus == 305];

        }
            break;
        case 102:{
            

            [self showPopAnimation:[NSString stringWithFormat:@"%@",model.eventTitle] type:model.taskId imageName:model.eventParam];
            
            return;
            
            
        }
            break;
        case 103:
        {
            WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
            launchMiniProgramReq.userName = model.eventTitle;  //拉起的小程序的username
            launchMiniProgramReq.path = [NSString stringWithFormat:@"%@",model.eventParam];    //拉起小程序页面的可带参路径，不填默认拉起小程序首页
            launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
            [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
                
            }];
            
            if (model.taskStatus == 305) {
                [self performSelector:@selector(increaseScoreWithType:) withObject:model.taskId afterDelay:1.5];
            }
        }
            break;
        case 104:
        {
            
            [self jumpToHTML5:model.eventParam andJAnalytics:model.eventTitle WithModel:model];
            if (model.taskStatus == 305) {
                if (model.clickeventFlag == 601) {
                    [self performSelector:@selector(increaseScoreWithType:) withObject:model.taskId afterDelay:model.clickTime];
                }else{
                    [self performSelector:@selector(increaseScoreWithType:) withObject:model.taskId afterDelay:1.5];
                }
                
            }
        }
            
            break;
        case 105:
            break;
            
        default:
            break;
    }
}
- (void)goToCoinsDetailVC:(UIButton *)sender
{
   
    CoinsDetailListVC *vc = [[CoinsDetailListVC alloc]init];
    vc.title = @"金币明细";
    vc.type = ListVCTypeCoinsDetail;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}


#pragma mark - 处理原生任务跳转
- (void)handelOriginalTaskWithModel:(KKTaskModel *)model taskDone:(BOOL)success
{
    if (![Tools isBlankString:model.eventParam]) {
        if (model.eventParam.length > 0) {
            if ([model.eventParam isEqualToString:@"getMovieUrl"]) {
                //看电影
                [self GetHeyshadowUrlWithModel:model];
            }else if ([model.eventParam isEqualToString:@"homeTwo6"]) {
                //限时特惠
                [self goToFanLiVCWithModel:model];
            }else{
//                NSDictionary *dict = [Tools dictionaryWithJsonString:model.eventParam];
//                [self goToVCWithReflexDic:dict];
                [[clickEvent instance] clickEventRooterVC:self Content:model.eventParam menuName:@"" TaskModel:model];
            }
        }
    }else
        if ([model.eventTitle isEqualToString:@"看视频赚金币"]) {
            [self goToTVVC:YES WithModel:model];
        }else if ([model.eventTitle isEqualToString:@"看视频送红包"]){
            [self goToTVVC:NO WithModel:model];
        }else if ([model.eventTitle isEqualToString:@"首页抢红包"]){
            BOOL show =  [UserDefault boolForKey:@"grabRedEnvelope"];
            
            if (show) {
                [self goToTVVC:NO WithModel:model];
            }else{
                [self goToRewardVC];
            }
            show = !show;
            
            [UserDefault setBool:show forKey:@"grabRedEnvelope"];
            [UserDefault synchronize];
        }else if ([model.eventTitle isEqualToString:@"浏览小金库"]){
            [self goToLittleGoldHouseVCWithModel:model taskDone:success];
        }else if ([model.eventTitle isEqualToString:@"0元领"]){
            [self getZeroInsuranceRequestWithType:@"100103"];
        }else if ([model.eventTitle isEqualToString:@"免费果园"]){
            [self goToFreeFruitVCWithModel:model];
        }else if ([model.eventTitle isEqualToString:@"阅读新闻头条"]){
            HeadLineViewController*newsVC = [HeadLineViewController new];
            newsVC.TaskModel = model;
            newsVC.title = @"新闻";
            newsVC.from = @"home";
            newsVC.currentIndex = 0;
            [self.navigationController pushViewController:newsVC animated:YES];
        }else if ([model.eventTitle isEqualToString:@"完善个人信息"]){
            WeakSelf
            PersonInfoViewController *pfVC = [PersonInfoViewController new];
            pfVC.title = @"个人信息";
            pfVC.from = @"coinCenter";
            pfVC.block = ^(NSString * _Nonnull coinsNum) {
              
                [weakSelf refreshPersonInfoAndShowAlertViewWithScore:coinsNum];
                
            };
            [self.navigationController pushViewController:pfVC animated:YES];
            return;
        }else if ([model.eventTitle isEqualToString:@"打开推送消息"]){
            if (model.taskStatus == 305) {
                if (![self isUserNotificationEnable]) {
                    [self goToAppSystemSetting:model.taskId];
                }else{
                    [self increaseScoreWithType:model.taskId];
                }
            }
            return;
        }else if ([model.eventTitle isEqualToString:@"浏览在线兼职"]){
            [self goToOnlinePartTimeJobVCWithModel:model];
        }
    
    if (model.taskStatus == 305) {
        if (model.clickeventFlag == 601) {
            [self performSelector:@selector(increaseScoreWithType:) withObject:model.taskId afterDelay:model.clickTime];
        }else{
            [self performSelector:@selector(increaseScoreWithType:) withObject:model.taskId afterDelay:1.5];
        }
    }
}
#pragma mark - 电影券
- (void)GetHeyshadowUrlWithModel:(KKTaskModel *)model
{
    NSString *url = [NSString stringWithFormat:@"http://h5.weface.com.cn/20200228/haiying/login?tel=%@&id=%@",[getPeopleID PeopleIphoneNmber],@([getPeopleID PeopleID])];
    url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet  URLQueryAllowedCharacterSet]];
    NSDictionary *params = [NSDictionary dictionary];
    [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]];
           
            [self jumpToHTML5:url andJAnalytics:@"电影券" WithModel:model];

        }else{
            [self alertShow:describe];
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
    }];
}
#pragma mark - 返利网
- (void)goToFanLiVCWithModel:(KKTaskModel *)model
{
    NSString *url = [NSString stringWithFormat:@"https://web.kanface.com:444/get/fanli/url?uid=%@",@([getPeopleID PeopleID])];
    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]];
           
            [self jumpToHTML5:url andJAnalytics:@"限时特惠" WithModel:model];

        }else{
            [self alertShow:describe];
        }
        
        
    } Failure:^(NSError* error) {
        [KKLoadingAnimationView dismiss];
        NSLog(@"error:%@",error);
        [self alertShow:@"网络异常"];
    }];
}
#pragma mark - 提示
- (void)alertShow:(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)goToVCWithReflexDic:(NSDictionary *)dict
{
    // 根据字典字段反射出我们想要的类，并初始化控制器
    Class class = NSClassFromString(dict[@"className"]);
    UIViewController *vc = [[class alloc] init];
    vc.title = dict[@"classTitle"];
    // 获取参数列表，使用枚举的方式，对控制器属性进行KVC赋值
    NSDictionary *parameter = dict[@"propertys"];
    [parameter enumerateKeysAndObjectsUsingBlock:^(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
        // 在属性赋值时，做容错处理，防止因为后台数据导致的异常
        if ([vc respondsToSelector:NSSelectorFromString(key)]) {
            [vc setValue:obj forKey:key];
        }
    }];
    
    
    
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    // 从字典中获取方法名，并调用对应的方法
    NSString* methods = [NSString stringWithFormat:@"%@",dict[@"method"]];
    if (![Tools isBlankString:methods]) {
        SEL selector = NSSelectorFromString(methods);
        
        ((void (*)(id, SEL))[vc methodForSelector:selector])(vc, selector);
    }
}


#pragma mark - 跳转到小视频
- (void)goToTVVC:(BOOL)fromHome WithModel:(KKTaskModel *)model {
    KKSVideoViewController *oneVC = [[KKSVideoViewController alloc] init];
    oneVC.TaskModel = model;
    oneVC.fromHome = fromHome;
    oneVC.title = fromHome ?@"看视频" :@"红包视频";
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:oneVC animated:YES];
}
- (void)goToTVVC:(BOOL)fromHome{

    KKSVideoViewController *oneVC = [[KKSVideoViewController alloc]initWithType:fromHome];
    oneVC.title = fromHome ?@"看视频" :@"红包视频";
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:oneVC animated:YES];
}
//- (UITabBarItem *)getCustomItemWithTitle:(NSString *)title image:(NSString *)imageName selectedImage:(NSString *)selectedImageName
//{
//    UIImage *image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage* selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//     UITabBarItem *tabbarItem = [[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
//    [tabbarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHex:0x137ef6], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
//
//    return tabbarItem;
//}
#pragma mark - 0元领TabVC
- (void)goToInsurnceVC:(NSArray<KKInsuranceModel *> *)array
{
   
    KKInsuranceModel* leftModel = array[0];
    KKInsuranceContainerController *containerVC = [KKInsuranceContainerController new];
    
    containerVC.title = leftModel.title;

    containerVC.dataArray = array;

    containerVC.hidesBottomBarWhenPushed = YES;

    [self.navigationController pushViewController:containerVC animated:YES];
    
    
//    if ([leftModel.pageName isEqualToString:@"重疾险"]) {
//        [self makeInsuranceStatisticsRequestWithType:@"100104"];
//    }else if ([leftModel.pageName isEqualToString:@"综合险"]){
//        [self makeInsuranceStatisticsRequestWithType:@"100105"];
//    }

    return;
    
    
    /*
    
    KKInsuranceModel* leftModel = array[0];
    KKInsuranceModel* rightModel = array[1];
    
    KKInsuranceTabBarController *tabBarVC = [[KKInsuranceTabBarController alloc] init];
    tabBarVC.dataArray = array;
    
    KKInsuranceViewController *oneVC = [[KKInsuranceViewController alloc] init];
    oneVC.title = leftModel.title;
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.url = leftModel.path;
    oneVC.tabBarItem = [self getCustom2ItemWithTitle:leftModel.pageName image:@"" selectedImage:@""];
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:oneVC];
    [tabBarVC addChildViewController:nav1];
     
      
    KKInsuranceViewController *twoVC = [[KKInsuranceViewController alloc] init];
  
    twoVC.title = rightModel.title;
    twoVC.view.backgroundColor = [UIColor whiteColor];
    twoVC.url = rightModel.path;
    twoVC.tabBarItem = [self getCustom2ItemWithTitle:rightModel.path image:@"" selectedImage:@""];
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:twoVC];
    [tabBarVC addChildViewController:nav2];
      
      
    //修改主题的颜色
    tabBarVC.tabBar.tintColor = [UIColor colorWithHex:0x137ef6];
    tabBarVC.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:tabBarVC animated:YES];
     
     */
     
    
}


#pragma mark - 跳转到金币抽奖页面
- (void)goToRewardVC {

    NSDictionary *params = @{
                             @"userId":[NSNumber numberWithInteger:[getPeopleID PeopleID]],
                             @"telephone": [EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY]
                             };
    NSString *url =[NSString stringWithFormat:@"%@score/getpersonintegrals",CoinsBaseUrl];
    
    WeakSelf;
    [BaseNetManager POST2:url parameters:params completionHandler:^(id responseObj, NSError *error) {
        if (responseObj) {
            NSString *code = [responseObj[@"code"] stringValue];
            if ([code isEqualToString:@"0"]) {
                [getPeopleID getTotalCoins:responseObj[@"result"]];
                
                if ([self.navigationController.visibleViewController isKindOfClass:[CoinsCenterViewController class]]) {
                    
                    WebVC *webVC = [[WebVC alloc]init];
                     webVC.type = @"home";
                     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;
                     [weakSelf.navigationController pushViewController:webVC animated:YES];
                    
                }
                
                
            }
        }
    }];
    
}

#pragma mark - 跳转小金库
- (void)goToLittleGoldHouseVCWithModel:(KKTaskModel *)model taskDone:(BOOL)success
{
    LittleGoldHouseWebVC *oneVC = [[LittleGoldHouseWebVC alloc] init];
    oneVC.title = @"浏览小金库";
    oneVC.view.backgroundColor = [UIColor whiteColor];
    oneVC.fromHome = YES;
    oneVC.showTaskView = success;
    oneVC.taskType = LittleGoldHouseTaskTypeCoins;
    WeakSelf
    oneVC.block = ^(BOOL success) {
        [weakSelf increaseScoreWithType:model.taskId];
    };
    [self.navigationController pushViewController:oneVC animated:YES];
}

#pragma mark - 跳转在线兼职
- (void)goToOnlinePartTimeJobVCWithModel:(KKTaskModel *)model
{
    
    WebVC *oneVC = [[WebVC alloc] init];
    oneVC.TaskModel = model;
    oneVC.title = @"在线兼职";
    oneVC.url = [NSString stringWithFormat:@"https://squirrel.kxbwmedia.com/ditch/task?union_id=10222&phoneNum=%@&uuid=%@",[getPeopleID PeopleIphoneNmber],@([getPeopleID PeopleID])];
    oneVC.taskType = LittleGoldHouseTaskTypeCoins;
    oneVC.showTaskView = YES;
    oneVC.taskId = model.taskId;
    WeakSelf
    oneVC.block = ^(BOOL success) {
        [weakSelf increaseScoreWithType:model.taskId];
    };
    [self.navigationController pushViewController:oneVC animated:YES];
}


#pragma mark - 免费果园
- (void)goToFreeFruitVCWithModel:(KKTaskModel *)model
{
    MyFruitViewController *fruitVC = [MyFruitViewController new];
    fruitVC.TaskModel = model;
    fruitVC.title = @"免费果园";
    fruitVC.placeId = @"6666";
    fruitVC.buId = @"946405751";
    fruitVC.gdtAdId = @"2062615177198724";
    fruitVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:fruitVC animated:YES];
}

- (void)addRedPackage
{
    //素材使用代码
   //素材曝光,一般在素材加载完成的时候调用.如果不知道素材加载好的时机,可以在素材所在页面加载完成的时候调用
//  __block NSString*adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
   
   
   //加载素材
   //__weak typeof(self) weakSelf = self;
   [BXMediaMaterialManager getEntranceMaterialsWithAppkey:@"kksh-IOS-hdgj_xsekjn" placId:@"6666" thirdUserId:@"" success:^(BXMMaterialModel *model) {
       //weakSelf.model = model;
       if (model) {
           
           [BXMediaMaterialManager entranceShowEventTrackingWithPlaceId:@"6666" userId:@"" materialModel:model];
           
           [BXMediaMaterialManager entranceClickEventTrackingWithPlaceId:@"6666" userId:@"" materialModel:nil];
           
           
           KKActivityViewController *vc = [KKActivityViewController new];
           vc.title = @"免费果园";
           vc.placeId = @"6666";
           vc.buId = @"946405751";
           vc.gdtAdId = @"2062615177198724";
       //    vc.placeId = @"6666";
       //    vc.buId = @"946405751";
       //    vc.gdtAdId = @"2062615177198724";
           [self.navigationController pushViewController:vc animated:YES];
           
           
       }
   } fail:^(NSString *error) {
       
   }];
}



#pragma mark - 完成各个信息任务弹框
- (void)refreshPersonInfoAndShowAlertViewWithScore:(NSString *)score
{
    WeakSelf
    [PrizeInfoCommitSuccessAlertView showReceiveViewWithVC:self Number:score block:^(CTShareType type) {
        if (weakSelf.xmADView.superview) {
            [weakSelf.xmADView removeFromSuperview];
        }
    }];
//    [PrizeInfoCommitSuccessAlertView showReceiveViewWithVC:self Number:score block:^(CTShareType type) {
//       if (weakSelf.xmADView.superview) {
//           [weakSelf.xmADView removeFromSuperview];
//       }
//    } ExchangBlock:^{
//       //兑换
//       [[clickEvent instance] clickEventRooterVC:weakSelf Content:@"JBDH" menuName:@"金币兑换" ID:@"0"];
//        [NetworkRequest statisticsWithEventName:@"dialog_Task_JBDH"];
//    }];
    
//    UIView * adView = [[UIView alloc]initWithFrame:CGRectMake((ScreenWidth - 299) / 2, (ScreenHeight - 288) / 2 - 20 + 288 + 20, 299, 300/375.0 * 123.5 + 25)];
//
//    adView.backgroundColor = [UIColor whiteColor];
//
//    adView.layer.cornerRadius = 10 * WIDTHRADIU;
//
//    [self.view addSubview:adView];
//
//    self.xmADView = adView;


    [self loadBUADData3];
    
    [self sign2AndMakeCoinsInTasksRequest];
}


#pragma mark - h5跳转
-(void)jumpToHTML5:(NSString*)url andJAnalytics:(NSString*)janalytics WithModel:(KKTaskModel *)model
{
    WebVC *webvc = [[WebVC alloc]init];
    webvc.url = url;
    webvc.TaskModel = model;
    webvc.title = janalytics;
    [self.navigationController pushViewController:webvc animated:YES];
    return;
}

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

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



#pragma mark - 判断是否是同一天
- (BOOL)isSameDay:(NSDate*)date1 date2:(NSDate*)date2
{
    NSCalendar* calendar = [NSCalendar currentCalendar];
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
    NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1];
    NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2];
    return [comp1 day] == [comp2 day] &&
    [comp1 month] == [comp2 month] &&
    [comp1 year] == [comp2 year];
}

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

//计算今天周几
- (NSInteger)getNowWeekday {
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday |
    NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    NSDate *now = [NSDate date];
    // 话说在真机上需要设置区域，才能正确获取本地日期，天朝代码:zh_CN
    calendar.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
    comps = [calendar components:unitFlags fromDate:now];
    return [comps weekday]  - 1;
}

- (BOOL)isUserNotificationEnable { // 判断用户是否允许接收通知
    BOOL isEnable = NO;
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0f) { // iOS版本 >=8.0 处理逻辑
        UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];
        isEnable = (UIUserNotificationTypeNone == setting.types) ? NO : YES;
    } else { // iOS版本 <8.0 处理逻辑
        UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
        isEnable = (UIRemoteNotificationTypeNone == type) ? NO : YES;
    }
    return isEnable;
}


#pragma mark - 跳转
// 如果用户关闭了接收通知功能，该方法可以跳转到APP设置页面进行修改  iOS版本 >=8.0 处理逻辑
- (void)goToAppSystemSetting:(NSString *)scoreType {
    WeakSelf
    UIApplication *application = [UIApplication sharedApplication];
    NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
    if ([application canOpenURL:url]) {
        if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
            [application openURL:url options:@{} completionHandler:^(BOOL success) {
                     [weakSelf increaseScoreWithType:scoreType];
            }];
        } else {
            [application openURL:url];
             [self increaseScoreWithType:scoreType];
        }
    }
}


//跳转微信
-(void)openWechat:(NSString *)scoreType{
    UIApplication *application = [UIApplication sharedApplication];
    NSURL * url = [NSURL URLWithString:@"weixin://"];
    BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
    //先判断是否能打开该url
    if (canOpen)
    {   //打开微信
//        WeakSelf
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            
            if ([application respondsToSelector:@selector(openURL:options:completionHandler:)]) {
                [application openURL:url options:@{} completionHandler:^(BOOL success) {
                        //[weakSelf increaseScoreWithType:scoreType];
                    [self performSelector:@selector(increaseScoreWithType:) withObject:scoreType afterDelay:1.5];
                }];
            } else {
                [application openURL:url];
                 //[weakSelf increaseScoreWithType:scoreType];
                [self performSelector:@selector(increaseScoreWithType:) withObject:scoreType afterDelay:1.5];
            }
            
        });
        
        
    }else {
        [SVProgressHUD showInfoWithStatus:@"您的设备未安装微信APP"];
    }
}



#pragma mark 显示弹框
- (void)showPopAnimation:(NSString *)title type:(NSString *)scoreType imageName:(NSString *)imageName
{
    
    [OfficialAccountsAlertView alertWithVC:self Title:title imageName:imageName block:^(BOOL show) {
        [Tools showMessage:@"复制成功"];

        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        
        pasteboard.string = title;
    
        [self openWechat:scoreType];
    }];
    
    /*
    ZJAnimationPopStyle popStyle = ZJAnimationPopStyleShakeFromTop;
    ZJAnimationDismissStyle dismissStyle = ZJAnimationDismissStyleNO;
    
    
    OfficialAccountsAlertView *alertView = [OfficialAccountsAlertView alertWithTitle:title imageName:imageName];
//    alertView.backgroundColor = [UIColor whiteColor];
//    alertView.layer.cornerRadius = 15 * WIDTHRADIU;
    _customView = alertView;
    // 1.初始化
    ZJAnimationPopView *popView = [[ZJAnimationPopView alloc] initWithCustomView:alertView popStyle:popStyle dismissStyle:dismissStyle];
    
    // 2.设置属性，可不设置使用默认值，见注解
    // 2.1 显示时点击背景是否移除弹框
    popView.isClickBGDismiss = ![OfficialAccountsAlertView isKindOfClass:[OfficialAccountsAlertView class]];
    // 2.2 显示时背景的透明度
    popView.popBGAlpha = 0.5f;
    // 2.3 显示时是否监听屏幕旋转
    popView.isObserverOrientationChange = NO;
    // 2.4 显示时动画时长
    //    popView.popAnimationDuration = 0.8f;
    // 2.5 移除时动画时长
    //    popView.dismissAnimationDuration = 0.8f;
    
    // 2.6 显示完成回调
    popView.popComplete = ^{
        NSLog(@"显示完成");
    };
    // 2.7 移除完成回调
    popView.dismissComplete = ^{
        NSLog(@"移除完成");
    };
    
    // 3.处理自定义视图操作事件
    [self handleCustomActionEnvent:popView title:title type:scoreType];
    
    // 4.显示弹框
    [popView pop];
     */
}

#pragma mark 处理自定义视图操作事件
- (void)handleCustomActionEnvent:(ZJAnimationPopView *)popView title:(NSString *)title type:(NSString *)scoreType
{
    /*
    // 在监听自定义视图的block操作事件时，要使用弱对象来避免循环引用
    __weak typeof(popView) weakPopView = popView;
    if ([_customView isKindOfClass:[OfficialAccountsAlertView class]]) {
        OfficialAccountsAlertView *infoPopView = _customView;
        infoPopView.block = ^(BOOL click) {
            if (click) {
                [weakPopView dismiss];
                
                [self.view makeToast:@"复制成功"];
                UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
                if ([title containsString:@"看看社保"]) {
                    pasteboard.string = @"看看社保";
                }else if([title containsString:@"看看认证"]){
                    pasteboard.string = @"看看认证";
                }
               
                


                [self openWechat:scoreType];
            }
        };
    }
    
    */
}


#pragma mark - getters and setters

- (UIButton *)rightBtn
{
    if (!_rightBtn) {
        _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightBtn.frame = CGRectMake(0, 0, 65, 22);
        [_rightBtn setTitle:@"明细" forState:UIControlStateNormal];
        [_rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_rightBtn setImage:[UIImage imageNamed:@"btn_coinsdetail"] forState:UIControlStateNormal];
        _rightBtn.titleLabel.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
        [_rightBtn layoutButtonWithEdgeInsetsStyle:GLButtonEdgeInsetsStyleLeft imageTitleSpace:4 * WIDTHRADIU ];
        _rightBtn.backgroundColor = [UIColor colorWithHex:0xfa6b05];
        _rightBtn.layer.cornerRadius = 11;
        [_rightBtn addTarget:self action:@selector(goToCoinsDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rightBtn;
}

//- (CoinCenterSignTableViewCell *)headerView {
//    if (!_headerView) {
//        _headerView = [[CoinCenterSignTableViewCell alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 274 * WIDTHRADIU)];
//    }
//    return _headerView;
//}

//- (UIView *)headerView
//{
//    if (!_headerView) {
//        _headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 218 * WIDTHRADIU)];
//        _headerView.backgroundColor = [UIColor whiteColor];
//
//        [_headerView addSubview:self.cardView];
//        [_headerView addSubview:self.collectionView];
//        [_headerView addSubview:self.btn_signIn];
//    }
//    return _headerView;
//}

- (UIView *)cardView
{
    if (!_cardView) {
        _cardView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 95 * WIDTHRADIU)];
        _cardView.backgroundColor = [UIColor colorWithHex:0xf98505];
       
        [_cardView addSubview:self.lb_coinsNum];
        [_cardView addSubview:self.lb_coinsNumTitle];
        [_cardView addSubview:self.btn_exchangeMoney];
        
        [_cardView addSubview:self.btn_arrow];
        
    }
    return _cardView;
}

//- (UICountingLabel *)lb_coinsNum
//{
//    if (!_lb_coinsNum) {
//        _lb_coinsNum = [[UICountingLabel alloc]init];
//        _lb_coinsNum.text = @"0";
//        _lb_coinsNum.method = UILabelCountingMethodEaseOut;
//        _lb_coinsNum.format = @"%d";
//        _lb_coinsNum.textColor = [UIColor whiteColor];
//        _lb_coinsNum.font = [UIFont systemFontOfSize:35 * WIDTHRADIU];
//        _lb_coinsNum.textAlignment = NSTextAlignmentCenter;
//    }
//    return _lb_coinsNum;
//}

- (UILabel *)lb_coinsNumTitle
{
    if (!_lb_coinsNumTitle) {
        _lb_coinsNumTitle = [[UILabel alloc]init];
        _lb_coinsNumTitle.text = @"可用金币(个)";
        _lb_coinsNumTitle.textColor = [UIColor whiteColor];
        _lb_coinsNumTitle.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
        _lb_coinsNumTitle.textAlignment = NSTextAlignmentCenter;
    }
    return _lb_coinsNumTitle;
}

- (ExchangeMoneyBtn *)btn_exchangeMoney
{
    if (!_btn_exchangeMoney) {
        _btn_exchangeMoney = [ExchangeMoneyBtn buttonWithType:UIButtonTypeCustom];
        [_btn_exchangeMoney setTitle:@"金币抽奖" forState:UIControlStateNormal];
        [_btn_exchangeMoney setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn_exchangeMoney.titleLabel.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
        _btn_exchangeMoney.backgroundColor = [UIColor colorWithHex:0xfa6b05];
        [_btn_exchangeMoney addTarget:self action:@selector(exchangeMoneyClick:) forControlEvents:UIControlEventTouchUpInside];
        _btn_exchangeMoney.hidden = YES;
    }
    return _btn_exchangeMoney;
}

- (UIButton *)btn_arrow
{
    if (!_btn_arrow) {
        _btn_arrow = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btn_arrow setImage:[UIImage imageNamed:@"nextArrow"] forState:UIControlStateNormal];
        [_btn_arrow setTitle:@"" forState:UIControlStateNormal];
        [_btn_arrow addTarget:self action:@selector(goToCoinsDetailVC:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn_arrow;
}



- (UICollectionView *)collectionView
{
    if (!_collectionView) {
        //创建一个layout布局类
        UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
        //设置布局方向为垂直流布局
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        //设置每个item的大小为100*100
        layout.itemSize = CGSizeMake(100, 60);

        _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(20 * WIDTHRADIU, 105 * WIDTHRADIU, ScreenWidth - 40 * WIDTHRADIU, 49 * WIDTHRADIU) collectionViewLayout:layout];
        _collectionView.backgroundColor = [UIColor whiteColor];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        [_collectionView registerClass:[SignInCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
        [_collectionView registerClass:[LineCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"lineCell"];
    }
    return _collectionView;
}

- (UIButton *)btn_signIn
{
    if (!_btn_signIn) {
        _btn_signIn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn_signIn.frame = CGRectMake(10 * WIDTHRADIU, CGRectGetMaxY(self.collectionView.frame) + 15 * WIDTHRADIU, ScreenWidth - 20 * WIDTHRADIU, 45 * WIDTHRADIU);
        [_btn_signIn setTitle:@"打卡领金币" forState:UIControlStateNormal];
        [_btn_signIn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn_signIn.titleLabel.font = [UIFont systemFontOfSize:17 * WIDTHRADIU];
        _btn_signIn.backgroundColor = [UIColor colorWithHex:0xed8b0b];
        _btn_signIn.layer.cornerRadius = 22 * WIDTHRADIU;
        _btn_signIn.userInteractionEnabled = YES;
        [_btn_signIn addTarget:self action:@selector(signBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn_signIn;
}


- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.estimatedRowHeight = 50;
        
        UIView* headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cl_kNavigationBarHeight + (270 + 100) * WIDTHRADIU)];
        headerView.backgroundColor = [UIColor whiteColor];
        
        CoinCenterHeaderView* cell = [[CoinCenterHeaderView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, cl_kNavigationBarHeight + (270 + 100) * WIDTHRADIU)];
        cell.delegate = self;
        cell.rootVC = self;
        [headerView addSubview:cell];
        
        self.headerView = cell;
        self.lb_coinsNum = self.headerView.lb_coinsNum;
        //headerView.userInteractionEnabled = YES;
        
        _tableView.tableHeaderView = headerView;
        
        GoldBottomView* footView = [[GoldBottomView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-20*WIDTHRADIU, 480 * WIDTHRADIU)];
        footView.delegate = self;
        footView.reloadData;
        footView.rootVc=self;
        _tableView.tableFooterView=footView;
        [_tableView registerClass:[CoinCenterTableViewCell class] forCellReuseIdentifier:@"cell"];
        [_tableView registerClass:[KSFeedAdCell class] forCellReuseIdentifier:@"KSFeedAdCell"];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"nativeexpresscell"];
         _tableView.separatorStyle =  UITableViewCellSeparatorStyleNone;
       
        _tableView.hidden = YES;

    }
    return _tableView;
}
//底部商品点击
- (void)GoldBottomViewItemClick:(NSInteger)item:(NSDictionary*)model{
    NSLog(@"底部商品:%ld%@",(long)item,model);
    NSDictionary *dic = [getPeopleID totalCoins];
    NSString *url=[NSString stringWithFormat:@"https://h5p.weface.com.cn/appH5/kkmall/#/gooddetial?goodsId=%@&usableScore=%@&goodType=",model[@"id"],[NSString stringWithFormat:@"%@",[dic[@"totalScore"] stringValue]],model[@"goodType"]];
    WebVC *webvc = [[WebVC alloc]init];
    webvc.url=url;
    webvc.title=@"金币商城";
    [self.navigationController pushViewController:webvc animated:YES];
}
#pragma mark - 规则说明
- (void)showDeclareAlertView {
    NSString *str = @" 【签到规则】\n1、签到周期为连续7个自然日；\n2、平台所有用户均可参与；\n3、每日连续签到可获得对应金币奖励；\n4、签到周期内发生断签，则签到周期重新计算；\n5、签到金币累计明细可在【我的】-【可用金币】查看。\n\n 【好友助力规则】\n1、用户分享的助力链接仅当日有效，每天24点自动失效；\n2、每有1位好友助力成功，当天签到金币翻1倍。每日最高可有3位好友助力，当日金币最高翻3倍；\n3、若当日未打卡，分享活动给好友助力无法获得金币翻倍；\n4、同一用户账号，同一手机号，同一设备终端，同一身份账号，均视为同一用户。\n\n看看智能拥有最终解释权";
    
    InviteRegulationView *alertView = [[InviteRegulationView alloc]initWithTitle:@"签到规则" message:str delegate:self ButtonTitle:@"知道了"];
    
    [alertView show];
    
}
#pragma mark - 签到分享
- (void)SignShare{
    if (self.ShareDic.count > 0) {
        
        [self share5WebPageToPlatformType:UMSocialPlatformType_WechatSession url:self.ShareDic[@"targetUrl"] title:self.ShareDic[@"title"] message:self.ShareDic[@"description"] imageUrl:self.ShareDic[@"icoUrl"]];
    }
}
- (void)share5WebPageToPlatformType:(UMSocialPlatformType)platformType url:(NSString *)url title:(NSString *)title message:(NSString *)message imageUrl:(NSString *)imageUrl
{
    if (![WXApi isWXAppInstalled]) {
           [Tools showMessage:@"请先安装微信!!!"];
           return;
       }
    
//    WeakSelf
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    
    
    //创建网页内容对象
    UMShareWebpageObject *shareObject = nil;
    
    if (imageUrl.length > 0) {
        shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:message thumImage:imageUrl];
    }else{
        shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:message thumImage:[UIImage imageNamed:@"login_icon"]];
    }
   
      
    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);
            }
            
           // [weakSelf loadData2:@"1015"];
        }
        
    }];
}
#pragma mark - 获取签到提醒状态
- (void)RequestSignRemind{
    NSString *clientId = [UserDefault valueForKey:@"clientId"];
    if (clientId && clientId.length == 0) {
        return;
    }
    NSString *url = [NSString stringWithFormat:@"%@query/cid",[NetworkConfig ipYinShuConfig]];
//    NSString *url = [NSString stringWithFormat:@"%@query/cid",@"http://172.16.10.18:8017/"];
    NSDictionary *params1 = @{
        @"cid":clientId,
        @"uid":@([getPeopleID PeopleID]),
        @"type":@(1001)
    };
    WeakSelf
    [NetworkRequest PostNo:url Params:params1 Success:^(id _Nonnull objc) {
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
            if ([state isEqualToString:@"200"]) {
                [weakSelf.headerView setSignRemindBtnInterace:[objc[@"result"][@"status"] boolValue]];
            }
        }
    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
}
#pragma mark - 获取分享地址
- (void)getShareUrl{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    app_Version = [app_Version stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSString *url = [NSString stringWithFormat:@"%@shareservice/getShareUrl",CoinsBaseUrl];
//    NSString *url = [NSString stringWithFormat:@"%@scoreService/shareservice/getShareUrl",@"http://172.16.10.215:8080/"];
    NSDictionary *params1 = @{
        @"userId":@([getPeopleID PeopleID]),
        @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
        @"shareType":@"21001",
        @"fromModel":@(2),
        @"platform":@"kksh",
        @"version":app_Version,
    };
    WeakSelf
    [NetworkRequest Post11:url Params:params1 Success:^(id _Nonnull objc) {
        if ([objc[@"result"] isKindOfClass:[NSDictionary class]]) {
            weakSelf.ShareDic = objc[@"result"];
        }
    } Failure:^(NSError *error) {
        NSLog(@"error:%@",error);
    }];
}
#pragma mark - 获取分享用户
- (void)getshredusers{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    app_Version = [app_Version stringByReplacingOccurrencesOfString:@"." withString:@""];
    NSString *url = [NSString stringWithFormat:@"%@shareservice/getshredusers",CoinsBaseUrl];
//    NSString *url = [NSString stringWithFormat:@"%@scoreService/shareservice/getshredusers",@"http://172.16.10.215:8080/"];
    NSDictionary *params1 = @{
        @"platform":@"kksh",
        @"version":app_Version,
        @"shareType":@"21001",
        @"userId":@([getPeopleID PeopleID]),
        @"telephone":[EnercryTool encryptUseDES:[getPeopleID PeopleIphoneNmber] key:DESKEY],
    };
    WeakSelf
    [NetworkRequest Post11:url Params:params1 Success:^(id _Nonnull objc) {
        if ([objc isKindOfClass:[NSDictionary class]]) {
            NSString *state = [NSString stringWithFormat:@"%@",objc[@"code"]];
            if ([state isEqualToString:@"0"]) {
                if ([objc[@"result"] isKindOfClass:[NSArray class]]) {
                    [weakSelf.headerView setshareUser:objc[@"result"]];
                }
            }
        }
    } 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
