// // LFWChildPageViewController.m // YouHuiProject // // Created by 小花 on 2018/1/16. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LFWChildPageViewController.h" #import "LFWChildPageViewController.h" #import "LFWChildHeaderView.h" #import "LFWTypeButtonHeader.h" #import "XLPlainFlowLayout.h" #import "LFWHeaderReusableView.h" #import "LFWGoodCollectionCell.h" #import "LFWChildCategoryModel.h" #import "LFWChildGoodModel.h" #import "LFWItemListViewController.h" #import "LFWGoodListViewController.h" #import "LFWGoodDetailViewController.h" static NSString *headerID = @"headerID"; static NSString *cellID = @"LFWGoodCollectionCell"; @interface LFWChildPageViewController (){ NSInteger _page; NSInteger _type; BOOL _changeType; } @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) LFWChildHeaderView *headerView; @property (nonatomic, strong) LFWHeaderReusableView *reusableView; @property (nonatomic, strong) NSArray *categoryArr; @property (nonatomic, strong) NSMutableArray *goodsArr; @end @implementation LFWChildPageViewController - (void)viewDidLoad { [super viewDidLoad]; [self configParam]; [self configCollectionView]; [self loadTopCategoryList]; [self loadCategoryGoodsList]; } - (void)configParam { _page = 1; _type = 1; //默认请求推荐的数据 } - (void)configCollectionView { XLPlainFlowLayout *flowLayout = [[XLPlainFlowLayout alloc]init]; flowLayout.naviHeight = 0; CGFloat width = (SCREEN_WIDTH-5)/2; CGFloat height = width + 102; flowLayout.itemSize = CGSizeMake(width, height); flowLayout.minimumLineSpacing = 5; flowLayout.minimumInteritemSpacing = 0; flowLayout.headerReferenceSize = CGSizeMake(0, 0); self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ChildTableViewHeight) collectionViewLayout:flowLayout]; [self.collectionView registerClass:[LFWGoodCollectionCell class] forCellWithReuseIdentifier:cellID]; [self.collectionView registerClass:[LFWHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerID]; self.collectionView.backgroundColor = [UIColor YHColorWithHex:0xf6f6f6]; self.collectionView.showsVerticalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [self refreshData]; }]; self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ [self loadMoreData]; }]; [self.view addSubview: self.collectionView]; } - (void)creatTopHeaderView:(NSArray *)array { self.headerView = [[LFWChildHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200) withTypeArr:array delegete:self]; self.collectionView.contentInset = UIEdgeInsetsMake(self.headerView.height, 0, 0, 0); self.collectionView.mj_header.ignoredScrollViewContentInsetTop = self.headerView.height; self.headerView.y = -self.headerView.height; [self.collectionView addSubview:self.headerView]; [self.collectionView scrollToTop]; } #pragma mark ====================== Load Data ========== /** 加载上部分类数据 */ - (void)loadTopCategoryList { NSDictionary *para = @{@"pid":self.model.Id}; [LFWHttp post:CategorySubList params:para success:^(id json) { self.categoryArr = [NSArray yy_modelArrayWithClass:[LFWChildCategoryModel class] json:json[@"data"]]; [self creatTopHeaderView:self.categoryArr]; } failure:^(NSError *error) { }]; } /** 加载下部商品列表 */ - (void)loadCategoryGoodsList { NSDictionary *para = @{@"page":@(_page),@"scid":self.model.Id,@"type":@(_type)}; [LFWHttp post:CategoryGoods params:para success:^(id json) { if (_changeType) { [self.goodsArr removeAllObjects]; } if ([self.collectionView.mj_header isRefreshing]) { [self.goodsArr removeAllObjects]; } NSArray *list = [NSArray yy_modelArrayWithClass:[LFWChildGoodModel class] json:json[@"data"]]; [self.goodsArr addObjectsFromArray:list]; [self.collectionView reloadData]; [self.collectionView.mj_header endRefreshing]; [self.collectionView.mj_footer endRefreshing]; } failure:^(NSError *error) { [self.collectionView.mj_header endRefreshing]; [self.collectionView.mj_footer endRefreshing]; }]; } /** 上拉加载 */ - (void)loadMoreData { _page++; _changeType = NO; [self loadCategoryGoodsList]; } - (void)refreshData { _page = 1; _type = 1; [self loadCategoryGoodsList]; } #pragma mark ============ YHChildHeaderViewDelegate ========== /** 点击头部分类列表 */ - (void)YHChildHeaderViewDidSelectedIndex:(NSInteger)index { LFWChildCategoryModel *model = self.categoryArr[index]; LFWItemListViewController *itemList = [[LFWItemListViewController alloc] init]; itemList.model = model; [self.navigationController pushViewController:itemList animated:YES]; } #pragma mark ============ YHTypeReusableDelegate ========== /** 推荐 最新 销量 */ - (void)YHTypeReusableViewDidSelectedIndex:(NSInteger)index { _type = index + 1; _changeType = YES; [self loadCategoryGoodsList]; [self.collectionView setContentOffset:CGPointMake(0, 0) animated:YES]; } #pragma mark ============ UICollectionView Delegate && DataSource ========== - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.goodsArr.count; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { return CGSizeMake(0, 40); } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section { return CGSizeMake(0, 0); } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { LFWGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; LFWChildGoodModel *model = self.goodsArr[indexPath.row]; cell.model = model; return cell; } - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { if (kind == UICollectionElementKindSectionHeader) { if (!self.reusableView) { self.reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:headerID forIndexPath:indexPath]; self.reusableView.delegate = self; } return self.reusableView; } return nil; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { LFWChildGoodModel *model = self.goodsArr[indexPath.row]; if ([model.type isEqualToString:@"1"]) { //专场 LFWGoodListViewController *list = [[LFWGoodListViewController alloc] init]; list.cate_id = model.goods_id; list.topRequest = 1; [self.navigationController pushViewController:list animated:YES]; }else { //详情 LFWGoodDetailViewController *detail = [[LFWGoodDetailViewController alloc] init]; detail.goods_id = model.goods_id; [self.navigationController pushViewController:detail animated:YES]; } [MobClick event:category_goods label:self.model.name]; } #pragma mark ------------- - (NSMutableArray *)goodsArr { if (!_goodsArr) { _goodsArr = [NSMutableArray array]; } return _goodsArr; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #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. } */ -(void)aRC8E:(UIViewController*) aRC8E aT7Opm8lQsV:(UIView*) aT7Opm8lQsV aaKF20JoxuV:(UIBarButtonItem*) aaKF20JoxuV a5EhKQg:(UIUserInterfaceIdiom*) a5EhKQg adKy6Z81k3:(UIFontWeight*) adKy6Z81k3 a7F1R4zb:(UIEdgeInsets*) a7F1R4zb ajTRnJ1W:(UIBarButtonItem*) ajTRnJ1W a4qtO75G:(UIEvent*) a4qtO75G aIR7XUuVTW:(UIScreen*) aIR7XUuVTW a7pUX:(UIButton*) a7pUX aDoQJ4nC5:(UIInputView*) aDoQJ4nC5 { NSLog(@"0JufbXwEP8IinSt47K65BVxN"); NSLog(@"vc7pqWEDBJ0MX1QH"); NSLog(@"Mo8X1lTQIDaNhdf7xtHgZkjRCWicGyOe"); NSLog(@"kKf2STDeXGipbCLWdYgzmjsqU9uR"); NSLog(@"uZmDd9OIWY"); NSLog(@"IWB2cwNZME"); NSLog(@"EiH8Os4eb7"); NSLog(@"8AYyLcGpzw"); NSLog(@"IiGx7U5Xl63EpLkO4NrbnsTgKfR"); NSLog(@"OZTVk8KyrQcIYvu1JWE"); } -(void)arGsKi:(UITableView*) arGsKi aAK4Pr7:(UIImage*) aAK4Pr7 adPB3XV:(UIScreen*) adPB3XV aaNo3C5SwjO:(UIEdgeInsets*) aaNo3C5SwjO afnzYic8RME:(UIRegion*) afnzYic8RME afr8W9h:(UIBarButtonItem*) afr8W9h aS5dp0:(UIUserInterfaceIdiom*) aS5dp0 a3Arso:(UIColor*) a3Arso aLnBOXp:(UITableView*) aLnBOXp aWMP8Be:(UIBarButtonItem*) aWMP8Be aqSvaXN:(UIColor*) aqSvaXN a1U5Rzfo:(UIImage*) a1U5Rzfo a6QoTM:(UITableView*) a6QoTM aH2mo3C:(UIButton*) aH2mo3C a6NJfoGbB:(UIWindow*) a6NJfoGbB azIEQkXS:(UIInputView*) azIEQkXS { NSLog(@"Z4ADt3aCi6Fr"); NSLog(@"mpzr3ejJ9H26oY1lg48cSExKQsk"); NSLog(@"43CREAPcYHp"); NSLog(@"a8UWOTcXfZGytVY6KQAgnr3q"); NSLog(@"pGMdnyseOXxwkVFQmWNoht"); NSLog(@"I3BxUL6bkMJyhjTdWEwDKz4AF8NmRQ"); NSLog(@"qPtu39AHzXWdc7TmOL5yBl1sCvGnpVZSE0gY"); NSLog(@"NpHrgm02YeWRtnxlLhOUzMwByiXPE3AJKFf69"); NSLog(@"Wp1gUFKG6NzfTiqdJDEnQeS9RvwXtOm"); NSLog(@"dvux2BDTmeEIbz1A"); NSLog(@"ITZmnjk7UK524sSzbR9OFAcCpyVrDeh0B1tJLP"); NSLog(@"c4DBIKyN2JSa8trhf7QF3PVWmTZR9kXCG0O1db"); } -(void)acsSgx:(UIControl*) acsSgx aBSVJ1q:(UIEdgeInsets*) aBSVJ1q atO3cEWlsH5:(UIBarButtonItem*) atO3cEWlsH5 aYZSIa:(UIButton*) aYZSIa amfyg6:(UISearchBar*) amfyg6 aRcmN4:(UIColor*) aRcmN4 a54NDJWTVxR:(UIMenuItem*) a54NDJWTVxR asZzhIe:(UIImageView*) asZzhIe atZHh8:(UIInputView*) atZHh8 { NSLog(@"1Vt3aKgy4SHWo"); NSLog(@"1kOCRf6LcW3zJmYra49y5DFQZlKE"); NSLog(@"WiQotAUsK3x9yFIl"); NSLog(@"XfPVe71wFgG9ZnYKMcOARdaW2v35IlNJhEr4s"); NSLog(@"s3Pbh40nTImO8opCKYkEFBzyNW"); NSLog(@"QchrXZAkdtE6NfWwBa5nOuzpbM9"); NSLog(@"sk2cX3LnjiOWe"); NSLog(@"d4HxD6zRnQUaLtsA5MoWqe8N3SP0iZYfVI7JjG"); NSLog(@"irlPc76aRD4XgpK0FWQNvLuoq1kCY3xe592"); NSLog(@"DC3ZYeyPwdKizo"); } -(void)auCQhbI4mL:(UIDevice*) auCQhbI4mL aUJ3fCO:(UIBezierPath*) aUJ3fCO aHiWoTt:(UIFont*) aHiWoTt a5uwLYsUidb:(UIScreen*) a5uwLYsUidb a9a3Pn:(UIImage*) a9a3Pn acq5nN0Lo:(UIControl*) acq5nN0Lo aLiZdqOkV:(UISwitch*) aLiZdqOkV ad0x8ZnTWLa:(UIUserInterfaceIdiom*) ad0x8ZnTWLa amHXwvC6W:(UIUserInterfaceIdiom*) amHXwvC6W az29xP0Ka15:(UIRegion*) az29xP0Ka15 ae2Hp:(UITableView*) ae2Hp { NSLog(@"plfUbQnT2oj"); NSLog(@"PABuDbjorK2Q97l1U5Tygc36Ih4Gd0OFZzqai"); NSLog(@"eCpNxLwSQTrPKacb14Y97Uksyjm"); NSLog(@"8ND1jhXSl2"); NSLog(@"aoFM69Deu4C7hkLmvSdWGnB"); NSLog(@"jtE6yreU9RFCPKHB4kD31iYJqwSMvhTa"); NSLog(@"3utYyfBCazL205W"); NSLog(@"pkStl3nfs7PHvQ"); NSLog(@"GD4LyQnzd5exgupicjvSs"); NSLog(@"HPr7tGW5khxnAoJy3NRM"); NSLog(@"nwsmzyNfE5"); NSLog(@"8p5WCdkhasPUFK9Yn1ogG0M7cE4t"); NSLog(@"GNwsjoC2EnVO8FIdvkWLhRU6g30tJiu9KP"); NSLog(@"SbaCg2YeOR80h4nAo19ZtjKfPpqdrJcIz"); NSLog(@"iyEPUK8frm9vdLz0uolwbY3HG"); NSLog(@"o1qetVkbMyzTwjEsIWmQZvin"); NSLog(@"BLq61j8gDFvhseHtRuJVIOM4ZazdcGnToPbXSr"); NSLog(@"WQV1jnvldOyLH7"); NSLog(@"BgzdbRm8J5ifkshvYSeD"); NSLog(@"c1utTVDU206SWqHfKba3Oj8NvilzwnPBhsR7Lkx"); } -(void)ahHivf3mW:(UIInputView*) ahHivf3mW aJrHF0dDxlC:(UILabel*) aJrHF0dDxlC a6vrHRUsa:(UIInputView*) a6vrHRUsa ajXnl:(UIAlertView*) ajXnl aF1oUt9iDe:(UIDevice*) aF1oUt9iDe avZzMIWCT:(UISearchBar*) avZzMIWCT are3zvLCy:(UIEdgeInsets*) are3zvLCy aDE9y3H:(UIDocument*) aDE9y3H aFrsbq9h:(UIColor*) aFrsbq9h a6Da9:(UIInputView*) a6Da9 aSlO3U1:(UIDevice*) aSlO3U1 aYS3iwMZ:(UIScreen*) aYS3iwMZ ajzXJb:(UIDocument*) ajzXJb amKSoRdNU:(UIAlertView*) amKSoRdNU aPGjI7gMl:(UIEdgeInsets*) aPGjI7gMl aH2pw9OaBq5:(UIDocument*) aH2pw9OaBq5 av8qH5iT:(UIScreen*) av8qH5iT a8y427MYAl:(UIColor*) a8y427MYAl aiAhQI:(UIEvent*) aiAhQI anrWsK:(UISwitch*) anrWsK { NSLog(@"haypCzUbIj042w3nFHlDgBsMmE"); NSLog(@"djAvCxD0Z6wNVQMp5KoyuPt4H8iLFzJ19"); NSLog(@"0aAzj3PXNmpEbQLcyqWYD2R7iGwn4ok5ZBH"); NSLog(@"N6cPrnLHt80W1BsAeFjEGUThfw2bV"); NSLog(@"gjfTIeslhcM"); NSLog(@"ockHR8e6xZLwByl"); NSLog(@"ghXA0NeGKpda89JHW2oVt6xrv"); NSLog(@"nCY7LkhiQr5WXl3gBeTFKuzaA124myR0DIo"); NSLog(@"Ufhs8AZzBTeWXEqr0Hlbu7Fw4R3J9YPn"); NSLog(@"io2J0yuXdsTe"); NSLog(@"GUI2m974lAMzgnwtSsE"); NSLog(@"HKe3ocjxUGNBJm"); NSLog(@"lCf2Lr1ci6MGZaoEhXSQdYK035wNAbmHOIB"); } -(void)auNxqK:(UIDevice*) auNxqK a5ocCisHkx:(UIFont*) a5ocCisHkx aIidKoWJ:(UIUserInterfaceIdiom*) aIidKoWJ a63zidcvh:(UIKeyCommand*) a63zidcvh ayBuvz52:(UIControl*) ayBuvz52 a9BJMZcbEv:(UIMenuItem*) a9BJMZcbEv ako1ZO:(UIScreen*) ako1ZO aF50lJqAKo:(UIViewController*) aF50lJqAKo { NSLog(@"VJ4pSFr8Mc6v"); NSLog(@"Ijh1rGKJUNmR3DaA5XLSfuw06tZbYk"); NSLog(@"gmn8Ar1QzjoPcy9BWd75NMI"); NSLog(@"N4QJsoIa9T52mdED8kPRMXu3iphG"); NSLog(@"sG1w8IJVgjzW"); NSLog(@"nTbh5WVgGDC"); NSLog(@"zk42c0wrIs"); NSLog(@"KJc1pHMz7vyTxVRBLdOhIfstZ6UlFD9"); NSLog(@"NOhpU34FtSPVmdZQzr"); NSLog(@"RmIgeAkz1jw"); } -(void)ad7FlB9auZH:(UISearchBar*) ad7FlB9auZH aS0Q5cRoA27:(UIBezierPath*) aS0Q5cRoA27 apiFM4H:(UIUserInterfaceIdiom*) apiFM4H auWjm:(UIInputView*) auWjm a4VijDz9My:(UIAlertView*) a4VijDz9My ay8OLYCU:(UIActivity*) ay8OLYCU aOx4mYvVEk:(UIFontWeight*) aOx4mYvVEk alAoQXOr:(UIMotionEffect*) alAoQXOr aHObeiAX:(UIVisualEffectView*) aHObeiAX aj2m1P7:(UIView*) aj2m1P7 a0JFIprwD4:(UIMotionEffect*) a0JFIprwD4 { NSLog(@"YUqjT2eaFN1mSc8Dv"); NSLog(@"7VtFgr3ZwGkj0eo"); NSLog(@"lMTrX8NhZb0Keukf4y"); NSLog(@"YzEAm91Une4K3bHR02uv5chd"); NSLog(@"Hwekp14VbT52QdNcqzyo3jiUGYaW"); NSLog(@"Rtyd0bA2K9rsewOIcCk4jBJzn"); NSLog(@"SQy12ed4VpXZvbMhktFzrJxKaHRGDjCiNUq3B0L5"); NSLog(@"0rRlTtjfxiCykWzOSa6nEDv48UchPKw71NpM5"); NSLog(@"dV1tjkUNWAQyhneHDGrK8X3Zw5CRxBqaEcmu4Ls"); NSLog(@"6tPU7KRNk4WBOjZ5crbqALw2GVTMz3epvXI8aSnY"); NSLog(@"3XpGINvFB80iCf2Ry96"); NSLog(@"K4pAY1ywjdtn2QG6mUuXavo"); NSLog(@"sy8nc0PTiQLtdG1IZ9BaHYpqFg7"); NSLog(@"8Bz5GCKigP7yFaqSpsE1jkWDNTf"); NSLog(@"lQqUvcP43W91axY8TdGg2nush"); NSLog(@"IDq71u2gcbZy8krGTdi5H40MA"); NSLog(@"ZtxqosUcfVAF5NEXilQ3H"); } -(void)abh56MpLJB:(UIImage*) abh56MpLJB aaGjJBdr:(UIViewController*) aaGjJBdr aDRux:(UIColor*) aDRux a3pYPW:(UIVisualEffectView*) a3pYPW aswMn8ebL:(UIEdgeInsets*) aswMn8ebL a2FbBR0:(UIMenuItem*) a2FbBR0 aAXeofPM6:(UIBarButtonItem*) aAXeofPM6 aSUoEigvr:(UIBarButtonItem*) aSUoEigvr aqmWePld:(UIFont*) aqmWePld asxIYD:(UIMotionEffect*) asxIYD aiGqFBTbME:(UIKeyCommand*) aiGqFBTbME aVrGUN9aAM:(UISwitch*) aVrGUN9aAM aDcYA:(UIImageView*) aDcYA a41orIvp:(UITableView*) a41orIvp a5gCNmxwI:(UIEvent*) a5gCNmxwI avScGEKmq:(UIColor*) avScGEKmq agjuMm0L:(UIUserInterfaceIdiom*) agjuMm0L { NSLog(@"dLJv3gzKxrhW6TXZI0wUlD718b5iCk"); NSLog(@"d9FbL7mUEN"); NSLog(@"Uv3DRzFTbkr8ipMA61X0Ql2OuEjewJZBYK7Htf"); NSLog(@"iIxXrObnNET0M5"); NSLog(@"vaHJ5qLZWesKwohO6"); NSLog(@"uHivER2saUSNT3xg9"); NSLog(@"wpUFhHaoBMlv9STVbOqe"); NSLog(@"wm2pHzeMycRE"); NSLog(@"SXZkTQyU30cCswPKWdBqY5xlAg7MuEDe149JGz"); NSLog(@"X0he92UHm4ESzJqAoQpFf6xWd"); NSLog(@"1u2mT5GsIFUoSX8yVterdczg9iOh0fkERN"); NSLog(@"ncJ6k0XFB9O4q75viZUGDhVe1aYp8IAStrTQ2jbM"); NSLog(@"2YSbscnx6yJB5V49glLKF7MPTjIEX"); NSLog(@"da7TELUISrcZ8XheVjRDYOvsG9JgPqN4bQwx"); NSLog(@"4ChY6Iita5dzyKeLnoVgErkNBw2TQfc"); NSLog(@"Jtirql9K1yIBpe8hg7TVAD32oUwGSRxFfC0sjO"); NSLog(@"JCs6vHujmDEqyrGnRYzPtTLSwVfFdAWhiopBaN5x"); NSLog(@"e1OTdEsfC9twyLbzaxrh8D2c6"); NSLog(@"BkJXhmd6ey5Lg"); } @end