2025-11-21 16:17:05 +08:00
|
|
|
//
|
|
|
|
|
// QXSingerSongListContentView.m
|
|
|
|
|
// QXLive
|
|
|
|
|
//
|
|
|
|
|
// Created by 启星 on 2025/11/14.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "QXSingerSongListContentView.h"
|
|
|
|
|
#import "QXSingerSongListCell.h"
|
|
|
|
|
#import "QXMineNetwork.h"
|
|
|
|
|
|
|
|
|
|
@interface QXSingerSongListContentView()<UITableViewDelegate,UITableViewDataSource,QXSingerSongListCellDelegate>
|
|
|
|
|
@property (nonatomic,strong)UITableView *tableView;
|
|
|
|
|
@property (nonatomic,assign)NSInteger page ;
|
|
|
|
|
@property (nonatomic,strong)NSMutableArray *dataArray;
|
|
|
|
|
@end
|
|
|
|
|
@implementation QXSingerSongListContentView
|
|
|
|
|
-(UIView *)listView{
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
-(void)listWillAppear{
|
|
|
|
|
[self getSongList];
|
|
|
|
|
}
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
|
|
{
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self initSubviews];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)initSubviews{
|
|
|
|
|
|
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
|
self.page = 1;
|
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height) style:(UITableViewStylePlain)];
|
|
|
|
|
self.tableView.delegate = self;
|
|
|
|
|
self.tableView.dataSource = self;
|
|
|
|
|
self.tableView.backgroundColor = RGB16(0x1B1926);
|
|
|
|
|
// self.tableView.rowHeight = 73;
|
|
|
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
|
|
|
|
weakSelf.page++;
|
|
|
|
|
[weakSelf getSongList];
|
|
|
|
|
}];
|
|
|
|
|
self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
|
|
|
weakSelf.page = 1;
|
|
|
|
|
[weakSelf getSongList];
|
|
|
|
|
}];
|
|
|
|
|
[self addSubview:self.tableView];
|
|
|
|
|
}
|
|
|
|
|
-(void)setType:(NSInteger)type{
|
|
|
|
|
_type = type;
|
|
|
|
|
}
|
|
|
|
|
-(void)setPitModel:(QXRoomPitModel *)pitModel{
|
|
|
|
|
_pitModel = pitModel;
|
|
|
|
|
}
|
|
|
|
|
-(void)getSongList{
|
|
|
|
|
MJWeakSelf
|
|
|
|
|
if (self.type == 0) {
|
|
|
|
|
/// 点歌
|
|
|
|
|
NSString *roomId = @"";
|
|
|
|
|
NSString *userId = @"";
|
|
|
|
|
if (self.pitModel == nil) {
|
|
|
|
|
/// 全部
|
|
|
|
|
roomId = self.roomId;
|
|
|
|
|
userId = @"";
|
|
|
|
|
}else{
|
|
|
|
|
/// 麦位上的歌手
|
|
|
|
|
userId = self.pitModel.user_id;
|
|
|
|
|
roomId = @"";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[QXMineNetwork getUserSongListWithRoomId:roomId user_id:userId page:self.page SuccessBlock:^(NSArray<QXUserSongListModel *> * _Nonnull list, NSString * _Nonnull count) {
|
|
|
|
|
if (weakSelf.page == 1) {
|
|
|
|
|
[weakSelf.dataArray removeAllObjects];
|
|
|
|
|
}
|
|
|
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
|
|
|
[weakSelf.tableView reloadData];
|
|
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
if (list.count == 0) {
|
|
|
|
|
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
|
|
|
}else{
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}];
|
|
|
|
|
}else if (self.type == 1){
|
|
|
|
|
/// 已点歌曲
|
|
|
|
|
[QXMineNetwork requestSongWithRoomId:self.roomId type:1 page:self.page successBlock:^(NSArray<QXUserSongListModel *> * _Nonnull list, NSString * _Nonnull count) {
|
|
|
|
|
if (weakSelf.page == 1) {
|
|
|
|
|
[weakSelf.dataArray removeAllObjects];
|
|
|
|
|
}
|
|
|
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
|
|
|
[weakSelf.tableView reloadData];
|
|
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
if (list.count == 0) {
|
|
|
|
|
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
|
|
|
}else{
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}];
|
|
|
|
|
}else{
|
|
|
|
|
/// 历史歌曲
|
|
|
|
|
[QXMineNetwork requestSongWithRoomId:self.roomId type:self.historyType page:self.page successBlock:^(NSArray<QXUserSongListModel *> * _Nonnull list, NSString * _Nonnull count) {
|
|
|
|
|
if (weakSelf.page == 1) {
|
|
|
|
|
[weakSelf.dataArray removeAllObjects];
|
|
|
|
|
}
|
|
|
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
|
|
|
[weakSelf.tableView reloadData];
|
|
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
if (list.count == 0) {
|
|
|
|
|
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
|
|
|
}else{
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
2025-12-04 23:35:49 +08:00
|
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
|
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
2025-11-21 16:17:05 +08:00
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)updateSongList{
|
|
|
|
|
self.page = 1;
|
|
|
|
|
[self getSongList];
|
|
|
|
|
}
|
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
|
return self.dataArray.count;
|
|
|
|
|
}
|
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
QXSingerSongListCell *cell = [QXSingerSongListCell cellWithTableView:tableView];
|
|
|
|
|
cell.type = self.type;
|
|
|
|
|
cell.isCompere = self.isCompere;
|
|
|
|
|
cell.index = indexPath.row;
|
|
|
|
|
cell.model = self.dataArray[indexPath.row];
|
|
|
|
|
cell.roomId = self.roomId;
|
|
|
|
|
cell.delegate = self;
|
|
|
|
|
return cell;
|
|
|
|
|
}
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
|
if (self.type == 0) {
|
|
|
|
|
return 73;
|
|
|
|
|
}else{
|
|
|
|
|
return 75+8;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
-(NSMutableArray *)dataArray{
|
|
|
|
|
if (!_dataArray) {
|
|
|
|
|
_dataArray = [NSMutableArray array];
|
|
|
|
|
}
|
|
|
|
|
return _dataArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|