MOPinkStarsTableView.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // MOPinkStarsTableView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/5/13.
  6. //
  7. #import "MOPinkStarsTableView.h"
  8. #import "MOPinkStarsCell.h"
  9. #import "MOUserHomePageVC.h"
  10. @interface MOPinkStarsTableView ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, strong) UITableView *tableView;
  12. @property (nonatomic, strong) NSMutableArray *dataArr;
  13. /** 没有更多的数据视图 */
  14. @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
  15. @end
  16. @implementation MOPinkStarsTableView
  17. - (instancetype)init{
  18. self = [super init];
  19. if (self)
  20. {
  21. [self setupUI];
  22. }
  23. return self;
  24. }
  25. - (void)setupUI{
  26. [self addSubview:self.tableView];
  27. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.top.left.right.bottom.equalTo(self);
  29. }];
  30. }
  31. #pragma mark - JXCategoryListContentViewDelegate
  32. - (void)listWillAppear{
  33. if(self.dataArr.count == 0){
  34. WEAKSELF
  35. NSDictionary *dict = @{@"data":@(self.viewType)};
  36. [kHttpManager toGetTheFanClubRankListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  37. if(kCode_Success){
  38. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  39. MOFanClubAllData *baseData = [MOFanClubAllData modelObjectWithDictionary:data[@"data"]];
  40. weakSelf.dataArr = [baseData.fanClublist mutableCopy];
  41. weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
  42. [weakSelf.tableView reloadData];
  43. }
  44. else{
  45. MOLogV(@"toGetTheFanClubRankListWithParams 接口报错了");
  46. kShowNetError(data)
  47. }
  48. }];
  49. }
  50. }
  51. - (UIView *)listView{
  52. return self;
  53. }
  54. #pragma mark - UITableViewDelegate,UITableViewDataSource
  55. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  56. return 1;
  57. }
  58. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  59. return self.dataArr.count;
  60. }
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  62. MOFanClubData *model = self.dataArr[indexPath.row];
  63. MOPinkStarsCell *cell = [tableView dequeueReusableCellWithIdentifier:MOPinkStarsCell_ID];
  64. cell.cellModel = model;
  65. return cell;
  66. }
  67. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  68. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  69. MOFanClubData *model = self.dataArr[indexPath.row];
  70. UIViewController *currentVC = [MOTools currentViewController];
  71. MOUserHomePageVC *vc = [[MOUserHomePageVC alloc] init];
  72. vc.userId = model.commander.userProfile.id;
  73. [currentVC.navigationController pushViewController:vc animated:YES];
  74. }
  75. #pragma mark - Lazy
  76. - (UITableView *)tableView{
  77. if (!_tableView)
  78. {
  79. _tableView= [[UITableView alloc] init];
  80. if (@available(iOS 11.0, *))
  81. {
  82. _tableView.estimatedRowHeight = 0;
  83. _tableView.estimatedSectionFooterHeight = 0;
  84. _tableView.estimatedSectionHeaderHeight = 0;
  85. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  86. }
  87. //iOS15适配
  88. if (@available(iOS 15.0, *))
  89. {
  90. self.tableView.sectionHeaderTopPadding = 0;
  91. }
  92. _tableView.backgroundColor = [UIColor whiteColor];
  93. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  94. _tableView.dataSource = self;
  95. _tableView.delegate = self;
  96. _tableView.showsVerticalScrollIndicator = NO;
  97. _tableView.showsHorizontalScrollIndicator = NO;
  98. _tableView.rowHeight = 50.0;
  99. [_tableView registerNib:[UINib nibWithNibName:@"MOPinkStarsCell" bundle:nil] forCellReuseIdentifier:MOPinkStarsCell_ID];
  100. _tableView.backgroundView = self.noMoreDataView;
  101. }
  102. return _tableView;
  103. }
  104. - (NSMutableArray *)dataArr{
  105. if(!_dataArr){
  106. _dataArr = [NSMutableArray array];
  107. }
  108. return _dataArr;
  109. }
  110. - (MONoMoreDataView *)noMoreDataView{
  111. if(!_noMoreDataView){
  112. _noMoreDataView = [MONoMoreDataView new];
  113. }
  114. return _noMoreDataView;
  115. }
  116. @end