两折卖----返利app-----返利圈

LZMNineNineScrollChildViewController.m 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. //
  2. // LZMNineNineScrollChildViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/29.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMNineNineScrollChildViewController.h"
  9. #import "LZMCollectionView.h"
  10. #import "LZMScrollChildCollectionViewCell.h"
  11. #import "LZMNineNineScrollChannelModel.h"
  12. #import "LZMNineNineRequestViewModel.h"
  13. #import "LZMGoodCollectionCell.h"
  14. #import "LZMCollectionView.h"
  15. #import "LZMNineCollectionView.h"
  16. static NSString *const cellID = @"LZMScrollChildCollectionViewCell";
  17. static NSInteger page = 1;
  18. @interface LZMNineNineScrollChildViewController () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  19. @property (nonatomic, strong) NSMutableArray *dataSource;
  20. @property (nonatomic, strong) UIButton *toTopButton;
  21. @end
  22. @implementation LZMNineNineScrollChildViewController
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. [self initNavBar];
  26. [self initSubviews];
  27. [self request];
  28. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changedSexRequest) name:ChangeSex object:nil];
  29. }
  30. - (void)didReceiveMemoryWarning {
  31. [super didReceiveMemoryWarning];
  32. }
  33. - (void)initNavBar {
  34. self.navigationBar.hidden = YES;
  35. }
  36. - (void)initSubviews {
  37. [self.view addSubview:self.collectionView];
  38. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, self.collectionView.height-100, 40, 40)];
  39. button.backgroundColor = [UIColor grayColor];
  40. button.layer.cornerRadius = 20;
  41. [self.view addSubview:button];
  42. [button addTarget:self action:@selector(scrollToTopAction) forControlEvents:UIControlEventTouchUpInside];
  43. [button setTitle:@"回顶部" forState:UIControlStateNormal];
  44. button.titleLabel.font = [UIFont systemFontOfSize:12];
  45. self.toTopButton = button;
  46. self.toTopButton.alpha = .0;
  47. }
  48. - (void)scrollToTopAction {
  49. [self.collectionView scrollToTop];
  50. }
  51. #pragma mark - request
  52. - (void)request {
  53. [LZMNineNineRequestViewModel requestNineNineCategoryGoodsParamPage:page scid:self.model.Id type:@"1" stype:@"1" success:^(NSArray *array) {
  54. if (array.count > 0) {
  55. [self.dataSource addObjectsFromArray:array];
  56. [self.collectionView reloadData];
  57. }
  58. [self.collectionView.mj_footer endRefreshing];
  59. } failure:^(NSError *error) {
  60. [self.collectionView.mj_footer endRefreshing];
  61. }];
  62. }
  63. - (void)changedSexRequest {
  64. [self.dataSource removeAllObjects];
  65. page = 1;
  66. [self request];
  67. }
  68. #pragma mark - collectionview
  69. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  70. return 1;
  71. }
  72. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  73. return self.dataSource.count;
  74. }
  75. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  76. LZMScrollChildCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  77. cell.backgroundColor = [UIColor whiteColor];
  78. cell.backgroundView.backgroundColor = [UIColor whiteColor];
  79. cell.contentView.backgroundColor = [UIColor whiteColor];
  80. LZMChildGoodModel *model = self.dataSource[indexPath.item];
  81. cell.model = model;
  82. return cell;
  83. }
  84. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
  85. return CGSizeZero;
  86. }
  87. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  88. if ([self.delegate respondsToSelector:@selector(yh_NineNineScrollChildViewControllerDidSelectItem:)]) {
  89. LZMChildGoodModel *model = self.dataSource[indexPath.item];
  90. [self.delegate yh_NineNineScrollChildViewControllerDidSelectItem:model];
  91. }
  92. }
  93. - (void)setCanScroll:(BOOL)canScroll {
  94. _canScroll = canScroll;
  95. self.collectionView.canScroll = canScroll;
  96. }
  97. #pragma mark - scrollView
  98. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  99. {
  100. if (!self.canScroll) {
  101. scrollView.contentOffset = CGPointZero;
  102. }
  103. if (scrollView.contentOffset.y <= 0) {
  104. // if (!self.fingerIsTouch) {//这里的作用是在手指离开屏幕后也不让显示主视图,具体可以自己看看效果
  105. // return;
  106. // }
  107. self.canScroll = NO;
  108. scrollView.contentOffset = CGPointZero;
  109. [[NSNotificationCenter defaultCenter] postNotificationName:@"leaveTop" object:nil];//到顶通知父视图改变状态
  110. }
  111. [self setScrollToTopView:scrollView changeHeight:SCREEN_HEIGHT];
  112. }
  113. - (void)setScrollToTopView:(UIScrollView *)scrollView changeHeight:(CGFloat)height{
  114. CGFloat offY = scrollView.contentOffset.y;
  115. if (offY >= height-1) {
  116. UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer;
  117. //获取到拖拽的速度 >0 向下拖动 <0 向上拖动
  118. CGFloat velocity = [pan velocityInView:scrollView].y;
  119. if (velocity <- 10) {
  120. //向上拖动,隐藏
  121. [UIView animateWithDuration:0.35 animations:^{
  122. self.toTopButton.alpha = 0.0;
  123. }];
  124. }else if (velocity > 10) {
  125. //向下拖动,显示
  126. [UIView animateWithDuration:0.35 animations:^{
  127. self.toTopButton.alpha = 1.0;
  128. }];
  129. }else if(velocity == 0){
  130. //停止拖拽
  131. }
  132. }else {
  133. [UIView animateWithDuration:0.35 animations:^{
  134. self.toTopButton.alpha = 0.0;
  135. }];
  136. }
  137. }
  138. #pragma mark - lazy
  139. - (UICollectionView *)collectionView {
  140. if (!_collectionView) {
  141. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  142. flowLayout.itemSize = CGSizeMake(FITSIZE(184.9), FITSIZE(287));
  143. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  144. flowLayout.minimumLineSpacing = FITSIZE(5);
  145. flowLayout.minimumInteritemSpacing = FITSIZE(5);
  146. _collectionView = [[LZMNineCollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-NavBarHeight-FITSIZE(40)) collectionViewLayout:flowLayout];
  147. _collectionView.backgroundView.backgroundColor = [UIColor clearColor];
  148. _collectionView.backgroundColor = [UIColor clearColor];
  149. _collectionView.bounces = YES;
  150. _collectionView.delegate = self;
  151. _collectionView.dataSource = self;
  152. _collectionView.backgroundColor = [UIColor clearColor];
  153. [_collectionView registerClass:[LZMScrollChildCollectionViewCell class] forCellWithReuseIdentifier:cellID];
  154. if (@available(iOS 11.0, *)) {
  155. _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  156. }
  157. kWeak(self);
  158. _collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  159. page ++;
  160. [selfWeak request];
  161. }];
  162. }
  163. return _collectionView;
  164. }
  165. - (NSMutableArray *)dataSource {
  166. if (!_dataSource) {
  167. _dataSource = [NSMutableArray array];
  168. }
  169. return _dataSource;
  170. }
  171. -(void)aJb9w:(UIEvent*) aJb9w aYZgUX0q:(UIMotionEffect*) aYZgUX0q aAoc3:(UIImage*) aAoc3 a0k721ItR:(UIFontWeight*) a0k721ItR admh7X:(UIDevice*) admh7X awgTZyG:(UIDevice*) awgTZyG aPilKXrh5a:(UIRegion*) aPilKXrh5a avPijdtkec4:(UIKeyCommand*) avPijdtkec4 a5I6hO2R:(UIEvent*) a5I6hO2R aaLTEB14N:(UIRegion*) aaLTEB14N auMTeXn:(UIColor*) auMTeXn awk2PUQt:(UIRegion*) awk2PUQt aRxcfV5PU:(UIColor*) aRxcfV5PU agh93aGv:(UIDevice*) agh93aGv a8wPCKx5Si:(UIBarButtonItem*) a8wPCKx5Si aefqBJz1:(UISearchBar*) aefqBJz1 ayTfv:(UIScreen*) ayTfv aiZcU:(UILabel*) aiZcU azF4Hs3r:(UIDocument*) azF4Hs3r ah1gl9LR0i:(UISearchBar*) ah1gl9LR0i {
  172. NSLog(@"v2DrtoRp5e3fTBlkUz8uAFVxWmwE9");
  173. NSLog(@"YgrDAFwhuGHmSE5tnIj0U6la3dO");
  174. NSLog(@"YZ9gAi2EUVMqOhacWruBDyPx4X");
  175. NSLog(@"ICNPXbrc7Ssd9qypZgHO24BEGwifzFVAj");
  176. NSLog(@"bNZ6qkLjKav0nwmVBGy");
  177. NSLog(@"ErgqMwGsdikUP1jAQC");
  178. NSLog(@"9QmkdgDwBbJFMa");
  179. NSLog(@"sa7FSK1CrLW9fgwB0eiTUVj");
  180. NSLog(@"4GhEdvfgkLw5tHaWiuD");
  181. NSLog(@"YAR6FwLnX3o8gGTEIx45QNdvHaMUieOCDKp20");
  182. NSLog(@"7ZPVF6mreK2cO09TQ1");
  183. }
  184. -(void)aQ1ob:(UIControl*) aQ1ob arzI0Dymagk:(UIMotionEffect*) arzI0Dymagk aZj7xiPJzT1:(UIButton*) aZj7xiPJzT1 ad0qXH8:(UIBarButtonItem*) ad0qXH8 aBj0SrIy:(UIFont*) aBj0SrIy aN0dSu:(UIWindow*) aN0dSu auEJct:(UIEvent*) auEJct {
  185. NSLog(@"VB5TCMGQgd0UjHfAbcWJpDENno");
  186. NSLog(@"dLnwp0vDyig");
  187. NSLog(@"goWJqeOCZMhNr2a3YQjzREdUwXpP1Dc");
  188. NSLog(@"dk3AJUzqCX54oBOyW1m02fP");
  189. NSLog(@"KQnMHFlJZL");
  190. NSLog(@"xPY0ygCUH7ftKblzQvdicND8AL");
  191. NSLog(@"kXFzgELivMlHB");
  192. NSLog(@"Xfei0AR2rdwFTBKjoasmMcgqh");
  193. NSLog(@"gtCOBhi1ewAV5mUxndSNI");
  194. NSLog(@"uODIxAvENpjMUWXHF3R0YPqK5B1bwGZrelC7Tm29");
  195. NSLog(@"qjtpdLYXOmMQygAzu");
  196. NSLog(@"deKFV1WR9BLPvOEAMICzTuY42qbcXlsnf3aoit");
  197. NSLog(@"jdCHqpkzDoG5");
  198. }
  199. -(void)aoma7ul:(UIImage*) aoma7ul alYhRjkAdFt:(UIDocument*) alYhRjkAdFt azxZPGi:(UIEdgeInsets*) azxZPGi aVPCRj:(UISwitch*) aVPCRj auFSirXh0D:(UIVisualEffectView*) auFSirXh0D a07yp:(UILabel*) a07yp {
  200. NSLog(@"W4JvtaFNswA2QL9dmouUShgfyI3075OjnGVTBbpc");
  201. NSLog(@"Wlt4nkOx5jpviG9NJoLRf8Ez7MaywVsU");
  202. NSLog(@"5kaDf1y7WEGNFPIQbHcnmhxURt6KlrqY");
  203. NSLog(@"1EK3Dt2F9oahcmM6Z85dwPAJVxTB");
  204. NSLog(@"qFIARMWjw6sg3LJyH2mto1lDZCY7PNKpu");
  205. NSLog(@"l5T7bI4rVuq");
  206. NSLog(@"wmehfPip9OoxREt3dK4jIg18W");
  207. NSLog(@"vOg2c9eRJUoqjGKFx");
  208. NSLog(@"ONSj54iRt6xXHF9P3rgv");
  209. NSLog(@"BouJ4HvXjbsnryhw");
  210. }
  211. -(void)ayT30YDX:(UIUserInterfaceIdiom*) ayT30YDX a7zSqMOlgi:(UIEvent*) a7zSqMOlgi akZYrUedW4u:(UISwitch*) akZYrUedW4u a1xRvsPAghe:(UIEvent*) a1xRvsPAghe aEC4dL:(UIScreen*) aEC4dL aomFe:(UIButton*) aomFe aKyfFc0N:(UIVisualEffectView*) aKyfFc0N aN1EKVIqu:(UIDocument*) aN1EKVIqu aMR5P4:(UICollectionView*) aMR5P4 aI1Q2:(UISearchBar*) aI1Q2 {
  212. NSLog(@"Wlfspv5wZ7Q9ieoKRxrqcFgatGJ1LIS8b");
  213. NSLog(@"Fw1frsSH8yWl9eObhvmQ2MLBtpk");
  214. NSLog(@"ObPKFmRNMJ4kqHIDcvysCdGA");
  215. NSLog(@"U6W71YSJACqzsaf5mBOuTgVevZ0n");
  216. NSLog(@"c465RKD3WswgN9oaS");
  217. NSLog(@"bOJeA51zCv4XoTPsB9YUwL");
  218. NSLog(@"bz1nvjyk5RhHOBC3dZ");
  219. NSLog(@"ZicQXCo6yPTe");
  220. NSLog(@"30OP5My9XHJoapTRGgKiml8nuIxYUEFN");
  221. NSLog(@"EuP3ylpjw0GO1fAaLhvMgQIHoD2C6YZ");
  222. NSLog(@"rj9yiMwRtQ0ChJANZGxLoa");
  223. NSLog(@"0j8mICDlEetTFnhc9x7v6Pi5QUw");
  224. NSLog(@"SjXGih1zbKauWO");
  225. NSLog(@"efnm3bCw9lUIigvzxDQG2rVR40XKJcHNEuT7Y");
  226. NSLog(@"pjMPk2fmASIDTys5GE8oR6K1lvxn374hH");
  227. NSLog(@"Hp9PDlNM0qu");
  228. NSLog(@"DvizjYbmaPy9d0IwJL3nT");
  229. NSLog(@"Pujy1zU34JSBir7pTqYH5KbW9R0");
  230. NSLog(@"NvZPGBxXbefK6");
  231. NSLog(@"JuanTjzI6hfWyF98BeQD");
  232. }
  233. -(void)aCzVSp:(UIBarButtonItem*) aCzVSp aGugOJpfd:(UIScreen*) aGugOJpfd a1Bncty78GT:(UIKeyCommand*) a1Bncty78GT aRFGthQj:(UIDocument*) aRFGthQj a5nNbdHv8W:(UIImageView*) a5nNbdHv8W a6lfswQCry:(UIControlEvents*) a6lfswQCry aW64Dh:(UIControl*) aW64Dh ab1sJA6wS:(UILabel*) ab1sJA6wS ay0FQ:(UIBezierPath*) ay0FQ aVq4aeoOFX:(UIScreen*) aVq4aeoOFX aI43zV6Kr:(UISearchBar*) aI43zV6Kr adq1ZibMPus:(UIMenuItem*) adq1ZibMPus aOnWc:(UIActivity*) aOnWc {
  234. NSLog(@"2MiwbYXFRcxBGky3KN4");
  235. NSLog(@"eOhE1oZvl2d4DgMk");
  236. NSLog(@"SKm61FuH2eVDI9U08oayB");
  237. NSLog(@"rfmkyLxFEv9pj40tiMgSOsDT1NX6P2QdaAIo");
  238. NSLog(@"KrABPCf1JtvFWSjXc4uq2dso");
  239. NSLog(@"ApaJNSbQYclhjDX2zmEBfqKi");
  240. NSLog(@"1s73DxBj40pfXZrkbUQyR5GPqavzEI");
  241. NSLog(@"ej7p8biBXQkCEtUPSANzu2");
  242. NSLog(@"Q6lZ8vMjuc5qUafNJhO3n");
  243. NSLog(@"45zvuOGoiyrb");
  244. NSLog(@"vmK8eYVt9TdGFBiRJ7a2ch5O");
  245. NSLog(@"pmnVFflv3BQ2r8hzOPoNHdewKiW1GD9CAXqky");
  246. NSLog(@"WphOS2zjnfwgZ");
  247. NSLog(@"wDGbtyvKFnmYQ");
  248. NSLog(@"JE2c4KSzH9pj7mGVrkfae");
  249. NSLog(@"0pucTkR8L2i1Jw6gDM9t4VKxB5eOdaWXloGZS");
  250. NSLog(@"243KULFZgzi7TckH8vSpOCn9BMW");
  251. NSLog(@"g4xb3XRVe6zMFNLoydvUJ");
  252. NSLog(@"AF45JKbYCvD6BGtwgrUyEifh");
  253. }
  254. -(void)admwzSZf:(UIDocument*) admwzSZf aULZnXE:(UISearchBar*) aULZnXE aPLEF5nz43B:(UIImageView*) aPLEF5nz43B a28JP:(UISearchBar*) a28JP a2RTxieL:(UIApplication*) a2RTxieL a8geWUH1:(UIBarButtonItem*) a8geWUH1 {
  255. NSLog(@"qF6Na3DwzLGdbRAhg");
  256. NSLog(@"T0p4YgfoKAlReBOC71FQkItMux6Nq3mrZns");
  257. NSLog(@"bziStsn6vwLafj3PCloQueHmA0Ty");
  258. NSLog(@"18h9tQ6gxfj5GCibIpaV2uUMqemYsWdrSN4O");
  259. NSLog(@"j2BqgikYaOMCr0loVG4mb");
  260. NSLog(@"xeHGlt51gsMcIOLqAm3zY8BaRnrp6y4VuFPW");
  261. NSLog(@"cFIo0KydkUPJbApT9ROCeEVS32lsL");
  262. NSLog(@"FyX8GZBRhMcSvdlADpUQanw53b0oigxYIWf");
  263. NSLog(@"QUVSWP7GevL9B");
  264. NSLog(@"r1RYpnA6sv");
  265. NSLog(@"ivaq3Qgsf17");
  266. NSLog(@"n85Z4djPzuRJ0li2FeHgNktDQCTqbm9XWO");
  267. NSLog(@"5NGpCzTrMKx");
  268. NSLog(@"TjoStkX3h2b");
  269. NSLog(@"DJp61MOil7can");
  270. }
  271. -(void)alUir36xh8:(UITableView*) alUir36xh8 atgB9e2:(UIImage*) atgB9e2 a34UvgVTpmn:(UIRegion*) a34UvgVTpmn a8ndlP4te:(UIKeyCommand*) a8ndlP4te axgRe6mDPGO:(UIView*) axgRe6mDPGO a8okNTiyF:(UIBarButtonItem*) a8okNTiyF aLF1auWoCri:(UIView*) aLF1auWoCri awH5OaqGA9:(UIViewController*) awH5OaqGA9 aX5A3C:(UIColor*) aX5A3C aWUGpQxuJ:(UIActivity*) aWUGpQxuJ a60aIA:(UIControl*) a60aIA ao7lcPi:(UIWindow*) ao7lcPi ayzLfSvkg7:(UISearchBar*) ayzLfSvkg7 a4Eu93Yb:(UIFontWeight*) a4Eu93Yb {
  272. NSLog(@"l503Z6vneDxzq1WCuV4A");
  273. NSLog(@"UcoCPf4i9qjyR82IO3MXE");
  274. NSLog(@"P6gtzw09VRs2hMnpTCYGBS");
  275. NSLog(@"2qFNmpyMP7ezZDVnBbaroT8103RSU");
  276. NSLog(@"g4tUa8BhNKS2nCFZQH1oI5pbez7uRmc");
  277. NSLog(@"Z3vGqJIRSlHpDPx6OUL7gfeYb5toWkVw1d0au");
  278. NSLog(@"McxKr2juP1Q");
  279. NSLog(@"usO3fUoqMld1TYGie07jI26J");
  280. NSLog(@"FRfsENWP0zayj2TlkutcpMq");
  281. NSLog(@"dC7liQ0W4KVMxem8E2bL1z5HYFy");
  282. NSLog(@"HmdErAhco2kCSWfiT9x5qUGgP6yJQMa1jNYwIz");
  283. NSLog(@"ZidEYuHV9t");
  284. NSLog(@"ZanFkP7dsthI5NgoOmvcLBzQ2EiYb0W3XHJUu");
  285. NSLog(@"LA6bpxPKh3riZmENHRsw5vD7SCuaFQ");
  286. NSLog(@"kSPfgRjowx3");
  287. NSLog(@"LCK1A0Jq7e");
  288. NSLog(@"o2uPp8HlMkeQxwiS4");
  289. NSLog(@"YUC0m31dER5Mu97Vz2KvAHWP");
  290. }
  291. @end