| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- //
- // MOPkRankContributionTableView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/2/19.
- //
- #import "MOPkRankContributionTableView.h"
- @interface MOPkRankContributionTableView ()
- @property (nonatomic, strong) UITableView *tableView;
- /** 数据源 */
- @property (nonatomic, strong) NSMutableArray *dataArr;
- /** 没有更多的数据视图 */
- @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
- @end
- @implementation MOPkRankContributionTableView
- - (instancetype)init{
- self = [super init];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (instancetype)initWithCoder:(NSCoder *)coder{
- self = [super initWithCoder:coder];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (void)setupUI{
-
- self.backgroundColor = [UIColor clearColor];
-
- [self addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.bottom.equalTo(self);
- }];
- }
- - (UIView *)listView{
- return self;
- }
- #pragma mark - JXCategoryListContentViewDelegate
- - (void)listWillAppear{
- if(self.dataArr.count == 0){
-
- if(self.roomId.length == 0){
- return;
- }
-
- NSDictionary *pageDict = @{@"size":@(30),@"next":@""};
- NSDictionary *dict = @{@"page":pageDict,
- @"type":@(self.viewType),
- @"roomId":self.roomId};
-
- [self getHttpDataWith:dict];
- }
- }
- - (void)getHttpDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetThePkContributeInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOPkInviteData *baseData = [MOPkInviteData modelObjectWithDictionary:data[@"data"]];
- weakSelf.dataArr = [baseData.pkUserList mutableCopy];
- [weakSelf.tableView reloadData];
- weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.dataArr.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- MOPkUserList *model = self.dataArr[indexPath.row];
- MOPkContribuCell *cell = [tableView dequeueReusableCellWithIdentifier:MOPkContribuCell_ID];
-
- cell.cellIndexPath = indexPath;
- cell.cellModel = model;
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- MOPkUserList *model = self.dataArr[indexPath.row];
-
- self.cellClickBlock ? self.cellClickBlock(model.userProfile.id,self.viewType) : nil;
- }
- #pragma mark - Lazy
- - (UITableView *)tableView{
- if (!_tableView)
- {
- _tableView= [[UITableView alloc] init];
- if (@available(iOS 11.0, *))
- {
- _tableView.estimatedRowHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }
-
- //iOS15适配
- if (@available(iOS 15.0, *))
- {
- self.tableView.sectionHeaderTopPadding = 0;
- }
-
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.dataSource = self;
- _tableView.delegate = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.rowHeight = 89.0;
- [_tableView registerNib:[UINib nibWithNibName:@"MOPkContribuCell" bundle:nil] forCellReuseIdentifier:MOPkContribuCell_ID];
-
- _tableView.backgroundView = self.noMoreDataView;
-
- }
- return _tableView;
- }
- - (NSMutableArray *)dataArr{
- if(!_dataArr){
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (MONoMoreDataView *)noMoreDataView{
- if(!_noMoreDataView){
- _noMoreDataView = [MONoMoreDataView new];
- }
- return _noMoreDataView;
- }
- @end
|