新UI马甲包

HCMineMainViewController.m 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. //
  2. // HCMineMainViewController.m
  3. // hc
  4. //
  5. // Created by xiaoxi on 2018/1/16.
  6. // Copyright © 2018年 hc. All rights reserved.
  7. //
  8. #import "HCMineMainViewController.h"
  9. #import "HFStretchableTableHeaderView.h"
  10. #import "HCLoginViewController.h"
  11. #import "HCCollectionViewController.h"
  12. #import "HCSettingViewController.h"
  13. #import "HCMyTicketViewController.h"
  14. #import "HCMyOrderViewController.h"
  15. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  16. #import "HCBrowserHistoryController.h"
  17. #import "HCFeedbackController.h"
  18. #import <StoreKit/StoreKit.h>
  19. #import "HCFindBookWebViewController.h"
  20. #import "UITableViewCell+Cc_CornRadio.h"
  21. #import "HCFourButtonView.h"
  22. #import "HCShopCarViewController.h"
  23. #import "CCActionSheet.h"
  24. #import "HCMineBlanceView.h"
  25. #import "HCMineOrderView.h"
  26. #import "HCMoreMenuView.h"
  27. #import "HCOrderMainViewController.h"
  28. #import "HCOrderMainViewController.h"
  29. #import "HCCommissionMainViewController.h"
  30. #import "HCMyFansViewController.h"
  31. #import "HCMyCollectionViewController.h"
  32. #import "HCInviteFansViewController.h"
  33. #import "HCMessageListController.h"
  34. #import "HCUserInfo.h"
  35. #import "HCUserInfoView.h"
  36. #import "HCCollectionMainViewController.h"
  37. #import "HCLinkFansController.h"
  38. #import "HCPrivilegeReferralViewController.h"
  39. #import "HCUserInfo.h"
  40. #import "HCMonthMainViewController.h"
  41. #import "HCMineAdView.h"
  42. #import "HCAccountDetailController.h"
  43. #import "AdPopModel.h"
  44. #import "AdJumpManager.h"
  45. #import "UIView+BABadgeView.h"
  46. #import "HCBuyLimitMainController.h"
  47. #import "HCHistoryViewController.h"
  48. #import "HCUserView.h"
  49. #import "HCWebDetailController.h"
  50. #import "AdJumpManager.h"
  51. #import "HCGoodDetailViewController.h"
  52. #import "HCGoodCollectionCell.h"
  53. #import "CCAlertShowView.h"
  54. #import "HCPushAlertView.h"
  55. #import "HCFiveStartAlertView.h"
  56. #import "HCUpdateAlertView.h"
  57. #import "HCTitleMoreMeunView.h"
  58. #import "HCMineRecomGoodsView.h"
  59. #import "HCMyCoupleViewController.h"
  60. #import "HCGoodCollectionCell.h"
  61. #import "HCSignInViewController.h"
  62. #import "HCShopCarViewController.h"
  63. #import "UIView+SDAutoLayout.h"
  64. #import "HCMyOrderViewController.h"
  65. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  66. #import <AlibabaAuthSDK/ALBBSession.h>
  67. #import <AlibabaAuthSDK/ALBBSDK.h>
  68. #import "HCMineHeadView.h"
  69. #import "HCGoodHorzitolCollectionCell.h"
  70. #import "HCFindRequestViewModel.h"
  71. static NSString *KHorizontalCellId = @"KHorizontalCellId";
  72. static NSString *KYHGoodCollectionCell = @"KYHGoodCollectionCell";
  73. @interface HCMineMainViewController ()
  74. <
  75. CCActionSheetDelegate,
  76. YHMineFourButtonViewDelegate,
  77. YHMoreMenuViewDelegate,
  78. KBTitleMoreMenuViewDelegate,
  79. UICollectionViewDelegate,
  80. UICollectionViewDataSource,
  81. UICollectionViewDelegateFlowLayout
  82. >{
  83. UIView *_saveView;
  84. NSInteger _youLikePage;
  85. BOOL isAdd;
  86. }
  87. @property (nonatomic, strong) UIView *header;
  88. @property (nonatomic, strong) UIImageView *headerImg;
  89. @property (nonatomic, strong) HCMoreMenuView *topMenuView;
  90. @property (nonatomic, strong) HCTitleMoreMeunView *bottomMenuView;
  91. @property (nonatomic, strong) HCMineRecomGoodsView *recomGoodsView;
  92. @property (nonatomic, strong) HCMineAdView *adView;
  93. @property (nonatomic, strong) UIButton *messageBtn;
  94. @property (nonatomic, strong) HCUserInfo *userInfo;
  95. @property (nonatomic, strong) HCUserView *userView;
  96. @property (nonatomic, strong) YYLabel *totalSaveMoney;
  97. /*dataSource**/
  98. @property (nonatomic, strong) NSArray *cellData;
  99. @property (nonatomic, strong) NSArray *sexArr;
  100. @property(nonatomic,strong)UICollectionView *collections;
  101. @property (nonatomic, strong) UIView *leftLine;
  102. @property (nonatomic, strong) UIView *rightLine;
  103. @property (nonatomic, strong) UILabel *titleLabel;
  104. @property (nonatomic, strong) NSMutableArray *youLikeArr;
  105. @end
  106. @implementation HCMineMainViewController
  107. - (void)requestYouLikeData {
  108. [HCFindRequestViewModel requestGuessYouLikeParamPage:_youLikePage success:^(NSArray *array) {
  109. [self.youLikeArr addObjectsFromArray:array];
  110. [self.collections reloadData];
  111. [self noMoreDataWithArray:array];
  112. [self endRefreshing];
  113. if (self.youLikeArr.count != 0) {
  114. [self initSubViews];
  115. }
  116. } failure:^(NSError *error) {
  117. [MBProgressHUD showMessage:@"网络错误"];
  118. [SVProgressHUD dismiss];
  119. [self endRefreshing];
  120. }];
  121. }
  122. - (void)noMoreDataWithArray:(NSArray *)array {
  123. if (array.count <= 0) {
  124. MJRefreshAutoNormalFooter *foot = (MJRefreshAutoNormalFooter *)self.collections.mj_footer;
  125. [foot setTitle:@"到底啦" forState:MJRefreshStateIdle];
  126. }
  127. }
  128. - (void)endRefreshing {
  129. [self.collections.mj_header endRefreshing];
  130. [self.collections.mj_footer endRefreshing];
  131. }
  132. - (void)viewWillDisappear:(BOOL)animated {
  133. [super viewWillDisappear:animated];
  134. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  135. }
  136. - (void)viewDidAppear:(BOOL)animated {
  137. [super viewDidAppear:animated];
  138. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  139. }
  140. - (void)viewWillAppear:(BOOL)animated {
  141. [super viewWillAppear:animated];
  142. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  143. [self loadUserInfo];
  144. if ([AccountTool isLogin]) {
  145. [self checkForNewMessage];
  146. }
  147. }
  148. - (void)viewDidLoad {
  149. [super viewDidLoad];
  150. _youLikePage = 1;
  151. isAdd = YES;
  152. [self configNavightion];
  153. [self configTableView];
  154. [self loadAdData];
  155. [self requestYouLikeData];
  156. }
  157. - (void)configNavightion {
  158. self.navigationBar.backgroundColor = [UIColor clearColor];
  159. self.navigationBar.hidden = YES;
  160. }
  161. - (void)configTableView {
  162. [self.view addSubview:self.collections];
  163. __weak typeof(self) weakSelf = self;
  164. //头部背景图
  165. self.headerImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,KStatusBarHeight+Fitsize(130))];
  166. self.headerImg.userInteractionEnabled = YES;
  167. self.headerImg.clipsToBounds = YES;
  168. self.header.layer.masksToBounds = YES;
  169. self.headerImg.contentMode = UIViewContentModeScaleAspectFill;
  170. //头视图
  171. self.header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Fitsize(260))];
  172. self.headerImg.image = [UIImage imageNamed:@"mine_top_bg"];
  173. [self.header addSubview:self.headerImg];
  174. //上边的多菜单
  175. NSArray *buttons = @[@{@"title":@"我的优惠券",@"image":@"youhuiquan"},
  176. @{@"title":@"我的收藏",@"image":@"shoucang"},
  177. @{@"title":@"我的订单",@"image":@"dingdan"},
  178. @{@"title":@"浏览记录",@"image":@"liulanjilu"}];
  179. self.topMenuView = [[HCMoreMenuView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, (SCREEN_WIDTH-20)/4) buttonInfoArray:buttons];
  180. self.topMenuView.delelgate = self;
  181. [self.header addSubview:self.topMenuView];
  182. [self.topMenuView mas_updateConstraints:^(MASConstraintMaker *make) {
  183. make.top.mas_equalTo(self.headerImg.height-30);
  184. make.left.mas_equalTo(10);
  185. make.right.mas_equalTo(-10);
  186. make.height.mas_equalTo((SCREEN_WIDTH-20)/4);
  187. }];
  188. //用户信息
  189. self.userView = [[HCUserView alloc] initWithFrame:CGRectMake(25, 0, SCREEN_WIDTH-3, 95)];
  190. self.userView.centerY = KStatusBarHeight + (self.headerImg.height-KStatusBarHeight)/2+10;
  191. self.userView.tapActionBlock = ^{
  192. if ([AccountTool isLogin]) {
  193. [weakSelf settingAction];
  194. }else {
  195. [weakSelf goToLoginPage];
  196. }
  197. };
  198. [self.headerImg addSubview:self.userView];
  199. //消息按钮
  200. UIButton *msgButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, KStatusBarHeight, 40, 40)];
  201. [msgButton setImage:[UIImage imageNamed:@"xiaoxi"] forState:UIControlStateNormal];
  202. [msgButton addTarget:self action:@selector(gotoMyMessagesPage) forControlEvents:UIControlEventTouchUpInside];
  203. self.messageBtn = msgButton;
  204. [msgButton ba_addDotWithColor:[UIColor whiteColor]];
  205. [msgButton ba_moveBadgeWithX:-12 Y:15];
  206. [self.headerImg addSubview:msgButton];
  207. //消息按钮
  208. UIButton *setButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-100, KStatusBarHeight, 40, 40)];
  209. [setButton setImage:[UIImage imageNamed:@"shezhi"] forState:UIControlStateNormal];
  210. [setButton addTarget:self action:@selector(settingAction) forControlEvents:UIControlEventTouchUpInside];
  211. [self.headerImg addSubview:setButton];
  212. if (@available(iOS 11.0, *)) {
  213. self.collections.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
  214. }else {
  215. self.automaticallyAdjustsScrollViewInsets = NO;
  216. }
  217. }
  218. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  219. {
  220. //
  221. // CGFloat yOffset = scrollView.contentOffset.y;
  222. //
  223. // if(yOffset < 0)
  224. // {
  225. // self.headerImg.y = yOffset;
  226. // self.headerImg.height = 170+ABS(yOffset);
  227. // }
  228. }
  229. #pragma mark ============ UICollectionView Delegate && DataSource ==========
  230. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  231. {
  232. return self.youLikeArr.count;
  233. }
  234. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  235. return 1;
  236. }
  237. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
  238. {
  239. if (self.youLikeArr.count ==0) {
  240. return CGSizeMake(SCREEN_WIDTH, FITSIZE(220));
  241. }
  242. return CGSizeMake(SCREEN_WIDTH, FITSIZE(260));
  243. }
  244. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
  245. {
  246. return CGSizeMake(0, 0);
  247. }
  248. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  249. {
  250. HCChildGoodModel *model = self.youLikeArr[indexPath.item];
  251. HCGoodCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KYHGoodCollectionCell forIndexPath:indexPath];
  252. cell.backgroundColor =[UIColor whiteColor];
  253. cell.model = model;
  254. return cell;
  255. }
  256. - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
  257. UICollectionReusableView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headner" forIndexPath:indexPath];
  258. if (isAdd) {
  259. [header addSubview:self.header];
  260. isAdd = NO;
  261. }
  262. return header;
  263. }
  264. /**
  265. 加载用户信息
  266. */
  267. - (void)loadUserInfo {
  268. if (![AccountTool isLogin]) {
  269. [self noLoginView];
  270. return;
  271. }
  272. [HCHttp post:UserInfo params:nil success:^(id json) {
  273. self.userInfo = [HCUserInfo yy_modelWithJSON:json];
  274. [self.userView setLoginView:self.userInfo];//设置用户信息
  275. NSString *saveStr = [NSString stringWithFormat:@"已累计为你省钱%.2f元",[self.userInfo.allSaveMoney floatValue]];
  276. NSMutableAttributedString *disAttr = [[NSMutableAttributedString alloc] initWithString:saveStr];
  277. [disAttr yy_setFont:[UIFont systemFontOfSize:14] range:NSMakeRange(0, saveStr.length)];
  278. [disAttr yy_setFont:[UIFont systemFontOfSize:16] range:NSMakeRange(7, saveStr.length-8)];
  279. [disAttr yy_setColor:[UIColor homeRedColor] range:NSMakeRange(7, saveStr.length-8)];
  280. self.totalSaveMoney.attributedText = disAttr;
  281. } failure:^(NSError *error) {
  282. if (![AccountTool isLogin]) {
  283. [self noLoginView];
  284. }
  285. }];
  286. }
  287. - (void)noLoginView {
  288. [self.userView setUnLoginView];
  289. }
  290. /**
  291. 检查是否有新消息
  292. */
  293. - (void)checkForNewMessage {
  294. if ([AccountTool isLogin]) {
  295. NSString *url = [NSString stringWithFormat:@"%@/api/v2/message_push/messageNew",BaseURL];
  296. [HCHttp post:url params:nil success:^(id json) {
  297. NSNumber *new = json[@"data"][@"message_new"];
  298. if ([new boolValue]) {
  299. [self.messageBtn ba_showBadge];
  300. }else {
  301. [self.messageBtn ba_hiddenBadge];
  302. }
  303. [self.collections.mj_header endRefreshing];
  304. } failure:^(NSError *error) {
  305. }];
  306. }
  307. }
  308. /**
  309. 加载广告位数据
  310. */
  311. - (void)loadAdData {
  312. NSString *url = [NSString stringWithFormat:@"%@/api/v2/adv/advByType",BaseURL];
  313. NSDictionary *para = @{@"adv_type":@"4"};
  314. [HCHttp get:url params:para success:^(id json) {
  315. NSArray *list = [NSArray yy_modelArrayWithClass:[AdPopModel class] json:json[@"data"]];
  316. if (list.count > 0) {
  317. [self showAdViewWithAdModel:list.firstObject];
  318. }
  319. } failure:^(NSError *error) {
  320. }];
  321. }
  322. /**
  323. 加载我的页面推荐商品
  324. */
  325. - (void)loadMineRecomGood {
  326. NSString *url = [NSString stringWithFormat:@"%@/api/v2/goods/pocketMyCenter",BaseURL];
  327. [HCHttp post:url params:nil success:^(id json) {
  328. HCChildGoodModel *model = [HCChildGoodModel yy_modelWithJSON:json];
  329. self.recomGoodsView.model = model;
  330. } failure:^(NSError *error) {
  331. }];
  332. }
  333. - (void)showAdViewWithAdModel:(AdPopModel *)model {
  334. [self.adView mas_updateConstraints:^(MASConstraintMaker *make) {
  335. make.height.mas_equalTo(74+10);
  336. }];
  337. self.adView.model = model;
  338. }
  339. #pragma mark ------------
  340. - (void)settingAction {
  341. HCSettingViewController *setting = [[HCSettingViewController alloc] init];
  342. [self.navigationController pushViewController:setting animated:YES];
  343. }
  344. #pragma mark ---- YHMoreMenuViewDelegate
  345. - (void)morenMenu:(HCMoreMenuView *)menuView Button:(UIButton *)button clickIndex:(NSInteger)index {
  346. switch (index) {
  347. case 0:
  348. //我的优惠券
  349. [self gotoMycouplePage];
  350. break;
  351. case 1:
  352. //我的收藏
  353. [self goToMyCollectionPage];
  354. break;
  355. case 2:
  356. //我的订单
  357. [self goToMyOrderPage];
  358. break;
  359. case 3:{
  360. //浏览记录
  361. [self goToMyBrowserHistory];
  362. }
  363. break;
  364. default:
  365. break;
  366. }
  367. }
  368. #pragma mark ---------------- private ---------
  369. /**
  370. 用户登录
  371. */
  372. - (void)goToLoginPage {
  373. HCLoginViewController *login = [[HCLoginViewController alloc] init];
  374. [self presentViewController:login animated:YES completion:nil];
  375. }
  376. /**
  377. 我的订单
  378. */
  379. - (void)goToMyOrderPage {
  380. [self openMyOrderWebView];
  381. }
  382. - (void)openMyOrderWebView {
  383. if ([[ALBBSession sharedInstance] isLogin]){
  384. HCMyOrderViewController *order = [[HCMyOrderViewController alloc] init];
  385. [self.navigationController pushViewController:order animated:YES];
  386. }else {
  387. //淘宝授权
  388. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  389. [albbSDK setAppkey:ALBC_APP_KEY];
  390. [albbSDK setAuthOption:NormalAuth];
  391. [albbSDK auth:self successCallback:^(ALBBSession *session){
  392. HCMyOrderViewController *order = [[HCMyOrderViewController alloc] init];
  393. [self.navigationController pushViewController:order animated:YES];
  394. } failureCallback:^(ALBBSession *session,NSError *error){
  395. }];
  396. }
  397. }
  398. /**
  399. 我的优惠券
  400. */
  401. - (void)gotoMycouplePage {
  402. if (![AccountTool isLogin]) {
  403. [self goToLoginPage];
  404. return;
  405. }
  406. HCMyCoupleViewController *couple = [[HCMyCoupleViewController alloc] init];
  407. [self.navigationController pushViewController:couple animated:YES];
  408. }
  409. /**
  410. 购物车
  411. */
  412. - (void)goToMyshopCarPage {
  413. HCShopCarViewController *shopCar = [[HCShopCarViewController alloc] init];
  414. [self.navigationController pushViewController:shopCar animated:YES];
  415. }
  416. /**
  417. 我的收藏
  418. */
  419. - (void)goToMyCollectionPage {
  420. if (![AccountTool isLogin]) {
  421. [self goToLoginPage];
  422. return;
  423. }
  424. HCMyCollectionViewController *collection = [[HCMyCollectionViewController alloc] init];
  425. [self.navigationController pushViewController:collection animated:YES];
  426. }
  427. /**
  428. 我的消息
  429. */
  430. - (void)gotoMyMessagesPage {
  431. if (![AccountTool isLogin]) {
  432. [self goToLoginPage];
  433. return;
  434. }
  435. HCMessageListController *messages = [[HCMessageListController alloc] init];
  436. [self.navigationController pushViewController:messages animated:YES];
  437. }
  438. /**
  439. 已领优惠券
  440. */
  441. - (void)goToMyTicketPage {
  442. if (![AccountTool isLogin]) {
  443. [self goToLoginPage];
  444. return;
  445. }
  446. HCMyTicketViewController *ticket = [[HCMyTicketViewController alloc] init];
  447. [self.navigationController pushViewController:ticket animated:YES];
  448. }
  449. /**
  450. 浏览历史
  451. */
  452. - (void)goToMyBrowserHistory {
  453. if (![AccountTool isLogin]) {
  454. [self goToLoginPage];
  455. return;
  456. }
  457. HCHistoryViewController *history = [[HCHistoryViewController alloc] init];
  458. [self.navigationController pushViewController:history animated:YES];
  459. }
  460. #pragma mark -------------------- YHMineFourButtonViewDelegate ---------
  461. - (void)YHMineFourButtonViewDidClickButtonIndex:(NSInteger)index {
  462. switch (index) {
  463. case 0:
  464. [self goToMyOrderPage];
  465. break;
  466. case 1:
  467. [self goToMyTicketPage];
  468. break;
  469. case 2:
  470. [self goToMyshopCarPage];
  471. break;
  472. case 3:
  473. [self goToMyBrowserHistory];
  474. break;
  475. default:
  476. break;
  477. }
  478. }
  479. #pragma mark ===================== layezer ==============
  480. -(UICollectionView *)collections
  481. {
  482. if(!_collections)
  483. {
  484. CGRect collectionViewFrame= CGRectMake(0, 0,SCREEN_WIDTH, SCREEN_HEIGHT-TabbarHeight);
  485. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  486. flowLayout.sectionInset=UIEdgeInsetsMake(5, 7.5, 10, 7.5);
  487. CGFloat width = (SCREEN_WIDTH)/2;
  488. CGFloat height = width + 102;
  489. flowLayout.itemSize = CGSizeMake(width-FITSIZE(12.5f), height);// 该行代码就算不写,item也会有默认尺寸
  490. UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:flowLayout];
  491. collectionView.backgroundColor = [UIColor clearColor];
  492. collectionView.dataSource = self;
  493. collectionView.delegate = self;
  494. _collections = collectionView;
  495. _collections.showsVerticalScrollIndicator=NO;
  496. _collections.showsHorizontalScrollIndicator=NO;
  497. _collections.layer.masksToBounds=YES;
  498. [_collections registerClass:[HCGoodCollectionCell class] forCellWithReuseIdentifier:KYHGoodCollectionCell];
  499. [_collections registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headner"];
  500. _collections.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
  501. [self requestYouLikeData];
  502. }];
  503. [self.collections.mj_footer beginRefreshing];
  504. }
  505. return _collections;
  506. }
  507. - (void)initSubViews {
  508. [self.header addSubview:self.leftLine];
  509. [self.header addSubview:self.titleLabel];
  510. [self.header addSubview:self.rightLine];
  511. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  512. make.left.mas_equalTo(SCREEN_WIDTH/2-FITSIZE(30));
  513. make.top.mas_equalTo(self.headerImg.height+(SCREEN_WIDTH-20)/4-20);
  514. make.height.mas_equalTo(FITSIZE(40));
  515. }];
  516. [self.leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
  517. make.right.mas_equalTo(self.titleLabel.mas_left).mas_offset(-5);
  518. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  519. make.width.mas_equalTo(60);
  520. make.height.mas_equalTo(1);
  521. }];
  522. [self.rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
  523. make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(5);
  524. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  525. make.width.mas_equalTo(60);
  526. make.height.mas_equalTo(1);
  527. }];
  528. }
  529. - (NSMutableArray *)youLikeArr {
  530. if (!_youLikeArr) {
  531. _youLikeArr = [NSMutableArray array];
  532. }
  533. return _youLikeArr;
  534. }
  535. #pragma mark ------
  536. - (UIView *)leftLine {
  537. if (!_leftLine) {
  538. _leftLine = [[UIView alloc] init];
  539. _leftLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
  540. }
  541. return _leftLine;
  542. }
  543. - (UIView *)rightLine {
  544. if (!_rightLine) {
  545. _rightLine = [[UIView alloc] init];
  546. _rightLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd];
  547. }
  548. return _rightLine;
  549. }
  550. - (UILabel *)titleLabel {
  551. if (!_titleLabel) {
  552. _titleLabel = [[UILabel alloc] init];
  553. _titleLabel.textColor = [UIColor YHColorWithHex:0x666666];
  554. _titleLabel.font = [UIFont systemFontOfSize:14];
  555. _titleLabel.textAlignment = NSTextAlignmentCenter;
  556. _titleLabel.text = @"猜你喜欢";
  557. }
  558. return _titleLabel;
  559. }
  560. @end