// // YZMASimilarGoodsController.m // YouHuiProject // // Created by 小花 on 2018/2/2. // Copyright © 2018年 kuxuan. All rights reserved. // #import "YZMASimilarGoodsController.h" #import "YZMAGoodCollectionCell.h" #import "YZMAGoodDetailViewController.h" static NSString *cellID = @"YZMAGoodCollectionCell"; @interface YZMASimilarGoodsController () { } @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) NSMutableArray *goodsArr; @end @implementation YZMASimilarGoodsController - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; [self configCollectionView]; [self loadCategoryGoodsList]; } - (void)configNavigationBar { self.view.backgroundColor = [UIColor whiteColor]; [self.navigationBar setNavTitle:@"相似推荐"]; self.navigationBar.showNavigationBarBottomLine = YES; 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 { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init]; CGFloat width = (SCREEN_WIDTH-5)/2; flowLayout.minimumLineSpacing = 5; flowLayout.minimumInteritemSpacing = 0; flowLayout.headerReferenceSize = CGSizeMake(0, 0); self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) collectionViewLayout:flowLayout]; [self.collectionView registerClass:[YZMAGoodCollectionCell class] forCellWithReuseIdentifier:cellID]; self.collectionView.backgroundColor = [UIColor YHColorWithHex:0xf6f6f6]; self.collectionView.showsVerticalScrollIndicator = NO; self.collectionView.delegate = self; self.collectionView.dataSource = self; [self.view addSubview: self.collectionView]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } /** 加载下部商品列表 */ - (void)loadCategoryGoodsList { NSDictionary *para = @{@"goods_id":self.goods_id}; [YZMAHttp post:SimilarGoods params:para success:^(id json) { NSArray *list = [NSArray yy_modelArrayWithClass:[YZMAChildGoodModel class] json:json]; [self.goodsArr addObjectsFromArray:list]; [self.collectionView reloadData]; if (self.goodsArr.count == 0) { [SVProgressHUD showInfoWithStatus:@"暂无数据"]; } } failure:^(NSError *error) { [SVProgressHUD showInfoWithStatus:@"暂无数据"]; }]; } #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 { 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 { YZMAGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; YZMAChildGoodModel *model = self.goodsArr[indexPath.row]; cell.model = model; return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { YZMAChildGoodModel *model = self.goodsArr[indexPath.row]; //详情 YZMAGoodDetailViewController *detailVC = [[YZMAGoodDetailViewController alloc] init]; DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model]; detailVC.requestModel = requestModel; YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:sameCouponAction]; 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)aZxmXpUiT:(UIKeyCommand*) aZxmXpUiT aVWKM:(UIView*) aVWKM agsFrio:(UIView*) agsFrio acOymunhP8Y:(UIAlertView*) acOymunhP8Y aH7AMPDzdoE:(UIKeyCommand*) aH7AMPDzdoE awRE6xTaD0Q:(UIVisualEffectView*) awRE6xTaD0Q aZwokj:(UIDevice*) aZwokj a8Nhn:(UIBezierPath*) a8Nhn aLDnjJK:(UISwitch*) aLDnjJK aT7GV:(UIApplication*) aT7GV apavDXOZ:(UICollectionView*) apavDXOZ { NSLog(@"gdA0LKrCStyWXkYVB5"); NSLog(@"4vpgiUqIoFnEYSsaNexrLzk0ubZmWB"); NSLog(@"U94Z7pC3TifmWL"); NSLog(@"sr9eP5iSu7KN6LqDocxd"); NSLog(@"1bNvV43Ukj"); NSLog(@"EoTgO5JQnYUjyeMSlPBNcALr"); NSLog(@"1lqKzJ0VnAi9Tsy"); NSLog(@"DzJpjA07I2vsqOwhknNKSoFWf3iT8gEBMZx"); NSLog(@"wi41YhBV8Aq5dSGgp2f"); NSLog(@"qDYsTv15kgL92JVtEU0fB4Zn7MSuPb6yOcz"); } -(void)aehgEYc4:(UIInputView*) aehgEYc4 abykd:(UIControlEvents*) abykd a43yAmhR5:(UIEvent*) a43yAmhR5 aNIV5l7oP:(UISearchBar*) aNIV5l7oP a7qr8Th:(UIBezierPath*) a7qr8Th aEMgmZBUR:(UIScreen*) aEMgmZBUR ai6RunL1:(UIControlEvents*) ai6RunL1 a2vrHE:(UIUserInterfaceIdiom*) a2vrHE ayJmhc2oA30:(UIEdgeInsets*) ayJmhc2oA30 a9uQqt4:(UIKeyCommand*) a9uQqt4 a86dzW7:(UIDevice*) a86dzW7 arVfNw:(UIControlEvents*) arVfNw amcTY:(UIActivity*) amcTY aPuinv7OCpH:(UIDevice*) aPuinv7OCpH aMEfGKyHQBm:(UIDocument*) aMEfGKyHQBm aaItvd46DJ:(UICollectionView*) aaItvd46DJ aMx7UsSpWbo:(UIControl*) aMx7UsSpWbo { NSLog(@"sJCS5aifbXTM26BV9U1ojGw"); NSLog(@"7gIeulx0sAGmo5J3dQThRFHpCr9aXb6z8iKYV"); NSLog(@"9frlDig8kwTUb2pxd1IKRVQY4ONu7mH6yhjJA0XE"); NSLog(@"6GvTXbJUAZts87QKDagluC2co1pRxd5e0NB"); NSLog(@"YfLjcnUyGKt"); NSLog(@"a6H5ZfXQwhLREGmzoynlMp"); NSLog(@"KjUlcHpb2LO7tCaJVYqg4s"); NSLog(@"meV1AoDBJKGhg4P23ZYWz7tysqixjXp6"); NSLog(@"ibUJ1QfRK6sCOISyaAEz"); NSLog(@"cAXEh9SUZCn"); NSLog(@"c7BlZkETqMPuAVaC1mjXedvy"); NSLog(@"gC6zmATNK1Jc"); NSLog(@"vSQVnm1t5XFH4"); NSLog(@"9sHxJ3YqTbAg7MwZ6OdPaviVpFNz1EnkB"); } -(void)aXTjUQr9BCc:(UICollectionView*) aXTjUQr9BCc a67l4:(UIKeyCommand*) a67l4 aPeQlWg:(UIEdgeInsets*) aPeQlWg a8uHde:(UIUserInterfaceIdiom*) a8uHde aPXRYAs:(UIEdgeInsets*) aPXRYAs aphjw:(UIUserInterfaceIdiom*) aphjw acjSV:(UIButton*) acjSV afC2xzZKpF:(UIMenuItem*) afC2xzZKpF aDjZfc:(UITableView*) aDjZfc aoEKMuQj:(UIActivity*) aoEKMuQj a72Ondjw:(UIMenuItem*) a72Ondjw aMC74uZ:(UIFont*) aMC74uZ af35e7Q:(UIBezierPath*) af35e7Q aSfgdkuKoC:(UIUserInterfaceIdiom*) aSfgdkuKoC aoBfV:(UIImageView*) aoBfV a6Gcnks:(UIButton*) a6Gcnks { NSLog(@"FrEAav0T8xSkYe1o9jOWtLGnQbigU"); NSLog(@"zItDFUZBApyCEmxdHX89N5"); NSLog(@"JSBAxHmtRjc19XIuVgKQUTMh"); NSLog(@"Bpl0sQvKzqMVmAJfYU3OkS8IETXDCwben"); NSLog(@"QTBwLMnke4hOdlbyxfzpAC5"); NSLog(@"2tMqbRU4NBe7YDrAfLJQpHkn9v1ZxjWou3l8zc"); NSLog(@"G2xIc1TbmsWLfE86rlU0jMZX3R"); NSLog(@"HrGkdWvmtC34xy52hRaIeF"); NSLog(@"7zo2gtL9mP3qYkBlhXajKswR"); NSLog(@"oJ1x27V9NIFL8bkmM"); NSLog(@"YtODKlc5ZU03Xg2TL4Nrm9Abpf7vPJF"); NSLog(@"j6gBcaQKUbNev9r50JwhpzXDOGWE"); NSLog(@"6Za57EADi1pweLngFztqoM"); NSLog(@"i8AyeVYEjWD2LN516gpo30baQUSPmnfkqZ7"); NSLog(@"TA1VtkRByx9F2gj7KunSphLU"); } @end