Files
fanyin-ios/QXLive/Mine(音域)/Controller/设置/QXBlackListlViewController.m

151 lines
5.2 KiB
Mathematica
Raw Permalink Normal View History

2025-08-12 14:27:12 +08:00
//
// QXBlackListlViewController.m
// QXLive
//
// Created by on 2025/5/12.
//
#import "QXBlackListlViewController.h"
#import "QXBlackListCell.h"
#import "QXMineNetwork.h"
#import "QXDynamicNetwork.h"
#import "QXUserHomePageViewController.h"
@interface QXBlackListlViewController ()<UITableViewDelegate,UITableViewDataSource,QXBlackListCellDelegate>
@property (nonatomic,strong)UITableView *tableView;
@end
@implementation QXBlackListlViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)setNavgationItems{
[super setNavgationItems];
if (self.type == 0) {
self.navigationItem.title = QXText(@"黑名单");
}else if (self.type == 1) {
self.navigationItem.title = QXText(@"粉丝");
}else if (self.type == 2) {
self.navigationItem.title = QXText(@"关注");
}else if (self.type == 3) {
self.navigationItem.title = QXText(@"访客");
}
}
-(void)initSubViews{
self.page = 1;
[self.view addSubview:self.tableView];
}
-(void)getData{
MJWeakSelf
[QXMineNetwork focusListWithPage:self.page
type:self.type
successBlock:^(NSArray<QXUserHomeModel *> * _Nonnull users) {
if (weakSelf.page == 1) {
[weakSelf.dataArray removeAllObjects];
}
[weakSelf.dataArray addObjectsFromArray:users];
[weakSelf.tableView.mj_header endRefreshing];
if (users.count > 0) {
[weakSelf.tableView.mj_footer endRefreshing];
}else{
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
}
[weakSelf.tableView reloadData];
}failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
[weakSelf.tableView.mj_header endRefreshing];
[weakSelf.tableView.mj_footer endRefreshing];
if (weakSelf.type == 3) {
showToast(msg);
[self performSelector:@selector(backAction) afterDelay:1];
}
}];
}
#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{
QXBlackListCell *cell = [QXBlackListCell cellWithTableView:tableView];
if (self.type == 0) {
cell.cellType = QXBlackListCellTypeBlack;
}else if (self.type == 1) {
cell.cellType = QXBlackListCellTypeFans;
}else if (self.type == 2) {
cell.cellType = QXBlackListCellTypeFocus;
}else if (self.type == 3) {
cell.cellType = QXBlackListCellTypeVisit;
}
cell.delegate = self;
cell.userModel = self.dataArray[indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
QXUserHomeModel *model = self.dataArray[indexPath.row];
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
vc.user_id = model.user_id;
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - QXBlackListCellDelegate
-(void)didRemoveSuccess:(QXUserHomeModel *)userModel{
MJWeakSelf
[QXMineNetwork addOrRemoveBlackListIsAdd:NO userId:userModel.user_id successBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf getData];
showToast(@"移除成功");
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)didFocus:(UIButton *)sender userModel:(nonnull QXUserHomeModel *)userModel{
[QXDynamicNetwork followWithUserId:userModel.user_id type:@"1" successBlock:^(NSDictionary * _Nonnull dict) {
sender.selected = !sender.selected;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(UITableView *)tableView{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) style:(UITableViewStylePlain)];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.rowHeight = 62;
MJWeakSelf
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
weakSelf.page = 1;
[weakSelf getData];
}];
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
weakSelf.page++;
[weakSelf getData];
}];
}
return _tableView;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end