Files
featherVoice/QXLive/HomePage(声播)/Controlller/QXRankHomeSubVC.m
2025-10-20 09:43:10 +08:00

266 lines
11 KiB
Objective-C

//
// QXRankHomeSubVC.m
// IsLandVoice
//
// Created by 启星 on 2025/3/3.
//
#import "QXRankHomeSubVC.h"
#import "QXRankTypeView.h"
#import "QXRankListCell.h"
#import "QXRankTopThreeView.h"
//#import "SRRankListRequest.h"
//#import "SRRankListAdapter.h"
#import "QXMyRankView.h"
#import "QXRankCPListCell.h"
#import "QXRankCPTopThreeView.h"
#import "QXHomePageNetwork.h"
#import "QXUserHomePageViewController.h"
@interface QXRankHomeSubVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)QXRankTypeView *rankTypeView;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic, strong) QXRankTopThreeView *headerView;
@property (nonatomic, strong) QXRankCPTopThreeView *cpHeaderView;
@property (nonatomic, strong) QXMyRankView *myRankView;
@property (nonatomic, strong) NSMutableArray *topDataArray;
@end
@implementation QXRankHomeSubVC
-(UIView *)listView{
return self.view;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self initSubViews];
}
-(void)initSubViews{
self.bgImageHidden = YES;
self.dataType = @"1";
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.rankTypeView];
[self.view addSubview:self.myRankView];
if (self.rankType == 4) {
self.tableView.tableHeaderView = self.cpHeaderView;
self.myRankView.isCP = YES;
}else{
self.myRankView.isCP = NO;
self.tableView.tableHeaderView = self.headerView;
}
[self.view addSubview:self.tableView];
[self getRankData];
}
-(void)getRankData{
MJWeakSelf
if (self.rankType == 0) {//房间榜
[QXHomePageNetwork rankOfRoomWithType:self.dataType successBlock:^(QXRankModel * _Nonnull model) {
[weakSelf.headerView resetView];
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.topDataArray removeAllObjects];
for (int i = 0; i < model.lists.count; i++) {
if (i < 3) {
[weakSelf.topDataArray addObject:model.lists[i]];
}else{
[weakSelf.dataArray addObject:model.lists[i]];
}
}
}
weakSelf.headerView.roomList = weakSelf.topDataArray;
weakSelf.myRankView.roomModel = model.my_ranking;
weakSelf.tableView.tableHeaderView = weakSelf.headerView;
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
}];
}else if (self.rankType == 1){//财富榜
[QXHomePageNetwork rankOfCharmWithRankingType:@"1" type:self.dataType page:self.page successBlock:^(QXRankModel * _Nonnull model) {
[weakSelf.headerView resetView];
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.topDataArray removeAllObjects];
for (int i = 0; i < model.lists.count; i++) {
if (i < 3) {
[weakSelf.topDataArray addObject:model.lists[i]];
}else{
[weakSelf.dataArray addObject:model.lists[i]];
}
}
}
weakSelf.headerView.list = weakSelf.topDataArray;
weakSelf.myRankView.model = model.my_ranking;
weakSelf.tableView.tableHeaderView = weakSelf.headerView;
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
}];
}else if (self.rankType == 2){//魅力榜
[QXHomePageNetwork rankOfCharmWithRankingType:@"2" type:self.dataType page:self.page successBlock:^(QXRankModel * _Nonnull model) {
[weakSelf.headerView resetView];
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.topDataArray removeAllObjects];
for (int i = 0; i < model.lists.count; i++) {
if (i < 3) {
[weakSelf.topDataArray addObject:model.lists[i]];
}else{
[weakSelf.dataArray addObject:model.lists[i]];
}
}
}
weakSelf.headerView.list = weakSelf.topDataArray;
weakSelf.myRankView.model = model.my_ranking;
weakSelf.tableView.tableHeaderView = weakSelf.headerView;
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
}];
}else if (self.rankType == 3){//公会榜
[QXHomePageNetwork rankOfGuildWithType:self.dataType successBlock:^(QXRankModel * _Nonnull model) {
[weakSelf.headerView resetView];
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.topDataArray removeAllObjects];
for (int i = 0; i < model.lists.count; i++) {
if (i < 3) {
[weakSelf.topDataArray addObject:model.lists[i]];
}else{
[weakSelf.dataArray addObject:model.lists[i]];
}
}
}
weakSelf.headerView.guildList = weakSelf.topDataArray;
weakSelf.myRankView.guildModel = model.my_ranking;
weakSelf.tableView.tableHeaderView = weakSelf.headerView;
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
}];
}else{//cp榜
[QXHomePageNetwork rankOfRealLoveWithType:self.dataType successBlock:^(QXRankModel * _Nonnull model) {
[weakSelf.cpHeaderView resetView];
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.topDataArray removeAllObjects];
for (int i = 0; i < model.lists.count; i++) {
if (i < 3) {
[weakSelf.topDataArray addObject:model.lists[i]];
}else{
[weakSelf.dataArray addObject:model.lists[i]];
}
}
}
weakSelf.cpHeaderView.list = weakSelf.topDataArray;
weakSelf.myRankView.cpModel = model.my_ranking;
weakSelf.tableView.tableHeaderView = weakSelf.cpHeaderView;
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
}];
}
}
#pragma mark - <UITableViewDelegate,UITableViewDataSource>
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (self.rankType == 4) {//CP
QXRankCPListCell *cell = [QXRankCPListCell cellWithTableView:tableView];
// cell.model = self.dataArray[indexPath.row];
return cell;
}else{
QXRankListCell *cell = [QXRankListCell cellWithTableView:tableView];
cell.rankType = self.rankType;
cell.model = self.dataArray[indexPath.row];
return cell;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
QXMyRankModel *model = self.dataArray[indexPath.row];
// if (self.rankType == 0) {
// if ([model.room_id isExist]) {
// [[QXGlobal shareGlobal] joinRoomWithRoomId:model.room_id isRejoin:NO navagationController:self.navigationController];
// }
// return;
// }
if (self.rankType == 1 || self.rankType == 2) {
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
vc.user_id = model.user_id;
[self.navigationController pushViewController:vc animated:YES];
return;
}
// if (self.rankType != 4) {//CP
// QXHomeRoomListModel *model = self.dataArray[indexPath.row];
// SRPersonalViewController *pvc = [[SRPersonalViewController alloc] initWithUserId:[model.user_id longLongValue]];
// pvc.emchatUsername = model.emchat_username;
// [self.navigationController pushViewController:pvc animated:YES];
// }
}
-(QXRankTypeView *)rankTypeView{
if (!_rankTypeView) {
_rankTypeView = [[QXRankTypeView alloc] initWithFrame:CGRectMake(0, kSafeAreaTop+30, SCREEN_WIDTH, 30)];
MJWeakSelf
_rankTypeView.rankTypeBlock = ^(QXRankType type) {
weakSelf.dataType = [NSString stringWithFormat:@"%ld",type];
[weakSelf getRankData];
};
}
return _rankTypeView;
}
-(QXRankTopThreeView *)headerView{
if (!_headerView) {
_headerView = [[QXRankTopThreeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 230)];
}
return _headerView;
}
-(QXRankCPTopThreeView *)cpHeaderView{
if (!_cpHeaderView) {
_cpHeaderView = [[QXRankCPTopThreeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 230)];
}
return _cpHeaderView;
}
-(QXMyRankView *)myRankView{
if (!_myRankView) {
_myRankView = [[QXMyRankView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-TabbarContentHeight-60-44, SCREEN_WIDTH, 60)];
}
return _myRankView;
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.rankTypeView.bottom+10, SCREEN_WIDTH, self.myRankView.top - self.rankTypeView.bottom-10) style:(UITableViewStyleGrouped)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.rowHeight = 50;
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
[weakSelf getRankData];
}];
}
return _tableView;
}
-(NSMutableArray *)topDataArray{
if (!_topDataArray) {
_topDataArray = [NSMutableArray array] ;
}
return _topDataArray;
}
@end