123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 |
- //
- // LDTodayViewController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/1/17.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDTodayViewController.h"
- #import "SDCycleScrollView.h"
- #import "LDOnePicCell.h"
- #import "LDCountHeaderView.h"
- #import "LDMorePicCell.h"
- #import "LDTodayBannerModel.h"
- #import "LDChildGoodModel.h"
- #import "LDMorePicModel.h"
- #import "LDGoodsInfo.h"
- #import "LDAdversementCell.h"
- #import "LDAdWebViewController.h"
- #import "LDGoodListViewController.h"
- #import "FSBaseViewController.h"
- #import "LDMorePicCollectionCell.h"
- #import "LDMorePicCollectionModel.h"
- #import "LDGoodCollectionCell.h"
- #import "LDSearchCoupleWebViewController.h"
- #import "LDShareGoodsModel.h"
- #import "LDShareGoodsViewController.h"
- #import "LDPrivilegeReferralViewController.h"
- #import "NSNumber+YHExpanded.h"
- #import "LDTodayModelCollectionCell.h"
- #import "LDRankListViewController.h"
- #import "LDTodayMudleModel.h"
- #import "FSBaseViewController.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import <AlibabaAuthSDK/ALBBSession.h>
- #import <AlibabaAuthSDK/ALBBSDK.h>
- #import "KBTodayReatCollectionCell.h"
- #import "LDBuyLimitMainController.h"
- #import "NewPagedFlowView.h"
- #import "LDSearchCoupleWebViewController.h"
- #import "LDLoginViewController.h"
- #import "FSBaseViewController.h"
- #import "LDTodayAdView.h"
- #import "AdJumpManager.h"
- #import "LDHomeMainViewController.h"
- #import "LDTodayNewsView.h"
- #import "LDSuperBrandView.h"
- #import "LDTodayHorizontalGoodCell.h"
- #import "LDSuperBrandModel.h"
- #import "LDTodayGoodModel.h"
- #import "LDTodayGroupCell.h"
- #import "LDTodayFlowLayout.h"
- #import "LDNewsListViewController.h"
- #import "LDScrollNewsModel.h"
- static NSString *KYHMorePicCollectionCell = @"KYHMorePicCollectionCell";
- static NSString *KYHMorePicCell = @"KYHMorePicCell";
- static NSString *KYHGoodCollectionCell = @"KYHGoodCollectionCell";
- static NSString *KModelCollecionCell = @"modelCollecionCell";
- static NSString *KTodayNewsCell = @"KTodayNewsCell";
- static NSString *KSuperBrandCell = @"KSuperBrandCell";
- static NSString *KTodayGroupCell = @"KTodayGroupCell";
- static NSString *KSectionOne = @"KSectionOne";
- static NSString *KSectionTwo = @"KSectionTwo";
- static NSString *KSectionThree = @"KSectionThree";
- static NSString *KReactCollecionCell = @"ReactCollecionCell";
- static CGFloat bannerScale = 117.f/355.f;
- @interface LDTodayViewController ()
- <
- UICollectionViewDelegate,
- UICollectionViewDataSource,
- TodayCollectionViewDelegateFlowLayout,
- SDCycleScrollViewDelegate,
- YHMorePicCellDelegate,
- YHMorePicCollectionCellDelegate,
- LDTodayModelCollectionCellDelegate,
- YHCountDownViewDelegate,
- NewPagedFlowViewDelegate,
- NewPagedFlowViewDataSource
- >
- {
- NSInteger _page;
- LDTodayAdView *_adView;
- NSArray *_adDataArr;
- UIButton *redBtn;
- NSMutableDictionary *redDic;
- }
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) SDCycleScrollView *cycleScrollView;
- @property (nonatomic, strong) NSArray *bannerList;
- @property (nonatomic, strong) NSArray *superBrandList;
- @property (nonatomic, strong) NSMutableArray *goodsArr;
- @property (nonatomic, strong) LDMorePicCell *morePicCell;
- @property (nonatomic, strong) LDMorePicCollectionCell *morePicCollectionCell;
- @property (nonatomic, strong) NSArray *morePicArr;
- @property (nonatomic, strong) NSArray *morePicCollectionArr;
- @property (nonatomic, strong) NSMutableArray *moduleDataArr;
- @property (nonatomic, strong) LDGoodsInfo *goodsInfo; //商品信息,包括刷新事件
- @property (nonatomic, strong) NewPagedFlowView *NewPagedFlowView;
- @property (nonatomic, strong) LDTodayNewsView *scrollNewsView;
- @property (nonatomic, strong) LDSuperBrandView *superBrandView;
- /**组头*/
- @property (nonatomic, strong) UICollectionReusableView *sectionOne;
- @property (nonatomic, strong) UICollectionReusableView *sectionThree;
- @end
- @implementation LDTodayViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configCollectionView];
- [self request];
- [self.collectionView reloadData];
- }
- - (void)request {
- [self loadBannerData];
- [self loadHotRecomPicCollectionData];
- [self loadCategoryGoodsList];
- [self loadAdData];
- // [self loadSuperBrand];
- [self addRedView];
-
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self isredViewHidden];
- }
- #pragma mark-添加红包图表
- -(void)addRedView
- {
- redBtn =[[UIButton alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-94, SCREEN_HEIGHT/4, 81, 59)];
- [redBtn setImage:[UIImage imageNamed:@"top_red"] forState:UIControlStateNormal];
- [redBtn addTarget:self action:@selector(redBtnclick) forControlEvents:UIControlEventTouchUpInside];
- redBtn.hidden=YES;
- [self.view addSubview:redBtn];
-
- UILabel *priceLabel =[[UILabel alloc]initWithFrame:CGRectMake(0, 25, 81, 24)];
- priceLabel.textColor=[UIColor YHColorWithHex:0xFFFFFF];
- if (@available(iOS 8.2, *)) {
- priceLabel.font=[UIFont systemFontOfSize:17 weight:0.5];
- }
- priceLabel.textAlignment=NSTextAlignmentCenter;
- priceLabel.tag=12342;
- [redBtn addSubview:priceLabel];
-
- UILabel *tipelabel =[[UILabel alloc]initWithFrame:CGRectMake(0, 46, 81, 11)];
- tipelabel.textColor=[UIColor YHColorWithHex:0xFFFFFF];
- tipelabel.font=[UIFont systemFontOfSize:8];
- tipelabel.textAlignment=NSTextAlignmentCenter;
- tipelabel.text=@"未拆完";
- [redBtn addSubview:tipelabel];
-
- }
- #pragma mark-红包点击
- -(void)redBtnclick
- {
- LDAdWebViewController *web = [[LDAdWebViewController alloc] init];
- web.url = redDic[@"url"];
- [self.navigationController pushViewController:web animated:YES];
- }
- #pragma mark-----是否显示红包
- -(void)isredViewHidden
- {
- [LDHttp post:[NSString stringWithFormat:@"%@/api/v2/redactive/getRedPopo",BaseURL] params:nil success:^(id json) {
- redDic=[NSMutableDictionary dictionaryWithDictionary:json[@"data"]];
- if ([redDic[@"status"] integerValue] == 1) {
- redBtn.hidden=NO;
- UILabel *priceL =[redBtn viewWithTag:12342];
- NSString *price =[NSString stringWithFormat:@"¥%@元",redDic[@"money"]];
- NSMutableAttributedString *attri = [[NSMutableAttributedString alloc]initWithString:price];
-
- [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12]range:NSMakeRange(0,1)];
- [attri addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17]range:NSMakeRange(1,price.length-1)];
- priceL.attributedText=attri;
- }else{
- redBtn.hidden=YES;
- }
-
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)configCollectionView {
-
- _page = 1;
-
- LDTodayFlowLayout *flowLayout = [[LDTodayFlowLayout alloc]init];
- self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 5, SCREEN_WIDTH, ChildTableViewHeight+40) collectionViewLayout:flowLayout];
- flowLayout.minimumLineSpacing = 0;
- flowLayout.minimumInteritemSpacing = 0;
- [self.collectionView registerClass:[LDMorePicCollectionCell class] forCellWithReuseIdentifier:KYHMorePicCollectionCell];
- [self.collectionView registerClass:[LDMorePicCell class] forCellWithReuseIdentifier:KYHMorePicCell];
- [self.collectionView registerClass:[LDTodayHorizontalGoodCell class] forCellWithReuseIdentifier:KYHGoodCollectionCell];
- [self.collectionView registerClass:[LDTodayModelCollectionCell class] forCellWithReuseIdentifier:KModelCollecionCell];
- [self.collectionView registerClass:[KBTodayReatCollectionCell class] forCellWithReuseIdentifier:KReactCollecionCell];
- [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:KTodayNewsCell];
- [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:KSuperBrandCell];
- [self.collectionView registerClass:[LDTodayGroupCell class] forCellWithReuseIdentifier:KTodayGroupCell];
-
- [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionOne];
- [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo];
- [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionThree];
- self.collectionView.backgroundColor = [UIColor clearColor];
- self.collectionView.showsVerticalScrollIndicator = NO;
- self.collectionView.delegate = self;
- self.collectionView.dataSource = self;
- MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
- [self refreshData];
- }];
- header.lastUpdatedTimeLabel.hidden = YES;
- header.stateLabel.hidden = YES;
- //正在刷新的图片
- NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
- [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
- [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
- [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
- self.collectionView.mj_header = header;
-
-
- self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
- [self loadMoreData];
- }];
- [self.collectionView.mj_footer beginRefreshing];
-
-
- if (@available(iOS 11.0, *)) {
- self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
- }else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- [self.view addSubview:self.collectionView];
-
-
-
- // CGFloat height = (bannerHeight/375.f)*SCREEN_WIDTH;
- // CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, height);
- //
- // self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:rect delegate:self placeholderImage:nil];
- // self.cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"page_sel"];
- // self.cycleScrollView.pageDotImage = [UIImage imageNamed:@"page_nor"];
- // self.cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleToFill;
- self.NewPagedFlowView = [[NewPagedFlowView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH * bannerScale)];
- self.NewPagedFlowView.backgroundColor = [UIColor clearColor];
- self.NewPagedFlowView.delegate = self;
- self.NewPagedFlowView.dataSource = self;
- self.NewPagedFlowView.minimumPageAlpha = 0.1;
- self.NewPagedFlowView.isCarousel = YES;
- self.NewPagedFlowView.orientation = NewPagedFlowViewOrientationHorizontal;
- self.NewPagedFlowView.isOpenAutoScroll = YES;
- // self.NewPagedFlowView.layer.shadowOffset = CGSizeMake(2, 5);
- // self.NewPagedFlowView.layer.shadowOpacity = 0.3;
- // self.NewPagedFlowView.layer.shadowColor = [UIColor blackColor].CGColor;
-
-
-
- // [self.loginBackView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.width.mas_equalTo(SCREEN_WIDTH);
- // make.height.mas_equalTo(FITSIZE(45));
- // make.bottom.mas_equalTo(200);
- // }];
- }
- - (void)loadAdData {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
- NSDictionary *para = @{@"adv_type":@"1"};
- [LDHttp get:url params:para success:^(id json) {
-
- _adDataArr = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
- if (_adDataArr.count > 0) {
- [self creatAdView:_adDataArr];
- }
- [self.collectionView reloadData];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)creatAdView:(NSArray *)list {
- // LDTodayAdView *adView = [[LDTodayAdView alloc] initWithFrame:CGRectMake(Fitsize(10), Fitsize(3), SCREEN_WIDTH-Fitsize(20), (SCREEN_WIDTH-Fitsize(20))*200/750)];
- LDTodayAdView *adView = [[LDTodayAdView alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-10, (SCREEN_WIDTH-10)*200/750)];
- _adView.tag=2002;
- _adView = adView;
- _adView.model = list.firstObject;
- adView.tapAdBlock = ^{
- [MobClick event:AdvClick label:@"1"];
- [AdJumpManager jumpToPageWithModel:list.firstObject ParentViewControll:self];
- };
- }
- - (void)loadBannerData {
-
- [LDCacheHttp get:Banner_list params:nil success:^(id json, BOOL isCache) {
- self.bannerList = [NSArray yy_modelArrayWithClass:[LDTodayBannerModel class] json:json[@"data"]];
- NSLog(@"%@",json[@"data"]);
- [self creatCycleScrollView];
- } failure:^(NSError *error) {
-
- }];
-
- }
- /**
- 加载超级大牌
- */
- - (void)loadSuperBrand {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/SuperBrand",BaseURL];
- NSDictionary *para = @{@"position":@"1",
- @"category_id":self.model.Id
- };
- [LDCacheHttp post:url params:para success:^(id json, BOOL isCache) {
- self.superBrandList = [NSArray yy_modelArrayWithClass:[LDSuperBrandModel class] json:json[@"data"]];
- [self.superBrandView setSuperBrandData:self.superBrandList];
- [self.collectionView reloadData];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)creatCycleScrollView {
- NSMutableArray *imgArr = [NSMutableArray array];
- for (LDTodayBannerModel *model in self.bannerList) {
- [imgArr addObject:model.photo];
- }
- // self.cycleScrollView.imageURLStringsGroup = imgArr;
- [self.NewPagedFlowView reloadData];
- }
- /**
- 加载下部商品列表
- */
- - (void)loadCategoryGoodsList {
-
- NSDictionary *para = @{@"sort":@"1",
- @"page":@(_page),
- @"category_id":self.model.Id,
- @"stype":@"0"};
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/goodsAndStockList",BaseURL];
- [LDCacheHttp post:url params:para success:^(id json, BOOL isCache) {
-
- if ([self.collectionView.mj_header isRefreshing]) [self.goodsArr removeAllObjects];
-
- //清空缓存数据,展示真正的数据(如果page是1,且不是缓存数据,说明是真正的数据)
- if (_page == 1 && !isCache) [self.goodsArr removeAllObjects];
- NSArray *list = [NSArray yy_modelArrayWithClass:[LDTodayGoodModel class] json:json];
- [self noMoreDataWithArray:list];
- [self.goodsArr addObjectsFromArray:list];
- [self.collectionView reloadData];
- [self.collectionView.mj_header endRefreshing];
- } failure:^(NSError *error) {
- [self endRefreshing];
- [self.collectionView.mj_footer endRefreshing];
- }];
-
- }
- - (void)noMoreDataWithArray:(NSArray *)array {
- if (array.count <= 0) {
- [self.collectionView.mj_footer endRefreshingWithNoMoreData];
- }else {
- [self.collectionView.mj_footer endRefreshing];
- }
- }
- - (void)endRefreshing {
- [self.collectionView.mj_header endRefreshing];
- }
- - (void)refreshData {
- _page = 1;
- [self loadBannerData];
- // [self loadModelCellData];
- // [self loadHotRecomPicData];
- [self loadAdData];
- [self loadHotRecomPicCollectionData];
- [self loadCategoryGoodsList];
- // [self loadSuperBrand];//超级大牌数据
- // [self loadTodayScollNews];
-
- }
- /**
- 上拉加载
- */
- - (void)loadMoreData {
- _page++;
- [self loadCategoryGoodsList];
- }
- /**
- 多图推荐
- */
- - (void)loadHotRecomPicData {
-
- [LDCacheHttp get:Goldgroups params:nil success:^(id json, BOOL isCache) {
- self.morePicArr = [NSArray yy_modelArrayWithClass:[LDMorePicModel class] json:json[@"data"]];
- if (self.morePicArr.count==0) {
- [self.collectionView reloadData];
- }
- [self.morePicCell setModelDatas:self.morePicArr];
- [self.collectionView reloadData];
- } failure:^(NSError *error) {
-
- }];
-
- }
- /**
- 加载菜单栏目
- */
- - (void)loadHotRecomPicCollectionData {
-
- [LDCacheHttp post:GoldCollectiongroups params:nil success:^(id json, BOOL isCache) {
- self.morePicCollectionArr = [NSArray yy_modelArrayWithClass:[LDMorePicCollectionModel class] json:json[@"data"]];
- [self.morePicCollectionCell setModelDatas:self.morePicCollectionArr];
- [self.collectionView reloadData];
- } failure:^(NSError *error) {
-
- }];
-
- }
- /**
- 加载滚动头条
- */
- - (void)loadTodayScollNews {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/message_push/LieDouHeadlines",BaseURL];
- [LDHttp post:url params:nil success:^(id json) {
-
- NSArray *list = [NSArray yy_modelArrayWithClass:[LDScrollNewsModel class] json:json[@"data"]];
- [self.scrollNewsView setDataList:list];
-
- } failure:^(NSError *error) {
-
- }];
- }
- /**
- 加载分类模块数据
- */
- - (void)loadModelCellData {
-
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/advFourList",BaseURL];
- [LDCacheHttp post:url params:@{@"platform":@"2"} success:^(id json, BOOL isCache) {
- NSArray *list = [NSArray yy_modelArrayWithClass:[LDTodayMudleModel class] json:json[@"list"]];
- if (list.count > 0) {
- [self countDownViewSetCount:list.firstObject];
- }
- [self.moduleDataArr removeAllObjects];
- [self.moduleDataArr addObjectsFromArray:list];
- [self.collectionView reloadData];
-
- [self endRefreshing];
- } failure:^(NSError *error) {
- [self endRefreshing];
- }];
- }
- - (void)countDownViewSetCount:(LDTodayMudleModel *)model {
- NSString *endTime = [NSString stringWithFormat:@"%@000",model.remainTime];
- [[LDCountDownView shareInstace] setEndTimer:endTime];
- }
- #pragma mark ------ YHCountDownViewDelegate -------
- - (void)countViewTimeOutAction {
- [self.collectionView.mj_header beginRefreshing];
- }
- #pragma mark NewPagedFlowView Datasource
- - (NSInteger)numberOfPagesInFlowView:(NewPagedFlowView *)flowView {
-
- return self.bannerList.count;
-
- }
- - (PGIndexBannerSubiew *)flowView:(NewPagedFlowView *)flowView cellForPageAtIndex:(NSInteger)index{
- PGIndexBannerSubiew *bannerView = [flowView dequeueReusableCell];
- if (!bannerView) {
- bannerView = [[PGIndexBannerSubiew alloc] init];
- bannerView.tag = index;
- bannerView.layer.cornerRadius = 4;
- bannerView.layer.masksToBounds = YES;
- }
- if (self.bannerList.count > 0 && self.bannerList.count>index) {
- LDTodayBannerModel *model = self.bannerList[index];
- //在这里下载网络图片
- [bannerView.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@""]];
- }
-
-
- return bannerView;
- }
- - (CGSize)sizeForPageInFlowView:(NewPagedFlowView *)flowView {
- return CGSizeMake(SCREEN_WIDTH - 20, (SCREEN_WIDTH - 20) * bannerScale);
- }
- - (void)didSelectCell:(UIView *)subView withSubViewIndex:(NSInteger)subIndex {
-
-
- LDTodayBannerModel *model = self.bannerList[subIndex];
- switch (model.click_type.integerValue) {
- case 1:
- {//h5跳转
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url =model.click_param;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
- break;
- case 2://商品详情
- {
- LDGoodDetailViewController *detailVC = [[LDGoodDetailViewController alloc] init];
-
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithDTodayBannerModels:model];
- detailVC.requestModel = requestModel;
- detailVC.requestModel.goods_id = model.click_param;
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- break;
- case 3://专题列表
- //列表页
- {
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.click_param;
- list.name = model.groupTitle;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- }
- break;
- case 4://淘宝链接
- {
- [self jumpToTaobaoWithUrl:model.click_param];
- }
- break;
- case 5://天猫超市\国际\聚划算\天猫大牌
- {
- LDSearchCoupleWebViewController *searchCoupleWeb = [[LDSearchCoupleWebViewController alloc] init];
-
- searchCoupleWeb.url = model.click_param;
- searchCoupleWeb.jsString = model.ios_js_string;
- searchCoupleWeb.name = model.note;
- if ([[ALBBSession sharedInstance] isLogin] && [AccountTool isLogin]) {
- //进入
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
- }else if (![AccountTool isLogin]) {
- //未登录
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:login animated:YES completion:nil];
- }else if (![[ALBBSession sharedInstance] isLogin]) {
- //淘宝未授权
- ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
- [albbSDK setAppkey:ALBC_APP_KEY];
- [albbSDK setAuthOption:NormalAuth];
-
- [albbSDK auth:self successCallback:^(ALBBSession *session){
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
- } failureCallback:^(ALBBSession *session,NSError *error){
- NSLog(@"session == %@,error == %@",session,error);
- }];
- }
-
-
- }
- break;
- default:
- break;
- }
-
- [MobClick event:home_banner label:model.photo];
-
- }
- - (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(NewPagedFlowView *)flowView {
- if (flowView == self.NewPagedFlowView) {
- LDHomeMainViewController *superVc = (LDHomeMainViewController *)self.parentViewController;
- //仅在今日精选时改变
- if (superVc.showIndex == 0) {
- UIImageView *bgImgView = superVc.bgImageView;
- LDTodayBannerModel *model = self.bannerList[pageNumber];
- [bgImgView sd_setImageWithURL:[NSURL URLWithString:model.photo_bg]];
- }
- }
-
-
-
- }
- #pragma mark ====================== YHMorePicCellDelegate==========
- /**
- 点击推荐位多图
- */
- - (void)YHMorePicCellDidSelectedItem:(NSInteger)index {
- LDMorePicModel *model = self.morePicArr[index];
- if (model.url.length > 0) {
- //活动页
- //type为2直接打开淘宝,无需访问中间网页
- if ([model.jump_type isEqualToString:@"2"]) {
- [self jumpToTaobaoWithUrl:model.url];
- }else{
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url = model.url;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
- }else {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- }
-
-
- [MobClick event:home_recommend label:model.name];
- }
- #pragma mark ====================== YHMorePicCollectionCellDelegate==========
- - (void)YHMorePicCollectionCellDidSelectedItem:(NSInteger)index{
- LDMorePicCollectionModel *model = self.morePicCollectionArr[index];
- switch ([model.show_type integerValue]) {
- case 1:
- {
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url = model.url;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
- break;
- case 2:
- {
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- }
- break;
- case 3:
- {
- [self jumpToTaobaoWithUrl:model.url];
- }
- break;
- case 4:
- {
- LDSearchCoupleWebViewController *searchCoupleWeb = [[LDSearchCoupleWebViewController alloc] init];
-
- searchCoupleWeb.url = model.url;
- searchCoupleWeb.jsString = model.ios_js_string;
- searchCoupleWeb.name = model.name;
- if ([[ALBBSession sharedInstance] isLogin] && [AccountTool isLogin]) {
- //进入
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
- }else if (![AccountTool isLogin]) {
- //未登录
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:login animated:YES completion:nil];
- }else if (![[ALBBSession sharedInstance] isLogin]) {
- //淘宝未授权
- ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
- [albbSDK setAppkey:ALBC_APP_KEY];
- [albbSDK setAuthOption:NormalAuth];
- [albbSDK auth:self successCallback:^(ALBBSession *session){
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
- [self.navigationController pushViewController:searchCoupleWeb animated:YES];
- } failureCallback:^(ALBBSession *session,NSError *error){
- NSLog(@"session == %@,error == %@",session,error);
- }];
- }
-
-
- }
- break;
-
- case 5:
- {
- LDGoodDetailViewController *detailVC = [[LDGoodDetailViewController alloc] init];
-
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithLDMorePicCollectionModels:model];
- detailVC.requestModel = requestModel;
-
- [self.navigationController pushViewController:detailVC animated:YES];
- }
- break;
- default:
- break;
- }
- [MobClick event:Home_Items label:model.name];
- }
- #pragma mark ============ SDCycleScrollViewDelegate ==========
- - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
- LDTodayBannerModel *model = self.bannerList[index];
-
- if (model.url.length > 0) {
- //活动页
- //type为2直接打开淘宝,无需访问中间网页
- if ([model.type isEqualToString:@"2"]) {
- [self jumpToTaobaoWithUrl:model.url];
- }else{
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url = model.url;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
-
-
-
- }else {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.group_id;
- list.name = model.note;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
-
- }
-
- [MobClick event:home_banner label:model.photo];
- }
- #pragma mark ------- LDTodayModelCollectionCellDelegate -----
- - (void)modelCollectionCellMoreButtonClick:(LDTodayModelCollectionCell *)cell{
-
- LDTodayMudleModel *model = cell.model;
- NSInteger type = model.type.integerValue;
- switch (type) {
- case 1:
- {
- LDBuyLimitMainController *buyLimit = [[LDBuyLimitMainController alloc] init];
- [self.navigationController pushViewController:buyLimit animated:YES];
- }
- break;
- case 2:
- {
- LDRankListViewController *rankList = [[LDRankListViewController alloc] init];
- rankList.name = model.name;
- [self.navigationController pushViewController:rankList animated:YES];
- }
-
- break;
- case 3:
- {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 2; //2为通用列表,1为大额券
- [self.navigationController pushViewController:list animated:YES];
- }
-
- break;
- case 4:
- {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 1;
- [self.navigationController pushViewController:list animated:YES];
- }
-
- break;
- default:
- break;
- }
-
-
- [MobClick event:TodayClickTop label:model.name];
- }
- #pragma mark ============ UICollectionView Delegate && DataSource ==========
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
-
- if (section == 0 ) {
-
- return 2;
- }else if (section == 1){
- return self.morePicArr.count;
- }else if (section == 2){
- return self.moduleDataArr.count;
- }else if(section == 3){
- return self.goodsArr.count;
- }
- return 0;
- }
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 4;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
-
- if (indexPath.section == 0) {
- //圆形菜单高度
- if (indexPath.row == 0) {
- if (self.morePicCollectionArr==nil||self.morePicCollectionArr.count==0) {
- return CGSizeMake(SCREEN_WIDTH, .1);
- }
- NSInteger offHeight=0;
- if (iPhone5) {
- offHeight=10;
- }
- NSInteger Crow=1;
- NSInteger Coff=-1;
- NSInteger CrowItemSum=5;
- Coff=self.morePicCollectionArr.count%CrowItemSum;
- if (Coff!=0) {
- CrowItemSum=4;
- Coff=self.morePicCollectionArr.count%CrowItemSum;
- if (Coff!=0) {
- CrowItemSum=3;
- Coff=self.morePicCollectionArr.count%CrowItemSum;
- if (Coff!=0) {
- CrowItemSum=5;
- Crow++;
- }
- }
- }
- Crow=self.morePicCollectionArr.count/CrowItemSum;
- if (Coff!=0) {
- Crow++;
- }
- NSInteger totalHeight = (SCREEN_WIDTH/4+offHeight)*Crow;
- return CGSizeMake(SCREEN_WIDTH, totalHeight);
- }
- if (indexPath.row == 1) {
- //猎豆头条高度
- return CGSizeMake(SCREEN_WIDTH, 0);
- }
- if (indexPath.row == 2) {
- //超级大牌高度
- CGFloat height = 100+(SCREEN_WIDTH-10)*36/365;
- return CGSizeMake(SCREEN_WIDTH, height);
- }
-
- }
-
- if (indexPath.section == 1) {
- // if (!self.morePicArr.count||self.morePicArr.count==0) {
- // return CGSizeMake(SCREEN_WIDTH, .1);
- // }
- // CGFloat leftWidth = SCREEN_WIDTH*0.37;
- // CGFloat leftHeight = leftWidth*19/14;
- // return CGSizeMake(SCREEN_WIDTH, leftHeight);
- CGFloat width = (SCREEN_WIDTH-13)/2;
- CGSize size = CGSizeMake(width, width*83/170);
- return size;
- }else if (indexPath.section == 2){
-
- return CGSizeMake(SCREEN_WIDTH, Fitsize(218));
- } else if (indexPath.section == 3) {
- LDTodayGoodModel *model = self.goodsArr[indexPath.row];
- if ([model.type integerValue] == 1) {
- CGFloat width = SCREEN_WIDTH;
- CGFloat height = 147;
- return CGSizeMake(width, height);
- }
- if ([model.type integerValue] == 2) {
- return CGSizeMake(SCREEN_WIDTH, Fitsize(215));
- }
-
- }
- return CGSizeZero;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
- {
- if (section == 0) {
- // CGFloat height = (bannerHeight/375.f)*SCREEN_WIDTH;
- // return CGSizeMake(SCREEN_WIDTH, height);
- return CGSizeMake(SCREEN_WIDTH, SCREEN_WIDTH * bannerScale);
- }else if (section == 1){
- if (_adDataArr.count > 0) {
- return CGSizeMake(SCREEN_WIDTH, ((SCREEN_WIDTH-10)*200/750)+10);
- }
- return CGSizeMake(SCREEN_WIDTH, 0);
- }else if (section == 2){
- return CGSizeMake(SCREEN_WIDTH, 0);
- }
- else {
- return CGSizeMake(SCREEN_WIDTH, FITSIZE(40));
- }
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
- {
- return CGSizeMake(0, 0);
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- if (section == 1) {
- return UIEdgeInsetsMake(0, 5, 0, 5);
- }else {
- return UIEdgeInsetsMake(0, 0, 0, 0);
- }
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
-
- if (indexPath.section==0) {
- if (indexPath.row == 0) {
- //圆形菜单
- self.morePicCollectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHMorePicCollectionCell forIndexPath:indexPath];
- self.morePicCollectionCell.backgroundColor = [UIColor greenColor];
- self.morePicCollectionCell.delegate = self;
- [self.morePicCollectionCell setModelDatas:self.morePicCollectionArr];
- return self.morePicCollectionCell;
- }
- if (indexPath.row == 1) {
- //滚动新闻
- UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KTodayNewsCell forIndexPath:indexPath];
- // [cell addSubview:self.scrollNewsView];
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
-
- if (indexPath.row == 2) {
- //超级大牌
- UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KSuperBrandCell forIndexPath:indexPath];
- [cell addSubview:self.superBrandView];
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- }
-
- }
- if (indexPath.section == 1) {
-
- // self.morePicCell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHMorePicCell forIndexPath:indexPath];
- // self.morePicCell.delegate = self;
- // [self.morePicCell setModelDatas:self.morePicArr];
- // return self.morePicCell;
- KBTodayReatCollectionCell *reactCell = [self.collectionView dequeueReusableCellWithReuseIdentifier:KReactCollecionCell forIndexPath:indexPath];
- LDMorePicModel *model = self.morePicArr[indexPath.row];
- reactCell.model = model;
- return reactCell;
-
- }else if (indexPath.section == 2){
- LDTodayModelCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KModelCollecionCell forIndexPath:indexPath];
- cell.delegate = self;
- cell.indexPath = indexPath;
- LDTodayMudleModel *model = self.moduleDataArr[indexPath.row];
- cell.model = model;
- if (indexPath.row == 0) {
- LDCountDownView *countdown = [LDCountDownView shareInstace];
- countdown.y = Fitsize(15);
- countdown.x = Fitsize(132);
- countdown.delegate = self;
- [cell addSubview:countdown];
- cell.desLabel.hidden = YES;
- }else {
- cell.desLabel.hidden = NO;
- }
-
- return cell;
- }
- else if(indexPath.section == 3){
- LDTodayGoodModel *model = self.goodsArr[indexPath.item];
- if ([model.type integerValue] == 1) {
- LDTodayHorizontalGoodCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHGoodCollectionCell forIndexPath:indexPath];
- cell.model = model.goods;
- return cell;
- }
- if ([model.type integerValue] == 2) {
- LDTodayGroupCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KTodayGroupCell forIndexPath:indexPath];
- cell.moreClick = ^{
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- };
- [cell setGoodData:model.goodsList];
- [cell.bgImgView sd_setFadeImageWithURL:[NSURL URLWithString:model.adv_background_img] placeholderImage:nil options:0 progress:nil completed:nil];
- return cell;
- }
-
- }
- return nil;
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.section == 0) {
- self.sectionOne = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionOne forIndexPath:indexPath];
- self.sectionOne.backgroundColor = [UIColor clearColor];
- [self.sectionOne addSubview:self.NewPagedFlowView];
- return self.sectionOne;
- }
-
- if (indexPath.section == 1) {
- UICollectionReusableView *sectionTwo = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo forIndexPath:indexPath];
- [sectionTwo addSubview:_adView];
- return sectionTwo;
- }
- if (indexPath.section == 2) {
- UICollectionReusableView *sectionTwo = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo forIndexPath:indexPath];
- return sectionTwo;
- }
-
- if (indexPath.section == 3) {
- self.sectionThree = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionThree forIndexPath:indexPath];
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, FITSIZE(40))];
- imageView.image = [UIImage imageNamed:@"section_img"];
- [self.sectionThree addSubview:imageView];
- return self.sectionThree;
- }
-
- return nil;
- }
- - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
-
- if (section == 0) {
- return 0;
- }
- if (section == 1 || section == 2) {
- return 5;
- }
- if (section == 3) {
- return 10;
- }
- return 0;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
-
-
- if (indexPath.section == 1) {
- LDMorePicModel *model = self.morePicArr[indexPath.row];
- if (model.url.length > 0) {
- //活动页
- //type为2直接打开淘宝,无需访问中间网页
- if ([model.jump_type isEqualToString:@"2"]) {
- [self jumpToTaobaoWithUrl:model.url];
- }else{
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url = model.url;
- [self.navigationController pushViewController:adWeb animated:YES];
- }
- }else {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = model.Id;
- list.name = model.name;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- }
-
- [MobClick event:home_recommend label:model.name];
- }
- if (indexPath.section == 0) {
- if (indexPath.row == 2) {
- FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
- faVC.model = self.model;
- [self.navigationController pushViewController:faVC animated:YES];
- }
- }
-
- if (indexPath.section == 3) {
- LDTodayGoodModel *todayModel = self.goodsArr[indexPath.row];
- if ([todayModel.type integerValue] == 1) {
- LDChildGoodModel *model = todayModel.goods;
- LDEventModel *evevtModel = [[LDEventModel alloc] initWithOrigin:model.origin category_id:self.model.Id source:homeAction];
-
- LDGoodDetailViewController *detail = [[LDGoodDetailViewController alloc] init];
- detail.eventModel = evevtModel;
- DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
- detail.requestModel = requestModel;
- [self.navigationController pushViewController:detail animated:YES];
-
- [MobClick event:home_hot];
- }
-
- if ([todayModel.type integerValue] == 2) {
- //列表页
- LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
- list.cate_id = todayModel.Id;
- list.name = todayModel.name;
- list.topRequest = 2;
- [self.navigationController pushViewController:list animated:YES];
- }
-
- }
-
- }
- - (UIColor *)todayCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout backgroundColorForSection:(NSInteger)section {
- if (section == 0) {
- return [UIColor clearColor];
- }else {
- return [UIColor yhGrayColor];
- }
- }
- #pragma mark ------
- -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
- {
- [UIView animateWithDuration:1 animations:^{
- redBtn.frame=CGRectMake(SCREEN_WIDTH-25, SCREEN_HEIGHT/4, 81, 59);
- }];
- }
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
- BOOL scrollToScrollStop = !scrollView.tracking && !scrollView.dragging && !scrollView.decelerating;
- if (scrollToScrollStop) {
-
- if ([redDic.allKeys containsObject:@"status"]&& [redDic[@"status"] integerValue]==1) {
- // 停止后要执行的代码
-
- [UIView animateWithDuration:1 animations:^{
- redBtn.frame=CGRectMake(SCREEN_WIDTH-94, SCREEN_HEIGHT/4, 81, 59);
- }];
- }
-
- }
-
-
- }
- - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
- if (!decelerate) {
- BOOL dragToDragStop = scrollView.tracking && !scrollView.dragging && !scrollView.decelerating;
- if (dragToDragStop) {
- if ([redDic.allKeys containsObject:@"status"]&& [redDic[@"status"] integerValue]==1) {
- [UIView animateWithDuration:1 animations:^{
- redBtn.frame=CGRectMake(SCREEN_WIDTH-94, SCREEN_HEIGHT/4, 81, 59);
- }];
- }
- }
- }
- }
- #pragma mark - scrollView
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
-
-
- //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
- UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
- //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
- CGFloat velocity = [pan velocityInView:scrollView].y;
- if (velocity <- 10) {
- //向上拖动,隐藏导航栏
-
- self.collectionView.height = ChildTableViewHeight+NavBarHeight-KStatusBarHeight;
- }else if (velocity > 10) {
- //向下拖动,显示导航栏
-
- self.collectionView.height = ChildTableViewHeight;
- }else if(velocity == 0){
- //停止拖拽
- }
-
- NSNotification *noti = [[NSNotification alloc] initWithName:ScrollDirectorNoti object:nil userInfo:@{@"director":@(velocity)}];
- [[NSNotificationCenter defaultCenter] postNotification:noti];
- }
- #pragma mark ------
- - (void)jumpToTaobaoWithUrl:(NSString *)url {
-
- id<AlibcTradePage> page = [AlibcTradePageFactory page:url];
- //淘客信息
- AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
- taoKeParams.pid= ALTK_PID;
- //打开方式
- AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
-
- showParam.openType = AlibcOpenTypeAuto;
-
- [[AlibcTradeSDK sharedInstance].tradeService openByUrl:url identity:@"trade" webView:nil parentController:self.parentViewController showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
-
- } tradeProcessFailedCallback:^(NSError * _Nullable error) {
-
- }];
-
- }
- #pragma mark ===================== layezer ==============
- - (NSArray *)goodsArr {
- if (!_goodsArr) {
- _goodsArr = [NSMutableArray array];
- }
- return _goodsArr;
- }
- - (NSMutableArray *)moduleDataArr {
- if (!_moduleDataArr) {
- _moduleDataArr = [NSMutableArray array];
- }
- return _moduleDataArr;
- }
- - (LDTodayNewsView *)scrollNewsView {
- if (!_scrollNewsView) {
- _scrollNewsView = [[LDTodayNewsView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
- _scrollNewsView.backgroundColor = [UIColor whiteColor];
- __weak typeof(self) weakSelf = self;
- _scrollNewsView.clickMessage = ^(NSInteger index) {
- LDNewsListViewController *list = [[LDNewsListViewController alloc] init];
- [weakSelf.navigationController pushViewController:list animated:YES];
- };
- }
- return _scrollNewsView;
- }
- - (LDSuperBrandView *)superBrandView {
- if (!_superBrandView) {
- _superBrandView = [[LDSuperBrandView alloc] initWithFrame:CGRectMake(5, 0, SCREEN_WIDTH-10, 100+SCREEN_WIDTH*36/365)];
- _superBrandView.layer.cornerRadius = 6;
- _superBrandView.layer.masksToBounds = YES;
- __weak typeof(self) weakSelf = self;
- _superBrandView.selectedClick = ^(LDSuperBrandModel *model) {
- //点击大牌商品
- LDSearchCoupleWebViewController *searchCoupleWeb = [[LDSearchCoupleWebViewController alloc] init];
-
- searchCoupleWeb.url = model.url;
- searchCoupleWeb.jsString = model.ios_js_string;
- searchCoupleWeb.name = model.name;
- if ([[ALBBSession sharedInstance] isLogin] && [AccountTool isLogin]) {
- //进入
- [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
- }else if (![AccountTool isLogin]) {
- //未登录
- LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
- login.modalPresentationStyle = UIModalPresentationFullScreen;
- [weakSelf presentViewController:login animated:YES completion:nil];
- }else if (![[ALBBSession sharedInstance] isLogin]) {
- //淘宝未授权
- ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
- [albbSDK setAppkey:ALBC_APP_KEY];
- [albbSDK setAuthOption:NormalAuth];
-
- [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
- [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
- } failureCallback:^(ALBBSession *session,NSError *error){
- NSLog(@"session == %@,error == %@",session,error);
- }];
- }
- };
- _superBrandView.moreClick = ^{
- //点击更多
- FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
- faVC.model=weakSelf.model;
- [weakSelf.navigationController pushViewController:faVC animated:YES];
-
- };
- }
- return _superBrandView;
- }
- @end
|