// // KXEventViewController.m // CAISHEN // // Created by jikaipeng on 2017/8/24. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXEventViewController.h" #import "KXEventTopView.h" #import "KXEventCollectionViewCell.h" #import "KXbodyPriceColumnViewController.h" #import "KXCalculatePageViewController.h" #import "KXLittleLogginView.h" #import "KXFindToolListModel.h" #import "KXInstallmentViewController.h" //分期计算器 #import "KXCarLoancalViewController.h" // 车贷计算器 #import "KXHouseCalculateViewController.h" //房贷计算器 #import "KXIndividualIncomeViewController.h" //个税计算器 #import "KXBaseLinkViewController.h" static NSString *collectionHeaderIdenti = @"collectionHeaderIdenti"; static NSString *collectionCellID = @"cellID"; @interface KXEventViewController () @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, assign) NSInteger page; @property (nonatomic ,strong) NSMutableArray *dataSource; @property (nonatomic,assign) NSInteger index; @property (nonatomic,strong) NSMutableArray *systemArr; @property (nonatomic,strong) UIView *headerView; @property (nonatomic,strong) NSMutableArray *custonArr; @end @implementation KXEventViewController - (void)viewDidLoad { [super viewDidLoad]; [self setupNavBackground]; self.name = @"发现"; self.view.backgroundColor = [UIColor KXColorWithHex:0xf5f4f9]; // 2.0的头 // [self CreateTopView]; [self requestFindCustomData]; [self setUpCollectionView]; [MobClick event:@"FindTab"]; } #pragma mark - 请求发现页工具列表 - (void)requestFindCustomData{ NSString *url = [NSString stringWithFormat:@"%@/activity/getToolsList",URL]; [KXHTTP get:url params:nil success:^(id json) { [self.custonArr removeAllObjects]; NSArray *array = [NSArray yy_modelArrayWithClass:[KXFindToolListModel class] json:json]; for (KXFindToolListModel *model in array) { if ([model.show integerValue] == 1) { [self.custonArr addObject:model]; } } [self setUpHeaderView]; } failure:^(NSError *error) { [self setUpHeaderView]; }]; } #pragma mark - getter and setter - (UICollectionView *)collectionView{ if (!_collectionView) { UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(SCREEN_WIDTH-20, 230); layout.minimumInteritemSpacing = 6; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, SCREEN_HEIGHT-NavHeight-TabbarHeight) collectionViewLayout:layout]; _collectionView.showsVerticalScrollIndicator = NO; } return _collectionView; } -(NSMutableArray *)dataSource { if (!_dataSource) { _dataSource=[[NSMutableArray alloc]init]; } return _dataSource; } #pragma mark - event handle - (void)tapAction1:(UITapGestureRecognizer *)tapG { KXbodyPriceColumnViewController *bodyPriceVC = [[KXbodyPriceColumnViewController alloc]init]; bodyPriceVC.webString = [NSString stringWithFormat:@"%@/Atesting/?channel_id=%@",CALURL,KXCHANNEL_ID]; bodyPriceVC.titleString = @"身价计算器"; bodyPriceVC.enterSource = @"valueCalculationa"; self.tabBarController.tabBar.hidden = NO; [self.navigationController pushViewController:bodyPriceVC animated:YES]; } - (void)tapAction2:(UITapGestureRecognizer *)tapG { KXCalculatePageViewController *calculate = [[KXCalculatePageViewController alloc]init]; self.tabBarController.tabBar.hidden = NO; [self.navigationController pushViewController:calculate animated:YES]; } - (void)CreateTopView{ NSArray *imageNameArray = @[@"main_event_price",@"main_event_calculator"]; NSArray *titleArray = @[@"身价计算器",@"贷款计算器"]; NSArray *detailArray = @[@"等你来测",@"比价神器"]; UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_MUTI*80)]; backView.backgroundColor = [UIColor KXColorWithHex:0xffe100]; for (NSInteger i = 0; i < 2; i++) { KXEventTopView *topView = [[KXEventTopView alloc] initWithFrame:CGRectMake(i*(SCREEN_WIDTH-1)/2, 0, (SCREEN_WIDTH-1)/2, SCREEN_MUTI*80)]; topView.imageview.image = [UIImage imageNamed:imageNameArray[i]]; topView.titleLabel.text = titleArray[i]; topView.detaileLabel.text = detailArray[i]; [backView addSubview:topView]; if (i == 0) { UIView *view = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-1)/2, 10*SCREEN_MUTI, 1, 60*SCREEN_MUTI)]; view.backgroundColor = [UIColor whiteColor]; UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction1:)]; tapG.numberOfTapsRequired = 1; [topView addGestureRecognizer:tapG]; [backView addSubview:view]; } else{ UITapGestureRecognizer *tapG = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction2:)]; tapG.numberOfTapsRequired = 1; [topView addGestureRecognizer:tapG]; } } [self.view addSubview:backView]; } /** 贷款超市3.0的头 */ - (void)setUpHeaderView{ UIView *topBackView = [[UIView alloc] init]; topBackView.backgroundColor = [UIColor whiteColor]; CGFloat width = (SCREEN_WIDTH-20)/4; CGFloat height = 95; NSInteger rank = 4; for (NSInteger i=0; i