《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRChildPageViewController.m 23KB

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