123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- //
- // YHGoodDetailViewController.m
- // YouHuiProject
- //
- // Created by xiaoxi on 2018/1/22.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "YHGoodDetailViewController.h"
- #import "YHGoodDetailRequestViewModel.h"
- #import "SDCycleScrollView.h"
- #import "YHTableView.h"
- #import "YHGoodDetailBottomView.h"
- #import "YHGoodDetailView.h"
- #import "YHCollectionView.h"
- #import "YHGoodCollectionCell.h"
- #import "YHShopDetailViewController.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import "YHHistoryTool.h"
- #import "YHHistoryModel.h"
- #import "YHGoodListViewController.h"
- #import "YHLoginViewController.h"
- #import "YHAdWebViewController.h"
- #import <WebKit/WebKit.h>
- #define GoodSimilarViewHeight ((self.goodSimilarArr.count-1)/2+1)*FITSIZE(292)+FITSIZE(45)
- static CGFloat detailDescWebHeight = 0.1;
- static NSInteger const detailDescWebTag = 111;
- static NSString *const cellID = @"YHGoodCollectionCell";
- static NSString *const collectionViewHeader = @"collectionViewHeader";
- @interface YHGoodDetailViewController () <SDCycleScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,YHGoodDetailBottomViewDelegate,YHGoodDetailViewDelegate,UIWebViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,SGPageTitleViewDelegate,UIWebViewDelegate,WKNavigationDelegate>
- @property (nonatomic, strong) YHGoodDetailModel *goodModel;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) WKWebView *detailDescWebView;
- @property (nonatomic, strong) UIView *tableHeaderView;
- @property (nonatomic, strong) YHGoodDetailView *goodDetailView;
- @property (nonatomic, strong) SDCycleScrollView *cycleView;
- @property (nonatomic, strong) NSArray *goodSimilarArr;
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) UIButton *backButton;
- @property (nonatomic, strong) SGPageTitleView *topTitleView;
- @property (nonatomic, strong) YYFPSLabel *fpsLabel;
- @property (nonatomic, strong) YHGoodDetailBottomView *goodBottomView;
- @end
- @implementation YHGoodDetailViewController
- - (void)dealloc {
- [self.detailDescWebView removeObserver:self forKeyPath:@"scrollView.contentSize"];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [SVProgressHUD dismiss];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initHUD];
- [self initNavBar];
- [self request];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- self.navigationController.navigationBar.hidden = YES;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- - (void)initNavBar {
- [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0.0]];
-
- UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
- leftButton.frame = CGRectMake(0, 0, FITSIZE(22), FITSIZE(22));
- leftButton.backgroundColor = [UIColor clearColor];
- [leftButton setBackgroundImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
- [leftButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- self.backButton = leftButton;
- [self.navigationBar setCustomLeftButtons:@[leftButton]];
-
- [self.navigationBar addSubview:self.topTitleView];
- }
- - (void)initSubviews {
- //底部栏
- YHGoodDetailBottomView *bottomView = [[YHGoodDetailBottomView alloc] initWithFrame:CGRectMake(0, kScreenHeight-FITSIZE(55)-BottomMargin, kScreenWidth, FITSIZE(55))];
- bottomView.delegate = self;
- bottomView.goodModel = self.goodModel;
- [self.view addSubview:bottomView];
- self.goodBottomView = bottomView;
-
- //轮播
- SDCycleScrollView *cycleView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, FITSIZE(375), FITSIZE(375)) delegate:self placeholderImage:[UIImage imageNamed:@""]];
- cycleView.imageURLStringsGroup = self.goodModel.small_img;
- self.cycleView = cycleView;
-
- //商品信息
- self.goodDetailView = [[YHGoodDetailView alloc] initWithFrame:CGRectMake(0, cycleView.height, kScreenWidth, FITSIZE(359))];
- self.goodDetailView.delegate = self;
- self.goodDetailView.goodModel = self.goodModel;
-
- self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, cycleView.height+self.goodDetailView.height)];
-
- [self.tableHeaderView addSubview:cycleView];
- [self.tableHeaderView addSubview:self.goodDetailView];
-
- //间隔线
- UIView *lineGapView = [[UIView alloc] initWithFrame:CGRectMake(0, cycleView.height+self.goodDetailView.height, kScreenWidth, FITSIZE(45))];
- lineGapView.backgroundColor = [UIColor clearColor];
- [self.tableHeaderView addSubview:lineGapView];
-
- CALayer *lineGapLayer = [CALayer layer];
- lineGapLayer.frame = CGRectMake(0, 0, kScreenWidth, FITSIZE(5));
- lineGapLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor;
- [lineGapView.layer addSublayer:lineGapLayer];
-
- UILabel *lineGapLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, kScreenWidth, FITSIZE(40))];
- lineGapLabel.backgroundColor = [UIColor whiteColor];
- lineGapLabel.textColor = [UIColor YHColorWithHex:0x222222];
- lineGapLabel.font = [UIFont systemFontOfSize:FITSIZE(13)];
- lineGapLabel.text = @"宝贝详情";
- lineGapLabel.textAlignment = NSTextAlignmentCenter;
- [lineGapView addSubview:lineGapLabel];
-
- //详情webview
- _detailDescWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, cycleView.height+self.goodDetailView.height+FITSIZE(45), kScreenWidth, detailDescWebHeight)];
- _detailDescWebView.tag = detailDescWebTag;
- _detailDescWebView.navigationDelegate = self;
- _detailDescWebView.scrollView.scrollEnabled = NO;
- NSURL *url = [NSURL URLWithString:self.goodModel.desc_url];
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
- [_detailDescWebView loadRequest:request];
- [self.tableHeaderView addSubview:_detailDescWebView];
-
- [self.view addSubview:self.tableView];
- self.tableView.tableHeaderView = self.tableHeaderView;
-
- [self.view bringSubviewToFront:self.navigationBar];
-
- _fpsLabel = [YYFPSLabel new];
- [_fpsLabel sizeToFit];
- _fpsLabel.bottom = kScreenHeight - TabbarHeight;
- _fpsLabel.left = 0;
- _fpsLabel.alpha = 0;
- // [self.view addSubview:_fpsLabel];
-
- //添加监听
- [_detailDescWebView addObserver:self forKeyPath:@"scrollView.contentSize" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
-
- [YHGoodDetailRequestViewModel requestGoodSimilarParamGoods_id:self.goods_id success:^(NSArray *array) {
- if (array.count > 0) {
- self.goodSimilarArr = array;
- self.tableView.tableFooterView = self.collectionView;
- }
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
- if ([keyPath isEqualToString:@"scrollView.contentSize"]) {
- id height = [change valueForKey:NSKeyValueChangeNewKey];
- CGSize size;
- [(NSValue *)height getValue:&size];
- if (detailDescWebHeight != size.height) {
- detailDescWebHeight = size.height;
- self.detailDescWebView.height = size.height;
- self.tableHeaderView.height = self.cycleView.height+self.goodDetailView.height+FITSIZE(45)+size.height;
- self.tableView.tableHeaderView = self.tableHeaderView;
- }
-
- }
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark - HUD
- - (void)initHUD {
- [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
- [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
- [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
- }
- #pragma mark - request
- - (void)request {
- // [SVProgressHUD show];
-
- [YHGoodDetailRequestViewModel requestGoodDetailParamGoods_id:self.goods_id success:^(YHGoodDetailModel *model,NSDictionary *dic) {
- if (model) {
- self.goodModel = model;
- [self initSubviews];
- [self saveGoodsInfoAsBrowserHistoryWith:dic];
- }
- } failure:^(NSError *error) {
- [SVProgressHUD dismiss];
- }];
- }
- /**
- 保存浏览记录,最多30条
- */
- - (void)saveGoodsInfoAsBrowserHistoryWith:(NSDictionary *)dic {
-
- NSMutableDictionary *mDic = [NSMutableDictionary dictionary];
-
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"goods_id"]] forKey:@"goods_id"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"title"]] forKey:@"title"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"end_time"]] forKey:@"end_time"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"price"]] forKey:@"price"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"discount_price"]] forKey:@"discount_price"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"coupon_price"]] forKey:@"coupon_price"];
- [mDic setObject:[NSString stringWithFormat:@"%@",dic[@"img"]] forKey:@"img"];
- [mDic setObject:[PublicFunction getCurrentDate] forKey:@"browserTime"];
-
- NSMutableArray *hisArr = [[NSMutableDictionary dictionaryWithContentsOfFile:[YHHistoryTool getHistoryFilePath]] objectForKey:BrowserHistoryKey];
-
- if (!hisArr) {
- hisArr = [NSMutableArray array];
- }
-
- NSMutableArray *mupArr = [NSMutableArray array];
- for (NSDictionary *dic in hisArr) {
- if ([dic[@"goods_id"] isEqualToString:mDic[@"goods_id"]]) {
- [mupArr addObject:dic];
- }
- }
-
- //去重
- for (NSDictionary *dic in mupArr) {
- [hisArr removeObject:dic];
- }
-
- [hisArr insertObject:mDic atIndex:0];
-
- if (hisArr.count > 30) {
- [hisArr removeLastObject];
- }
-
- NSDictionary *historyDic = @{BrowserHistoryKey:hisArr};
- [historyDic writeToFile:[YHHistoryTool getHistoryFilePath] atomically:YES];
- }
- #pragma mark - scrollView
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- CGFloat offsetY = scrollView.contentOffset.y;
- // CGFloat standard = FITSIZE(734)-NavBarHeight;
- CGFloat standard = self.cycleView.height-NavBarHeight;
- if (offsetY > -standard && offsetY < standard) {
- [self.navigationBar setNavightionBarBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:offsetY/standard]];
- self.topTitleView.alpha = offsetY/standard;
- if (offsetY/standard < 0.5) {
- [self.backButton setBackgroundImage:[UIImage imageNamed:@"detail_back_g"] forState:UIControlStateNormal];
- self.backButton.alpha = 1-offsetY/standard;
- }
- else {
- [self.backButton setBackgroundImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- self.backButton.alpha = offsetY/standard;
- }
- }
- else {
-
- }
- if (offsetY >= standard) {
- [self.navigationBar setShowNavigationBarBottomLine:YES];
- } else {
- [self.navigationBar setShowNavigationBarBottomLine:NO];
- }
-
- //设置导航栏头部seg下标
- CGFloat indexOneHeight = self.goodDetailView.height+self.cycleView.height-NavBarHeight;
- CGFloat indexTwoHeight = self.tableHeaderView.height-NavBarHeight;
-
- if (offsetY < indexOneHeight) {
- self.topTitleView.newSelectedIndex = 0;
- }else if (offsetY>=indexOneHeight && offsetY<indexTwoHeight){
- self.topTitleView.newSelectedIndex = 1;
- }else {
- self.topTitleView.newSelectedIndex = 2;
- }
-
- }
- - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
-
- }
- - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
- if (!decelerate) {
- if (_fpsLabel.alpha != 0) {
- [UIView animateWithDuration:1 delay:2 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
- _fpsLabel.alpha = 0;
- } completion:NULL];
- }
- }
- }
- - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
- if (_fpsLabel.alpha == 0) {
- [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
- _fpsLabel.alpha = 1;
- } completion:^(BOOL finished) {
- }];
- }
- }
- #pragma mark - topTitleViewDelegate
- - (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
- switch (selectedIndex) {
- case 0:
- [self.tableView setContentOffset:CGPointMake(0, 0) animated:YES];
- break;
- case 1:
- [self.tableView setContentOffset:CGPointMake(0, FITSIZE(734)-NavBarHeight) animated:YES];
- break;
- case 2:
- [self.tableView setContentOffset:CGPointMake(0, FITSIZE(779)+detailDescWebHeight-NavBarHeight) animated:YES];
- break;
- default:
- break;
- }
- }
- #pragma mark - goodDetailBottomViewDelegate
- - (void)yh_GoodDetailBottomViewClickShopButton {
- YHShopDetailViewController *shopVC = [[YHShopDetailViewController alloc] init];
- shopVC.goodModel = self.goodModel;
- [self.navigationController pushViewController:shopVC animated:YES];
- }
- - (void)yh_GoodDetailBottomViewClickCollectButton {
- if ([AccountTool isLogin]) {
- [MobClick event:collection_count];
-
- [YHGoodDetailRequestViewModel requestCollectGoodParamGoods_id:self.goods_id is_collect:self.goodModel.is_collect success:^(NSString *msg) {
- [SVProgressHUD showSuccessWithStatus:msg];
- if ([msg isEqualToString:@"收藏成功"]) {
- self.goodModel.is_collect = @1;
- self.goodBottomView.collectButton.selected = YES;
- }
- else {
- self.goodModel.is_collect = @0;
- self.goodBottomView.collectButton.selected = NO;
- }
- } failure:^(NSError *error) {
-
- }];
- }
- else {
- YHLoginViewController *login = [[YHLoginViewController alloc] init];
- [self.navigationController presentViewController:login animated:YES completion:nil];
- }
- }
- /**
- 跳到淘宝领券
- */
- - (void)yh_GoodDetailBottomViewClickBuyButton {
-
-
- if ([self isInstallTaobaoAPP]) {
- id<AlibcTradePage> page = [AlibcTradePageFactory page:self.goodModel.coupon_url];
- //淘客信息
- AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
- taoKeParams.pid = ALTK_PID; //
- //打开方式
- AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
- showParam.openType = AlibcOpenTypeNative;
- [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
-
- } tradeProcessFailedCallback:^(NSError * _Nullable error) {
-
- }];
- }else {
- YHAdWebViewController *webVc = [[YHAdWebViewController alloc] init];
- webVc.url = self.goodModel.coupon_url;
- [self.navigationController pushViewController:webVc animated:YES];
- }
-
- [MobClick event:pay_count];
- }
- /**
- 判断是否安装淘宝app
- */
- - (BOOL)isInstallTaobaoAPP {
- if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"taobao://"]]) {
- return YES;
- }else {
- return NO;
- }
- }
- #pragma mark - goodDetailViewDelegate
- - (void)yh_GoodDetailViewTapCoupon {
- [YHGoodDetailRequestViewModel requestTicketProcessParamGoods_id:self.goods_id coupon_price:self.goodModel.coupon_price success:^(NSString *msg) {
- [self yh_GoodDetailBottomViewClickBuyButton];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)yh_GoodDetailViewTapShop {
- YHShopDetailViewController *shopVC = [[YHShopDetailViewController alloc] init];
- shopVC.goodModel = self.goodModel;
- [self.navigationController pushViewController:shopVC animated:YES];
- }
- #pragma mark - webView
- - (void)webViewDidStartLoad:(UIWebView *)webView {
- [SVProgressHUD dismiss];
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView {
- [SVProgressHUD dismiss];
-
- CGSize contentSize = webView.scrollView.contentSize;
- CGSize viewSize = self.detailDescWebView.bounds.size;
-
- float rw = viewSize.width / contentSize.width;
- webView.scrollView.minimumZoomScale = rw;
- webView.scrollView.maximumZoomScale = rw;
- webView.scrollView.zoomScale = rw;
- }
- - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
- [SVProgressHUD dismiss];
- }
- #pragma mark - tableView
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
- return cell;
- }
- #pragma mark - collectionView
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.goodSimilarArr.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- YHGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
- cell.backgroundColor = [UIColor whiteColor];
- cell.backgroundView.backgroundColor = [UIColor whiteColor];
- cell.contentView.backgroundColor = [UIColor whiteColor];
- YHChildGoodModel *model = self.goodSimilarArr[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];
-
- CALayer *lineGapLayer = [CALayer layer];
- lineGapLayer.frame = CGRectMake(0, 0, kScreenWidth, FITSIZE(5));
- lineGapLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor;
- [view.layer addSublayer:lineGapLayer];
-
- UILabel *lineGapLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, kScreenWidth, FITSIZE(40))];
- lineGapLabel.backgroundColor = [UIColor whiteColor];
- lineGapLabel.textColor = [UIColor YHColorWithHex:0x222222];
- lineGapLabel.font = [UIFont systemFontOfSize:FITSIZE(13)];
- lineGapLabel.text = @"相关推荐";
- lineGapLabel.textAlignment = NSTextAlignmentCenter;
- [view addSubview:lineGapLabel];
-
- return view;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
- return CGSizeMake(kScreenWidth, FITSIZE(45));
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- YHChildGoodModel *model = self.goodSimilarArr[indexPath.item];
- if ([model.type isEqualToString:@"0"]) {
- //详情
- YHGoodDetailViewController *detailVC = [[YHGoodDetailViewController alloc] init];
- detailVC.goods_id = model.goods_id;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- else {
- //专场
- YHGoodListViewController *listVC = [[YHGoodListViewController alloc] init];
- listVC.cate_id = model.goods_id;
- listVC.topRequest = 1;
- [self.navigationController pushViewController:listVC animated:YES];
- }
- }
- #pragma mark - lazy
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[YHTableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-FITSIZE(55)-BottomMargin) style:UITableViewStylePlain];
- _tableView.rowHeight = 0.1;
- _tableView.estimatedRowHeight = 0;
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
- if (@available(iOS 11.0, *)) {
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
- }
- return _tableView;
- }
- - (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 = [[YHCollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, GoodSimilarViewHeight) collectionViewLayout:flowLayout];
- _collectionView.scrollEnabled = NO;
- _collectionView.bounces = NO;
- _collectionView.showsVerticalScrollIndicator = NO;
- _collectionView.delegate = self;
- _collectionView.dataSource = self;
- [_collectionView registerClass:[YHGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
- [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader];
- }
- return _collectionView;
- }
- - (SGPageTitleView *)topTitleView {
- if (!_topTitleView) {
- SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
- configure.titleFont = [UIFont systemFontOfSize:FITSIZE(14)];
- configure.titleColor = [UIColor YHColorWithHex:0x222222];
- configure.titleSelectedColor = [UIColor YHColorWithHex:0xff2420];
- configure.indicatorColor = [UIColor YHColorWithHex:0xff2420];
- configure.indicatorScrollStyle = SGIndicatorScrollStyleHalf;
-
- _topTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kScreenWidth/2-FITSIZE(100), KStatusBarHeight, FITSIZE(200), FITSIZE(44)) delegate:self titleNames:@[@"宝贝",@"详情",@"推荐"] configure:configure];
- _topTitleView.backgroundColor = [UIColor clearColor];
- _topTitleView.alpha = 0.0;
- _topTitleView.isNeedBounces = NO;
- _topTitleView.isTitleGradientEffect = NO;
- _topTitleView.isOpenTitleTextZoom = YES;
- _topTitleView.isShowBottomSeparator = NO;
- }
- return _topTitleView;
- }
- @end
|