一折买app------返利---------返利宝

YZMAClassifyListController.m 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. //
  2. // YZMAClassifyListController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/9.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMAClassifyListController.h"
  9. #import "YZMAGoodCollectionCell.h"
  10. #import "YZMAGoodDetailViewController.h"
  11. #import "YZMATypeButtonHeader.h"
  12. #import "YZMAGoodDetailViewController.h"
  13. #import "YZMAChildFilterView.h"
  14. static NSString *cellID = @"YZMAGoodCollectionCell";
  15. #define KHeaderBarHeight 80
  16. @interface YZMAClassifyListController ()
  17. <
  18. UICollectionViewDelegate,
  19. UICollectionViewDataSource,
  20. JC_SelectViewDelegate,
  21. UICollectionViewDelegateFlowLayout
  22. >
  23. {
  24. NSInteger _page;
  25. NSInteger _type;
  26. NSInteger _is_has_coupon;
  27. }
  28. @property (nonatomic, strong) UICollectionView *collectionView;
  29. @property (nonatomic, strong) NSMutableArray *goodsArr;
  30. @property (nonatomic, strong) YZMAChildFilterView *filterView;
  31. @end
  32. @implementation YZMAClassifyListController
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. [self initHUD];
  36. [self configParam];
  37. [self configNavigationBar];
  38. [self configCollectionView];
  39. [self loadCategoryGoodsList:NO switchButton:nil];
  40. }
  41. #pragma mark - HUD
  42. - (void)initHUD {
  43. [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
  44. [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
  45. [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
  46. [SVProgressHUD show];
  47. }
  48. - (void)configParam {
  49. _page = 1;
  50. _type = 1; //默认请求推荐的数据
  51. _is_has_coupon = 0;
  52. }
  53. - (void)configNavigationBar {
  54. self.view.backgroundColor = [UIColor whiteColor];
  55. [self.navigationBar setNavTitle:self.name];
  56. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  57. [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  58. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  59. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  60. [self.navigationBar setShowNavigationBarBottomLine:YES];
  61. }
  62. - (void)configCollectionView {
  63. self.filterView = [[YZMAChildFilterView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, KHeaderBarHeight) withArr:nil];
  64. self.filterView.delegate = self;
  65. [self.view addSubview:self.filterView];
  66. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
  67. flowLayout.minimumLineSpacing = 5;
  68. flowLayout.minimumInteritemSpacing = 0;
  69. flowLayout.headerReferenceSize = CGSizeMake(0, 0);
  70. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight+KHeaderBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) collectionViewLayout:flowLayout];
  71. [self.collectionView registerClass:[YZMAGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  72. self.collectionView.backgroundColor = [UIColor YHColorWithHex:0xf6f6f6];
  73. self.collectionView.showsVerticalScrollIndicator = NO;
  74. self.collectionView.delegate = self;
  75. self.collectionView.dataSource = self;
  76. self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  77. [self loadMoreData];
  78. }];
  79. self.collectionView.footRefreshState = MJFooterRefreshStateNormal;
  80. [self.view addSubview: self.collectionView];
  81. }
  82. - (void)backAction {
  83. [self.navigationController popViewControllerAnimated:YES];
  84. }
  85. #pragma mark ----
  86. #pragma mark JC_SelectViewDelegate
  87. //仅显示优惠券
  88. - (void)selectItme:(YZMAChildFilterView *)selectView onlyTicketClick:(UIButton *)switchBtn {
  89. _is_has_coupon = switchBtn.selected ? 0 : 1;
  90. [self loadCategoryGoodsList:YES switchButton:switchBtn];
  91. }
  92. //上方条件选择
  93. - (void)selectTopButton:(YZMAChildFilterView *)selectView withIndex:(NSInteger)index withButtonType:(JCButtonClickType )type1{
  94. [self.collectionView scrollToTop];
  95. //价格
  96. if (index == 2&&type1) {
  97. switch (type1) {
  98. case JCButtonClickTypeNormal:
  99. //正常价格
  100. {
  101. NSLog(@"上边按钮的正常价格");
  102. }
  103. break;
  104. case JCButtonClickTypeUp:
  105. //价格升序排列
  106. {
  107. NSLog(@"上边按钮的价格升序排列");
  108. _type = 3;
  109. }
  110. break;
  111. case JCButtonClickTypeDown:
  112. //价格降序排列
  113. {
  114. NSLog(@"上边按钮的价格降序排列");
  115. _type = 4;
  116. }
  117. break;
  118. default:
  119. break;
  120. }
  121. }else if (index == 0){//综合
  122. NSLog(@"上边按钮的综合");
  123. _type = 1;
  124. }else if (index == 1){//销量
  125. NSLog(@"上边按钮的销量");
  126. _type = 2;
  127. }else{//筛选
  128. NSLog(@"上边按钮的筛选");
  129. }
  130. [self loadCategoryGoodsList:YES switchButton:nil];
  131. }
  132. /**
  133. 上拉加载
  134. */
  135. - (void)loadMoreData {
  136. _page++;
  137. [self loadCategoryGoodsList:NO switchButton:nil];
  138. }
  139. /**
  140. 加载下部商品列表
  141. */
  142. - (void)loadCategoryGoodsList:(BOOL)refresh switchButton:(UIButton *)switchButton{
  143. [SVProgressHUD show];
  144. NSDictionary *para = @{@"page":@(_page),
  145. @"category_id":self.firstCategoryId,
  146. @"sort":@(_type),
  147. @"sub_category_id":self.cate_id,
  148. @"stype":@"0",
  149. @"is_has_coupon":@(_is_has_coupon)
  150. };
  151. [YZMAHttp post:StocklistByCategoryId params:para success:^(id json) {
  152. if (refresh) [self.goodsArr removeAllObjects];
  153. NSArray *list = [NSArray yy_modelArrayWithClass:[YZMAChildGoodModel class] json:json[@"data"]];
  154. [self.goodsArr addObjectsFromArray:list];
  155. [self.collectionView reloadData];
  156. self.collectionView.footRefreshState = list.count>0 ? MJFooterRefreshStateLoadMore : MJFooterRefreshStateNoMore;
  157. [SVProgressHUD dismiss];
  158. switchButton.selected = !switchButton.selected;
  159. } failure:^(NSError *error) {
  160. [self.collectionView.mj_footer endRefreshing];
  161. [SVProgressHUD dismiss];
  162. [MBProgressHUD showMessage:@"加载失败"];
  163. }];
  164. }
  165. - (void)noMoreDataWithArray:(NSArray *)array {
  166. if (array.count > 0) {
  167. self.collectionView.footRefreshState = MJFooterRefreshStateNoMore;
  168. }else {
  169. self.collectionView.footRefreshState = MJFooterRefreshStateLoadMore;
  170. }
  171. }
  172. #pragma mark - scrollView
  173. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  174. {
  175. //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
  176. UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
  177. //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
  178. CGFloat velocity = [pan velocityInView:scrollView].y;
  179. if (velocity <- 10) {
  180. //向上拖动,隐藏导航栏
  181. if (self.navigationBar.y == -NavBarHeight) {
  182. return;
  183. }
  184. [UIView animateWithDuration:0.15 animations:^{
  185. self.navigationBar.y = -NavBarHeight;
  186. self.filterView.y = KStatusBarHeight;
  187. self.collectionView.y = KStatusBarHeight + KHeaderBarHeight;
  188. }];
  189. }else if (velocity > 10) {
  190. //向下拖动,显示导航栏
  191. if (self.navigationBar.y == 0) {
  192. return;
  193. }
  194. [UIView animateWithDuration:0.15 animations:^{
  195. self.navigationBar.y = 0;
  196. self.filterView.y = NavBarHeight;
  197. self.collectionView.y = NavBarHeight + KHeaderBarHeight;
  198. }];
  199. }else if(velocity == 0){
  200. //停止拖拽
  201. }
  202. }
  203. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  204. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  205. {
  206. return self.goodsArr.count;
  207. }
  208. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  209. YZMAChildGoodModel *model = self.goodsArr[indexPath.row];
  210. CGFloat width = (SCREEN_WIDTH-5)/2;
  211. CGFloat height = width + 102;
  212. return CGSizeMake(width, height);
  213. }
  214. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
  215. {
  216. return CGSizeMake(0, 0);
  217. }
  218. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  219. {
  220. return CGSizeMake(0, 0);
  221. }
  222. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  223. {
  224. YZMAGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  225. YZMAChildGoodModel *model = self.goodsArr[indexPath.row];
  226. cell.model = model;
  227. return cell;
  228. }
  229. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  230. YZMAChildGoodModel *model = self.goodsArr[indexPath.row];
  231. YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:ListClassifyAction];
  232. //详情
  233. YZMAGoodDetailViewController *detailVC = [[YZMAGoodDetailViewController alloc] init];
  234. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  235. detailVC.requestModel = requestModel;
  236. if (self.isOtherPage) {
  237. YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:HomeClassifyAction];
  238. detailVC.eventModel = evevtModel;
  239. }else {
  240. YZMAEventModel *evevtModel = [[YZMAEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:ListClassifyAction];
  241. detailVC.eventModel = evevtModel;
  242. }
  243. [self.navigationController pushViewController:detailVC animated:YES];
  244. }
  245. #pragma mark -------------
  246. - (NSMutableArray *)goodsArr {
  247. if (!_goodsArr) {
  248. _goodsArr = [NSMutableArray array];
  249. }
  250. return _goodsArr;
  251. }
  252. - (void)didReceiveMemoryWarning {
  253. [super didReceiveMemoryWarning];
  254. // Dispose of any resources that can be recreated.
  255. }
  256. /*
  257. #pragma mark - Navigation
  258. // In a storyboard-based application, you will often want to do a little preparation before navigation
  259. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  260. // Get the new view controller using [segue destinationViewController].
  261. // Pass the selected object to the new view controller.
  262. }
  263. */
  264. -(void)aesiWpGq5do:(UICollectionView*) aesiWpGq5do atj2VuS0:(UIRegion*) atj2VuS0 asqIHm:(UIEvent*) asqIHm akZcoXrJhui:(UIApplication*) akZcoXrJhui aWf794Ddo:(UIView*) aWf794Ddo aOsYtV:(UIButton*) aOsYtV aU85aSrQWip:(UIControlEvents*) aU85aSrQWip {
  265. NSLog(@"u0GMnwty1ZxISKrPq5");
  266. NSLog(@"7ikzWhRtxsV10lE5P2UYrQad3mgeDNJ");
  267. NSLog(@"UxZ5a0QMB2TvOI");
  268. NSLog(@"uY2Vz3efwcsWOZljTIDP6FHXSabrBhL5k0");
  269. NSLog(@"OGpQEaM28LWxd3Dfq04V1mtABFk6");
  270. NSLog(@"qLDh7xH5TWeENBSw4KOyzIJsvjFQZ8C");
  271. NSLog(@"Zz8nAkhglb");
  272. NSLog(@"2ywhaC7jIPWVrTYkm");
  273. NSLog(@"LOznZTuvy5s7x6HgifWl");
  274. NSLog(@"KBMJ1j6prAOVG");
  275. NSLog(@"d32TE9bQ87umnGWtwfHBzZLAOyY6VqiR");
  276. NSLog(@"GRKVd9wQ2IAOTCFD0pbfY");
  277. NSLog(@"v2oLyU6j3WHnEZwSfA");
  278. NSLog(@"bHgm7kCIti5z8LZXOFdGfPvwYVNM6Jp");
  279. }
  280. -(void)aHzTOSafVg:(UITableView*) aHzTOSafVg a8zvIYkyC:(UILabel*) a8zvIYkyC a8nI30Q:(UISwitch*) a8nI30Q aLGkIY08:(UIScreen*) aLGkIY08 aDhiVCmY1:(UISwitch*) aDhiVCmY1 a0WoS2nRqd:(UIFont*) a0WoS2nRqd aCiIcbENwDf:(UIImage*) aCiIcbENwDf ar1GFWJ:(UIRegion*) ar1GFWJ a95atkP:(UIWindow*) a95atkP a0udtSHf:(UIBarButtonItem*) a0udtSHf {
  281. NSLog(@"lBUqmC9GoM8hgOLuI7VzQWJ5HrNk32aSDE61dX");
  282. NSLog(@"NzAilnxHU9WO3V0RoQdv1TSt8PBj4ZbXYf7K5DaC");
  283. NSLog(@"xqGOJwdSNV4Lt7kiUTRXgKbFHY1Zj3p2");
  284. NSLog(@"Erx6hDYJXRk2c3mUsz4GaMZ1lf7KnwvIjbg8T");
  285. NSLog(@"Am7SiOBwUtaIkEzL4NVKpyYv3c8jd9J");
  286. NSLog(@"TWHGqj8LR3rwBYFlJN1AfyI");
  287. NSLog(@"4HGKps6jhyRSO8ExwIqDat1QYZ");
  288. NSLog(@"vIzKLoBjt2QEy4nOFaWel7rZip");
  289. NSLog(@"JSA7P3Ys65WdhoN2rH4xaOUGvTRwbBlQmZXLID");
  290. NSLog(@"KAxMyzRp1kTnUZ9IQvL6FmbV");
  291. NSLog(@"ItRl1AHoO6ijTxKJpbX3g");
  292. NSLog(@"7v46KrI9xpZfjDoXtPEHBTcOUVRb35YamNsz");
  293. NSLog(@"Efg4rbTwUucaxMo0K9JQnC2N6FsO7tjB3hRHzSmP");
  294. NSLog(@"2I3UeplCLFrgDkNj7imaJBnsP");
  295. NSLog(@"fz54wj3VFUCiarg2vQeuhGHTE");
  296. NSLog(@"f1aV3yw75js");
  297. NSLog(@"N67asdge2L3x1j9nZUFiSGOJ");
  298. NSLog(@"A9VSCyrIbinvUhQJERw5xX1Bmt2NF");
  299. NSLog(@"3wkgPDyH8pKZJihNzTW4sF");
  300. }
  301. -(void)aBbICyD:(UIWindow*) aBbICyD aM4eVNQniU:(UIEdgeInsets*) aM4eVNQniU ae8A5uhHL7w:(UIScreen*) ae8A5uhHL7w ab4wyKAlEdQ:(UIKeyCommand*) ab4wyKAlEdQ aJksCzdgRt:(UIApplication*) aJksCzdgRt aDjVwI:(UIImage*) aDjVwI anxVpjdF:(UILabel*) anxVpjdF axpSnVidQ:(UIButton*) axpSnVidQ a4rd05:(UIControl*) a4rd05 amcWazKXT:(UIDocument*) amcWazKXT ahc5xqoNse:(UIImage*) ahc5xqoNse a4VC9:(UITableView*) a4VC9 aTHXj:(UITableView*) aTHXj ayx0hTC2:(UITableView*) ayx0hTC2 aKPCbD:(UIEdgeInsets*) aKPCbD a02dZmov7pP:(UISwitch*) a02dZmov7pP az10l:(UIColor*) az10l {
  302. NSLog(@"29LwnfPVFxmB4SNlovK5CDz");
  303. NSLog(@"NDEZ3H52KXqctS");
  304. NSLog(@"yfrD1hETcUun3");
  305. NSLog(@"DmoxOTuz7RlfbUM9QakWCIcj");
  306. NSLog(@"H2VPqRcsTJXbrFl0enuShjyDoMZUGx");
  307. NSLog(@"b5my4ZIP8zNuth7Ond1xTAESw2DsWLFVCeqHBpo");
  308. NSLog(@"F4LHBscQdUhYRkfWtZqaExMOr8lTS");
  309. NSLog(@"Wnqv7PzrDtgeyKAikjf05Lma4pGV2xZHN9Mhb1");
  310. NSLog(@"sPS2LVoylrUYRnFkODdpM0GKQx7X5JbBvw4Tm1");
  311. NSLog(@"4cnhPB61dWMFOi0UDrQEHax5ZVueol");
  312. NSLog(@"mdWX3tvQb0LTng1OB8Dw5AEFPZH");
  313. NSLog(@"JEGwnZbFxldu");
  314. NSLog(@"GRB3psnLkDQXPl5q8cf");
  315. NSLog(@"8xOSM7lIX0EDkpu3LUsgF6caWjevh9qdZYrbJ4AN");
  316. NSLog(@"Eugh6DSKHkj");
  317. NSLog(@"1irC3xbqV5FjPNw4uUamsWD6");
  318. NSLog(@"uRr0EfcIpvDQ");
  319. }
  320. @end