Files
yuyin_ios/SweetParty/主类/Mine/Controller/SPFocusFansListVC.m
2025-08-08 11:05:33 +08:00

138 lines
3.7 KiB
Objective-C
Executable File

//
// SPFocusFansListVC.m
// SweetParty
//
// Created by bj_szd on 2022/6/8.
//
#import "SPFocusFansListVC.h"
#import "SPFocusFansCell.h"
@interface SPFocusFansListVC ()
@end
@implementation SPFocusFansListVC
- (void)viewDidLoad {
[super viewDidLoad];
NSString *titleStr = @"";
if (self.type == 1) {
titleStr = @"关注";
}else if (self.type == 2) {
titleStr = @"粉丝";
}else if (self.type == 3) {
titleStr = @"收藏";
}
[self showNaviBarWithTitle:titleStr];
UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"home_bg")];
[self.view insertSubview:bgImgV atIndex:0];
[bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.height.mas_equalTo(ScreenWidth/375*812);
}];
[self createUI];
[self fetchData];
}
-(void)createUI {
[self.tableView registerNib:[UINib nibWithNibName:@"SPFocusFansCell" bundle:nil] forCellReuseIdentifier:@"SPFocusFansCell"];
self.tableView.rowHeight = 85;
[self showPullToRefresh];
[self showLoadMoreRefresh];
}
- (void)fetchData {
NSDictionary *params = @{@"page":@(self.page), @"page_limit":@(10)};
NSString *urlStr = @"api/user/get_user_follow_list";
if (self.type == 1) {
urlStr = @"api/user/get_user_follow_list";
}else if (self.type == 2) {
urlStr = @"api/user/get_user_fans_list";
}else if (self.type == 3) {
urlStr = @"api/room/get_user_collect_list";
}
[AFNetworkRequset.shared postRequestWithParams:params Path:urlStr Loading:YES Hud:NO Success:^(id _Nonnull responseDic) {
if (self.page == 1) {
[self.dataArray removeAllObjects];
[self.tableView reloadData];
}
[self endRefresh];
NSArray *arr = [SPFocusFansModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"]];
[self.dataArray addObjectsFromArray:arr];
if (self.type == 3) {
for (SPFocusFansModel *model in self.dataArray) {
model.is_collect = YES;
}
}
[self.tableView reloadData];
if (arr.count > 0) {
[self endFooterRefreshWithMore];
}else {
[self endFooterRefreshWithNoMore];
}
if (self.dataArray.count <= 0) {
[self showNoContentView];
} else {
[self hideNoContentView];
}
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)refreshFetchData {
self.page = 1;
[self fetchData];
}
- (void)fetchMoreData {
self.page ++;
[self fetchData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SPFocusFansCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SPFocusFansCell" forIndexPath:indexPath];
cell.selectionStyle = NO;
SPFocusFansModel *model = self.dataArray[indexPath.row];
[cell onUpdateSPFocusFansCell:model type:self.type];
WEAK_SELF
cell.refreshAction = ^{
[weakSelf fetchData];
};
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
SPFocusFansModel *model = self.dataArray[indexPath.row];
if (self.type == 3) {
[UIViewController goMicRoomWithRid:model.rid withPwd:@""];
}else {
[UIViewController goUserMainpageWith:model.uid withRid:@""];
}
}
@end