123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- //
- // YOUPAILZChatRoomUpSeatApplyWindow.m
- // VQU
- //
- // Created by CY on 2021/11/6.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZChatRoomUpSeatApplyWindow.h"
- #import "UIScrollView+LZRefresh.h"
- #import "YOUPAILZChatRoomUpSeatApplyCell.h"
- @interface YOUPAILZChatRoomUpSeatApplyWindow ()<UITableViewDataSource,UITableViewDelegate>
- @property (nonatomic, weak)UITableView *youpaiptableView;
- @property (nonatomic, assign) NSInteger youpaippage;
- @property (nonatomic, strong) NSMutableArray <YOUPAILZChatRoomMemberModel *>*youpaipdataSource;
- @end
- @implementation YOUPAILZChatRoomUpSeatApplyWindow
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.baseView.hidden = YES;
- [self youpaifinitUI];
- [self youpaifrequestUpSeatApplyListWithStatus:kRefreshNormal];
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchatRoomConfirmSuccess:) name:@"ChatRoomConfirmSuccess" object:nil];
- }
- -(void)youpaifchatRoomConfirmSuccess:(NSNotification *)notify{
- NSString *userId = notify.userInfo[@"userId"];
- for (YOUPAILZChatRoomMemberModel *memberModel in self.youpaipdataSource) {
- if ([memberModel.youpaipid isEqual:userId]) {
- [self.youpaipdataSource removeObject:memberModel];
- [self.youpaiptableView reloadData];
- break;
- }
- }
- [self.youpaiptableView lz_hideEmptyView];
- if (self.youpaipdataSource.count == 0) {
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"当前还没有人申请呢~"];
- }
- }
- - (void)youpaifinitUI{
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 400.0f + SafeHeight)];
- bgV.backgroundColor = HexColorFromRGB(0x2A2935);
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.offset(0.0f);
- make.height.offset(400.0f + SafeHeight);
- }];
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
-
-
- UIView *navV = [[UIView alloc] init];
- [bgV addSubview:navV];
- [navV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.offset(0.0f);
- make.height.offset(43.0f);
- }];
-
- [navV addLineWithColor:[[UIColor whiteColor] colorWithAlphaComponent:0.07f] lineRect:CGRectMake(0, 42.5f, KScreenWidth, 0.5f)];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.text = @"上麦申请";
- titleL.textColor = [UIColor whiteColor];
- titleL.font = LCBoldFont(16.0f);
- [navV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(navV);
- }];
- UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
- tableView.delegate = self;
- tableView.dataSource = self;
- tableView.rowHeight = 60.0f;
- tableView.estimatedRowHeight = 60.0f;
- tableView.estimatedSectionHeaderHeight = 0.0f;
- tableView.estimatedSectionFooterHeight = 0.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor clearColor];
- tableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
- @weakify(self);
- [tableView setRefreshHeaderWithBlock:^{
- @strongify(self);
- [self youpaifrequestUpSeatApplyListWithStatus:kRefreshHeader];
- }];
- [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.bottom.offset(-SafeHeight);
- make.top.equalTo(navV.mas_bottom).offset(0.0f);
- }];
-
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSString *cellID = @"YOUPAILZChatRoomUpSeatApplyCell";
- YOUPAILZChatRoomUpSeatApplyCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (cell == nil) {
- cell = [[YOUPAILZChatRoomUpSeatApplyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.row] index:indexPath.row playType:self.youpaipplayType];
- @weakify(self);
- [cell setYoupaipignoreBtnClickBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model, NSInteger index) {
- @strongify(self);
- [self youpaifignoreWithModel:model index:index];
- }];
- [cell setYoupaipupseatBtnClickBlock:^(YOUPAILZChatRoomMemberModel * _Nonnull model, NSInteger index) {
- @strongify(self);
- if (self.youpaipupseatBlock != nil) {
- self.youpaipupseatBlock(model);
- }
- }];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- /// 忽略
- - (void)youpaifignoreWithModel:(YOUPAILZChatRoomMemberModel *)model index:(NSInteger)index{
-
- [self.youpaipdataSource removeObject:model];
- [self.youpaiptableView reloadData];
- [self.youpaiptableView lz_hideEmptyView];
- if (self.youpaipdataSource.count == 0) {
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"当前还没有人申请呢~"];
- }
- [LCHttpHelper requestWithURLString:RejectApply parameters:@{@"room_id":self.youpaiproomId,@"op_uid":model.youpaipid} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- } failure:^(NSError *error) {
- }];
- }
- /// 设置加载更多
- - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{
- @weakify(self);
- [self.youpaiptableView setRefreshFooter:hidden withBlock:^{
- @strongify(self);
- [self youpaifrequestUpSeatApplyListWithStatus:kRefreshFooter];
- }];
- }
- - (void)youpaifrequestUpSeatApplyListWithStatus:(kRefreshStatus)status{
- if (status == kRefreshFooter) {
- self.youpaippage ++;
- }else{
- self.youpaippage = 1;
- }
- @weakify(self);
- [LCHttpHelper requestWithURLString:ApplyList parameters:@{@"page":@(self.youpaippage),@"room_id":self.youpaiproomId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- if (status != kRefreshFooter) {
- [self.youpaipdataSource removeAllObjects];
- }
- NSDictionary *data = [dict objectForKey:@"data"];
- NSArray <YOUPAILZChatRoomMemberModel *>*list = [YOUPAILZChatRoomMemberModel mj_objectArrayWithKeyValuesArray:[data objectForKey:@"list"]];
-
- [self.youpaipdataSource addObjectsFromArray:list];
- [self.youpaiptableView reloadData];
- [self.youpaiptableView lz_hideEmptyView];
- if (self.youpaipdataSource.count == 0) {
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"当前还没有人申请呢~"];
- }
- NSInteger totalPage = [[data objectForKey:@"total_page"] integerValue];
- [self youpaifrefreshFooterWithHidden:self.youpaippage >= totalPage];
- }
- } failure:^(NSError *error) {
- @strongify(self);
- [self.youpaiptableView endRefreshing:kRefreshAll];
- }];
- }
- - (NSMutableArray<YOUPAILZChatRoomMemberModel *> *)youpaipdataSource{
- if (!_youpaipdataSource) {
- _youpaipdataSource = [NSMutableArray array];
- }
- return _youpaipdataSource;
- }
- @end
|