| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- //
- // MOContributionListView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/8/26.
- //
- //一页的size
- #define kPageSize 15
- #import "MOContributionListView.h"
- #import "MOVoiceContriCell.h"
- @interface MOContributionListView ()<UITableViewDelegate,UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UILabel *titleLab;
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- /** 展示数据 */
- @property (nonatomic, strong) NSMutableArray *dataArr;
- /** 没有更多的数据视图 */
- @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
- @property (nonatomic, copy) NSString *next;
- @end
- @implementation MOContributionListView
- + (instancetype)moContributionListView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOContributionListView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.next = @"";
-
- //上方 两个圆角
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.masksToBounds = YES;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
-
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.tableView.rowHeight = 62.0;
- self.tableView.estimatedRowHeight = 0;
- self.tableView.estimatedSectionHeaderHeight = 0;
- self.tableView.estimatedSectionFooterHeight = 0;
- //iOS15适配
- if (@available(iOS 15.0, *))
- {
- self.tableView.sectionHeaderTopPadding = 0;
- }
-
- [self.tableView registerNib:[UINib nibWithNibName:@"MOVoiceContriCell" bundle:nil] forCellReuseIdentifier:MOVoiceContriCell_ID];
-
- WEAKSELF
- self.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,
- @"roomId":roomId,
- @"userId":weakSelf.userId};
- [weakSelf getTheVoiceOutcomeRankDataWith:baseDict];
- }];
-
- self.tableView.mj_footer.hidden = YES;
-
- self.tableView.backgroundView = self.noMoreDataView;
-
- self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalTitleFontStr];
- }
- - (IBAction)closeBtnClick:(id)sender {
- [self dismissContributionListView];
- }
- - (void)getFirstHttpData{
-
- self.next = @"";
- NSString *roomId = self.roomId;
- if(roomId.length == 0 || self.userId.length == 0){
- return;
- }
-
- NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
- NSDictionary *baseDict = @{@"page":basePage,
- @"roomId":roomId,
- @"userId":self.userId};
- [self getTheVoiceOutcomeRankDataWith:baseDict];
- }
- - (void)getTheVoiceOutcomeRankDataWith:(NSDictionary *)dict{
- WEAKSELF
- [kHttpManager toGetTheOutcomeAboutGuestWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MORankBasedata *personModel = [MORankBasedata modelObjectWithDictionary:data[@"data"]];
- if(personModel.next == nil || personModel.next.length == 0){
- if(self.next == nil || self.next.length == 0){
- //第一页
- self.dataArr = [personModel.ranklist mutableCopy];
- }
- else{
- //最后一页
- [self.dataArr addObjectsFromArray:personModel.ranklist];
- }
- self.next = @"";
-
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- else{
- self.next = personModel.next;
- [self.dataArr addObjectsFromArray:personModel.ranklist];
- }
-
- [self.tableView reloadData];
- self.tableView.mj_footer.hidden = (self.dataArr.count > 0) ? NO : YES;
- self.noMoreDataView.isHaveData = (self.dataArr.count > 0) ? YES : NO;
- }
- else{
- MOLogV(@"toGetTheOutcomeAboutGuestWithParams 接口报错了");
- 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{
- MORanklist *model = self.dataArr[indexPath.row];
- MOVoiceContriCell *cell = [tableView dequeueReusableCellWithIdentifier:MOVoiceContriCell_ID];
- cell.cellIndexPath = indexPath;
- cell.cellModel = model;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
-
- return 0.01;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
-
- return 0.01;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view;
- }
- - (void)showContributionListView{
- self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT;
- self.bgView.frame = actionViewRect;
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT - 480.0;
- weakSelf.bgView.frame = actionViewRect;
- }];
-
- //不能滑动
- SendNotification(@"MOShowLivePagesVCCannotScroll")
- }
- - (void)dismissContributionListView{
- //完成下移动画
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.y = SCREENHEIGHT;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self removeFromSuperview];
- }];
-
- //可以滑动
- SendNotification(@"MOShowLivePagesVCCanScroll")
- }
- - (NSMutableArray *)dataArr{
- if(!_dataArr){
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (MONoMoreDataView *)noMoreDataView{
- if(!_noMoreDataView){
- _noMoreDataView = [MONoMoreDataView new];
- }
- return _noMoreDataView;
- }
- @end
|