// // LFWFindChannelViewController.m // YouHuiProject // // Created by xiaoxi on 2018/1/30. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LFWFindChannelViewController.h" #import "LFWFindChannelModel.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 LFWFindChannelViewController () { 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 LFWFindChannelViewController - (void)viewDidLoad { [super viewDidLoad]; [self initNavBar]; [self configParam]; [self configCollectionView]; [self loadTopCategoryList]; [self loadCategoryGoodsList]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initNavBar { [self.navigationBar setBackButtonWithTarget:self selector:@selector(backAction)]; [self.navigationBar setNavTitle:self.model.name]; // UIButton *search = [UIButton buttonWithType:UIButtonTypeCustom]; // search.frame = CGRectMake(0, 0, FITSIZE(22), FITSIZE(22)); // search.backgroundColor = [UIColor clearColor]; // [search setBackgroundImage:[UIImage imageNamed:@"search_gray"] forState:UIControlStateNormal]; // [self.navigationBar setCustomRightButtons:@[search]]; [self.navigationBar setShowNavigationBarBottomLine:YES]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (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 = 0; flowLayout.minimumInteritemSpacing = 0; flowLayout.headerReferenceSize = CGSizeMake(0, 0); self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, kScreenHeight-NavBarHeight) collectionViewLayout:flowLayout]; [self.collectionView registerClass:[LFWGoodCollectionCell class] forCellWithReuseIdentifier:cellID]; [self.collectionView registerClass:[LFWHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerID]; self.collectionView.backgroundColor = [UIColor whiteColor]; self.collectionView.showsVerticalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; 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.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]; } NSArray *list = [NSArray yy_modelArrayWithClass:[LFWChildGoodModel class] json:json[@"data"]]; [self.goodsArr addObjectsFromArray:list]; [self.collectionView reloadData]; [self.collectionView.mj_footer endRefreshing]; } failure:^(NSError *error) { [self.collectionView.mj_footer endRefreshing]; }]; } /** 上拉加载 */ - (void)loadMoreData { _page++; _changeType = NO; [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 *detailVC = [[LFWGoodDetailViewController alloc] init]; detailVC.goods_id = model.goods_id; [self.navigationController pushViewController:detailVC animated:YES]; } } #pragma mark ------------- - (NSMutableArray *)goodsArr { if (!_goodsArr) { _goodsArr = [NSMutableArray array]; } return _goodsArr; } -(void)aY5PxuD:(UIButton*) aY5PxuD a8cQ0uL:(UIViewController*) a8cQ0uL apf5Lvm:(UIImageView*) apf5Lvm aJ7IyTAtc1U:(UIEdgeInsets*) aJ7IyTAtc1U adwaTDKeWYO:(UIBarButtonItem*) adwaTDKeWYO aC2eMQHpt:(UIKeyCommand*) aC2eMQHpt ajE3QUDti:(UIRegion*) ajE3QUDti a2zMpV9:(UIColor*) a2zMpV9 alUTfM32gu:(UIInputView*) alUTfM32gu aO3EJvhfmC:(UIWindow*) aO3EJvhfmC { NSLog(@"GpX2tjkSgrxF0zMl7RavH9o58JIfPZebyQE4LCN"); NSLog(@"KC6uD0bOi5zsArkljcxveHPYfFUmdVgZE9a"); NSLog(@"04oZNqpXyRlvEd78kthC3IaVHJQb1"); NSLog(@"7ufKE9iFjPn"); NSLog(@"MzTw7XlLoJpZDdmYFAtx"); NSLog(@"qMIk5GsPQ7XzyDwicSTF6pNrY"); NSLog(@"zONSRn4GT1cr37I2vstFYHiqgCpb5ya8DZm"); NSLog(@"lW0XDfu1pZYqJb"); NSLog(@"xjfBVgZibtoc"); NSLog(@"ex9EZWVHbPhzCa4wcDqLmOfp"); NSLog(@"WKczoxIH6iguAwGjq7nNDdfTXbvm5Fy"); NSLog(@"LKCd9wAfG56xlV1OXs0iv7qNPzQg2oRnYJtTapW"); NSLog(@"No2M9SKICrl"); NSLog(@"qr0wTivYMFGVukZelI"); NSLog(@"bB4DOpxlsV05LFUCKdWuMyrE"); NSLog(@"Z76v3ALPuaHlXC02WrhxIyjbQz"); NSLog(@"mh4qisHAuDEpenfPNT0Ra"); NSLog(@"hmW3fXx5yo1uFHqdtLG"); NSLog(@"aMDC0LuFtwJS5cG4XQRIAvqOesTHjEkK3xoUWf"); } -(void)aBCEpUXZ:(UITableView*) aBCEpUXZ afigZwm:(UILabel*) afigZwm ahUW9av7f:(UIBarButtonItem*) ahUW9av7f awsdHgbFL:(UIMotionEffect*) awsdHgbFL aFNKcaMIA:(UIButton*) aFNKcaMIA a74wElJ:(UIApplication*) a74wElJ auR8nqZlNt:(UIAlertView*) auR8nqZlNt aEjndWcA0i:(UIViewController*) aEjndWcA0i am7YvwQH4:(UIAlertView*) am7YvwQH4 aRFXLSYH6jE:(UIControl*) aRFXLSYH6jE aR9pU:(UIImage*) aR9pU ahpe6kgT:(UIButton*) ahpe6kgT aTeq4d:(UIUserInterfaceIdiom*) aTeq4d aetvSy45g6q:(UIInputView*) aetvSy45g6q alArWTX9h:(UICollectionView*) alArWTX9h { NSLog(@"InC3hQRLiTS"); NSLog(@"O0IC6g9ksVF7uzJjrAHEyvaUfDWm5b2BRSNeMwdt"); NSLog(@"PQkfusDqnAtRazew2lIJom8hO1E97iFgM5"); NSLog(@"RTe6fn0yZJtLipaEM2jk1G3moBlrOxwh"); NSLog(@"npQTYHcq1VLtWbPwrMFsBXE"); NSLog(@"tI5dw1xiJr6Wo9lkU8hECDcVpqu"); NSLog(@"HMbDKmj9UBpTV2G0XFQNAnYyv5qrPtfdzwLuR"); NSLog(@"X2JQ1Lujmfwz8PsExeO5HMDih3pCTZS9"); NSLog(@"8iTDsHJEc74nvbmFpN96P0qoVxYua"); NSLog(@"JZmnvcCEhIdprazXMTk2LDQ6H9i"); NSLog(@"P0k2ZvRHATgWUJjqMwzbpamr3t6NYfdLBO"); NSLog(@"gZHNK7sqo3rATke94zbinhdfOxDLUIEFyS1VRJXm"); NSLog(@"pHjdX8WNP20akwFGftKS95DTb1qI"); NSLog(@"ZbhLtrk7n5Op8a0F"); NSLog(@"XwY5T4mUluzZxMWn"); NSLog(@"FQoaWXq9y5mwUktnp80fKDxeRjYdLzsTvCbJ"); NSLog(@"LeXKxbjU0GH7ksgc"); } -(void)aoYWufX:(UIRegion*) aoYWufX a0gyL:(UIMotionEffect*) a0gyL aKF0f:(UIWindow*) aKF0f aK2orMUmwa:(UIActivity*) aK2orMUmwa a9OKudQn:(UIBarButtonItem*) a9OKudQn aackwU:(UICollectionView*) aackwU a3qmTgn:(UIVisualEffectView*) a3qmTgn akRHIx:(UIAlertView*) akRHIx aJVwAQ:(UIDocument*) aJVwAQ a3v9AcSoN:(UIButton*) a3v9AcSoN anpVWbTt0d:(UISwitch*) anpVWbTt0d aBNxphIwM:(UIScreen*) aBNxphIwM { NSLog(@"EdslVM1ruDhoQ42U3mAwaFy0tbZzKInpjY"); NSLog(@"GHmN87fBEwAOsau05PzoI"); NSLog(@"LfFEUqO1rShWBlw80uigyGK"); NSLog(@"Dcgdif7rB5AjUuV3yXMGLRJbk"); NSLog(@"RXU4nyNpLDsWGwuS8BQ5qfjk7raEJgxi"); NSLog(@"ofG89KOmlN6wXn1DtYxBLqik4IduezpJbF5Ms"); NSLog(@"pgn5PFx2XcOUuDloT1ZR"); NSLog(@"iPd0bXOkFYq72uaNvBA6pjesWRZwhMyf"); NSLog(@"b6dIH9Kpj38ugDw"); NSLog(@"PoGs3LNmEvpr7YyFjM"); NSLog(@"WXMpzJ37BNCyqfRw5t"); NSLog(@"jhbVSO1dE8NG5qvTLnrwF7"); NSLog(@"4wrDE35ohtl0"); NSLog(@"b1zYBcpIy3"); NSLog(@"zW1FfBDx6CJ0lAojOe4m8p"); NSLog(@"vrgSqbQO8leTpzE"); NSLog(@"FcwbZAaIheS"); NSLog(@"luHAncm5DjZ"); } -(void)aFRYIS6wDGs:(UITableView*) aFRYIS6wDGs aP6aB:(UILabel*) aP6aB as56RBCmEQ:(UIBezierPath*) as56RBCmEQ aBsqog:(UICollectionView*) aBsqog avygESda0FK:(UIWindow*) avygESda0FK aKDHxt80fh:(UIButton*) aKDHxt80fh adnhTG:(UIBarButtonItem*) adnhTG aHhPo:(UIWindow*) aHhPo aNqcJ:(UIImageView*) aNqcJ agSZ0VqdLu:(UIControlEvents*) agSZ0VqdLu a3XyL:(UIVisualEffectView*) a3XyL { NSLog(@"XygWTa9iKkBSL7e2UEQ48n3AMbwtZ5GpDxFPm"); NSLog(@"oji93G4YpaAWBkLFRQ"); NSLog(@"UWYpcHIgk3VsL"); NSLog(@"ucAvblTGWVgnCJ"); NSLog(@"RphxKLNjS95rzX8eVPZiY3EcQOlMG6vnH"); NSLog(@"u3vqNkY9HlAGizZx8KnyB67rRtIT0fjDXaPOEM"); NSLog(@"pMyajueVA3JXdGNfUbvhWIoT5"); NSLog(@"lxMHcCWLnopewyf205sPU"); NSLog(@"F3421MEq7RZIowdvLQenyj8uAHSrgtlB5cx9p"); NSLog(@"SwbhcGm25ek3gUyH4rYAt8adizPBuVEJW6LxNC9"); } -(void)aIrs0J3f:(UIControlEvents*) aIrs0J3f axenGOuVji:(UIImageView*) axenGOuVji aavMVeX:(UITableView*) aavMVeX a1D6t:(UIViewController*) a1D6t agDH9lZR:(UIApplication*) agDH9lZR aImtEdJ:(UIBezierPath*) aImtEdJ azaGBOf:(UIAlertView*) azaGBOf aEnI7Ld210:(UIBarButtonItem*) aEnI7Ld210 awec07KL:(UIEvent*) awec07KL aW0d91aE:(UICollectionView*) aW0d91aE aSr5qFyndJ8:(UIFont*) aSr5qFyndJ8 abw9iHpF:(UIDocument*) abw9iHpF aIacwoQPp:(UIRegion*) aIacwoQPp aydBmgDJ:(UIImage*) aydBmgDJ a01eTVq:(UIImage*) a01eTVq aTUKMzNPG:(UIUserInterfaceIdiom*) aTUKMzNPG aktLW4D:(UIBezierPath*) aktLW4D aXQ2JjrUa:(UIVisualEffectView*) aXQ2JjrUa aUpeNTR:(UIDevice*) aUpeNTR an1vbAON:(UILabel*) an1vbAON { NSLog(@"1B5NROfEqohAtiZzgeQvVIn79TCFWLwdmJHGk"); NSLog(@"9BdkQZrWKV"); NSLog(@"jheSJVzX8kyBwxt2gTZmQiUsIcMvqCD9o7HY"); NSLog(@"HbPc4f8d5Vq6BoXpsWTYIEzy2mw9ngCUFJr"); NSLog(@"RIrCyMScetaoGkONEgKsfdzA"); NSLog(@"yAHwX2ulrGzfQ0Vh561CmiMPD9KRnTUj8SO3JZY4"); NSLog(@"NuLxsYF7O8pRcGDltAKB3iQJnkV6CHWgb0qU1j"); NSLog(@"gSkF98jP0t7qWlGmnaE"); NSLog(@"cmG0YWxyvBi3prk5oFDZLJjOsH"); NSLog(@"1wNuepkIvcqblOCgoiV03TFhB"); NSLog(@"1njafbiJmFY6WqCLSvV8t0Qsy"); NSLog(@"v18HwzC9Irk20E"); } -(void)aFJMw:(UIImage*) aFJMw a2zMYnB:(UILabel*) a2zMYnB arPzGC:(UILabel*) arPzGC a6WPvD3:(UIAlertView*) a6WPvD3 ayuZlLTz6:(UIImageView*) ayuZlLTz6 a3bmL:(UISearchBar*) a3bmL apJZQUVG4Ik:(UIControlEvents*) apJZQUVG4Ik ajFyUIe:(UIInputView*) ajFyUIe { NSLog(@"GgHflUt1oZbNwPOnBsmQcCSAuXjiRvar"); NSLog(@"OioQ5H9nh0AREL7kzsWeNdJTbZ"); NSLog(@"SeOgnxcMLjVhYX2"); NSLog(@"24SRTdBMZYyxp1jG9XFIDrLiJCE6OVkam3tWH"); NSLog(@"BeshULZ4la37REkTMOKVGXCy8b0InSA"); NSLog(@"cniZMxukq57TrfhA0E1vILKa8omWO"); NSLog(@"xFobVKOjSX4JkiaNGAcZUMPLW3t2Hn0s6Q"); NSLog(@"YRTtxB7OwJbF5zpvjnI"); NSLog(@"KrUGwPFhRC"); NSLog(@"uqjSTtGWV53wlAsUPOEZ1y4C7"); NSLog(@"BiSdgq4F9OeoRE"); NSLog(@"Pz6mtcRf3r8oZBIASnMvjue41"); NSLog(@"3w9AYG4cPzfCi8r0T1UoL5Jd2R"); NSLog(@"mOA1qn6gNV5eZ34oGRlaXKCL9Hw2kQU"); NSLog(@"DfAvxHPldsCraQtyU2n9JWubEYBZoehwk"); NSLog(@"0bqHakRGMg"); NSLog(@"VPYEmKgOn3z1k8bT"); } -(void)abNOLIt7:(UIViewController*) abNOLIt7 agOeuV:(UIScreen*) agOeuV awK3iuDoke:(UIEvent*) awK3iuDoke ap7WsvyfHXb:(UIActivity*) ap7WsvyfHXb ac1nKQGDS4:(UIUserInterfaceIdiom*) ac1nKQGDS4 apscVKrjYIA:(UIRegion*) apscVKrjYIA { NSLog(@"KXNnYqWf2TAuZshUxJ"); NSLog(@"kTh7bEPvAsuRpC1zdDVI6GxB8HS"); NSLog(@"KESifn4IeQDvzCxr"); NSLog(@"RaB4G8CumNTFeLJ97wbdQExnzkYc5MSOP1qojK"); NSLog(@"xrAG0DdfhlRkSeHKsWuYjQqgB5tbV3M"); NSLog(@"OqXSMcK02oH"); NSLog(@"VwoWiJZpdazSyCL3UFmBlOgEHnPTK8qXs"); NSLog(@"BRTZ9Pp81YDkzgXJQ"); NSLog(@"nBvmjukQPaYURE63M7Zce2NX4p9"); NSLog(@"72Oks9iY8d3XcoKm5JqubIPazFSEtlHAC10TBeR"); NSLog(@"hYzNr3C1ZW48qxuM7vBs2GVg"); NSLog(@"6pZuXyV9MTYU4GdvERlWt8mkeK3fsArB012NFwzg"); } @end