| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- //
- // MOInviteTableView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/8/8.
- //
- //一页的size
- #define kPageSize 15
- #import "MOInviteTableView.h"
- #import "MOInviteTableViewCell.h"
- @interface MOInviteTableView ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *dataArr;
- /** 没有更多的数据视图 */
- @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
- @property (nonatomic, copy) NSString *next;
- @property (nonatomic, strong) NSMutableArray *inviteArr;
- @end
- @implementation MOInviteTableView
- - (instancetype)init{
- self = [super init];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (void)setupUI{
- [self addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.bottom.equalTo(self);
- }];
- self.next = @"";
- }
- #pragma mark - JXCategoryListContentViewDelegate
- - (void)listWillAppear{
- if(self.dataArr.count == 0){
- [self getFirstHttpData];
- }
- }
- - (void)getFirstHttpData{
-
- self.next = @"";
- NSString *roomId = self.roomId;
- if(roomId.length == 0){
- return;
- }
-
- NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
- NSDictionary *baseDict = @{@"page":basePage,
- @"relation":@(self.relation),
- @"roomId":roomId};
- [self toGetLinkMicListDataWith:baseDict];
- }
- - (void)toGetLinkMicListDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetTheLinkMicInviteListDataWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- __strong typeof(weakSelf) self = weakSelf;
- [self.tableView.mj_header endRefreshing];
- [self.tableView.mj_footer endRefreshing];
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
-
- MOPkInviteData *personModel = [MOPkInviteData modelObjectWithDictionary:data[@"data"]];
- if(personModel.next == nil || personModel.next.length == 0){
- if(self.next == nil || self.next.length == 0){
- //第一页
- self.dataArr = [personModel.pkUserList mutableCopy];
- }
- else{
- //最后一页
- [self.dataArr addObjectsFromArray:personModel.pkUserList];
- }
- self.next = @"";
-
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- self.next = personModel.next;
- [self.dataArr addObjectsFromArray:personModel.pkUserList];
- }
-
- [self.tableView reloadData];
- self.tableView.mj_footer.hidden = (self.dataArr.count > 0) ? NO : YES;
- self.noMoreDataView.isHaveData = (self.dataArr.count > 0) ? YES : NO;
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (UIView *)listView{
- return self;
- }
- #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{
- WEAKSELF
- MOPkUserList *model = self.dataArr[indexPath.row];
- MOInviteTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MOInviteTableViewCell_ID];
-
- cell.roomId = self.roomId;
- cell.camera = self.camera;
- cell.cellModel = model;
-
- cell.inviteActionBlock = ^(MOPkUserList * _Nonnull cellModel) {
- for (MOPkUserList *object in weakSelf.dataArr) {
- if([object.userProfile.id isEqualToString:cellModel.userProfile.id]){
- object.isSelect = !object.isSelect;
- break;
- }
- }
-
- [weakSelf.tableView reloadData];
- };
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- #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 whiteColor];
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.dataSource = self;
- _tableView.delegate = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.rowHeight = 50.0;
- [_tableView registerNib:[UINib nibWithNibName:@"MOInviteTableViewCell" bundle:nil] forCellReuseIdentifier:MOInviteTableViewCell_ID];
- _tableView.backgroundView = self.noMoreDataView;
-
- WEAKSELF
- MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [weakSelf getFirstHttpData];
- }];
-
- header.lastUpdatedTimeLabel.hidden = YES;
- header.stateLabel.hidden = YES;
- _tableView.mj_header = header;
-
- _tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
-
- NSString *roomId = weakSelf.roomId;
- if(roomId.length == 0){
- return;
- }
-
- NSDictionary *basePage = @{@"size":@(kPageSize),@"next":weakSelf.next};
- NSDictionary *baseDict = @{@"page":basePage,
- @"relation":@(weakSelf.relation),
- @"roomId":roomId};
- [weakSelf toGetLinkMicListDataWith:baseDict];
- }];
-
- _tableView.mj_footer.hidden = YES;
- }
- return _tableView;
- }
- - (NSMutableArray *)dataArr{
- if(!_dataArr){
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (MONoMoreDataView *)noMoreDataView{
- if(!_noMoreDataView){
- _noMoreDataView = [MONoMoreDataView new];
- }
- return _noMoreDataView;
- }
- - (NSMutableArray *)inviteArr{
- if(!_inviteArr){
- _inviteArr = [NSMutableArray array];
- }
- return _inviteArr;
- }
- @end
|