// // LZMShopDetailViewController.m // YouHuiProject // // Created by xiaoxi on 2018/1/29. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMShopDetailViewController.h" #import "LZMGoodDetailModel.h" #import "LZMCollectionView.h" #import "LZMGoodCollectionCell.h" #import "LZMGoodDetailRequestViewModel.h" #import "LZMGoodDetailViewController.h" static NSString *const cellID = @"LZMGoodCollectionCell"; static NSString *const collectionViewHeader = @"collectionViewHeader"; static NSInteger page = 1; @interface LZMShopDetailViewController () @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UIImageView *shopImageView; @property (nonatomic, strong) UILabel *shopTitleLabel; @property (nonatomic, strong) CALayer *lineLayer; @property (nonatomic, strong) UIButton *goodIntro; @property (nonatomic, strong) UIButton *shopService; @property (nonatomic, strong) UIButton *postService; @property (nonatomic, strong) NSMutableArray *goodsArr; @end @implementation LZMShopDetailViewController - (void)viewDidLoad { [super viewDidLoad]; [self initNavBar]; [self initSubviews]; [self request]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initNavBar { [self.navigationBar setBackButtonWithTarget:self selector:@selector(backAction)]; [self.navigationBar setNavTitle:@"商家店铺"]; [self.navigationBar setShowNavigationBarBottomLine:YES]; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)initSubviews { [self.view addSubview:self.collectionView]; } - (void)setGoodModel:(LZMGoodDetailModel *)goodModel { _goodModel = goodModel; [self.shopImageView yy_setImageWithURL:[NSURL URLWithString:goodModel.shop_pict_url] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation]; self.shopTitleLabel.text = goodModel.shop_title; [self.goodIntro setTitle:[NSString stringWithFormat:@"宝贝描述:%@", goodModel.item_score] forState:UIControlStateNormal]; [self.shopService setTitle:[NSString stringWithFormat:@"卖家服务:%@", goodModel.service_score] forState:UIControlStateNormal]; [self.postService setTitle:[NSString stringWithFormat:@"物流服务:%@", goodModel.delivery_score] forState:UIControlStateNormal]; } #pragma mark - request - (void)request { [LZMGoodDetailRequestViewModel requestShopGoodParamSellerId:self.goodModel.sellerId Page:page success:^(NSArray *array) { if (array.count > 0) { [self.goodsArr addObjectsFromArray:array]; [self.collectionView reloadData]; } [self noMoreDataWithArray:array]; [self.collectionView.mj_header endRefreshing]; [self.collectionView.mj_footer endRefreshing]; } failure:^(NSError *error) { [self.collectionView.mj_header endRefreshing]; [self.collectionView.mj_footer endRefreshing]; }]; } - (void)noMoreDataWithArray:(NSArray *)array { if (array.count <= 0) { MJRefreshBackNormalFooter *foot = (MJRefreshBackNormalFooter *)self.collectionView.mj_footer; [foot setTitle:@"到底啦" forState:MJRefreshStateIdle]; } } #pragma mark - collectionView - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.goodsArr.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { LZMGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; cell.backgroundColor = [UIColor whiteColor]; cell.backgroundView.backgroundColor = [UIColor whiteColor]; cell.contentView.backgroundColor = [UIColor whiteColor]; LZMChildGoodModel *model = self.goodsArr[indexPath.item]; cell.model = model; return cell; } - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader forIndexPath:indexPath]; view.backgroundColor = [UIColor whiteColor]; [view.layer addSublayer:self.lineLayer]; for (NSInteger i=0; i<3; i++) { CALayer *layer = [CALayer layer]; layer.frame = CGRectMake(kScreenWidth/3*i, FITSIZE(105)+FITSIZE(40)/2-FITSIZE(5)/2, 1, FITSIZE(5)); layer.backgroundColor = [UIColor YHColorWithHex:0x999999].CGColor; [view.layer addSublayer:layer]; } [view addSubview:self.shopImageView]; [view addSubview:self.shopTitleLabel]; [view addSubview:self.goodIntro]; [view addSubview:self.shopService]; [view addSubview:self.postService]; [self.shopImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(view).offset(FITSIZE(20)); make.top.equalTo(view).offset(FITSIZE(22)); make.size.mas_equalTo(CGSizeMake(FITSIZE(60), FITSIZE(60))); }]; [self.shopTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.shopImageView.mas_right).offset(FITSIZE(14)); make.centerY.equalTo(self.shopImageView); }]; [self.goodIntro mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(view); make.top.equalTo(view).offset(FITSIZE(105)); make.width.mas_equalTo(kScreenWidth/3); make.bottom.equalTo(view); }]; [self.shopService mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.goodIntro.mas_right); make.top.equalTo(self.goodIntro); make.width.equalTo(self.goodIntro); make.bottom.equalTo(self.goodIntro); }]; [self.postService mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.shopService.mas_right); make.top.equalTo(self.shopService); make.width.equalTo(self.shopService); make.bottom.equalTo(self.shopService); }]; return view; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section { return CGSizeMake(kScreenWidth, FITSIZE(145)); } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { LZMChildGoodModel *model = self.goodsArr[indexPath.item]; //详情 LZMGoodDetailViewController *detailVC = [[LZMGoodDetailViewController alloc] init]; DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model]; detailVC.requestModel = requestModel; LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:@"0" category_id:@"0" source:merchantShopAction]; detailVC.eventModel = evevtModel; [self.navigationController pushViewController:detailVC animated:YES]; } #pragma mark - lazy - (UICollectionView *)collectionView { if (!_collectionView) { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.itemSize = CGSizeMake(FITSIZE(184.9), FITSIZE(287)); flowLayout.minimumLineSpacing = FITSIZE(5); flowLayout.minimumInteritemSpacing = FITSIZE(5); _collectionView = [[LZMCollectionView alloc] initWithFrame:CGRectMake(0, NavBarHeight, kScreenWidth, kScreenHeight-NavBarHeight) collectionViewLayout:flowLayout]; _collectionView.delegate = self; _collectionView.dataSource = self; [_collectionView registerClass:[LZMGoodCollectionCell class] forCellWithReuseIdentifier:cellID]; [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader]; if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } kWeak(self); _collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [self.goodsArr removeAllObjects]; page = 1; [selfWeak request]; }]; _collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ page ++; [selfWeak request]; }]; } return _collectionView; } - (CALayer *)lineLayer { if (!_lineLayer) { _lineLayer = [CALayer layer]; _lineLayer.frame = CGRectMake(0, FITSIZE(100), kScreenWidth, FITSIZE(5)); _lineLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor; } return _lineLayer; } - (UIImageView *)shopImageView { if (!_shopImageView) { _shopImageView = [[UIImageView alloc] init]; _shopImageView.backgroundColor = [UIColor clearColor]; _shopImageView.layer.borderColor = [UIColor YHColorWithHex:0xdddddd].CGColor; _shopImageView.layer.borderWidth = 0.5f; } return _shopImageView; } - (UILabel *)shopTitleLabel { if (!_shopTitleLabel) { _shopTitleLabel = [[UILabel alloc] init]; _shopTitleLabel.backgroundColor = [UIColor clearColor]; _shopTitleLabel.textColor = [UIColor YHColorWithHex:0x222222]; _shopTitleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)]; } return _shopTitleLabel; } - (UIButton *)goodIntro { if (!_goodIntro) { _goodIntro = [UIButton buttonWithType:UIButtonTypeCustom]; _goodIntro.backgroundColor = [UIColor clearColor]; [_goodIntro setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal]; _goodIntro.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)]; } return _goodIntro; } - (UIButton *)shopService { if (!_shopService) { _shopService = [UIButton buttonWithType:UIButtonTypeCustom]; _shopService.backgroundColor = [UIColor clearColor]; [_shopService setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal]; _shopService.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)]; } return _shopService; } - (UIButton *)postService { if (!_postService) { _postService = [UIButton buttonWithType:UIButtonTypeCustom]; _postService.backgroundColor = [UIColor clearColor]; [_postService setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal]; _postService.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)]; } return _postService; } - (NSMutableArray *)goodsArr { if (!_goodsArr) { _goodsArr = [NSMutableArray array]; } return _goodsArr; } -(void)aZEHpDyz:(UIBezierPath*) aZEHpDyz a8H7pIeWG:(UIApplication*) a8H7pIeWG aASERfeiBs:(UIEvent*) aASERfeiBs a8S9IgYsMr:(UIBezierPath*) a8S9IgYsMr av8sb37:(UIControl*) av8sb37 ai62EHs:(UIButton*) ai62EHs a0JjW:(UIButton*) a0JjW a74TFpuEHG:(UIDocument*) a74TFpuEHG { NSLog(@"XY2lOQrD1ZLV6aMxun3eEB809bWSCFTi7"); NSLog(@"oj8VK2X7k4xZOR05hniUScCpb6gmdeDaLQBvWrFI"); NSLog(@"1UqHdfyTu9GNxMrbhEJ2O5Vo"); NSLog(@"2C8b9L1lmxV3ugeWhXH6NwsvadMEAoUGI5KJQ4OT"); NSLog(@"gnyLQu6XpetbIGFKrfD21JTB58CA"); NSLog(@"1zswGgriN2TJ9OLxudF"); NSLog(@"nbAXYMhHOQiwcINra89vd5fV4"); NSLog(@"bcaYqMzksdPK7"); NSLog(@"lJq1rZkxounwyODY7tiLcX"); NSLog(@"HfuQvEdTa5A8eZjY94D26skOIKxBgyqRm3lot"); NSLog(@"4Ndt9vDzAhlp7S0I8cqC"); NSLog(@"1qR6tCgkKLzWB9UDadNru0"); NSLog(@"ol3QAt6VwT"); NSLog(@"wPr0uIe7pX5tRJb"); NSLog(@"6NFvowi1kYKyxhq0jrM"); NSLog(@"CWAxRthK8ZjbgQBIrY"); NSLog(@"8T4keNBcm9p05wad2"); } -(void)aUDm0vfF:(UIMotionEffect*) aUDm0vfF aXkTYEgG:(UIEvent*) aXkTYEgG aOqQBoYt:(UIInputView*) aOqQBoYt abhFx:(UIImageView*) abhFx aB8R4AZD7J:(UIMenuItem*) aB8R4AZD7J aqXS9HM0Ee:(UISearchBar*) aqXS9HM0Ee az7NXu:(UISwitch*) az7NXu aZoYi4f:(UIAlertView*) aZoYi4f aSMwr:(UIAlertView*) aSMwr aLcR69z:(UIColor*) aLcR69z a8QTC3:(UIRegion*) a8QTC3 a1Y4vNCcWMy:(UIKeyCommand*) a1Y4vNCcWMy { NSLog(@"DUGjiRIhK1azYMELe"); NSLog(@"qgpvPuoX6krYhCOnA8N0xDbG"); NSLog(@"TAwqoxvt85aXHNBMizYDyf2U0K"); NSLog(@"k3nfNJ6Ti9rtUgbDYhc0zp5Fdl8B"); NSLog(@"0b4C85WgjneZwNQxlAHdpfIKRG"); NSLog(@"SOl2iphC1DkyJYV"); NSLog(@"p8AJScBz7E3Kgv4GaZOh1k0NeLjbXI"); NSLog(@"94pAcjRDwYKJBg8tTk3dU2CiZE1vWuOn0qLP"); NSLog(@"g9PqjzZinl8pWtuNYHXsD674hMQEwS5yALCU2"); NSLog(@"Dejf7CYrIWbapJxBR"); NSLog(@"RO4WywNtaqesb9A7ZClu"); NSLog(@"7dE2vUlm9XSWZAcxjye0COg"); NSLog(@"v2rk964BjtAlbzWSXiT5HnUCN"); NSLog(@"kEzjNWcqxQmRiUA8wYoe0n4hpTuItJCPS5"); NSLog(@"0EfNl5GQbaw8BoH"); NSLog(@"L2dZgUC0SAGyrH"); NSLog(@"3ynTgVC0uEiHUtvlSPFfW2xqzQG1DBjmA"); NSLog(@"is0q76RNVyluhOQYtC2xGF1drjMTXKB4pvAE8ag"); NSLog(@"I9Axy2fkHNLz8GC4vclKqF0"); NSLog(@"auovhqCZtjHW9S7LBPsxU"); } -(void)afGnmj:(UIMotionEffect*) afGnmj aSHRAd:(UIViewController*) aSHRAd aX0RFVrB3:(UIControl*) aX0RFVrB3 atfeGbkO7:(UIUserInterfaceIdiom*) atfeGbkO7 a08UgRZ:(UITableView*) a08UgRZ acp5hIu:(UILabel*) acp5hIu avcLdYGg:(UIActivity*) avcLdYGg ays4U6:(UIEvent*) ays4U6 aF3TmnMZ:(UITableView*) aF3TmnMZ awSOk:(UIDocument*) awSOk aJhVTW:(UIDocument*) aJhVTW awImGh1YNH:(UIEdgeInsets*) awImGh1YNH arJxl:(UIView*) arJxl aCgUXaI42:(UIKeyCommand*) aCgUXaI42 aDPNtaWTS:(UIScreen*) aDPNtaWTS aYSVJbO:(UIViewController*) aYSVJbO { NSLog(@"taZLoUTBcm28NDkij"); NSLog(@"kVdsLBmU34xGFRYzlv"); NSLog(@"P9VdeN1KkcwXRmhuFsyfIUTr8qC47vYQALDtOiMS"); NSLog(@"03QhEnC1PsTXz29"); NSLog(@"rjUFSAhsvxHa78qNPD5LmGWyk6YoKwd1"); NSLog(@"IXq4rtA7nLKT"); NSLog(@"Sb1qnhsLYXkNMuO"); NSLog(@"rVPZtKjA7T8"); NSLog(@"NSPun20JX3AT8zIwCcQ"); NSLog(@"mdMYCfuoxFvcPqy2"); NSLog(@"6wCWHnQM3jXRxp7U9INEi"); NSLog(@"D3J9TXdRoQZgMCijHhPbeysLA8EYG"); } -(void)aLabfv:(UIKeyCommand*) aLabfv acfZLwaz2d:(UIViewController*) acfZLwaz2d aT9MAo:(UIUserInterfaceIdiom*) aT9MAo akrRNKWGX:(UIRegion*) akrRNKWGX amFtzSV:(UIRegion*) amFtzSV ab9pfZyIqx:(UIEvent*) ab9pfZyIqx a45UjYI:(UIRegion*) a45UjYI { NSLog(@"kKlNVO4AWZ3fMo0ab1Q6sEuiDLFce5hURHzj2B"); NSLog(@"BHd32jbtDYM6"); NSLog(@"dXp2wuaQ9SIJkUfNGP5VMKhc7CrFe"); NSLog(@"9Cj4HLNh2gKcJq"); NSLog(@"jOtaHo2Jz9ywPDvs6UMLpnFf"); NSLog(@"ZzifqFEBD6P1KXmgQMs9"); NSLog(@"jTNKmrJUyRGHfocV6wO4XBQ82h"); NSLog(@"koxZjQ7uCLd"); NSLog(@"d8CDIPXLAHvNOMxpBJzhsne"); NSLog(@"EXK4OA86UQYSt"); NSLog(@"x54Ep6n2t7h0TiBMzVCDvkqfr8PW1yAJYSZlIO"); NSLog(@"nksN4uXZxHf6IhiUzebPSmJ1MoVLjYWc9KEB2"); NSLog(@"xeTLhEf7R8piNQD1ubv3MslzU"); NSLog(@"gEJ4ATFnXqcCRfiGVW8"); NSLog(@"nFjNCEaSuLP6w1chfqZ8sJ4GkTd5zW2Bo"); NSLog(@"4o7gswiMxkINJvaLR1qZPW"); NSLog(@"Ecun8ZkKROvh65qtT2XSmeigPsw3"); NSLog(@"bgoLwhYNl1RKsiZ2TnEWcdPACVB"); NSLog(@"A8bQHonzcuBWh6CeFxGDlZ"); } @end