| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // MOPinkStarsTableView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/5/13.
- //
- #import "MOPinkStarsTableView.h"
- #import "MOPinkStarsCell.h"
- #import "MOUserHomePageVC.h"
- @interface MOPinkStarsTableView ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *dataArr;
- /** 没有更多的数据视图 */
- @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
- @end
- @implementation MOPinkStarsTableView
- - (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);
- }];
- }
- #pragma mark - JXCategoryListContentViewDelegate
- - (void)listWillAppear{
- if(self.dataArr.count == 0){
- WEAKSELF
- NSDictionary *dict = @{@"data":@(self.viewType)};
- [kHttpManager toGetTheFanClubRankListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MOFanClubAllData *baseData = [MOFanClubAllData modelObjectWithDictionary:data[@"data"]];
- weakSelf.dataArr = [baseData.fanClublist mutableCopy];
-
- weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
- [weakSelf.tableView reloadData];
- }
- else{
- MOLogV(@"toGetTheFanClubRankListWithParams 接口报错了");
- 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{
- MOFanClubData *model = self.dataArr[indexPath.row];
- MOPinkStarsCell *cell = [tableView dequeueReusableCellWithIdentifier:MOPinkStarsCell_ID];
- cell.cellModel = model;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- MOFanClubData *model = self.dataArr[indexPath.row];
-
- UIViewController *currentVC = [MOTools currentViewController];
- MOUserHomePageVC *vc = [[MOUserHomePageVC alloc] init];
- vc.userId = model.commander.userProfile.id;
- [currentVC.navigationController pushViewController:vc 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:@"MOPinkStarsCell" bundle:nil] forCellReuseIdentifier:MOPinkStarsCell_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
|