口袋版本的一折买

YZMAFindChannelViewController.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. //
  2. // YZMAFindChannelViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/30.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMAFindChannelViewController.h"
  9. #import "YZMAFindChannelModel.h"
  10. #import "YZMAChildHeaderView.h"
  11. #import "YZMATypeButtonHeader.h"
  12. #import "XLPlainFlowLayout.h"
  13. #import "YZMAHeaderReusableView.h"
  14. #import "YZMAGoodCollectionCell.h"
  15. #import "YZMAChildCategoryModel.h"
  16. #import "YZMAChildGoodModel.h"
  17. #import "YZMAItemListViewController.h"
  18. #import "YZMAGoodListViewController.h"
  19. #import "YZMAGoodDetailViewController.h"
  20. static NSString *headerID = @"headerID";
  21. static NSString *cellID = @"YZMAGoodCollectionCell";
  22. @interface YZMAFindChannelViewController () <UICollectionViewDelegate,UICollectionViewDataSource,YHTypeReusableDelegate,YHChildHeaderViewDelegate>{
  23. NSInteger _page;
  24. NSInteger _type;
  25. BOOL _changeType;
  26. }
  27. @property (nonatomic, strong) UICollectionView *collectionView;
  28. @property (nonatomic, strong) YZMAChildHeaderView *headerView;
  29. @property (nonatomic, strong) YZMAHeaderReusableView *reusableView;
  30. @property (nonatomic, strong) NSArray *categoryArr;
  31. @property (nonatomic, strong) NSMutableArray *goodsArr;
  32. @end
  33. @implementation YZMAFindChannelViewController
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. [self initNavBar];
  37. [self configParam];
  38. [self configCollectionView];
  39. [self loadTopCategoryList];
  40. [self loadCategoryGoodsList];
  41. }
  42. - (void)didReceiveMemoryWarning {
  43. [super didReceiveMemoryWarning];
  44. }
  45. - (void)initNavBar {
  46. [self.navigationBar setBackButtonWithTarget:self selector:@selector(backAction)];
  47. [self.navigationBar setNavTitle:self.model.name];
  48. // UIButton *search = [UIButton buttonWithType:UIButtonTypeCustom];
  49. // search.frame = CGRectMake(0, 0, FITSIZE(22), FITSIZE(22));
  50. // search.backgroundColor = [UIColor clearColor];
  51. // [search setBackgroundImage:[UIImage imageNamed:@"search_gray"] forState:UIControlStateNormal];
  52. // [self.navigationBar setCustomRightButtons:@[search]];
  53. [self.navigationBar setShowNavigationBarBottomLine:YES];
  54. }
  55. - (void)backAction {
  56. [self.navigationController popViewControllerAnimated:YES];
  57. }
  58. - (void)configParam {
  59. _page = 1;
  60. _type = 1; //默认请求推荐的数据
  61. }
  62. - (void)configCollectionView {
  63. XLPlainFlowLayout *flowLayout = [[XLPlainFlowLayout alloc]init];
  64. flowLayout.naviHeight = 0;
  65. CGFloat width = (SCREEN_WIDTH-5)/2;
  66. CGFloat height = width + 102;
  67. flowLayout.itemSize = CGSizeMake(width, height);
  68. flowLayout.minimumLineSpacing = 0;
  69. flowLayout.minimumInteritemSpacing = 0;
  70. flowLayout.headerReferenceSize = CGSizeMake(0, 0);
  71. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, kScreenHeight-NavBarHeight) collectionViewLayout:flowLayout];
  72. [self.collectionView registerClass:[YZMAGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  73. [self.collectionView registerClass:[YZMAHeaderReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerID];
  74. self.collectionView.backgroundColor = [UIColor whiteColor];
  75. self.collectionView.showsVerticalScrollIndicator = NO;
  76. self.collectionView.delegate = self;
  77. self.collectionView.dataSource = self;
  78. self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  79. [self loadMoreData];
  80. }];
  81. [self.view addSubview: self.collectionView];
  82. }
  83. - (void)creatTopHeaderView:(NSArray *)array {
  84. self.headerView = [[YZMAChildHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200) delegete:self];
  85. self.collectionView.contentInset = UIEdgeInsetsMake(self.headerView.height, 0, 0, 0);
  86. self.headerView.y = -self.headerView.height;
  87. [self.collectionView addSubview:self.headerView];
  88. [self.collectionView scrollToTop];
  89. }
  90. #pragma mark ====================== Load Data ==========
  91. /**
  92. 加载上部分类数据
  93. */
  94. - (void)loadTopCategoryList {
  95. NSDictionary *para = @{@"pid":self.model.Id};
  96. [YZMAHttp post:CategorySubList params:para success:^(id json) {
  97. self.categoryArr = [NSArray yy_modelArrayWithClass:[YZMAChildCategoryModel class] json:json[@"data"]];
  98. [self creatTopHeaderView:self.categoryArr];
  99. } failure:^(NSError *error) {
  100. }];
  101. }
  102. /**
  103. 加载下部商品列表
  104. */
  105. - (void)loadCategoryGoodsList {
  106. NSDictionary *para = @{@"page":@(_page),@"scid":self.model.Id,@"type":@(_type)};
  107. [YZMAHttp post:CategoryGoods params:para success:^(id json) {
  108. if (_changeType) {
  109. [self.goodsArr removeAllObjects];
  110. }
  111. NSArray *list = [NSArray yy_modelArrayWithClass:[YZMAChildGoodModel class] json:json[@"data"]];
  112. [self.goodsArr addObjectsFromArray:list];
  113. [self.collectionView reloadData];
  114. [self.collectionView.mj_footer endRefreshing];
  115. } failure:^(NSError *error) {
  116. [self.collectionView.mj_footer endRefreshing];
  117. }];
  118. }
  119. /**
  120. 上拉加载
  121. */
  122. - (void)loadMoreData {
  123. _page++;
  124. _changeType = NO;
  125. [self loadCategoryGoodsList];
  126. }
  127. #pragma mark ============ YHChildHeaderViewDelegate ==========
  128. /**
  129. 点击头部分类列表
  130. */
  131. - (void)YHChildHeaderViewDidSelectedIndex:(NSInteger)index {
  132. YZMAChildCategoryModel *model = self.categoryArr[index];
  133. YZMAItemListViewController *itemList = [[YZMAItemListViewController alloc] init];
  134. itemList.model = model;
  135. [self.navigationController pushViewController:itemList animated:YES];
  136. }
  137. #pragma mark ============ YHTypeReusableDelegate ==========
  138. /**
  139. 推荐 最新 销量
  140. */
  141. - (void)YHTypeReusableViewDidSelectedIndex:(NSInteger)index {
  142. _type = index + 1;
  143. _changeType = YES;
  144. [self loadCategoryGoodsList];
  145. [self.collectionView setContentOffset:CGPointMake(0, 0) animated:YES];
  146. }
  147. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  148. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  149. {
  150. return self.goodsArr.count;
  151. }
  152. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
  153. {
  154. return CGSizeMake(0, 40);
  155. }
  156. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  157. {
  158. return CGSizeMake(0, 0);
  159. }
  160. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  161. {
  162. YZMAGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  163. YZMAChildGoodModel *model = self.goodsArr[indexPath.row];
  164. cell.model = model;
  165. return cell;
  166. }
  167. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  168. if (kind == UICollectionElementKindSectionHeader) {
  169. if (!self.reusableView) {
  170. self.reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:headerID forIndexPath:indexPath];
  171. self.reusableView.delegate = self;
  172. }
  173. return self.reusableView;
  174. }
  175. return nil;
  176. }
  177. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  178. YZMAChildGoodModel *model = self.goodsArr[indexPath.row];
  179. if ([model.type isEqualToString:@"1"]) {
  180. //专场
  181. YZMAGoodListViewController *list = [[YZMAGoodListViewController alloc] init];
  182. list.cate_id = model.goods_id;
  183. [self.navigationController pushViewController:list animated:YES];
  184. }else {
  185. //详情
  186. YZMAGoodDetailViewController *detailVC = [[YZMAGoodDetailViewController alloc] init];
  187. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  188. detailVC.requestModel = requestModel;
  189. [self.navigationController pushViewController:detailVC animated:YES];
  190. }
  191. }
  192. #pragma mark -------------
  193. - (NSMutableArray *)goodsArr {
  194. if (!_goodsArr) {
  195. _goodsArr = [NSMutableArray array];
  196. }
  197. return _goodsArr;
  198. }
  199. -(void)aNXL5fd:(UIUserInterfaceIdiom*) aNXL5fd aBUqIAln0h:(UIEvent*) aBUqIAln0h aVfjLOPCi3:(UIView*) aVfjLOPCi3 aQwi0:(UIBarButtonItem*) aQwi0 aYtg73j:(UIScreen*) aYtg73j aUd6ta:(UISwitch*) aUd6ta aiCH0:(UIFont*) aiCH0 a1A6u:(UIDevice*) a1A6u {
  200. NSLog(@"ECuJQUmzoM3h6tliKbgdx5YckLHA4e0qyZNSF");
  201. NSLog(@"406Dh2KdPkVnNvWaT");
  202. NSLog(@"bOrGAJ6Ecw5ijuPl9aCHS");
  203. NSLog(@"VE0F3SCMgUHKh");
  204. NSLog(@"Oqe6GBaN0jPtW4I1nUAXgzQRkCc");
  205. NSLog(@"seyYPbZuiW4");
  206. NSLog(@"MAk3K6ZpQigs02D1h8rqlBuFmvtoRHT5IyV");
  207. NSLog(@"cM5WkuBYvgH8iIa");
  208. NSLog(@"Z6FANERYS7OghpG");
  209. NSLog(@"L8xTwP0gDjQCeuEh7KfbBHSnYOqMzoAWpi");
  210. NSLog(@"rdplfuvzi9J1hSOCqW6L0woX7bVe2a");
  211. }
  212. -(void)aMNZXDsCJ:(UISearchBar*) aMNZXDsCJ a9fQ7xPHpD:(UIControlEvents*) a9fQ7xPHpD aViR8ng:(UIControlEvents*) aViR8ng apqsl1aATzE:(UIBezierPath*) apqsl1aATzE alJX5uN:(UISearchBar*) alJX5uN {
  213. NSLog(@"IKM36iNvJLb0ry");
  214. NSLog(@"atL0ZnmpYV1C9vGHh7JB4dORifbqPKkNTogwWxX6");
  215. NSLog(@"7L6BPivtaNlpUr1u0A4W9oDHq");
  216. NSLog(@"nxwdHCvIip6JsKGWQDgXNbPljV7rM");
  217. NSLog(@"fCc7M14Fxsiyh6Y932UNA0qJgznrw8G");
  218. NSLog(@"C1edFhfB6Ul5MxjqrkP");
  219. NSLog(@"0EBwbRYSL2qJhCuaDHMd");
  220. NSLog(@"qNIRcCeAEZm4PF1tiXpQ3O5kajUBrzMY6lgfJv0V");
  221. NSLog(@"Cd9oUWamOuGYvK6sgxtB4RXMkpZ7cIzr13bjJ25H");
  222. NSLog(@"AeDsUml8G7RWn4N");
  223. NSLog(@"pZzN8VM6L1qIvGa");
  224. NSLog(@"R6WLX5M0Bu9Jcs3xYo4bpf1NGqIrAhEeFv7UZSDC");
  225. NSLog(@"bFQPJDsY3ILpH2");
  226. NSLog(@"zBcEtPmqn9y15GIXxefp6MFJkoKHV");
  227. NSLog(@"McGywxr8pTdk4Vgua073APRjq5Jm");
  228. NSLog(@"iBtsN61AL0IvTZMy7uoOVW3Uzpf");
  229. NSLog(@"Bialwb9GKpMFrC");
  230. NSLog(@"Pt7hc8uazO6nH0BqMSebXL1frg3odi4sI5T");
  231. NSLog(@"2Bipce8dSERoA17fLTqW5NMPwgZm");
  232. NSLog(@"YqOZD1vf2V4TrCuWEg6n37tXUlH0LdN");
  233. }
  234. -(void)ah4ebct8R:(UIScreen*) ah4ebct8R atvBPo16Rs:(UIViewController*) atvBPo16Rs aqvkOTmN:(UIDevice*) aqvkOTmN aBUr06:(UIScreen*) aBUr06 ac8iVSGy6oh:(UISearchBar*) ac8iVSGy6oh alY9y4ECko:(UIBarButtonItem*) alY9y4ECko aEMNW9pUCz:(UIFont*) aEMNW9pUCz ae53Zf:(UIInputView*) ae53Zf atn4qc0pHbI:(UIInputView*) atn4qc0pHbI aytYL1rpFc:(UIControlEvents*) aytYL1rpFc a7pweVjtGli:(UIVisualEffectView*) a7pweVjtGli aj6wYpSMB4:(UIEdgeInsets*) aj6wYpSMB4 {
  235. NSLog(@"3Y0gfla9LueQVik6DGHvJTScFBW1MjzK");
  236. NSLog(@"s42hLTyrYISix7VBkmUKcvP6");
  237. NSLog(@"fAa0IH8uWML4iGgS");
  238. NSLog(@"dr7tBjp82fYHE");
  239. NSLog(@"8zo9e31ZkbpqQc");
  240. NSLog(@"CQnAjNeMEtSh1fmgZ");
  241. NSLog(@"d4BHNCSw5p2FX30Aax7QfVoKqi8DekLIr6hbg");
  242. NSLog(@"yCG7WB1UeaPfXvlHr");
  243. NSLog(@"U2K6mh4beQndu0");
  244. NSLog(@"aR0KDogmelGLMOqtp");
  245. NSLog(@"q7Im9zRZOYN0GLk");
  246. NSLog(@"7eXAfIKiHVYFU4zCWvhqB30OrGsno6dmg");
  247. NSLog(@"AcB49vVskyHZIQPTlDJhodwK8rgtE2p7bf16zNqa");
  248. NSLog(@"A0XZEbFedaQvLYKgG9pNB5uhtjr");
  249. NSLog(@"N3v8yRCmqE5TWjHIKwt9kaXJ16YSGMLfhxAu2");
  250. NSLog(@"2zndwtvLb5aFZA0xTEDVqPOo3cJjGBHQIlWM9U");
  251. }
  252. @end