// // QXRoomAuctionRankView.m // QXLive // // Created by 启星 on 2025/7/1. // #import "QXRoomAuctionRankView.h" #import "QXMineNetwork.h" #import "QXRoomRankSubView.h" #import "QXBlackListCell.h" @interface QXRoomAuctionRankView() @property (nonatomic,strong)UILabel *titleLabel; @property (nonatomic,strong)UIImageView *bgImageView; @property (nonatomic,strong)UIView *bgView; @property (nonatomic,strong)UIView *tableHeaderView; @property (nonatomic,strong)QXRoomRankTopThreeView *firstView; @property (nonatomic,strong)QXRoomRankTopThreeView *secondView; @property (nonatomic,strong)QXRoomRankTopThreeView *thirdView; @property (nonatomic,strong)UITableView *tableView; @property (nonatomic,strong)NSMutableArray *dataArray; @property (nonatomic,assign)NSInteger page; @end @implementation QXRoomAuctionRankView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)]; tap.delegate = self; [self addGestureRecognizer:tap]; self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, ScaleWidth(144), SCREEN_WIDTH, SCREEN_HEIGHT-ScaleWidth(144))]; [self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)]; [self addSubview:self.bgView]; self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_rank_bg"]]; self.bgImageView.contentMode = UIViewContentModeScaleToFill; self.bgImageView.frame = self.bgView.bounds; [self.bgView addSubview:self.bgImageView]; self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 12, self.bgView.width, 30)]; self.titleLabel.font = [UIFont boldSystemFontOfSize:18]; self.titleLabel.textColor = [UIColor whiteColor]; self.titleLabel.text = @"出价榜单"; self.titleLabel.textAlignment = NSTextAlignmentCenter; [self.bgView addSubview:self.titleLabel]; self.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 220+44+38+40+8)]; CGFloat itemWidth = (self.width-36)/3; self.secondView = [[QXRoomRankTopThreeView alloc] initWithFrame:CGRectMake(18, 44+38+40+8+50, itemWidth, 135)]; self.secondView.number = 2; [self.tableHeaderView addSubview:self.secondView]; self.firstView = [[QXRoomRankTopThreeView alloc] initWithFrame:CGRectMake(self.secondView.right, 44+38+40+8, itemWidth, 161)]; self.firstView.number = 1; [self.tableHeaderView addSubview:self.firstView]; self.thirdView = [[QXRoomRankTopThreeView alloc] initWithFrame:CGRectMake(self.firstView.right, 44+38+40+8+50, itemWidth, 135)]; self.thirdView.number = 3; [self.tableHeaderView addSubview:self.thirdView]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.bgView.height) style:(UITableViewStylePlain)]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.rowHeight = 60; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.tableHeaderView = self.tableHeaderView; MJWeakSelf self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{ weakSelf.page++; [weakSelf getAuctionUserList]; }]; self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ weakSelf.page = 1; [weakSelf getAuctionUserList]; }]; [self.bgView addSubview:self.tableView]; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ return touch.view == self; } -(void)setAuctionId:(NSString *)auctionId{ _auctionId = auctionId; self.page = 1; [self getAuctionUserList]; } -(void)getAuctionUserList{ MJWeakSelf [QXMineNetwork roomAuctionUserListWithAuctionId:self.auctionId successBlock:^(NSArray * _Nonnull list) { if (weakSelf.page == 1) { weakSelf.firstView.md = nil; weakSelf.secondView.md = nil; weakSelf.thirdView.md = nil; [weakSelf.dataArray removeAllObjects]; for (int i = 0 ; i < list.count; i++) { QXRoomOnlineList*md = list[i]; if (i == 0) { // [weakSelf.topArray addObject:md]; weakSelf.firstView.md = md; }else if (i == 1) { weakSelf.secondView.md = md; }else if (i == 2) { weakSelf.thirdView.md = md; }else{ [weakSelf.dataArray addObject:md]; } } }else{ [weakSelf.dataArray addObjectsFromArray:list]; } [self.tableView reloadData]; if (list.count == 0) { self.tableView.mj_footer.state = MJRefreshStateNoMoreData; }else{ [self.tableView.mj_footer endRefreshing]; } [self.tableView.mj_header endRefreshing]; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; }]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataArray.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ QXBlackListCell *cell = [QXBlackListCell cellWithTableView:tableView]; cell.cellType = QXBlackListCellTypeRank; cell.backgroundColor = [UIColor clearColor]; cell.titleLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row+4]; cell.rankModel = self.dataArray[indexPath.row]; return cell; } -(void)showInView:(UIView *)view{ self.bgView.y = SCREEN_HEIGHT; [view addSubview:self]; [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = ScaleWidth(144); }]; } -(void)hide{ [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } -(NSMutableArray *)dataArray{ if (!_dataArray) { _dataArray = [NSMutableArray array]; } return _dataArray; } @end