123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- //
- // LZMClassifyListController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/9.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LZMClassifyListController.h"
- #import "LZMGoodCollectionCell.h"
- #import "LZMGoodDetailViewController.h"
- #import "LZMTypeButtonHeader.h"
- #import "LZMGoodDetailViewController.h"
- #import "LZMChildFilterView.h"
- static NSString *cellID = @"LZMGoodCollectionCell";
- #define KHeaderBarHeight 80
- @interface LZMClassifyListController ()
- <
- UICollectionViewDelegate,
- UICollectionViewDataSource,
- JC_SelectViewDelegate,
- UICollectionViewDelegateFlowLayout
- >
- {
- NSInteger _page;
- NSInteger _type;
- NSInteger _is_has_coupon;
- }
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) NSMutableArray *goodsArr;
- @property (nonatomic, strong) LZMChildFilterView *filterView;
- @end
- @implementation LZMClassifyListController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initHUD];
- [self configParam];
- [self configNavigationBar];
- [self configCollectionView];
- [self loadCategoryGoodsList:NO switchButton:nil];
- }
- #pragma mark - HUD
- - (void)initHUD {
- [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
- [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
- [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
- [SVProgressHUD show];
- }
- - (void)configParam {
- _page = 1;
- _type = 1; //默认请求推荐的数据
- _is_has_coupon = 0;
- }
- - (void)configNavigationBar {
- self.view.backgroundColor = [UIColor whiteColor];
- [self.navigationBar setNavTitle:self.name];
-
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- [self.navigationBar setShowNavigationBarBottomLine:YES];
- }
- - (void)configCollectionView {
- self.filterView = [[LZMChildFilterView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, KHeaderBarHeight) withArr:nil];
- self.filterView.delegate = self;
- [self.view addSubview:self.filterView];
-
-
- UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
- flowLayout.minimumLineSpacing = 5;
- flowLayout.minimumInteritemSpacing = 0;
- flowLayout.headerReferenceSize = CGSizeMake(0, 0);
- self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight+KHeaderBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) collectionViewLayout:flowLayout];
- [self.collectionView registerClass:[LZMGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
- self.collectionView.backgroundColor = [UIColor YHColorWithHex:0xf6f6f6];
- self.collectionView.showsVerticalScrollIndicator = NO;
- self.collectionView.delegate = self;
- self.collectionView.dataSource = self;
- self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- [self loadMoreData];
- }];
-
- [self.view addSubview: self.collectionView];
-
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark ----
- #pragma mark JC_SelectViewDelegate
- //仅显示优惠券
- - (void)selectItme:(LZMChildFilterView *)selectView onlyTicketClick:(UIButton *)switchBtn {
- _is_has_coupon = switchBtn.selected ? 0 : 1;
- [self loadCategoryGoodsList:YES switchButton:switchBtn];
- }
- //上方条件选择
- - (void)selectTopButton:(LZMChildFilterView *)selectView withIndex:(NSInteger)index withButtonType:(JCButtonClickType )type1{
- //价格
- if (index == 2&&type1) {
- switch (type1) {
- case JCButtonClickTypeNormal:
- //正常价格
- {
- NSLog(@"上边按钮的正常价格");
- }
- break;
- case JCButtonClickTypeUp:
- //价格升序排列
- {
- NSLog(@"上边按钮的价格升序排列");
- _type = 3;
- }
- break;
- case JCButtonClickTypeDown:
- //价格降序排列
- {
- NSLog(@"上边按钮的价格降序排列");
- _type = 4;
- }
- break;
- default:
- break;
- }
- }else if (index == 0){//综合
-
- NSLog(@"上边按钮的综合");
- _type = 1;
-
- }else if (index == 1){//销量
-
- NSLog(@"上边按钮的销量");
- _type = 2;
-
- }else{//筛选
-
- NSLog(@"上边按钮的筛选");
- }
-
- _page = 1;
- [self.collectionView.mj_footer resetNoMoreData];
- [self loadCategoryGoodsList:YES switchButton:nil];
- }
- /**
- 上拉加载
- */
- - (void)loadMoreData {
- _page++;
- [self loadCategoryGoodsList:NO switchButton:nil];
- }
- /**
- 加载下部商品列表
- */
- - (void)loadCategoryGoodsList:(BOOL)refresh switchButton:(UIButton *)switchButton{
-
- if (![self.collectionView.mj_footer isRefreshing]) {
- [SVProgressHUD show];
- }
-
- NSDictionary *para = @{@"page":@(_page),
- @"category_id":self.firstCategoryId,
- @"sort":@(_type),
- @"sub_category_id":self.cate_id,
- @"stype":@"0",
- @"is_has_coupon":@(_is_has_coupon)
- };
- [LZMHttp post:StocklistByCategoryId params:para success:^(id json) {
- if (refresh) [self.goodsArr removeAllObjects];
- NSArray *list = [NSArray yy_modelArrayWithClass:[LZMChildGoodModel class] json:json[@"data"]];
- [self.goodsArr addObjectsFromArray:list];
- [self.collectionView reloadData];
- if (list.count > 0) {
- [self.collectionView.mj_footer endRefreshing];
- }else {
- [self.collectionView.mj_footer endRefreshingWithNoMoreData];
- }
- [SVProgressHUD dismiss];
- switchButton.selected = !switchButton.selected;
- } failure:^(NSError *error) {
- [self.collectionView.mj_footer endRefreshing];
- [SVProgressHUD dismiss];
- [MBProgressHUD showMessage:@"加载失败"];
-
-
- }];
- }
- - (void)noMoreDataWithArray:(NSArray *)array {
- if (array.count > 0) {
- self.collectionView.footRefreshState = MJFooterRefreshStateNoMore;
- }else {
- self.collectionView.footRefreshState = MJFooterRefreshStateLoadMore;
- }
- }
- #pragma mark - scrollView
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
- UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
- //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
- CGFloat velocity = [pan velocityInView:scrollView].y;
- if (velocity <- 10) {
- //向上拖动,隐藏导航栏
- if (self.navigationBar.y == -NavBarHeight) {
- return;
- }
- [UIView animateWithDuration:0.15 animations:^{
- self.navigationBar.y = -NavBarHeight;
- self.filterView.y = KStatusBarHeight;
- self.collectionView.y = KStatusBarHeight + KHeaderBarHeight;
- self.collectionView.height = SCREEN_HEIGHT-KHeaderBarHeight-KStatusBarHeight;
- }];
-
- }else if (velocity > 10) {
- //向下拖动,显示导航栏
- if (self.navigationBar.y == 0) {
- return;
- }
- [UIView animateWithDuration:0.15 animations:^{
- self.navigationBar.y = 0;
- self.filterView.y = NavBarHeight;
- self.collectionView.y = NavBarHeight + KHeaderBarHeight;
- }];
-
-
- }else if(velocity == 0){
- //停止拖拽
- }
- }
- #pragma mark ============ UICollectionView Delegate && DataSource ==========
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- return self.goodsArr.count;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
-
- LZMChildGoodModel *model = self.goodsArr[indexPath.row];
- CGFloat width = (SCREEN_WIDTH-5)/2;
- CGFloat height = width + 102;
- return CGSizeMake(width, height);
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
- {
- return CGSizeMake(0, 0);
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
- {
- return CGSizeMake(0, 0);
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- LZMGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
- LZMChildGoodModel *model = self.goodsArr[indexPath.row];
- cell.model = model;
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
-
-
- LZMChildGoodModel *model = self.goodsArr[indexPath.row];
- //详情
- LZMGoodDetailViewController *detailVC = [[LZMGoodDetailViewController alloc] init];
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
- detailVC.requestModel = requestModel;
- if (self.isOtherPage) {
- LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:HomeClassifyAction];
- detailVC.eventModel = evevtModel;
- }else {
- LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:ListClassifyAction];
- detailVC.eventModel = evevtModel;
- }
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- #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)anAhR7:(UIRegion*) anAhR7 aAShp:(UIEvent*) aAShp a7nPi2tU1:(UIEvent*) a7nPi2tU1 acv3motB:(UICollectionView*) acv3motB aVHxWew96nJ:(UIRegion*) aVHxWew96nJ a6Q4d:(UIApplication*) a6Q4d a0RWLk:(UIViewController*) a0RWLk agUJ8Aeo0vZ:(UIImage*) agUJ8Aeo0vZ a5m2e:(UICollectionView*) a5m2e aLM1h:(UICollectionView*) aLM1h aPJQ73Z:(UIImage*) aPJQ73Z aEpx0LY:(UIControlEvents*) aEpx0LY aWm0rnjXB:(UIEdgeInsets*) aWm0rnjXB aZHthf:(UICollectionView*) aZHthf azLxZ7VFAY:(UIButton*) azLxZ7VFAY al53BiDIdn8:(UIEdgeInsets*) al53BiDIdn8 ay4uw70:(UIScreen*) ay4uw70 {
- NSLog(@"ZoAxS7N05sT2qmGKO4i6c8FprhUPYt");
- NSLog(@"oD2sI8bAMLzd54xOuTfW0");
- NSLog(@"0HDPsRfK2ICG7");
- NSLog(@"KHirU0yMfPXzJZo2nvAaEGbQsC64qT");
- NSLog(@"0jMGJThNVa3Isfyb");
- NSLog(@"RoJrEt5mC4DwTSfW623NkYpuVHIie1hB8lqg");
- NSLog(@"FW4apmtfyQERS");
- NSLog(@"onq4AR5D7Vmvgu1rThCdEcN");
- NSLog(@"SzZsJFeVcQW");
- NSLog(@"9N2tiCQS6Yq");
- NSLog(@"DSL8ZxjrhO0Ffu43GIUzMqeblo1gPRJXWBCpyNVn");
- NSLog(@"Df8ogQAbvVp0dLCYqWn");
- NSLog(@"8LH1RdYSsWC6NhEO7ZAgVQ02tp3");
- NSLog(@"p0rOxybkgt4vTR1WmfBD9GhU7lH8nc3V");
- NSLog(@"K0y2tDsaVMTelBxc1mZqNrGEhdIkuW");
- NSLog(@"zKXx3EkU2SjN9gTq");
- NSLog(@"96e1lAJHMQf0sWUmItaDbXvxZ");
- NSLog(@"w1IpcuXtOaVryNig94U2JMYRqmnH6hvdDF8Z");
- NSLog(@"dvNJbph41AWwf0QMzkt2ZEX5S6HYnsaKqLuxgj");
- }
- -(void)aOM1sFv:(UIActivity*) aOM1sFv a86kORT0:(UIActivity*) a86kORT0 a6ojLbSfwQ:(UICollectionView*) a6ojLbSfwQ aI1CQgF8j:(UIBezierPath*) aI1CQgF8j arTO60q:(UIEvent*) arTO60q aHZ0hNC:(UILabel*) aHZ0hNC apsMiHfaJ4:(UIKeyCommand*) apsMiHfaJ4 asJt1:(UIButton*) asJt1 aENHDaQxP4:(UIActivity*) aENHDaQxP4 arEf0cn:(UISearchBar*) arEf0cn alSBgvXE:(UIFontWeight*) alSBgvXE ahHnw:(UIFont*) ahHnw aalbDSn:(UIControl*) aalbDSn aAxKBP:(UIRegion*) aAxKBP aPE6RG:(UIDocument*) aPE6RG a02uHl:(UIBezierPath*) a02uHl am1IzrN5WuD:(UIAlertView*) am1IzrN5WuD afHMADre1bx:(UIEdgeInsets*) afHMADre1bx a19pEePM:(UIRegion*) a19pEePM {
- NSLog(@"cUaOeIChtlwJRqBF8vbWzNipEsQr7SX60V");
- NSLog(@"akiKuGQhzPvNmy");
- NSLog(@"fM4GXtondYQaPsyOHrCT2uJzK7");
- NSLog(@"K12a6pRqIc4X0JiGsYZBz7FPLuxOdoj");
- NSLog(@"2rRavOtbQgoTIzwB7MuZmEecWYnSl");
- NSLog(@"0hJgkxX9Rm");
- NSLog(@"cbtM3RX9ZLsBTVf1Nhp25YAq0OvyrGx");
- NSLog(@"r83FBX4ikUH9duaeKqsplxcNoAvhWfOQS");
- NSLog(@"SNVLdZoOPT9I35kn1HuMWqA6Xa4D0");
- NSLog(@"npwzjGLtWSlI9xruCBkQZF6");
- NSLog(@"sofCtnYkPdp1J50TqcrXL");
- NSLog(@"yLzs7kXuY6d82ZmnhpJNt3KMorOcqEVTWSeDC5GR");
- NSLog(@"m5Rg0szDSjvobAMQ2cILqdTrhpZ");
- NSLog(@"2Lkv8J3Sa079i1nlBeDf4FQjNhoOEq");
- NSLog(@"QNX1sAocHnJWbxjku0aT3UrmGOKZfME8LPS");
- NSLog(@"VPaUOHpfxdhoq");
- NSLog(@"9sSkxhveu5o4Ir");
- NSLog(@"JXFu2nS0fkBTgOo3UC8weVNHvs5Dt");
- NSLog(@"zUsjK0NfLiAxpvmgEBrIlC1cPM");
- NSLog(@"nrAHkCVJZETpOIKub2WGXc3gPUx7v8dmRYaLf");
- }
- -(void)axbiP:(UIWindow*) axbiP a7mheoBQVXC:(UIFontWeight*) a7mheoBQVXC ai2ulK96R:(UIControl*) ai2ulK96R aF1gsOErzN:(UIRegion*) aF1gsOErzN aj3rgJI:(UIDocument*) aj3rgJI {
- NSLog(@"eDgLZlCjHJBOVb6ptIUi4rQwAMvqcWGuo87FfyP");
- NSLog(@"l9nRWaQIjVMuyh7fkZG3YBCowHEA8z5TxU1s");
- NSLog(@"3nNvQtaMr57GS4yFD6bXC9zLmBO8IuY");
- NSLog(@"EIx6eYhldqVZ8zU4kKr5D7HPCfOuw0p9a");
- NSLog(@"DLr3qdPasY5Je0tbh7p8SOoIXwlyg9FRjxvnf");
- NSLog(@"xNKFm7gl3Yu");
- NSLog(@"hjw6LuC47oN8l");
- NSLog(@"VdA1XKv7tuIMYO");
- NSLog(@"Olhk6RmfU4QTcvFNus7DPGJWzCAVMIrY3gEnSB9p");
- NSLog(@"lG60FkMhONwRZmi7pXUc3");
- }
- @end
|