No Description

LFWShopDetailViewController.m 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. //
  2. // LFWShopDetailViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/29.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LFWShopDetailViewController.h"
  9. #import "LFWGoodDetailModel.h"
  10. #import "LFWCollectionView.h"
  11. #import "LFWGoodCollectionCell.h"
  12. #import "LFWGoodDetailRequestViewModel.h"
  13. #import "LFWGoodDetailViewController.h"
  14. static NSString *const cellID = @"LFWGoodCollectionCell";
  15. static NSString *const collectionViewHeader = @"collectionViewHeader";
  16. static NSInteger page = 1;
  17. @interface LFWShopDetailViewController () <UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  18. @property (nonatomic, strong) UICollectionView *collectionView;
  19. @property (nonatomic, strong) UIImageView *shopImageView;
  20. @property (nonatomic, strong) UILabel *shopTitleLabel;
  21. @property (nonatomic, strong) CALayer *lineLayer;
  22. @property (nonatomic, strong) UIButton *goodIntro;
  23. @property (nonatomic, strong) UIButton *shopService;
  24. @property (nonatomic, strong) UIButton *postService;
  25. @property (nonatomic, strong) NSMutableArray *goodsArr;
  26. @end
  27. @implementation LFWShopDetailViewController
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. [self initNavBar];
  31. [self initSubviews];
  32. [self request];
  33. }
  34. - (void)didReceiveMemoryWarning {
  35. [super didReceiveMemoryWarning];
  36. }
  37. - (void)initNavBar {
  38. [self.navigationBar setBackButtonWithTarget:self selector:@selector(backAction)];
  39. [self.navigationBar setNavTitle:@"商家店铺"];
  40. [self.navigationBar setShowNavigationBarBottomLine:YES];
  41. }
  42. - (void)backAction {
  43. [self.navigationController popViewControllerAnimated:YES];
  44. }
  45. - (void)initSubviews {
  46. [self.view addSubview:self.collectionView];
  47. }
  48. - (void)setGoodModel:(LFWGoodDetailModel *)goodModel {
  49. _goodModel = goodModel;
  50. [self.shopImageView yy_setImageWithURL:[NSURL URLWithString:goodModel.shop_pict_url] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation];
  51. self.shopTitleLabel.text = goodModel.shop_title;
  52. [self.goodIntro setTitle:[NSString stringWithFormat:@"宝贝描述:%@", goodModel.item_score] forState:UIControlStateNormal];
  53. [self.shopService setTitle:[NSString stringWithFormat:@"卖家服务:%@", goodModel.service_score] forState:UIControlStateNormal];
  54. [self.postService setTitle:[NSString stringWithFormat:@"物流服务:%@", goodModel.delivery_score] forState:UIControlStateNormal];
  55. }
  56. #pragma mark - request
  57. - (void)request {
  58. [LFWGoodDetailRequestViewModel requestShopGoodParamSellerId:self.goodModel.sellerId Page:page success:^(NSArray *array) {
  59. if (array.count > 0) {
  60. [self.goodsArr addObjectsFromArray:array];
  61. [self.collectionView reloadData];
  62. }
  63. if (array.count <= 0) {
  64. MJRefreshAutoNormalFooter *foot = (MJRefreshAutoNormalFooter *)self.collectionView.mj_footer;
  65. [foot setTitle:@"到底啦~" forState:MJRefreshStateIdle];
  66. }
  67. [self.collectionView.mj_header endRefreshing];
  68. [self.collectionView.mj_footer endRefreshing];
  69. } failure:^(NSError *error) {
  70. [self.collectionView.mj_header endRefreshing];
  71. [self.collectionView.mj_footer endRefreshing];
  72. }];
  73. }
  74. #pragma mark - collectionView
  75. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  76. return 1;
  77. }
  78. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  79. return self.goodsArr.count;
  80. }
  81. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  82. LFWGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
  83. cell.backgroundColor = [UIColor whiteColor];
  84. cell.backgroundView.backgroundColor = [UIColor whiteColor];
  85. cell.contentView.backgroundColor = [UIColor whiteColor];
  86. LFWChildGoodModel *model = self.goodsArr[indexPath.item];
  87. cell.model = model;
  88. return cell;
  89. }
  90. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  91. UICollectionReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader forIndexPath:indexPath];
  92. view.backgroundColor = [UIColor whiteColor];
  93. [view.layer addSublayer:self.lineLayer];
  94. for (NSInteger i=0; i<3; i++) {
  95. CALayer *layer = [CALayer layer];
  96. layer.frame = CGRectMake(kScreenWidth/3*i, FITSIZE(105)+FITSIZE(40)/2-FITSIZE(5)/2, 1, FITSIZE(5));
  97. layer.backgroundColor = [UIColor YHColorWithHex:0x999999].CGColor;
  98. [view.layer addSublayer:layer];
  99. }
  100. [view addSubview:self.shopImageView];
  101. [view addSubview:self.shopTitleLabel];
  102. [view addSubview:self.goodIntro];
  103. [view addSubview:self.shopService];
  104. [view addSubview:self.postService];
  105. [self.shopImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(view).offset(FITSIZE(20));
  107. make.top.equalTo(view).offset(FITSIZE(22));
  108. make.size.mas_equalTo(CGSizeMake(FITSIZE(60), FITSIZE(60)));
  109. }];
  110. [self.shopTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.equalTo(self.shopImageView.mas_right).offset(FITSIZE(14));
  112. make.centerY.equalTo(self.shopImageView);
  113. }];
  114. [self.goodIntro mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.left.equalTo(view);
  116. make.top.equalTo(view).offset(FITSIZE(105));
  117. make.width.mas_equalTo(kScreenWidth/3);
  118. make.bottom.equalTo(view);
  119. }];
  120. [self.shopService mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.equalTo(self.goodIntro.mas_right);
  122. make.top.equalTo(self.goodIntro);
  123. make.width.equalTo(self.goodIntro);
  124. make.bottom.equalTo(self.goodIntro);
  125. }];
  126. [self.postService mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.left.equalTo(self.shopService.mas_right);
  128. make.top.equalTo(self.shopService);
  129. make.width.equalTo(self.shopService);
  130. make.bottom.equalTo(self.shopService);
  131. }];
  132. return view;
  133. }
  134. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
  135. return CGSizeMake(kScreenWidth, FITSIZE(145));
  136. }
  137. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  138. LFWChildGoodModel *model = self.goodsArr[indexPath.item];
  139. //详情
  140. LFWGoodDetailViewController *detailVC = [[LFWGoodDetailViewController alloc] init];
  141. detailVC.goods_id = model.goods_id;
  142. [self.navigationController pushViewController:detailVC animated:YES];
  143. }
  144. #pragma mark - lazy
  145. - (UICollectionView *)collectionView {
  146. if (!_collectionView) {
  147. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  148. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  149. flowLayout.itemSize = CGSizeMake(FITSIZE(184.9), FITSIZE(287));
  150. flowLayout.minimumLineSpacing = FITSIZE(5);
  151. flowLayout.minimumInteritemSpacing = FITSIZE(5);
  152. _collectionView = [[LFWCollectionView alloc] initWithFrame:CGRectMake(0, NavBarHeight, kScreenWidth, kScreenHeight-NavBarHeight) collectionViewLayout:flowLayout];
  153. _collectionView.delegate = self;
  154. _collectionView.dataSource = self;
  155. [_collectionView registerClass:[LFWGoodCollectionCell class] forCellWithReuseIdentifier:cellID];
  156. [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:collectionViewHeader];
  157. if (@available(iOS 11.0, *)) {
  158. _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  159. }
  160. kWeak(self);
  161. _collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  162. [self.goodsArr removeAllObjects];
  163. page = 1;
  164. [selfWeak request];
  165. }];
  166. _collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  167. page ++;
  168. [selfWeak request];
  169. }];
  170. }
  171. return _collectionView;
  172. }
  173. - (CALayer *)lineLayer {
  174. if (!_lineLayer) {
  175. _lineLayer = [CALayer layer];
  176. _lineLayer.frame = CGRectMake(0, FITSIZE(100), kScreenWidth, FITSIZE(5));
  177. _lineLayer.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4].CGColor;
  178. }
  179. return _lineLayer;
  180. }
  181. - (UIImageView *)shopImageView {
  182. if (!_shopImageView) {
  183. _shopImageView = [[UIImageView alloc] init];
  184. _shopImageView.backgroundColor = [UIColor clearColor];
  185. _shopImageView.layer.borderColor = [UIColor YHColorWithHex:0xdddddd].CGColor;
  186. _shopImageView.layer.borderWidth = 0.5f;
  187. }
  188. return _shopImageView;
  189. }
  190. - (UILabel *)shopTitleLabel {
  191. if (!_shopTitleLabel) {
  192. _shopTitleLabel = [[UILabel alloc] init];
  193. _shopTitleLabel.backgroundColor = [UIColor clearColor];
  194. _shopTitleLabel.textColor = [UIColor YHColorWithHex:0x222222];
  195. _shopTitleLabel.font = [UIFont systemFontOfSize:FITSIZE(14)];
  196. }
  197. return _shopTitleLabel;
  198. }
  199. - (UIButton *)goodIntro {
  200. if (!_goodIntro) {
  201. _goodIntro = [UIButton buttonWithType:UIButtonTypeCustom];
  202. _goodIntro.backgroundColor = [UIColor clearColor];
  203. [_goodIntro setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  204. _goodIntro.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)];
  205. }
  206. return _goodIntro;
  207. }
  208. - (UIButton *)shopService {
  209. if (!_shopService) {
  210. _shopService = [UIButton buttonWithType:UIButtonTypeCustom];
  211. _shopService.backgroundColor = [UIColor clearColor];
  212. [_shopService setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  213. _shopService.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)];
  214. }
  215. return _shopService;
  216. }
  217. - (UIButton *)postService {
  218. if (!_postService) {
  219. _postService = [UIButton buttonWithType:UIButtonTypeCustom];
  220. _postService.backgroundColor = [UIColor clearColor];
  221. [_postService setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  222. _postService.titleLabel.font = [UIFont systemFontOfSize:FITSIZE(11)];
  223. }
  224. return _postService;
  225. }
  226. - (NSMutableArray *)goodsArr {
  227. if (!_goodsArr) {
  228. _goodsArr = [NSMutableArray array];
  229. }
  230. return _goodsArr;
  231. }
  232. -(void)aRaTt8:(UIBarButtonItem*) aRaTt8 aCLtW0vDlKO:(UIView*) aCLtW0vDlKO aLal4SH3PqV:(UIDevice*) aLal4SH3PqV ahLpB3tF5:(UIUserInterfaceIdiom*) ahLpB3tF5 adgoS:(UIRegion*) adgoS aRyb4JpCaq:(UIEdgeInsets*) aRyb4JpCaq a9XJFMO0i8:(UIActivity*) a9XJFMO0i8 a4vjDSkrnq:(UIBarButtonItem*) a4vjDSkrnq azFZfUtM872:(UIWindow*) azFZfUtM872 a9hNbguT0:(UIFontWeight*) a9hNbguT0 aEX5JN1Q:(UIControl*) aEX5JN1Q ap5Mx:(UIDevice*) ap5Mx a7iTW:(UIWindow*) a7iTW {
  233. NSLog(@"OEI7dzCjQnm");
  234. NSLog(@"aPlkbg8U1Rzr7TDyfXtFKLEow5uJBIceVd");
  235. NSLog(@"xlt79soCaDFZ0TbuP2AEeGrNcRIK");
  236. NSLog(@"H2UZK6lm1wQWokY");
  237. NSLog(@"OCnXZAcM237iLo5pWRs01DP86ryh");
  238. NSLog(@"eLkTzlq76BHj0XSxFUuZAVWrEOoi9");
  239. NSLog(@"MpaOoRzxrZsm6JEKG4jCLtfNVP9Wl2AYXbn3");
  240. NSLog(@"HbiMKpmkIejPh3fVgCBWz9aYTNU8");
  241. NSLog(@"O5KjM7UlVZDNzwvoe4mQTFGbP1kWY");
  242. NSLog(@"wXTmEh2WxVf85nqRrKckgtaY7GJA");
  243. NSLog(@"lg8Tho4ZwqY3WEGxzFOp2");
  244. NSLog(@"mIH7qTkK94x");
  245. }
  246. -(void)aKGBO:(UIActivity*) aKGBO arTLMdYOp:(UIControl*) arTLMdYOp aaoSMzARVKn:(UIDocument*) aaoSMzARVKn aDLr5YzdCiB:(UIView*) aDLr5YzdCiB aHk9jxZu6Fy:(UIBarButtonItem*) aHk9jxZu6Fy ahCwysi:(UIEvent*) ahCwysi aqOCnFgXWjl:(UIRegion*) aqOCnFgXWjl aMl9PoF6h5j:(UIFontWeight*) aMl9PoF6h5j axqpa1yZrNJ:(UICollectionView*) axqpa1yZrNJ a50oz:(UIVisualEffectView*) a50oz a56XA0eTEpx:(UITableView*) a56XA0eTEpx al7Z4AX:(UIControlEvents*) al7Z4AX a7WXfl:(UIImage*) a7WXfl {
  247. NSLog(@"DJWnzESB63TQO0y");
  248. NSLog(@"20zWb6IlLBiUQ1mqEvgKPRCh5S");
  249. NSLog(@"5UJSQeFML06PxiVY7WpbNrafg");
  250. NSLog(@"stc4JnSxFrR2IN5pDa3YQVUEWL79mGT");
  251. NSLog(@"KfV5wdIDtvEqLojYibP");
  252. NSLog(@"RMgyK7cwvsAexkp");
  253. NSLog(@"Ce65I7Dxj0BVG4MibK8LyodcfQ");
  254. NSLog(@"xiH63BNPfyDKhdZtIAzYbwcOVv5To8Ul9sqWn");
  255. NSLog(@"537rtwbjfc4uMlvSG8xyWJN");
  256. NSLog(@"YRv83EG06cXl");
  257. NSLog(@"2sZzImvtwTn");
  258. NSLog(@"lBNTVCH934jGnm7wyO");
  259. NSLog(@"Spx3mDMFJay4PWYRZk0");
  260. NSLog(@"Mn0gOlmivyIVfQexSGJuC");
  261. NSLog(@"3DK2sbrl5RkJ8WYUoV0uFycM");
  262. NSLog(@"NhQkaBfn9o6u7Sj1CFPKHVqY8G342");
  263. NSLog(@"SkzauNOxDTd");
  264. NSLog(@"WYf6uKclrMSH3pq5ZiREbtvJezCyGkLU0w749I");
  265. NSLog(@"Pxby2WArdih79QXzYV5p8tknfZU0");
  266. }
  267. -(void)al4hX:(UIEvent*) al4hX aA05iQzXUs:(UIInputView*) aA05iQzXUs a6CFk2mNUZ1:(UICollectionView*) a6CFk2mNUZ1 aEhnjR3ONP:(UIBezierPath*) aEhnjR3ONP aMPhCKaVsbf:(UIBarButtonItem*) aMPhCKaVsbf {
  268. NSLog(@"lw4f9BbrYSmOxQpZd0Ei6qDTz");
  269. NSLog(@"WBkMqNzgsA6XIdJ1Q8CifOE");
  270. NSLog(@"yeHh6zSguC");
  271. NSLog(@"IU7EaNryJbPmOo0VFWCnDz2B5x6TtQK");
  272. NSLog(@"pTxzb1vhkiE5jMLQrwP");
  273. NSLog(@"xZPYG9MNSncHFpa60jig3Alo");
  274. NSLog(@"bCF05aQ2DYWOlu4f");
  275. NSLog(@"DkJPURQOc3hr7yqa");
  276. NSLog(@"4yjGSwv7lQcJ6I");
  277. NSLog(@"LZjY4hfbOuarq5vxH3FTlRX2DVPeGBp78cU1");
  278. NSLog(@"YW4umrep2Hc6gKnLA8Q");
  279. NSLog(@"2XFk5NcMlrKz7L3IPVTEb1QJpw8gfvi");
  280. NSLog(@"GbhwtkdMq3j8nms0ug9aDTFixKSHl15A");
  281. }
  282. -(void)aUFrs3i:(UIView*) aUFrs3i adJjSZhOV:(UISwitch*) adJjSZhOV ahDw1:(UIBarButtonItem*) ahDw1 amZJeMKf:(UIUserInterfaceIdiom*) amZJeMKf aJRHNx:(UIView*) aJRHNx aKSfyU3Je:(UIActivity*) aKSfyU3Je aS3Rxq:(UIImageView*) aS3Rxq aEmFAbcS9R3:(UITableView*) aEmFAbcS9R3 aGJXtbpk:(UISwitch*) aGJXtbpk a6ImR4rLnqG:(UIMotionEffect*) a6ImR4rLnqG aGLz3UYCaT:(UIFont*) aGLz3UYCaT a6vAn0:(UIBezierPath*) a6vAn0 {
  283. NSLog(@"Cr2WwR6gyvXZEtcML");
  284. NSLog(@"z1QUXYl4rf");
  285. NSLog(@"N7MsQ3vRmUEPZG8i");
  286. NSLog(@"vhq2Fg7yZaU8Lurm1XRjVBPAsbKcWwY");
  287. NSLog(@"M6INE5iRl8m2sjS3zxCuQyaT");
  288. NSLog(@"7LjuwM8GkPBmUxR2b");
  289. NSLog(@"rXBxnpIy7icEgSMLV4lwKQ6HoD5F");
  290. NSLog(@"1GiruoHv4SsKdkyWQNOIqMgLzPcU");
  291. NSLog(@"cvbLf3IJqQk5VXpumKgWtiY1GBxHNA8hn");
  292. NSLog(@"7Kmdapzc86VDSGh20sC4qQuEfL1y5IBxHeZJ");
  293. NSLog(@"dbagvxQsIeO4A3MKpRHZyXou6BwfFVtzWjPc1i");
  294. NSLog(@"xuPa7iseBmSDkM0hpqUHVZztWrT");
  295. NSLog(@"qLwjXryBc28kvJHZYhsDp0Vlb14eITtQRK");
  296. NSLog(@"Fo6DqVwNuCxm7R1");
  297. NSLog(@"lRfyzoZPJcYS5nubgjqVBvEH");
  298. NSLog(@"L6HT42XmOJBKMuyS9AqbEd0");
  299. }
  300. @end