猎豆优选

LDChildPageViewController.m 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. //
  2. // LDChildPageViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/16.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDChildPageViewController.h"
  9. #import "LDChildPageViewController.h"
  10. #import "LDChildHeaderView.h"
  11. #import "LDTypeButtonHeader.h"
  12. #import "XLPlainFlowLayout.h"
  13. #import "LDHeaderReusableView.h"
  14. #import "LDGoodCollectionCell.h"
  15. #import "LDChildCategoryModel.h"
  16. #import "LDChildGoodModel.h"
  17. #import "LDItemListViewController.h"
  18. #import "LDGoodListViewController.h"
  19. #import "SelectView.h"
  20. #import "LDOtherFilterView.h"
  21. #import "LDTodayModelView.h"
  22. #import "LDClassifyListController.h"
  23. #import "LDOtherTopCollectionCell.h"
  24. #import "FSBaseViewController.h"
  25. #import "FSBaseViewController.h"
  26. #import "LDChildPageAdView.h"
  27. #import "AdJumpManager.h"
  28. #import "LDChildSuperBrand.h"
  29. #import "LDSuperBrandModel.h"
  30. #import "LDSearchCoupleWebViewController.h"
  31. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  32. #import <AlibabaAuthSDK/ALBBSession.h>
  33. #import <AlibabaAuthSDK/ALBBSDK.h>
  34. #import "LDLoginViewController.h"
  35. static NSString *headerID = @"headerID";
  36. static NSString *cellID = @"LDGoodCollectionCell";
  37. static NSString *KSectionHeader = @"SectionHeader";
  38. static NSString *KLDOtherTopCollectionCell = @"LDOtherTopCollectionCell";
  39. static NSString *KSuperBrandCell = @"KSuperBrandCell";
  40. static CGFloat selectedViewHeight = 40.f;
  41. @interface LDChildPageViewController ()
  42. <
  43. UICollectionViewDelegate,
  44. UICollectionViewDataSource,
  45. XHCollectionViewDelegateFlowLayout,
  46. JC_SelectViewDelegate,
  47. YHChildHeaderViewDelegate
  48. >
  49. {
  50. NSInteger _page;
  51. NSInteger _type;
  52. NSInteger _is_has_coupon;
  53. BOOL _changeType;
  54. CGFloat _lastContentOffset;
  55. }
  56. @property (nonatomic, strong) UICollectionView *collectionView;
  57. @property (nonatomic, strong) NSArray *categoryArr;
  58. @property (nonatomic, strong) NSMutableArray *goodsArr;
  59. @property (nonatomic, strong) NSArray *adDataArr;
  60. @property (nonatomic, strong) NSArray *superBrandList;
  61. @property (nonatomic, strong) LDOtherFilterView *selectedView;
  62. @property (nonatomic, strong) NSArray *filtrateArray;
  63. @property (nonatomic, strong) LDChildHeaderView *channelHeader;
  64. @property (nonatomic, strong) LDChildPageAdView *headAdView;
  65. @property (nonatomic, strong) LDOtherTopCollectionCell *topCell;
  66. @property (nonatomic, strong) LDChildSuperBrand *childSuperBrand ;
  67. @end
  68. @implementation LDChildPageViewController
  69. - (void)viewDidLoad {
  70. [super viewDidLoad];
  71. [self configParam];
  72. [self configCollectionView];
  73. [self requesFiltrateParam];
  74. [self loadChannelHeader];
  75. [self loadAdData];
  76. // [self loadChildSuperBrandData];
  77. }
  78. - (void)configParam {
  79. _page = 0;
  80. _type = 1; //默认请求推荐的数据
  81. }
  82. - (void)configCollectionView {
  83. [self.collectionView removeFromSuperview];
  84. XLPlainFlowLayout *flowLayout = [[XLPlainFlowLayout alloc]init];
  85. flowLayout.naviHeight = 0;
  86. flowLayout.minimumLineSpacing = 5;
  87. flowLayout.minimumInteritemSpacing = 0;
  88. flowLayout.headerReferenceSize = CGSizeMake(0, 0);
  89. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 2, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:flowLayout];
  90. [self.collectionView registerClass:[LDGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  91. [self.collectionView registerClass:[LDOtherTopCollectionCell class] forCellWithReuseIdentifier:KLDOtherTopCollectionCell];
  92. [self.collectionView registerClass:[LDHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerID];
  93. [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionHeader];
  94. [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:KSuperBrandCell];
  95. self.collectionView.backgroundColor = [UIColor clearColor];
  96. self.collectionView.showsVerticalScrollIndicator = NO;
  97. self.collectionView.delegate = self;
  98. self.collectionView.dataSource = self;
  99. MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingBlock:^{
  100. [self refreshData];
  101. }];
  102. header.lastUpdatedTimeLabel.hidden = YES;
  103. header.stateLabel.hidden = YES;
  104. //正在刷新的图片
  105. NSArray *imgArr = @[[UIImage imageNamed:@"ant1"],[UIImage imageNamed:@"ant2"]];
  106. [header setImages:imgArr duration:0.3 forState:MJRefreshStateRefreshing];
  107. [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStateWillRefresh];
  108. [header setImages:@[[UIImage imageNamed:@"ant1"]] duration:1 forState:MJRefreshStatePulling];
  109. self.collectionView.mj_header = header;
  110. self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  111. [self loadMoreData];
  112. }];
  113. [self.collectionView.mj_footer beginRefreshing];
  114. [self.view addSubview: self.collectionView];
  115. [self configCollectionHeader];
  116. }
  117. - (void)configCollectionHeader {
  118. // UIView *recomView = [[UIView alloc] initWithFrame:CGRectMake(Fitsize(10), 0, SCREEN_WIDTH-Fitsize(20), Fitsize(208))];
  119. // recomView.layer.cornerRadius = Fitsize(8);
  120. // recomView.layer.masksToBounds = YES;
  121. // topRecomView = recomView;
  122. // recomView.backgroundColor = [UIColor whiteColor];
  123. // UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Fitsize(65), Fitsize(40))];
  124. // title.font = [UIFont systemFontOfSize:Fitsize(14)];
  125. // title.textColor = [UIColor homeRedColor];
  126. // title.centerX = SCREEN_WIDTH/2;
  127. // title.textAlignment = NSTextAlignmentCenter;
  128. // title.text = @"热门商品";
  129. // [recomView addSubview:title];
  130. //
  131. // UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake(title.left-15, 0, Fitsize(13), Fitsize(15))];
  132. // icon.centerY = title.centerY;
  133. // icon.image = [UIImage imageNamed:@"hotRecom"];
  134. // [recomView addSubview:icon];
  135. //
  136. // UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(icon.left-10, 0, 50, 1)];
  137. // leftLine.right = icon.left-10;
  138. // leftLine.backgroundColor = [UIColor homeRedColor];
  139. // leftLine.centerY = title.centerY;
  140. // [recomView addSubview:leftLine];
  141. //
  142. // UIView *rightLine = [[UIView alloc] initWithFrame:CGRectMake(title.right+10, 0, 50, 1)];
  143. // rightLine.backgroundColor = [UIColor homeRedColor];
  144. // rightLine.centerY = title.centerY;
  145. // [recomView addSubview:rightLine];
  146. //
  147. // LDTodayModelView *modelView = [[LDTodayModelView alloc] initWithFrame:CGRectMake(0, Fitsize(40), SCREEN_WIDTH-Fitsize(20), Fitsize(168)) titleNumOfLine:1];
  148. // modelView.isOhterPage = YES;
  149. // modelView.name = self.model.name;
  150. // modelView.Id = self.model.Id;
  151. // self.recommonView = modelView;
  152. // [recomView addSubview:modelView];
  153. self.channelHeader = [[LDChildHeaderView alloc] initWithFrame:CGRectMake(Fitsize(10), 0, SCREEN_WIDTH-Fitsize(20), 0) delegete:self];
  154. self.headAdView = [[LDChildPageAdView alloc] initWithFrame:CGRectMake(Fitsize(10), 0, SCREEN_WIDTH-Fitsize(20), 0)];
  155. __weak typeof(self) weakSelf = self;
  156. self.headAdView.tapAdBlock = ^(AdPopModel * _Nonnull model) {
  157. if (model) {
  158. [AdJumpManager jumpToPageWithModel:model ParentViewControll:weakSelf];
  159. }
  160. };
  161. }
  162. #pragma mark ====================== Load Data ==========
  163. - (void)loadAdData {
  164. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
  165. NSDictionary *para = @{@"adv_type":@"7",
  166. @"category_id":self.model.Id};
  167. [LDHttp get:url params:para success:^(id json) {
  168. self.adDataArr = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
  169. if (self.adDataArr.count > 0) {
  170. //展示广告
  171. self.headAdView.height = Fitsize(111);
  172. self.headAdView.y = self.channelHeader.height+5;
  173. AdPopModel *model = self.adDataArr.firstObject;
  174. [self.headAdView setAdModel:model];
  175. }else {
  176. //隐藏广告
  177. self.headAdView.y = self.channelHeader.height+5;
  178. self.headAdView.height = 0;
  179. }
  180. [self.collectionView reloadData];
  181. } failure:^(NSError *error) {
  182. }];
  183. }
  184. /**
  185. 加载超级大牌
  186. */
  187. - (void)loadChildSuperBrandData {
  188. NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/SuperBrand",BaseURL];
  189. NSDictionary *para = @{@"position":@"2",
  190. @"category_id":self.model.Id
  191. };
  192. [LDCacheHttp post:url params:para success:^(id json, BOOL isCache) {
  193. self.superBrandList = [NSArray yy_modelArrayWithClass:[LDSuperBrandModel class] json:json[@"data"]];
  194. [self.childSuperBrand setSuperBrandData:self.superBrandList];
  195. [self.collectionView reloadData];
  196. } failure:^(NSError *error) {
  197. }];
  198. }
  199. #pragma mark ====================== Load Data ==========
  200. /**
  201. 加载筛选范围
  202. */
  203. - (void)requesFiltrateParam {
  204. NSString *urlString = [NSString stringWithFormat:@"%@/api/categoryNew/priceSection", BaseURL];
  205. [LDHttp post:urlString params:nil success:^(id json) {
  206. self.filtrateArray = json[@"data"];
  207. // [self.view addSubview:self.selectedView];
  208. } failure:^(NSError *error) {
  209. }];
  210. }
  211. /**
  212. 加载下部商品列表
  213. */
  214. - (void)loadCategoryGoodsList:(BOOL)refresh switchButton:(UIButton *)switchButton{
  215. NSDictionary *param = @{@"page":@(_page),
  216. @"category_id":self.model.Id,
  217. @"sort":@(_type),
  218. @"is_has_coupon":@(_is_has_coupon),
  219. @"stype":@"0"
  220. };
  221. NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/stockTopCategoryList",BaseURL];
  222. [LDHttp post:url params:param success:^(id json) {
  223. if (refresh) [self.goodsArr removeAllObjects];
  224. if ([self.collectionView.mj_header isRefreshing])[self.goodsArr removeAllObjects];
  225. NSArray *list = [NSArray yy_modelArrayWithClass:[LDChildGoodModel class] json:json[@"data"][@"list"]];
  226. [self.goodsArr addObjectsFromArray:list];
  227. [self noMoreDataWithArray:list];
  228. [self.collectionView reloadData];
  229. [self.collectionView.mj_header endRefreshing];
  230. [self.collectionView.mj_footer endRefreshing];
  231. [SVProgressHUD dismiss];
  232. switchButton.selected = !switchButton.selected;
  233. } failure:^(NSError *error) {
  234. [self.collectionView.mj_header endRefreshing];
  235. [self.collectionView.mj_footer endRefreshing];
  236. [SVProgressHUD dismiss];
  237. [MBProgressHUD showMessage:@"加载失败"];
  238. }];
  239. }
  240. - (void)noMoreDataWithArray:(NSArray *)array {
  241. if (array > 0) {
  242. self.collectionView.footRefreshState = MJFooterRefreshStateLoadMore;
  243. }else {
  244. self.collectionView.footRefreshState = MJFooterRefreshStateNoMore;
  245. }
  246. }
  247. /**
  248. 加载头部分类
  249. */
  250. - (void)loadChannelHeader {
  251. NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/getSonGroup",BaseURL];
  252. NSDictionary *para = @{@"category_id":self.model.Id};
  253. [LDHttp post:url params:para success:^(id json) {
  254. NSArray *list = [NSArray yy_modelArrayWithClass:[LDChildCategoryModel class] json:json[@"data"]];
  255. [self.channelHeader setChannelDataArr:list];
  256. self.headAdView.y = self.channelHeader.bottom+5;
  257. [self.collectionView reloadData];
  258. [self loadCategoryGoodsList:NO switchButton:nil];
  259. } failure:^(NSError *error) {
  260. [self.collectionView.mj_header endRefreshing];
  261. [self.collectionView.mj_footer endRefreshing];
  262. }];
  263. }
  264. /**
  265. 上拉加载
  266. */
  267. - (void)loadMoreData {
  268. _page++;
  269. [self loadCategoryGoodsList:NO switchButton:nil];
  270. }
  271. - (void)refreshData {
  272. _page = 1;
  273. [self loadChannelHeader];
  274. // [self loadChildSuperBrandData];
  275. // [self loadCategoryGoodsList:YES switchButton:nil];
  276. }
  277. #pragma mark ------ YHChildHeaderViewDelegate --------
  278. - (void)YHChildHeaderViewDidSelectedIndex:(NSInteger)index model:(LDChildCategoryModel *)model {
  279. LDClassifyListController *list = [[LDClassifyListController alloc] init];
  280. list.firstCategoryId = self.model.Id;
  281. list.cate_id = model.Id;
  282. list.name = model.name;
  283. list.isOtherPage = YES;
  284. [self.navigationController pushViewController:list animated:YES];
  285. NSString *tag = [NSString stringWithFormat:@"%@-%@",self.model.name,model.name];
  286. [MobClick event:CategoryClassify label:tag];
  287. }
  288. #pragma mark -------JC_SelectViewDelegate
  289. //仅显示优惠券
  290. - (void)selectItme:(LDOtherFilterView *)selectView onlyTicketClick:(UIButton *)switchBtn {
  291. [SVProgressHUD show];
  292. [self.collectionView scrollToTop];
  293. _is_has_coupon = switchBtn.selected ? 0 : 1;
  294. [self loadCategoryGoodsList:YES switchButton:switchBtn];
  295. }
  296. //上方条件选择
  297. - (void)selectTopButton:(LDOtherFilterView *)selectView withIndex:(NSInteger)index withButtonType:(JCButtonClickType )type1 button:(UIButton *)button{
  298. [SVProgressHUD show];
  299. //价格
  300. if (index == 2&&type1) {
  301. switch (type1) {
  302. case JCButtonClickTypeNormal:
  303. //正常价格
  304. {
  305. NSLog(@"上边按钮的正常价格");
  306. }
  307. break;
  308. case JCButtonClickTypeUp:
  309. //价格升序排列
  310. {
  311. NSLog(@"上边按钮的价格升序排列");
  312. _type = 3;
  313. }
  314. break;
  315. case JCButtonClickTypeDown:
  316. //价格降序排列
  317. {
  318. NSLog(@"上边按钮的价格降序排列");
  319. _type = 4;
  320. }
  321. break;
  322. default:
  323. break;
  324. }
  325. }else if (index == 0){//综合
  326. NSLog(@"上边按钮的综合");
  327. _type = 1;
  328. }else if (index == 1){//销量
  329. NSLog(@"上边按钮的销量");
  330. _type = 2;
  331. }else{//筛选
  332. _is_has_coupon = button.selected ? 0 : 1;
  333. [self loadCategoryGoodsList:YES switchButton:button];
  334. return;
  335. NSLog(@"上边有券按钮");
  336. }
  337. [self loadCategoryGoodsList:YES switchButton:nil];
  338. }
  339. #pragma mark ------
  340. #pragma mark - scrollView
  341. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
  342. }
  343. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  344. {
  345. if (scrollView.contentOffset.y < 0 || [self.collectionView.mj_footer isRefreshing]) {
  346. return;
  347. }
  348. //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
  349. UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
  350. //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
  351. CGFloat velocity = [pan velocityInView:scrollView].y;
  352. CGFloat offY = scrollView.contentOffset.y - _lastContentOffset;
  353. NSNotification *noti = [[NSNotification alloc] initWithName:ScrollDirectorNoti object:nil userInfo:@{@"director":@(velocity),@"offY":@(offY)}];
  354. [[NSNotificationCenter defaultCenter] postNotification:noti];
  355. _lastContentOffset = scrollView.contentOffset.y;
  356. }
  357. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  358. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  359. return 2;
  360. }
  361. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  362. {
  363. if (section == 0) {
  364. return 1;
  365. }else {
  366. return self.goodsArr.count;
  367. }
  368. }
  369. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  370. if (indexPath.section == 0) {
  371. if (indexPath.row == 0) {
  372. CGFloat height = self.headAdView.bottom+.1;
  373. return CGSizeMake(SCREEN_WIDTH, height);
  374. }else {
  375. return CGSizeMake(SCREEN_WIDTH-20, 105+SCREEN_WIDTH*72/710);
  376. }
  377. }else {
  378. LDChildGoodModel *model = self.goodsArr[indexPath.row];
  379. CGFloat width = (SCREEN_WIDTH-25)/2;
  380. CGFloat height = width + 150;
  381. if (![AccountTool isLogin] && ![model.red_active_status boolValue]) {
  382. height = width +122;
  383. }
  384. return CGSizeMake(width, height);
  385. }
  386. }
  387. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  388. {
  389. if (indexPath.section == 0) {
  390. if (indexPath.row == 0) {
  391. self.topCell = [collectionView dequeueReusableCellWithReuseIdentifier:KLDOtherTopCollectionCell forIndexPath:indexPath];
  392. [self.topCell addSubview:self.channelHeader];
  393. [self.topCell addSubview:self.headAdView];
  394. return self.topCell;
  395. }else {
  396. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KSuperBrandCell forIndexPath:indexPath];
  397. [cell addSubview:self.childSuperBrand];
  398. return cell;
  399. }
  400. }else {
  401. LDGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  402. LDChildGoodModel *model = self.goodsArr[indexPath.row];
  403. cell.model = model;
  404. return cell;
  405. }
  406. }
  407. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  408. if (section == 0 ) {
  409. if (self.adDataArr.count==0) {
  410. return 0;
  411. }else {
  412. }
  413. }
  414. return 5;
  415. }
  416. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  417. UICollectionReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionHeader forIndexPath:indexPath];
  418. [header addSubview:self.selectedView];
  419. return header;
  420. }
  421. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  422. if (indexPath.section == 0) {
  423. if (indexPath.row == 1) {
  424. FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
  425. faVC.model = self.model;
  426. [self.navigationController pushViewController:faVC animated:YES];
  427. }
  428. }
  429. if (indexPath.section == 1) {
  430. LDChildGoodModel *model = self.goodsArr[indexPath.row];
  431. if ([model.type isEqualToString:@"1"]) {
  432. //专场
  433. LDGoodListViewController *list = [[LDGoodListViewController alloc] init];
  434. list.cate_id = model.goods_id;
  435. list.topRequest = 1;
  436. [self.navigationController pushViewController:list animated:YES];
  437. }else {
  438. //详情
  439. LDGoodDetailViewController *detail = [[LDGoodDetailViewController alloc] init];
  440. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  441. detail.requestModel = requestModel;
  442. LDEventModel *evevtModel = [[LDEventModel alloc] initWithOrigin:model.origin category_id:self.model.Id source:homeAction];
  443. detail.eventModel = evevtModel;
  444. [self.navigationController pushViewController:detail animated:YES];
  445. }
  446. }
  447. [MobClick event:category_goods label:self.model.name];
  448. }
  449. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  450. if (section == 0) {
  451. return CGSizeMake(0, 0);
  452. }else {
  453. return CGSizeMake(SCREEN_WIDTH, selectedViewHeight);
  454. }
  455. }
  456. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  457. if (section == 0) {
  458. return UIEdgeInsetsMake(0, 0, 0, 0);
  459. }else{
  460. return UIEdgeInsetsMake(0, FITSIZE(10), 0, FITSIZE(10));
  461. }
  462. }
  463. - (UIColor *)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout backgroundColorForSection:(NSInteger)section {
  464. if (section == 0) {
  465. return [UIColor clearColor];
  466. }else {
  467. return [UIColor yhGrayColor];
  468. }
  469. }
  470. #pragma mark -------------
  471. - (NSMutableArray *)goodsArr {
  472. if (!_goodsArr) {
  473. _goodsArr = [NSMutableArray array];
  474. }
  475. return _goodsArr;
  476. }
  477. - (LDOtherFilterView *)selectedView {
  478. if (!_selectedView) {
  479. _selectedView = [[LDOtherFilterView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, selectedViewHeight) withArr:self.filtrateArray];
  480. _selectedView.delegate = self;
  481. }
  482. return _selectedView;
  483. }
  484. - (LDChildSuperBrand *)childSuperBrand {
  485. if (!_childSuperBrand) {
  486. _childSuperBrand = [[LDChildSuperBrand alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-20, 100+SCREEN_WIDTH*72/710)];
  487. _childSuperBrand.layer.cornerRadius = 6;
  488. _childSuperBrand.layer.masksToBounds = YES;
  489. __weak typeof(self) weakSelf = self;
  490. _childSuperBrand.selectedClick = ^(LDSuperBrandModel *model) {
  491. //点击大牌商品
  492. LDSearchCoupleWebViewController *searchCoupleWeb = [[LDSearchCoupleWebViewController alloc] init];
  493. searchCoupleWeb.url = model.url;
  494. searchCoupleWeb.jsString = model.ios_js_string;
  495. searchCoupleWeb.name = model.name;
  496. if ([[ALBBSession sharedInstance] isLogin] && [AccountTool isLogin]) {
  497. //进入
  498. [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
  499. }else if (![AccountTool isLogin]) {
  500. //未登录
  501. LDNewLoginVC *login = [[LDNewLoginVC alloc] init];
  502. login.modalPresentationStyle = UIModalPresentationFullScreen;
  503. [weakSelf presentViewController:login animated:YES completion:nil];
  504. }else if (![[ALBBSession sharedInstance] isLogin]) {
  505. //淘宝未授权
  506. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  507. [albbSDK setAppkey:ALBC_APP_KEY];
  508. [albbSDK setAuthOption:NormalAuth];
  509. [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){
  510. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
  511. [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
  512. } failureCallback:^(ALBBSession *session,NSError *error){
  513. NSLog(@"session == %@,error == %@",session,error);
  514. }];
  515. }
  516. };
  517. _childSuperBrand.moreClick = ^{
  518. //点击更多
  519. //点击更多
  520. FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
  521. faVC.model=weakSelf.model;
  522. [weakSelf.navigationController pushViewController:faVC animated:YES];
  523. };
  524. }
  525. return _childSuperBrand;
  526. }
  527. - (void)didReceiveMemoryWarning {
  528. [super didReceiveMemoryWarning];
  529. // Dispose of any resources that can be recreated.
  530. }
  531. /*
  532. #pragma mark - Navigation
  533. // In a storyboard-based application, you will often want to do a little preparation before navigation
  534. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  535. // Get the new view controller using [segue destinationViewController].
  536. // Pass the selected object to the new view controller.
  537. }
  538. */
  539. @end