两折买改口袋样式

LZMClassifyListController.m 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. //
  2. // LZMClassifyListController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/9.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMClassifyListController.h"
  9. #import "LZMGoodCollectionCell.h"
  10. #import "LZMGoodDetailViewController.h"
  11. #import "LZMTypeButtonHeader.h"
  12. #import "LZMGoodDetailViewController.h"
  13. #import "LZMChildFilterView.h"
  14. static NSString *cellID = @"LZMGoodCollectionCell";
  15. #define KHeaderBarHeight 80
  16. @interface LZMClassifyListController ()
  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) LZMChildFilterView *filterView;
  31. @end
  32. @implementation LZMClassifyListController
  33. - (void)viewWillAppear:(BOOL)animated {
  34. [super viewWillAppear:animated];
  35. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  36. }
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. [self initHUD];
  40. [self configParam];
  41. [self configNavigationBar];
  42. [self configCollectionView];
  43. [self loadCategoryGoodsList:NO switchButton:nil];
  44. }
  45. #pragma mark - HUD
  46. - (void)initHUD {
  47. [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
  48. [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
  49. [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
  50. [SVProgressHUD show];
  51. }
  52. - (void)configParam {
  53. _page = 1;
  54. _type = 1; //默认请求推荐的数据
  55. _is_has_coupon = 0;
  56. }
  57. - (void)configNavigationBar {
  58. self.view.backgroundColor = [UIColor whiteColor];
  59. [self.navigationBar setNavTitle:self.name];
  60. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  61. [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  62. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  63. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  64. [self.navigationBar setShowNavigationBarBottomLine:YES];
  65. }
  66. - (void)configCollectionView {
  67. self.filterView = [[LZMChildFilterView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, KHeaderBarHeight) withArr:nil];
  68. self.filterView.delegate = self;
  69. [self.view addSubview:self.filterView];
  70. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
  71. flowLayout.minimumLineSpacing = 5;
  72. flowLayout.minimumInteritemSpacing = 0;
  73. flowLayout.headerReferenceSize = CGSizeMake(0, 0);
  74. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, NavBarHeight+KHeaderBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) collectionViewLayout:flowLayout];
  75. [self.collectionView registerClass:[LZMGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  76. self.collectionView.backgroundColor = [UIColor YHColorWithHex:0xf6f6f6];
  77. self.collectionView.showsVerticalScrollIndicator = NO;
  78. self.collectionView.delegate = self;
  79. self.collectionView.dataSource = self;
  80. self.collectionView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  81. [self loadMoreData];
  82. }];
  83. [self.view addSubview: self.collectionView];
  84. }
  85. - (void)backAction {
  86. [self.navigationController popViewControllerAnimated:YES];
  87. }
  88. #pragma mark ----
  89. #pragma mark JC_SelectViewDelegate
  90. //仅显示优惠券
  91. - (void)selectItme:(LZMChildFilterView *)selectView onlyTicketClick:(UIButton *)switchBtn {
  92. _is_has_coupon = switchBtn.selected ? 0 : 1;
  93. [self loadCategoryGoodsList:YES switchButton:switchBtn];
  94. }
  95. //上方条件选择
  96. - (void)selectTopButton:(LZMChildFilterView *)selectView withIndex:(NSInteger)index withButtonType:(JCButtonClickType )type1{
  97. //价格
  98. if (index == 2&&type1) {
  99. switch (type1) {
  100. case JCButtonClickTypeNormal:
  101. //正常价格
  102. {
  103. NSLog(@"上边按钮的正常价格");
  104. }
  105. break;
  106. case JCButtonClickTypeUp:
  107. //价格升序排列
  108. {
  109. NSLog(@"上边按钮的价格升序排列");
  110. _type = 3;
  111. }
  112. break;
  113. case JCButtonClickTypeDown:
  114. //价格降序排列
  115. {
  116. NSLog(@"上边按钮的价格降序排列");
  117. _type = 4;
  118. }
  119. break;
  120. default:
  121. break;
  122. }
  123. }else if (index == 0){//综合
  124. NSLog(@"上边按钮的综合");
  125. _type = 1;
  126. }else if (index == 1){//销量
  127. NSLog(@"上边按钮的销量");
  128. _type = 2;
  129. }else{//筛选
  130. NSLog(@"上边按钮的筛选");
  131. }
  132. _page = 1;
  133. [self.collectionView.mj_footer resetNoMoreData];
  134. [self loadCategoryGoodsList:YES switchButton:nil];
  135. }
  136. /**
  137. 上拉加载
  138. */
  139. - (void)loadMoreData {
  140. _page++;
  141. [self loadCategoryGoodsList:NO switchButton:nil];
  142. }
  143. /**
  144. 加载下部商品列表
  145. */
  146. - (void)loadCategoryGoodsList:(BOOL)refresh switchButton:(UIButton *)switchButton{
  147. if (![self.collectionView.mj_footer isRefreshing]) {
  148. [SVProgressHUD show];
  149. }
  150. NSDictionary *para = @{@"page":@(_page),
  151. @"category_id":self.firstCategoryId,
  152. @"sort":@(_type),
  153. @"sub_category_id":self.cate_id,
  154. @"stype":@"0",
  155. @"is_has_coupon":@(_is_has_coupon)
  156. };
  157. [LZMHttp post:StocklistByCategoryId params:para success:^(id json) {
  158. if (refresh) [self.goodsArr removeAllObjects];
  159. NSArray *list = [NSArray yy_modelArrayWithClass:[LZMChildGoodModel class] json:json[@"data"]];
  160. [self.goodsArr addObjectsFromArray:list];
  161. [self.collectionView reloadData];
  162. if (list.count > 0) {
  163. [self.collectionView.mj_footer endRefreshing];
  164. }else {
  165. [self.collectionView.mj_footer endRefreshingWithNoMoreData];
  166. }
  167. [SVProgressHUD dismiss];
  168. switchButton.selected = !switchButton.selected;
  169. } failure:^(NSError *error) {
  170. [self.collectionView.mj_footer endRefreshing];
  171. [SVProgressHUD dismiss];
  172. [MBProgressHUD showMessage:@"加载失败"];
  173. }];
  174. }
  175. - (void)noMoreDataWithArray:(NSArray *)array {
  176. if (array.count > 0) {
  177. self.collectionView.footRefreshState = MJFooterRefreshStateNoMore;
  178. }else {
  179. self.collectionView.footRefreshState = MJFooterRefreshStateLoadMore;
  180. }
  181. }
  182. #pragma mark - scrollView
  183. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  184. {
  185. //scrollView已经有拖拽手势,直接拿到scrollView的拖拽手势
  186. UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
  187. //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
  188. CGFloat velocity = [pan velocityInView:scrollView].y;
  189. if (velocity <- 10) {
  190. //向上拖动,隐藏导航栏
  191. if (self.navigationBar.y == -NavBarHeight) {
  192. return;
  193. }
  194. [UIView animateWithDuration:0.15 animations:^{
  195. self.navigationBar.y = -NavBarHeight;
  196. self.filterView.y = KStatusBarHeight;
  197. self.collectionView.y = KStatusBarHeight + KHeaderBarHeight;
  198. self.collectionView.height = SCREEN_HEIGHT-KHeaderBarHeight-KStatusBarHeight;
  199. }];
  200. }else if (velocity > 10) {
  201. //向下拖动,显示导航栏
  202. if (self.navigationBar.y == 0) {
  203. return;
  204. }
  205. [UIView animateWithDuration:0.15 animations:^{
  206. self.navigationBar.y = 0;
  207. self.filterView.y = NavBarHeight;
  208. self.collectionView.y = NavBarHeight + KHeaderBarHeight;
  209. }];
  210. }else if(velocity == 0){
  211. //停止拖拽
  212. }
  213. }
  214. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  215. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  216. {
  217. return self.goodsArr.count;
  218. }
  219. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  220. LZMChildGoodModel *model = self.goodsArr[indexPath.row];
  221. CGFloat width = (SCREEN_WIDTH-5)/2;
  222. CGFloat height = width + 102;
  223. return CGSizeMake(width, height);
  224. }
  225. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
  226. {
  227. return CGSizeMake(0, 0);
  228. }
  229. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  230. {
  231. return CGSizeMake(0, 0);
  232. }
  233. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  234. {
  235. LZMGoodCollectionCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  236. LZMChildGoodModel *model = self.goodsArr[indexPath.row];
  237. cell.model = model;
  238. return cell;
  239. }
  240. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  241. LZMChildGoodModel *model = self.goodsArr[indexPath.row];
  242. //详情
  243. LZMGoodDetailViewController *detailVC = [[LZMGoodDetailViewController alloc] init];
  244. DetailRequestModel *requestModel = [[DetailRequestModel alloc] initWithChildModel:model];
  245. detailVC.requestModel = requestModel;
  246. if (self.isOtherPage) {
  247. LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:HomeClassifyAction];
  248. detailVC.eventModel = evevtModel;
  249. }else {
  250. LZMEventModel *evevtModel = [[LZMEventModel alloc] initWithOrigin:model.origin category_id:self.cate_id source:ListClassifyAction];
  251. detailVC.eventModel = evevtModel;
  252. }
  253. [self.navigationController pushViewController:detailVC animated:YES];
  254. }
  255. #pragma mark -------------
  256. - (NSMutableArray *)goodsArr {
  257. if (!_goodsArr) {
  258. _goodsArr = [NSMutableArray array];
  259. }
  260. return _goodsArr;
  261. }
  262. - (void)didReceiveMemoryWarning {
  263. [super didReceiveMemoryWarning];
  264. // Dispose of any resources that can be recreated.
  265. }
  266. /*
  267. #pragma mark - Navigation
  268. // In a storyboard-based application, you will often want to do a little preparation before navigation
  269. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  270. // Get the new view controller using [segue destinationViewController].
  271. // Pass the selected object to the new view controller.
  272. }
  273. */
  274. -(void)anAhR7:(UIRegion*) anAhR7 aAShp:(UIEvent*) aAShp a7nPi2tU1:(UIEvent*) a7nPi2tU1 acv3motB:(UICollectionView*) acv3motB aVHxWew96nJ:(UIRegion*) aVHxWew96nJ a6Q4d:(UIApplication*) a6Q4d a0RWLk:(UIViewController*) a0RWLk agUJ8Aeo0vZ:(UIImage*) agUJ8Aeo0vZ a5m2e:(UICollectionView*) a5m2e aLM1h:(UICollectionView*) aLM1h aPJQ73Z:(UIImage*) aPJQ73Z aEpx0LY:(UIControlEvents*) aEpx0LY aWm0rnjXB:(UIEdgeInsets*) aWm0rnjXB aZHthf:(UICollectionView*) aZHthf azLxZ7VFAY:(UIButton*) azLxZ7VFAY al53BiDIdn8:(UIEdgeInsets*) al53BiDIdn8 ay4uw70:(UIScreen*) ay4uw70 {
  275. NSLog(@"ZoAxS7N05sT2qmGKO4i6c8FprhUPYt");
  276. NSLog(@"oD2sI8bAMLzd54xOuTfW0");
  277. NSLog(@"0HDPsRfK2ICG7");
  278. NSLog(@"KHirU0yMfPXzJZo2nvAaEGbQsC64qT");
  279. NSLog(@"0jMGJThNVa3Isfyb");
  280. NSLog(@"RoJrEt5mC4DwTSfW623NkYpuVHIie1hB8lqg");
  281. NSLog(@"FW4apmtfyQERS");
  282. NSLog(@"onq4AR5D7Vmvgu1rThCdEcN");
  283. NSLog(@"SzZsJFeVcQW");
  284. NSLog(@"9N2tiCQS6Yq");
  285. NSLog(@"DSL8ZxjrhO0Ffu43GIUzMqeblo1gPRJXWBCpyNVn");
  286. NSLog(@"Df8ogQAbvVp0dLCYqWn");
  287. NSLog(@"8LH1RdYSsWC6NhEO7ZAgVQ02tp3");
  288. NSLog(@"p0rOxybkgt4vTR1WmfBD9GhU7lH8nc3V");
  289. NSLog(@"K0y2tDsaVMTelBxc1mZqNrGEhdIkuW");
  290. NSLog(@"zKXx3EkU2SjN9gTq");
  291. NSLog(@"96e1lAJHMQf0sWUmItaDbXvxZ");
  292. NSLog(@"w1IpcuXtOaVryNig94U2JMYRqmnH6hvdDF8Z");
  293. NSLog(@"dvNJbph41AWwf0QMzkt2ZEX5S6HYnsaKqLuxgj");
  294. }
  295. -(void)aOM1sFv:(UIActivity*) aOM1sFv a86kORT0:(UIActivity*) a86kORT0 a6ojLbSfwQ:(UICollectionView*) a6ojLbSfwQ aI1CQgF8j:(UIBezierPath*) aI1CQgF8j arTO60q:(UIEvent*) arTO60q aHZ0hNC:(UILabel*) aHZ0hNC apsMiHfaJ4:(UIKeyCommand*) apsMiHfaJ4 asJt1:(UIButton*) asJt1 aENHDaQxP4:(UIActivity*) aENHDaQxP4 arEf0cn:(UISearchBar*) arEf0cn alSBgvXE:(UIFontWeight*) alSBgvXE ahHnw:(UIFont*) ahHnw aalbDSn:(UIControl*) aalbDSn aAxKBP:(UIRegion*) aAxKBP aPE6RG:(UIDocument*) aPE6RG a02uHl:(UIBezierPath*) a02uHl am1IzrN5WuD:(UIAlertView*) am1IzrN5WuD afHMADre1bx:(UIEdgeInsets*) afHMADre1bx a19pEePM:(UIRegion*) a19pEePM {
  296. NSLog(@"cUaOeIChtlwJRqBF8vbWzNipEsQr7SX60V");
  297. NSLog(@"akiKuGQhzPvNmy");
  298. NSLog(@"fM4GXtondYQaPsyOHrCT2uJzK7");
  299. NSLog(@"K12a6pRqIc4X0JiGsYZBz7FPLuxOdoj");
  300. NSLog(@"2rRavOtbQgoTIzwB7MuZmEecWYnSl");
  301. NSLog(@"0hJgkxX9Rm");
  302. NSLog(@"cbtM3RX9ZLsBTVf1Nhp25YAq0OvyrGx");
  303. NSLog(@"r83FBX4ikUH9duaeKqsplxcNoAvhWfOQS");
  304. NSLog(@"SNVLdZoOPT9I35kn1HuMWqA6Xa4D0");
  305. NSLog(@"npwzjGLtWSlI9xruCBkQZF6");
  306. NSLog(@"sofCtnYkPdp1J50TqcrXL");
  307. NSLog(@"yLzs7kXuY6d82ZmnhpJNt3KMorOcqEVTWSeDC5GR");
  308. NSLog(@"m5Rg0szDSjvobAMQ2cILqdTrhpZ");
  309. NSLog(@"2Lkv8J3Sa079i1nlBeDf4FQjNhoOEq");
  310. NSLog(@"QNX1sAocHnJWbxjku0aT3UrmGOKZfME8LPS");
  311. NSLog(@"VPaUOHpfxdhoq");
  312. NSLog(@"9sSkxhveu5o4Ir");
  313. NSLog(@"JXFu2nS0fkBTgOo3UC8weVNHvs5Dt");
  314. NSLog(@"zUsjK0NfLiAxpvmgEBrIlC1cPM");
  315. NSLog(@"nrAHkCVJZETpOIKub2WGXc3gPUx7v8dmRYaLf");
  316. }
  317. -(void)axbiP:(UIWindow*) axbiP a7mheoBQVXC:(UIFontWeight*) a7mheoBQVXC ai2ulK96R:(UIControl*) ai2ulK96R aF1gsOErzN:(UIRegion*) aF1gsOErzN aj3rgJI:(UIDocument*) aj3rgJI {
  318. NSLog(@"eDgLZlCjHJBOVb6ptIUi4rQwAMvqcWGuo87FfyP");
  319. NSLog(@"l9nRWaQIjVMuyh7fkZG3YBCowHEA8z5TxU1s");
  320. NSLog(@"3nNvQtaMr57GS4yFD6bXC9zLmBO8IuY");
  321. NSLog(@"EIx6eYhldqVZ8zU4kKr5D7HPCfOuw0p9a");
  322. NSLog(@"DLr3qdPasY5Je0tbh7p8SOoIXwlyg9FRjxvnf");
  323. NSLog(@"xNKFm7gl3Yu");
  324. NSLog(@"hjw6LuC47oN8l");
  325. NSLog(@"VdA1XKv7tuIMYO");
  326. NSLog(@"Olhk6RmfU4QTcvFNus7DPGJWzCAVMIrY3gEnSB9p");
  327. NSLog(@"lG60FkMhONwRZmi7pXUc3");
  328. }
  329. @end