MOPkRankContributionTableView.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // MOPkRankContributionTableView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/2/19.
  6. //
  7. #import "MOPkRankContributionTableView.h"
  8. @interface MOPkRankContributionTableView ()
  9. @property (nonatomic, strong) UITableView *tableView;
  10. /** 数据源 */
  11. @property (nonatomic, strong) NSMutableArray *dataArr;
  12. /** 没有更多的数据视图 */
  13. @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
  14. @end
  15. @implementation MOPkRankContributionTableView
  16. - (instancetype)init{
  17. self = [super init];
  18. if (self)
  19. {
  20. [self setupUI];
  21. }
  22. return self;
  23. }
  24. - (instancetype)initWithFrame:(CGRect)frame
  25. {
  26. self = [super initWithFrame:frame];
  27. if (self)
  28. {
  29. [self setupUI];
  30. }
  31. return self;
  32. }
  33. - (instancetype)initWithCoder:(NSCoder *)coder{
  34. self = [super initWithCoder:coder];
  35. if (self)
  36. {
  37. [self setupUI];
  38. }
  39. return self;
  40. }
  41. - (void)setupUI{
  42. self.backgroundColor = [UIColor clearColor];
  43. [self addSubview:self.tableView];
  44. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.left.right.bottom.equalTo(self);
  46. }];
  47. }
  48. - (UIView *)listView{
  49. return self;
  50. }
  51. #pragma mark - JXCategoryListContentViewDelegate
  52. - (void)listWillAppear{
  53. if(self.dataArr.count == 0){
  54. if(self.roomId.length == 0){
  55. return;
  56. }
  57. NSDictionary *pageDict = @{@"size":@(30),@"next":@""};
  58. NSDictionary *dict = @{@"page":pageDict,
  59. @"type":@(self.viewType),
  60. @"roomId":self.roomId};
  61. [self getHttpDataWith:dict];
  62. }
  63. }
  64. - (void)getHttpDataWith:(NSDictionary *)dict{
  65. WEAKSELF
  66. [kHttpManager toGetThePkContributeInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  67. if(kCode_Success){
  68. MOPkInviteData *baseData = [MOPkInviteData modelObjectWithDictionary:data[@"data"]];
  69. weakSelf.dataArr = [baseData.pkUserList mutableCopy];
  70. [weakSelf.tableView reloadData];
  71. weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
  72. }
  73. else{
  74. kShowNetError(data)
  75. }
  76. }];
  77. }
  78. #pragma mark - UITableViewDelegate,UITableViewDataSource
  79. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  80. return 1;
  81. }
  82. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  83. return self.dataArr.count;
  84. }
  85. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  86. MOPkUserList *model = self.dataArr[indexPath.row];
  87. MOPkContribuCell *cell = [tableView dequeueReusableCellWithIdentifier:MOPkContribuCell_ID];
  88. cell.cellIndexPath = indexPath;
  89. cell.cellModel = model;
  90. return cell;
  91. }
  92. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  93. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  94. MOPkUserList *model = self.dataArr[indexPath.row];
  95. self.cellClickBlock ? self.cellClickBlock(model.userProfile.id,self.viewType) : nil;
  96. }
  97. #pragma mark - Lazy
  98. - (UITableView *)tableView{
  99. if (!_tableView)
  100. {
  101. _tableView= [[UITableView alloc] init];
  102. if (@available(iOS 11.0, *))
  103. {
  104. _tableView.estimatedRowHeight = 0;
  105. _tableView.estimatedSectionFooterHeight = 0;
  106. _tableView.estimatedSectionHeaderHeight = 0;
  107. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  108. }
  109. //iOS15适配
  110. if (@available(iOS 15.0, *))
  111. {
  112. self.tableView.sectionHeaderTopPadding = 0;
  113. }
  114. _tableView.backgroundColor = [UIColor clearColor];
  115. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  116. _tableView.dataSource = self;
  117. _tableView.delegate = self;
  118. _tableView.showsVerticalScrollIndicator = NO;
  119. _tableView.showsHorizontalScrollIndicator = NO;
  120. _tableView.rowHeight = 89.0;
  121. [_tableView registerNib:[UINib nibWithNibName:@"MOPkContribuCell" bundle:nil] forCellReuseIdentifier:MOPkContribuCell_ID];
  122. _tableView.backgroundView = self.noMoreDataView;
  123. }
  124. return _tableView;
  125. }
  126. - (NSMutableArray *)dataArr{
  127. if(!_dataArr){
  128. _dataArr = [NSMutableArray array];
  129. }
  130. return _dataArr;
  131. }
  132. - (MONoMoreDataView *)noMoreDataView{
  133. if(!_noMoreDataView){
  134. _noMoreDataView = [MONoMoreDataView new];
  135. }
  136. return _noMoreDataView;
  137. }
  138. @end