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

134 lines
3.9 KiB
Objective-C

//
// YYMineRoomListVC.m
// SweetParty
//
// Created by MAC on 2024/5/9.
//
#import "YYMineRoomListVC.h"
#import "YYMineRoomListCell.h"
#import "SPCommonAlert.h"
@interface YYMineRoomListVC ()
@end
@implementation YYMineRoomListVC
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self fetchData];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self showNaviBarWithTitle:@"房间列表"];
[self createUI];
}
-(void)createUI {
[ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-60-10, yb_StatusBar_H+7, 60, 30) text:@"创建房间" font:YBMediumFont(13) color:HEXCOLOR(0x333333) backguoundColor:nil imageName:nil target:self action:@selector(onCreateRoom)];
[self.tableView registerNib:[UINib nibWithNibName:@"YYMineRoomListCell" bundle:nil] forCellReuseIdentifier:@"YYMineRoomListCell"];
self.tableView.rowHeight = 67;
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(yb_NavigationBar_H+40);
make.left.right.mas_equalTo(0);
make.bottom.mas_equalTo(-yb_HomeIndicator_H);
}];
[self showPullToRefresh];
// [self showLoadMoreRefresh];
}
- (void)onCreateRoom {
[UIViewController roomOwnerGoSelfRoom];
}
- (void)fetchData {
// NSDictionary *params = @{@"page":@(self.page), @"page_limit":@(10), @"uid":BJUserManager.userInfo.uid};
NSDictionary *params = @{};
[AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/room/get_user_room_power_list" Loading:NO 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];
[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 {
YYMineRoomListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YYMineRoomListCell" forIndexPath:indexPath];
cell.selectionStyle = NO;
SPFocusFansModel *model = self.dataArray[indexPath.row];
cell.model = model;
WEAK_SELF
[cell.cituiBtn buttonAddTaget:^(UIButton *btn) {
[SPCommonAlert showWithTitle:@"确定辞退该房间身份吗?" cancelTitle:@"取消" confirmTitle:@"确定" complete:^{
[weakSelf onRequestCitui:model];
}];
} forControlEvents:UIControlEventTouchUpInside];
[cell.jinruBtn buttonAddTaget:^(UIButton *btn) {
[UIViewController goMicRoomWithRid:model.rid withPwd:@""];
} forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)onRequestCitui:(SPFocusFansModel *)model {
NSDictionary *params = @{@"rid":C_string(model.rid), @"user_type":@(model.user_type)};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/user_retire_room_power" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
[self refreshFetchData];
} Failure:^(id _Nonnull errorData) {
}];
}
@end