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

DRTodayViewController.m 43KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. //
  2. // DRTodayViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/17.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRTodayViewController.h"
  9. #import "SDCycleScrollView.h"
  10. #import "DROnePicCell.h"
  11. #import "DRCountHeaderView.h"
  12. #import "DRMorePicCell.h"
  13. #import "DRTodayBannerModel.h"
  14. #import "DRChildGoodModel.h"
  15. #import "DRMorePicModel.h"
  16. #import "DRGoodsInfo.h"
  17. #import "DRAdversementCell.h"
  18. #import "DRGoodDetailViewController.h"
  19. #import "DRAdWebViewController.h"
  20. #import "DRGoodListViewController.h"
  21. #import "FSBaseViewController.h"
  22. #import "DRMorePicCollectionCell.h"
  23. #import "DRMorePicCollectionModel.h"
  24. #import "DRGoodCollectionCell.h"
  25. #import "DRSearchCoupleWebViewController.h"
  26. #import "DRShareGoodsModel.h"
  27. #import "DRShareGoodsViewController.h"
  28. #import "DRPrivilegeReferralViewController.h"
  29. #import "NSNumber+YHExpanded.h"
  30. #import "DRTodayModelCollectionCell.h"
  31. #import "DRRankListViewController.h"
  32. #import "DRTodayMudleModel.h"
  33. #import "FSBaseViewController.h"
  34. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  35. #import <AlibabaAuthSDK/ALBBSession.h>
  36. #import <AlibabaAuthSDK/ALBBSDK.h>
  37. #import "KBTodayReatCollectionCell.h"
  38. #import "DRBuyLimitMainController.h"
  39. #import "NewPagedFlowView.h"
  40. #import "DRSearchCoupleWebViewController.h"
  41. #import "DRLoginViewController.h"
  42. #import "FSBaseViewController.h"
  43. #import "DRTodayAdView.h"
  44. #import "AdJumpManager.h"
  45. #import "DRHomeMainViewController.h"
  46. #import "DRTodayNewsView.h"
  47. #import "DRSuperBrandView.h"
  48. #import "DRTodayHorizontalGoodCell.h"
  49. #import "DRSuperBrandModel.h"
  50. #import "DRTodayGoodModel.h"
  51. #import "DRTodayGroupCell.h"
  52. #import "DRTodayFlowLayout.h"
  53. #import "DRNewsListViewController.h"
  54. #import "DRScrollNewsModel.h"
  55. static NSString *KYHMorePicCollectionCell = @"KYHMorePicCollectionCell";
  56. static NSString *KYHMorePicCell = @"KYHMorePicCell";
  57. static NSString *KYHGoodCollectionCell = @"KYHGoodCollectionCell";
  58. static NSString *KModelCollecionCell = @"modelCollecionCell";
  59. static NSString *KTodayNewsCell = @"KTodayNewsCell";
  60. static NSString *KSuperBrandCell = @"KSuperBrandCell";
  61. static NSString *KTodayGroupCell = @"KTodayGroupCell";
  62. static NSString *KSectionOne = @"KSectionOne";
  63. static NSString *KSectionTwo = @"KSectionTwo";
  64. static NSString *KSectionThree = @"KSectionThree";
  65. static NSString *KReactCollecionCell = @"ReactCollecionCell";
  66. static CGFloat bannerScale = 117.f/355.f;
  67. @interface DRTodayViewController ()
  68. <
  69. UICollectionViewDelegate,
  70. UICollectionViewDataSource,
  71. TodayCollectionViewDelegateFlowLayout,
  72. SDCycleScrollViewDelegate,
  73. YHMorePicCellDelegate,
  74. YHMorePicCollectionCellDelegate,
  75. LDTodayModelCollectionCellDelegate,
  76. YHCountDownViewDelegate,
  77. NewPagedFlowViewDelegate,
  78. NewPagedFlowViewDataSource
  79. >
  80. {
  81. NSInteger _page;
  82. DRTodayAdView *_adView;
  83. NSArray *_adDataArr;
  84. }
  85. @property (nonatomic, strong) UICollectionView *collectionView;
  86. @property (nonatomic, strong) SDCycleScrollView *cycleScrollView;
  87. @property (nonatomic, strong) NSArray *bannerList;
  88. @property (nonatomic, strong) NSArray *superBrandList;
  89. @property (nonatomic, strong) NSMutableArray *goodsArr;
  90. @property (nonatomic, strong) DRMorePicCell *morePicCell;
  91. @property (nonatomic, strong) DRMorePicCollectionCell *morePicCollectionCell;
  92. @property (nonatomic, strong) NSArray *morePicArr;
  93. @property (nonatomic, strong) NSArray *morePicCollectionArr;
  94. @property (nonatomic, strong) NSMutableArray *moduleDataArr;
  95. @property (nonatomic, strong) DRGoodsInfo *goodsInfo; //商品信息,包括刷新事件
  96. @property (nonatomic, strong) NewPagedFlowView *NewPagedFlowView;
  97. @property (nonatomic, strong) DRTodayNewsView *scrollNewsView;
  98. @property (nonatomic, strong) DRSuperBrandView *superBrandView;
  99. /**组头*/
  100. @property (nonatomic, strong) UICollectionReusableView *sectionOne;
  101. @property (nonatomic, strong) UICollectionReusableView *sectionThree;
  102. @end
  103. @implementation DRTodayViewController
  104. - (void)viewDidLoad {
  105. [super viewDidLoad];
  106. [self configCollectionView];
  107. [self request];
  108. [self.collectionView reloadData];
  109. }
  110. - (void)request {
  111. [self loadBannerData];
  112. [self loadHotRecomPicCollectionData];
  113. [self loadCategoryGoodsList];
  114. [self loadAdData];
  115. [self loadSuperBrand];
  116. // [self loadTodayScollNews];
  117. }
  118. - (void)configCollectionView {
  119. _page = 1;
  120. DRTodayFlowLayout *flowLayout = [[DRTodayFlowLayout alloc]init];
  121. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 5, SCREEN_WIDTH, ChildTableViewHeight+40) collectionViewLayout:flowLayout];
  122. flowLayout.minimumLineSpacing = 0;
  123. flowLayout.minimumInteritemSpacing = 0;
  124. [self.collectionView registerClass:[DRMorePicCollectionCell class] forCellWithReuseIdentifier:KYHMorePicCollectionCell];
  125. [self.collectionView registerClass:[DRMorePicCell class] forCellWithReuseIdentifier:KYHMorePicCell];
  126. [self.collectionView registerClass:[DRTodayHorizontalGoodCell class] forCellWithReuseIdentifier:KYHGoodCollectionCell];
  127. [self.collectionView registerClass:[DRTodayModelCollectionCell class] forCellWithReuseIdentifier:KModelCollecionCell];
  128. [self.collectionView registerClass:[KBTodayReatCollectionCell class] forCellWithReuseIdentifier:KReactCollecionCell];
  129. [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:KTodayNewsCell];
  130. [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:KSuperBrandCell];
  131. [self.collectionView registerClass:[DRTodayGroupCell class] forCellWithReuseIdentifier:KTodayGroupCell];
  132. [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionOne];
  133. [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo];
  134. [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionThree];
  135. self.collectionView.backgroundColor = [UIColor clearColor];
  136. self.collectionView.showsVerticalScrollIndicator = NO;
  137. self.collectionView.delegate = self;
  138. self.collectionView.dataSource = self;
  139. MJRefreshStateHeader *header = [MJRefreshStateHeader headerWithRefreshingBlock:^{
  140. [self refreshData];
  141. }];
  142. header.lastUpdatedTimeLabel.hidden = YES;
  143. header.stateLabel.textColor = [UIColor whiteColor];
  144. self.collectionView.mj_header = header;
  145. self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  146. [self loadMoreData];
  147. }];
  148. [self.collectionView.mj_footer beginRefreshing];
  149. if (@available(iOS 11.0, *)) {
  150. self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
  151. }else {
  152. self.automaticallyAdjustsScrollViewInsets = NO;
  153. }
  154. [self.view addSubview:self.collectionView];
  155. // CGFloat height = (bannerHeight/375.f)*SCREEN_WIDTH;
  156. // CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, height);
  157. //
  158. // self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:rect delegate:self placeholderImage:nil];
  159. // self.cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"page_sel"];
  160. // self.cycleScrollView.pageDotImage = [UIImage imageNamed:@"page_nor"];
  161. // self.cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleToFill;
  162. self.NewPagedFlowView = [[NewPagedFlowView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH * bannerScale)];
  163. self.NewPagedFlowView.backgroundColor = [UIColor clearColor];
  164. self.NewPagedFlowView.delegate = self;
  165. self.NewPagedFlowView.dataSource = self;
  166. self.NewPagedFlowView.minimumPageAlpha = 0.1;
  167. self.NewPagedFlowView.isCarousel = YES;
  168. self.NewPagedFlowView.orientation = NewPagedFlowViewOrientationHorizontal;
  169. self.NewPagedFlowView.isOpenAutoScroll = YES;
  170. // self.NewPagedFlowView.layer.shadowOffset = CGSizeMake(2, 5);
  171. // self.NewPagedFlowView.layer.shadowOpacity = 0.3;
  172. // self.NewPagedFlowView.layer.shadowColor = [UIColor blackColor].CGColor;
  173. // [self.loginBackView mas_makeConstraints:^(MASConstraintMaker *make) {
  174. // make.width.mas_equalTo(SCREEN_WIDTH);
  175. // make.height.mas_equalTo(FITSIZE(45));
  176. // make.bottom.mas_equalTo(200);
  177. // }];
  178. }
  179. - (void)loadAdData {
  180. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
  181. NSDictionary *para = @{@"adv_type":@"1"};
  182. [DRHttp get:url params:para success:^(id json) {
  183. _adDataArr = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
  184. if (_adDataArr.count > 0) {
  185. [self creatAdView:_adDataArr];
  186. }
  187. [self.collectionView reloadData];
  188. } failure:^(NSError *error) {
  189. }];
  190. }
  191. - (void)creatAdView:(NSArray *)list {
  192. // DRTodayAdView *adView = [[DRTodayAdView alloc] initWithFrame:CGRectMake(Fitsize(10), Fitsize(3), SCREEN_WIDTH-Fitsize(20), (SCREEN_WIDTH-Fitsize(20))*200/750)];
  193. DRTodayAdView *adView = [[DRTodayAdView alloc] initWithFrame:CGRectMake(5, 5, SCREEN_WIDTH-10, (SCREEN_WIDTH-10)*200/750)];
  194. _adView.tag=2002;
  195. _adView = adView;
  196. _adView.model = list.firstObject;
  197. adView.tapAdBlock = ^{
  198. [MobClick event:AdvClick label:@"1"];
  199. [AdJumpManager jumpToPageWithModel:list.firstObject ParentViewControll:self];
  200. };
  201. }
  202. - (void)loadBannerData {
  203. [DRCacheHttp get:Banner_list params:nil success:^(id json, BOOL isCache) {
  204. self.bannerList = [NSArray yy_modelArrayWithClass:[DRTodayBannerModel class] json:json[@"data"]];
  205. NSLog(@"%@",json[@"data"]);
  206. [self creatCycleScrollView];
  207. } failure:^(NSError *error) {
  208. }];
  209. }
  210. /**
  211. 加载超级大牌
  212. */
  213. - (void)loadSuperBrand {
  214. NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/SuperBrand",BaseURL];
  215. NSDictionary *para = @{@"position":@"1",
  216. @"category_id":self.model.Id
  217. };
  218. [DRCacheHttp post:url params:para success:^(id json, BOOL isCache) {
  219. self.superBrandList = [NSArray yy_modelArrayWithClass:[DRSuperBrandModel class] json:json[@"data"]];
  220. [self.superBrandView setSuperBrandData:self.superBrandList];
  221. [self.collectionView reloadData];
  222. } failure:^(NSError *error) {
  223. }];
  224. }
  225. - (void)creatCycleScrollView {
  226. NSMutableArray *imgArr = [NSMutableArray array];
  227. for (DRTodayBannerModel *model in self.bannerList) {
  228. [imgArr addObject:model.photo];
  229. }
  230. // self.cycleScrollView.imageURLStringsGroup = imgArr;
  231. [self.NewPagedFlowView reloadData];
  232. }
  233. /**
  234. 加载下部商品列表
  235. */
  236. - (void)loadCategoryGoodsList {
  237. NSDictionary *para = @{@"sort":@"1",
  238. @"page":@(_page),
  239. @"category_id":self.model.Id,
  240. @"stype":@"0"};
  241. NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/goodsAndStockList",BaseURL];
  242. [DRCacheHttp post:url params:para success:^(id json, BOOL isCache) {
  243. if ([self.collectionView.mj_header isRefreshing]) [self.goodsArr removeAllObjects];
  244. //清空缓存数据,展示真正的数据(如果page是1,且不是缓存数据,说明是真正的数据)
  245. if (_page == 1 && !isCache) [self.goodsArr removeAllObjects];
  246. NSArray *list = [NSArray yy_modelArrayWithClass:[DRTodayGoodModel class] json:json];
  247. [self noMoreDataWithArray:list];
  248. [self.goodsArr addObjectsFromArray:list];
  249. [self.collectionView reloadData];
  250. [self.collectionView.mj_header endRefreshing];
  251. } failure:^(NSError *error) {
  252. [self endRefreshing];
  253. [self.collectionView.mj_footer endRefreshing];
  254. }];
  255. }
  256. - (void)noMoreDataWithArray:(NSArray *)array {
  257. if (array.count <= 0) {
  258. [self.collectionView.mj_footer endRefreshingWithNoMoreData];
  259. }else {
  260. [self.collectionView.mj_footer endRefreshing];
  261. }
  262. }
  263. - (void)endRefreshing {
  264. [self.collectionView.mj_header endRefreshing];
  265. }
  266. - (void)refreshData {
  267. _page = 1;
  268. [self loadBannerData];
  269. // [self loadModelCellData];
  270. // [self loadHotRecomPicData];
  271. [self loadAdData];
  272. [self loadHotRecomPicCollectionData];
  273. [self loadCategoryGoodsList];
  274. [self loadSuperBrand];
  275. // [self loadTodayScollNews];
  276. }
  277. /**
  278. 上拉加载
  279. */
  280. - (void)loadMoreData {
  281. _page++;
  282. [self loadCategoryGoodsList];
  283. }
  284. /**
  285. 多图推荐
  286. */
  287. - (void)loadHotRecomPicData {
  288. [DRCacheHttp get:Goldgroups params:nil success:^(id json, BOOL isCache) {
  289. self.morePicArr = [NSArray yy_modelArrayWithClass:[DRMorePicModel class] json:json[@"data"]];
  290. if (self.morePicArr.count==0) {
  291. [self.collectionView reloadData];
  292. }
  293. [self.morePicCell setModelDatas:self.morePicArr];
  294. [self.collectionView reloadData];
  295. } failure:^(NSError *error) {
  296. }];
  297. }
  298. /**
  299. 加载菜单栏目
  300. */
  301. - (void)loadHotRecomPicCollectionData {
  302. [DRCacheHttp post:GoldCollectiongroups params:nil success:^(id json, BOOL isCache) {
  303. self.morePicCollectionArr = [NSArray yy_modelArrayWithClass:[DRMorePicCollectionModel class] json:json[@"data"]];
  304. [self.morePicCollectionCell setModelDatas:self.morePicCollectionArr];
  305. [self.collectionView reloadData];
  306. } failure:^(NSError *error) {
  307. }];
  308. }
  309. /**
  310. 加载滚动头条
  311. */
  312. - (void)loadTodayScollNews {
  313. NSString *url = [NSString stringWithFormat:@"%@/api/v2/message_push/LieDouHeadlines",BaseURL];
  314. [DRHttp post:url params:nil success:^(id json) {
  315. NSArray *list = [NSArray yy_modelArrayWithClass:[DRScrollNewsModel class] json:json[@"data"]];
  316. [self.scrollNewsView setDataList:list];
  317. } failure:^(NSError *error) {
  318. }];
  319. }
  320. /**
  321. 加载分类模块数据
  322. */
  323. - (void)loadModelCellData {
  324. NSString *url = [NSString stringWithFormat:@"%@/api/v2/channel/advFourList",BaseURL];
  325. [DRCacheHttp post:url params:@{@"platform":@"2"} success:^(id json, BOOL isCache) {
  326. NSArray *list = [NSArray yy_modelArrayWithClass:[DRTodayMudleModel class] json:json[@"list"]];
  327. if (list.count > 0) {
  328. [self countDownViewSetCount:list.firstObject];
  329. }
  330. [self.moduleDataArr removeAllObjects];
  331. [self.moduleDataArr addObjectsFromArray:list];
  332. [self.collectionView reloadData];
  333. [self endRefreshing];
  334. } failure:^(NSError *error) {
  335. [self endRefreshing];
  336. }];
  337. }
  338. - (void)countDownViewSetCount:(DRTodayMudleModel *)model {
  339. NSString *endTime = [NSString stringWithFormat:@"%@000",model.remainTime];
  340. [[DRCountDownView shareInstace] setEndTimer:endTime];
  341. }
  342. #pragma mark ------ YHCountDownViewDelegate -------
  343. - (void)countViewTimeOutAction {
  344. [self.collectionView.mj_header beginRefreshing];
  345. }
  346. #pragma mark NewPagedFlowView Datasource
  347. - (NSInteger)numberOfPagesInFlowView:(NewPagedFlowView *)flowView {
  348. return self.bannerList.count;
  349. }
  350. - (PGIndexBannerSubiew *)flowView:(NewPagedFlowView *)flowView cellForPageAtIndex:(NSInteger)index{
  351. PGIndexBannerSubiew *bannerView = [flowView dequeueReusableCell];
  352. if (!bannerView) {
  353. bannerView = [[PGIndexBannerSubiew alloc] init];
  354. bannerView.tag = index;
  355. bannerView.layer.cornerRadius = 4;
  356. bannerView.layer.masksToBounds = YES;
  357. }
  358. if (self.bannerList.count > 0 && self.bannerList.count>index) {
  359. DRTodayBannerModel *model = self.bannerList[index];
  360. //在这里下载网络图片
  361. [bannerView.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@""]];
  362. }
  363. return bannerView;
  364. }
  365. - (CGSize)sizeForPageInFlowView:(NewPagedFlowView *)flowView {
  366. return CGSizeMake(SCREEN_WIDTH - 20, (SCREEN_WIDTH - 20) * bannerScale);
  367. }
  368. - (void)didSelectCell:(UIView *)subView withSubViewIndex:(NSInteger)subIndex {
  369. DRTodayBannerModel *model = self.bannerList[subIndex];
  370. switch (model.click_type.integerValue) {
  371. case 1:
  372. {//h5跳转
  373. DRAdWebViewController *adWeb = [[DRAdWebViewController alloc] init];
  374. adWeb.url = model.click_param;
  375. [self.navigationController pushViewController:adWeb animated:YES];
  376. }
  377. break;
  378. case 2://商品详情
  379. {
  380. DRGoodDetailViewController *detailVC = [[DRGoodDetailViewController alloc] init];
  381. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithDTodayBannerModels:model];
  382. detailVC.requestModel = requestModel;
  383. detailVC.requestModel.goods_id = model.click_param;
  384. [self.navigationController pushViewController:detailVC animated:YES];
  385. }
  386. break;
  387. case 3://专题列表
  388. //列表页
  389. {
  390. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  391. list.cate_id = model.click_param;
  392. list.name = model.groupTitle;
  393. list.topRequest = 2;
  394. [self.navigationController pushViewController:list animated:YES];
  395. }
  396. break;
  397. case 4://淘宝链接
  398. {
  399. [self jumpToTaobaoWithUrl:model.click_param];
  400. }
  401. break;
  402. case 5://天猫超市\国际\聚划算\天猫大牌
  403. {
  404. DRSearchCoupleWebViewController *searchCoupleWeb = [[DRSearchCoupleWebViewController alloc] init];
  405. searchCoupleWeb.url = model.click_param;
  406. searchCoupleWeb.jsString = model.ios_js_string;
  407. searchCoupleWeb.name = model.note;
  408. if ([[ALBBSession sharedInstance] isLogin]) {
  409. //进入
  410. [self.navigationController pushViewController:searchCoupleWeb animated:YES];
  411. }else {
  412. //淘宝未授权
  413. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  414. [albbSDK setAppkey:ALBC_APP_KEY];
  415. [albbSDK setAuthOption:NormalAuth];
  416. [albbSDK auth:self successCallback:^(ALBBSession *session){
  417. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
  418. [self.navigationController pushViewController:searchCoupleWeb animated:YES];
  419. } failureCallback:^(ALBBSession *session,NSError *error){
  420. NSLog(@"session == %@,error == %@",session,error);
  421. }];
  422. }
  423. }
  424. break;
  425. default:
  426. break;
  427. }
  428. [MobClick event:home_banner label:model.photo];
  429. }
  430. - (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(NewPagedFlowView *)flowView {
  431. if (flowView == self.NewPagedFlowView) {
  432. DRHomeMainViewController *superVc = (DRHomeMainViewController *)self.parentViewController;
  433. //仅在今日精选时改变
  434. if (superVc.showIndex == 0) {
  435. UIImageView *bgImgView = superVc.bgImageView;
  436. DRTodayBannerModel *model = self.bannerList[pageNumber];
  437. [bgImgView sd_setImageWithURL:[NSURL URLWithString:model.photo_bg]];
  438. }
  439. }
  440. }
  441. #pragma mark ====================== YHMorePicCellDelegate==========
  442. /**
  443. 点击推荐位多图
  444. */
  445. - (void)YHMorePicCellDidSelectedItem:(NSInteger)index {
  446. DRMorePicModel *model = self.morePicArr[index];
  447. if (model.url.length > 0) {
  448. //活动页
  449. //type为2直接打开淘宝,无需访问中间网页
  450. if ([model.jump_type isEqualToString:@"2"]) {
  451. [self jumpToTaobaoWithUrl:model.url];
  452. }else{
  453. DRAdWebViewController *adWeb = [[DRAdWebViewController alloc] init];
  454. adWeb.url = model.url;
  455. [self.navigationController pushViewController:adWeb animated:YES];
  456. }
  457. }else {
  458. //列表页
  459. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  460. list.cate_id = model.Id;
  461. list.name = model.name;
  462. list.topRequest = 2;
  463. [self.navigationController pushViewController:list animated:YES];
  464. }
  465. [MobClick event:home_recommend label:model.name];
  466. }
  467. #pragma mark ====================== YHMorePicCollectionCellDelegate==========
  468. - (void)YHMorePicCollectionCellDidSelectedItem:(NSInteger)index{
  469. DRMorePicCollectionModel *model = self.morePicCollectionArr[index];
  470. switch ([model.show_type integerValue]) {
  471. case 1:
  472. {
  473. DRAdWebViewController *adWeb = [[DRAdWebViewController alloc] init];
  474. adWeb.url = model.url;
  475. [self.navigationController pushViewController:adWeb animated:YES];
  476. }
  477. break;
  478. case 2:
  479. {
  480. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  481. list.cate_id = model.Id;
  482. list.name = model.name;
  483. list.topRequest = 2;
  484. [self.navigationController pushViewController:list animated:YES];
  485. }
  486. break;
  487. case 3:
  488. {
  489. [self jumpToTaobaoWithUrl:model.url];
  490. }
  491. break;
  492. case 4:
  493. {
  494. DRSearchCoupleWebViewController *searchCoupleWeb = [[DRSearchCoupleWebViewController alloc] init];
  495. searchCoupleWeb.url = model.url;
  496. searchCoupleWeb.jsString = model.ios_js_string;
  497. searchCoupleWeb.name = model.name;
  498. if ([[ALBBSession sharedInstance] isLogin]) {
  499. //进入
  500. [self.navigationController pushViewController:searchCoupleWeb animated:YES];
  501. }else{
  502. //淘宝未授权
  503. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  504. [albbSDK setAppkey:ALBC_APP_KEY];
  505. [albbSDK setAuthOption:NormalAuth];
  506. [albbSDK auth:self successCallback:^(ALBBSession *session){
  507. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
  508. [self.navigationController pushViewController:searchCoupleWeb animated:YES];
  509. } failureCallback:^(ALBBSession *session,NSError *error){
  510. NSLog(@"session == %@,error == %@",session,error);
  511. }];
  512. }
  513. }
  514. break;
  515. case 5:
  516. {
  517. DRGoodDetailViewController *detailVC = [[DRGoodDetailViewController alloc] init];
  518. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithLDMorePicCollectionModels:model];
  519. detailVC.requestModel = requestModel;
  520. [self.navigationController pushViewController:detailVC animated:YES];
  521. }
  522. break;
  523. default:
  524. break;
  525. }
  526. [MobClick event:Home_Items label:model.name];
  527. }
  528. #pragma mark ============ SDCycleScrollViewDelegate ==========
  529. - (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
  530. DRTodayBannerModel *model = self.bannerList[index];
  531. if (model.url.length > 0) {
  532. //活动页
  533. //type为2直接打开淘宝,无需访问中间网页
  534. if ([model.type isEqualToString:@"2"]) {
  535. [self jumpToTaobaoWithUrl:model.url];
  536. }else{
  537. DRAdWebViewController *adWeb = [[DRAdWebViewController alloc] init];
  538. adWeb.url = model.url;
  539. [self.navigationController pushViewController:adWeb animated:YES];
  540. }
  541. }else {
  542. //列表页
  543. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  544. list.cate_id = model.group_id;
  545. list.name = model.note;
  546. list.topRequest = 2;
  547. [self.navigationController pushViewController:list animated:YES];
  548. }
  549. [MobClick event:home_banner label:model.photo];
  550. }
  551. #pragma mark ------- LDTodayModelCollectionCellDelegate -----
  552. - (void)modelCollectionCellMoreButtonClick:(DRTodayModelCollectionCell *)cell{
  553. DRTodayMudleModel *model = cell.model;
  554. NSInteger type = model.type.integerValue;
  555. switch (type) {
  556. case 1:
  557. {
  558. DRBuyLimitMainController *buyLimit = [[DRBuyLimitMainController alloc] init];
  559. [self.navigationController pushViewController:buyLimit animated:YES];
  560. }
  561. break;
  562. case 2:
  563. {
  564. DRRankListViewController *rankList = [[DRRankListViewController alloc] init];
  565. rankList.name = model.name;
  566. [self.navigationController pushViewController:rankList animated:YES];
  567. }
  568. break;
  569. case 3:
  570. {
  571. //列表页
  572. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  573. list.cate_id = model.Id;
  574. list.name = model.name;
  575. list.topRequest = 2; //2为通用列表,1为大额券
  576. [self.navigationController pushViewController:list animated:YES];
  577. }
  578. break;
  579. case 4:
  580. {
  581. //列表页
  582. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  583. list.cate_id = model.Id;
  584. list.name = model.name;
  585. list.topRequest = 1;
  586. [self.navigationController pushViewController:list animated:YES];
  587. }
  588. break;
  589. default:
  590. break;
  591. }
  592. [MobClick event:TodayClickTop label:model.name];
  593. }
  594. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  595. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  596. {
  597. if (section == 0 ) {
  598. if (self.superBrandList.count == 0) {
  599. //没有拿到超级大牌数据
  600. return 2;
  601. }
  602. return 3;
  603. }else if (section == 1){
  604. return self.morePicArr.count;
  605. }else if (section == 2){
  606. return self.moduleDataArr.count;
  607. }else if(section == 3){
  608. return self.goodsArr.count;
  609. }
  610. return 0;
  611. }
  612. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  613. return 4;
  614. }
  615. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  616. if (indexPath.section == 0) {
  617. //圆形菜单高度
  618. if (indexPath.row == 0) {
  619. if (self.morePicCollectionArr==nil||self.morePicCollectionArr.count==0) {
  620. return CGSizeMake(SCREEN_WIDTH, .1);
  621. }
  622. NSInteger offHeight=0;
  623. if (iPhone5) {
  624. offHeight=10;
  625. }
  626. NSInteger Crow=1;
  627. NSInteger Coff=-1;
  628. NSInteger CrowItemSum=5;
  629. Coff=self.morePicCollectionArr.count%CrowItemSum;
  630. if (Coff!=0) {
  631. CrowItemSum=4;
  632. Coff=self.morePicCollectionArr.count%CrowItemSum;
  633. if (Coff!=0) {
  634. CrowItemSum=3;
  635. Coff=self.morePicCollectionArr.count%CrowItemSum;
  636. if (Coff!=0) {
  637. CrowItemSum=5;
  638. Crow++;
  639. }
  640. }
  641. }
  642. Crow=self.morePicCollectionArr.count/CrowItemSum;
  643. if (Coff!=0) {
  644. Crow++;
  645. }
  646. NSInteger totalHeight = (SCREEN_WIDTH/4+offHeight)*Crow;
  647. return CGSizeMake(SCREEN_WIDTH, totalHeight);
  648. }
  649. if (indexPath.row == 1) {
  650. //猎豆头条高度
  651. return CGSizeMake(SCREEN_WIDTH, 0);
  652. }
  653. if (indexPath.row == 2) {
  654. //超级大牌高度
  655. CGFloat height = 200+(SCREEN_WIDTH-10)*60/365;
  656. return CGSizeMake(SCREEN_WIDTH, height);
  657. }
  658. }
  659. if (indexPath.section == 1) {
  660. // if (!self.morePicArr.count||self.morePicArr.count==0) {
  661. // return CGSizeMake(SCREEN_WIDTH, .1);
  662. // }
  663. // CGFloat leftWidth = SCREEN_WIDTH*0.37;
  664. // CGFloat leftHeight = leftWidth*19/14;
  665. // return CGSizeMake(SCREEN_WIDTH, leftHeight);
  666. CGFloat width = (SCREEN_WIDTH-13)/2;
  667. CGSize size = CGSizeMake(width, width*83/170);
  668. return size;
  669. }else if (indexPath.section == 2){
  670. return CGSizeMake(SCREEN_WIDTH, Fitsize(218));
  671. } else if (indexPath.section == 3) {
  672. DRTodayGoodModel *model = self.goodsArr[indexPath.row];
  673. if ([model.type integerValue] == 1) {
  674. CGFloat width = SCREEN_WIDTH;
  675. CGFloat height = 147;
  676. return CGSizeMake(width, height);
  677. }
  678. if ([model.type integerValue] == 2) {
  679. return CGSizeMake(SCREEN_WIDTH, Fitsize(215));
  680. }
  681. }
  682. return CGSizeZero;
  683. }
  684. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
  685. {
  686. if (section == 0) {
  687. // CGFloat height = (bannerHeight/375.f)*SCREEN_WIDTH;
  688. // return CGSizeMake(SCREEN_WIDTH, height);
  689. return CGSizeMake(SCREEN_WIDTH, SCREEN_WIDTH * bannerScale);
  690. }else if (section == 1){
  691. if (_adDataArr.count > 0) {
  692. return CGSizeMake(SCREEN_WIDTH, ((SCREEN_WIDTH-10)*200/750)+10);
  693. }
  694. return CGSizeMake(SCREEN_WIDTH, 0);
  695. }else if (section == 2){
  696. return CGSizeMake(SCREEN_WIDTH, 0);
  697. }
  698. else {
  699. return CGSizeMake(SCREEN_WIDTH, FITSIZE(40));
  700. }
  701. }
  702. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  703. {
  704. return CGSizeMake(0, 0);
  705. }
  706. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
  707. if (section == 1) {
  708. return UIEdgeInsetsMake(0, 5, 0, 5);
  709. }else {
  710. return UIEdgeInsetsMake(0, 0, 0, 0);
  711. }
  712. }
  713. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  714. {
  715. if (indexPath.section==0) {
  716. if (indexPath.row == 0) {
  717. //圆形菜单
  718. self.morePicCollectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHMorePicCollectionCell forIndexPath:indexPath];
  719. self.morePicCollectionCell.backgroundColor = [UIColor greenColor];
  720. self.morePicCollectionCell.delegate = self;
  721. [self.morePicCollectionCell setModelDatas:self.morePicCollectionArr];
  722. return self.morePicCollectionCell;
  723. }
  724. if (indexPath.row == 1) {
  725. //滚动新闻
  726. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KTodayNewsCell forIndexPath:indexPath];
  727. // [cell addSubview:self.scrollNewsView];
  728. cell.backgroundColor = [UIColor whiteColor];
  729. return cell;
  730. }
  731. if (indexPath.row == 2) {
  732. //超级大牌
  733. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KSuperBrandCell forIndexPath:indexPath];
  734. [cell addSubview:self.superBrandView];
  735. cell.backgroundColor = [UIColor whiteColor];
  736. return cell;
  737. }
  738. }
  739. if (indexPath.section == 1) {
  740. // self.morePicCell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHMorePicCell forIndexPath:indexPath];
  741. // self.morePicCell.delegate = self;
  742. // [self.morePicCell setModelDatas:self.morePicArr];
  743. // return self.morePicCell;
  744. KBTodayReatCollectionCell *reactCell = [self.collectionView dequeueReusableCellWithReuseIdentifier:KReactCollecionCell forIndexPath:indexPath];
  745. DRMorePicModel *model = self.morePicArr[indexPath.row];
  746. reactCell.model = model;
  747. return reactCell;
  748. }else if (indexPath.section == 2){
  749. DRTodayModelCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KModelCollecionCell forIndexPath:indexPath];
  750. cell.delegate = self;
  751. cell.indexPath = indexPath;
  752. DRTodayMudleModel *model = self.moduleDataArr[indexPath.row];
  753. cell.model = model;
  754. if (indexPath.row == 0) {
  755. DRCountDownView *countdown = [DRCountDownView shareInstace];
  756. countdown.y = Fitsize(15);
  757. countdown.x = Fitsize(132);
  758. countdown.delegate = self;
  759. [cell addSubview:countdown];
  760. cell.desLabel.hidden = YES;
  761. }else {
  762. cell.desLabel.hidden = NO;
  763. }
  764. return cell;
  765. }
  766. else if(indexPath.section == 3){
  767. DRTodayGoodModel *model = self.goodsArr[indexPath.item];
  768. if ([model.type integerValue] == 1) {
  769. DRTodayHorizontalGoodCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHGoodCollectionCell forIndexPath:indexPath];
  770. cell.model = model.goods;
  771. return cell;
  772. }
  773. if ([model.type integerValue] == 2) {
  774. DRTodayGroupCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KTodayGroupCell forIndexPath:indexPath];
  775. cell.moreClick = ^{
  776. //列表页
  777. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  778. list.cate_id = model.Id;
  779. list.name = model.name;
  780. list.topRequest = 2;
  781. [self.navigationController pushViewController:list animated:YES];
  782. };
  783. [cell setGoodData:model.goodsList];
  784. [cell.bgImgView sd_setFadeImageWithURL:[NSURL URLWithString:model.adv_background_img] placeholderImage:nil options:0 progress:nil completed:nil];
  785. return cell;
  786. }
  787. }
  788. return nil;
  789. }
  790. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  791. if (indexPath.section == 0) {
  792. self.sectionOne = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionOne forIndexPath:indexPath];
  793. self.sectionOne.backgroundColor = [UIColor clearColor];
  794. [self.sectionOne addSubview:self.NewPagedFlowView];
  795. return self.sectionOne;
  796. }
  797. if (indexPath.section == 1) {
  798. UICollectionReusableView *sectionTwo = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo forIndexPath:indexPath];
  799. [sectionTwo addSubview:_adView];
  800. return sectionTwo;
  801. }
  802. if (indexPath.section == 2) {
  803. UICollectionReusableView *sectionTwo = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionTwo forIndexPath:indexPath];
  804. return sectionTwo;
  805. }
  806. if (indexPath.section == 3) {
  807. self.sectionThree = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:KSectionThree forIndexPath:indexPath];
  808. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, FITSIZE(40))];
  809. imageView.image = [UIImage imageNamed:@"section_img"];
  810. [self.sectionThree addSubview:imageView];
  811. return self.sectionThree;
  812. }
  813. return nil;
  814. }
  815. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  816. if (section == 0) {
  817. return 0;
  818. }
  819. if (section == 1 || section == 2) {
  820. return 5;
  821. }
  822. if (section == 3) {
  823. return 10;
  824. }
  825. return 0;
  826. }
  827. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  828. if (indexPath.section == 1) {
  829. DRMorePicModel *model = self.morePicArr[indexPath.row];
  830. if (model.url.length > 0) {
  831. //活动页
  832. //type为2直接打开淘宝,无需访问中间网页
  833. if ([model.jump_type isEqualToString:@"2"]) {
  834. [self jumpToTaobaoWithUrl:model.url];
  835. }else{
  836. DRAdWebViewController *adWeb = [[DRAdWebViewController alloc] init];
  837. adWeb.url = model.url;
  838. [self.navigationController pushViewController:adWeb animated:YES];
  839. }
  840. }else {
  841. //列表页
  842. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  843. list.cate_id = model.Id;
  844. list.name = model.name;
  845. list.topRequest = 2;
  846. [self.navigationController pushViewController:list animated:YES];
  847. }
  848. [MobClick event:home_recommend label:model.name];
  849. }
  850. if (indexPath.section == 0) {
  851. if (indexPath.row == 2) {
  852. FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
  853. faVC.model = self.model;
  854. [self.navigationController pushViewController:faVC animated:YES];
  855. }
  856. }
  857. if (indexPath.section == 3) {
  858. DRTodayGoodModel *todayModel = self.goodsArr[indexPath.row];
  859. if ([todayModel.type integerValue] == 1) {
  860. DRChildGoodModel *model = todayModel.goods;
  861. DREventModel *evevtModel = [[DREventModel alloc] initWithOrigin:model.origin category_id:self.model.Id source:homeAction];
  862. DRGoodDetailViewController *detail = [[DRGoodDetailViewController alloc] init];
  863. detail.eventModel = evevtModel;
  864. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  865. detail.requestModel = requestModel;
  866. [self.navigationController pushViewController:detail animated:YES];
  867. [MobClick event:home_hot];
  868. }
  869. if ([todayModel.type integerValue] == 2) {
  870. //列表页
  871. DRGoodListViewController *list = [[DRGoodListViewController alloc] init];
  872. list.cate_id = todayModel.Id;
  873. list.name = todayModel.name;
  874. list.topRequest = 2;
  875. [self.navigationController pushViewController:list animated:YES];
  876. }
  877. }
  878. }
  879. - (UIColor *)todayCollectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout backgroundColorForSection:(NSInteger)section {
  880. if (section == 0) {
  881. return [UIColor clearColor];
  882. }else {
  883. return [UIColor yhGrayColor];
  884. }
  885. }
  886. #pragma mark ------
  887. #pragma mark - scrollView
  888. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  889. {
  890. //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
  891. UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
  892. //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
  893. CGFloat velocity = [pan velocityInView:scrollView].y;
  894. if (velocity <- 10) {
  895. //向上拖动,隐藏导航栏
  896. self.collectionView.height = ChildTableViewHeight+NavBarHeight-KStatusBarHeight;
  897. }else if (velocity > 10) {
  898. //向下拖动,显示导航栏
  899. self.collectionView.height = ChildTableViewHeight;
  900. }else if(velocity == 0){
  901. //停止拖拽
  902. }
  903. NSNotification *noti = [[NSNotification alloc] initWithName:ScrollDirectorNoti object:nil userInfo:@{@"director":@(velocity)}];
  904. [[NSNotificationCenter defaultCenter] postNotification:noti];
  905. }
  906. #pragma mark ------
  907. - (void)jumpToTaobaoWithUrl:(NSString *)url {
  908. id<AlibcTradePage> page = [AlibcTradePageFactory page:url];
  909. //淘客信息
  910. AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
  911. taoKeParams.pid= ALTK_PID;
  912. //打开方式
  913. AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
  914. showParam.openType = AlibcOpenTypeAuto;
  915. [[AlibcTradeSDK sharedInstance].tradeService show:self.parentViewController page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
  916. } tradeProcessFailedCallback:^(NSError * _Nullable error) {
  917. }];
  918. }
  919. #pragma mark ===================== layezer ==============
  920. - (NSArray *)goodsArr {
  921. if (!_goodsArr) {
  922. _goodsArr = [NSMutableArray array];
  923. }
  924. return _goodsArr;
  925. }
  926. - (NSMutableArray *)moduleDataArr {
  927. if (!_moduleDataArr) {
  928. _moduleDataArr = [NSMutableArray array];
  929. }
  930. return _moduleDataArr;
  931. }
  932. - (DRTodayNewsView *)scrollNewsView {
  933. if (!_scrollNewsView) {
  934. _scrollNewsView = [[DRTodayNewsView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 47)];
  935. _scrollNewsView.backgroundColor = [UIColor whiteColor];
  936. __weak typeof(self) weakSelf = self;
  937. _scrollNewsView.clickMessage = ^(NSInteger index) {
  938. DRNewsListViewController *list = [[DRNewsListViewController alloc] init];
  939. [weakSelf.navigationController pushViewController:list animated:YES];
  940. };
  941. }
  942. return _scrollNewsView;
  943. }
  944. - (DRSuperBrandView *)superBrandView {
  945. if (!_superBrandView) {
  946. _superBrandView = [[DRSuperBrandView alloc] initWithFrame:CGRectMake(5, 0, SCREEN_WIDTH-10, 200+SCREEN_WIDTH*60/365)];
  947. _superBrandView.layer.cornerRadius = 6;
  948. _superBrandView.layer.masksToBounds = YES;
  949. __weak typeof(self) weakSelf = self;
  950. _superBrandView.selectedClick = ^(DRSuperBrandModel *model) {
  951. //点击大牌商品
  952. DRSearchCoupleWebViewController *searchCoupleWeb = [[DRSearchCoupleWebViewController alloc] init];
  953. searchCoupleWeb.url = model.url;
  954. searchCoupleWeb.jsString = model.ios_js_string;
  955. searchCoupleWeb.name = model.name;
  956. if ([[ALBBSession sharedInstance] isLogin]) {
  957. //进入
  958. [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
  959. }else {
  960. //淘宝未授权
  961. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  962. [albbSDK setAppkey:ALBC_APP_KEY];
  963. [albbSDK setAuthOption:NormalAuth];
  964. [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){
  965. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeTaoBaoAuthor object:nil];
  966. [weakSelf.navigationController pushViewController:searchCoupleWeb animated:YES];
  967. } failureCallback:^(ALBBSession *session,NSError *error){
  968. NSLog(@"session == %@,error == %@",session,error);
  969. }];
  970. }
  971. };
  972. _superBrandView.moreClick = ^{
  973. //点击更多
  974. FSBaseViewController *faVC= [[FSBaseViewController alloc]init];
  975. faVC.model=weakSelf.model;
  976. [weakSelf.navigationController pushViewController:faVC animated:YES];
  977. };
  978. }
  979. return _superBrandView;
  980. }
  981. @end