BogoSearchTableHeadView.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // BogoSearchTableHeadView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/6.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoSearchTableHeadView.h"
  9. #import "BogoSearchHistoryCell.h"
  10. #import "SHomePageVC.h"
  11. @implementation BogoSearchTableHeadView
  12. - (instancetype)initWithFrame:(CGRect)frame
  13. {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self setUpView];
  17. [self setModel];
  18. }
  19. return self;
  20. }
  21. -(void)setUpView{
  22. UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(10), kRealValue(10), kScreenW / 2, kRealValue(20))];
  23. titleL.text =ASLocalizedString( @"浏览历史");
  24. titleL.font = [UIFont systemFontOfSize:16];
  25. titleL.textColor = [UIColor colorWithHexString:@"#333333"];
  26. _titleL = titleL;
  27. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
  28. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  29. self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, titleL.bottom + kRealValue(5), kScreenW, kRealValue(100)) collectionViewLayout:layout];
  30. self.collectionView.delegate = self;
  31. self.collectionView.dataSource = self;
  32. self.collectionView.backgroundColor = kWhiteColor;
  33. self.collectionView.showsHorizontalScrollIndicator = NO;
  34. [_collectionView registerNib:[UINib nibWithNibName:@"BogoSearchHistoryCell" bundle:nil] forCellWithReuseIdentifier:@"BogoSearchHistoryCell"];
  35. [self addSubview:titleL];
  36. [self addSubview:self.collectionView];
  37. }
  38. -(void)setModel{
  39. self.listArr = [NSMutableArray array];
  40. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  41. [parmDict setObject:@"user" forKey:@"ctl"];
  42. [parmDict setObject:@"user_record" forKey:@"act"];
  43. [parmDict setObject:[BGIMLoginManager sharedInstance].loginParam.identifier forKey:@"uid"];
  44. [parmDict setObject:@"0" forKey:@"page"];
  45. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  46. {
  47. if ([responseJson toInt:@"status"] == 1)
  48. {
  49. NSArray *recommandArr = [NSArray modelArrayWithClass:[LivingModel class] json:[responseJson objectForKey:@"data"]];
  50. // [responseJson objectForKey:@"data"];
  51. [self.listArr addObjectsFromArray:recommandArr];
  52. // if (recommandArr && [recommandArr isKindOfClass:[NSArray class]])
  53. // {
  54. // if (recommandArr.count > 0)
  55. // {
  56. // for (NSDictionary *dict in recommandArr)
  57. // {
  58. // LivingModel *model = [LivingModel mj_objectWithKeyValues:dict];
  59. //// model.xponit = [dict toFloat:@"xpoint"];
  60. //// model.yponit = [dict toFloat:@"ypoint"];
  61. // [self.listArr addObject:model];
  62. // }
  63. // }
  64. // }
  65. [_collectionView reloadData];
  66. }
  67. [BGMJRefreshManager endRefresh:_collectionView];
  68. } FailureBlock:^(NSError *error)
  69. {
  70. [BGMJRefreshManager endRefresh:_collectionView];
  71. }];
  72. }
  73. #pragma mark UICollectionViewDataSource UICollectionViewDelegate
  74. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  75. {
  76. return 1;
  77. // FWNewEstTab_Count;
  78. }
  79. -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
  80. return CGSizeMake(0, 50);
  81. }
  82. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  83. {
  84. return self.listArr.count;
  85. }
  86. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  87. {
  88. BogoSearchHistoryCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BogoSearchHistoryCell" forIndexPath:indexPath];
  89. cell.backgroundColor = [UIColor whiteColor];
  90. cell.model = self.listArr[indexPath.row];
  91. return cell;
  92. }
  93. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  94. LivingModel *model = self.listArr[indexPath.row];
  95. SHomePageVC *tmpController= [[SHomePageVC alloc]init];
  96. tmpController.user_id = model.id;
  97. tmpController.type = 0;
  98. // BGNavigationController *nav = [[BGNavigationController alloc] initWithRootViewController:tmpController];
  99. [[AppDelegate sharedAppDelegate]pushViewController:tmpController animated:YES];
  100. // [self presentViewController:nav animated:YES completion:nil];
  101. }
  102. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  103. return CGSizeMake(kRealValue(80), kRealValue(120));
  104. }
  105. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  106. return 0;
  107. }
  108. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  109. {
  110. return UIEdgeInsetsMake(0, 0, 0, 0);
  111. }
  112. @end