结构调整

This commit is contained in:
启星
2025-10-20 10:29:42 +08:00
parent 2c66709436
commit fdeed970d4
145 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
//
// QXRoomAuctionRankView.h
// QXLive
//
// Created by 启星 on 2025/7/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomAuctionRankView : UIView
@property (nonatomic,strong)NSString *auctionId;
-(void)showInView:(UIView *)view;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,177 @@
//
// QXRoomAuctionRankView.m
// QXLive
//
// Created by on 2025/7/1.
//
#import "QXRoomAuctionRankView.h"
#import "QXMineNetwork.h"
#import "QXRoomRankSubView.h"
#import "QXBlackListCell.h"
@interface QXRoomAuctionRankView()<UIGestureRecognizerDelegate,UITableViewDataSource,UITableViewDelegate>
@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<QXRoomOnlineList *> * _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

View File

@@ -0,0 +1,55 @@
//
// QXRoomAuctionResultView.h
// QXLive
//
// Created by 启星 on 2025/6/30.
//
#import <UIKit/UIKit.h>
#import "QXTimer.h"
#import "QXRoomModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomAuctionResultView : UIView
@property (nonatomic,strong)QXRoomAuctionUser *user;
@property (nonatomic,strong)QXRoomAuctionUser *getUser;
-(instancetype)initWithStyle:(BOOL)isSuccess isRealLove:(BOOL)isRealLove;
-(void)showInView:(UIView *)view;
-(void)hide;
-(void)setResultWithUser:(QXRoomAuctionUser*)user getUser:(QXRoomAuctionUser *)getUser;
@end
@interface QXRoomAuctionFailView : UIView
@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UILabel *messageLabel;
@property (nonatomic,strong)UIButton *closeBtn;
@property (nonatomic,strong)QXTimer *timer;
@property (nonatomic,copy)void(^closeActionBlock)(void);
-(void)startTimer;
@end
@interface QXRoomAuctionSuccessView : UIView
-(instancetype)initWithIsRealLove:(BOOL)isRealLove;
@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)UIImageView *leftHeaderView;
@property (nonatomic,strong)UILabel *leftNameLabel;
@property (nonatomic,strong)UIImageView *rightHeaderView;
@property (nonatomic,strong)UILabel *rightNameLabel;
@property (nonatomic,strong)UILabel *resultLabel;
@property (nonatomic,assign)BOOL isRealLove;
@property (nonatomic,strong)QXTimer *timer;
@property (nonatomic,copy)void(^closeActionBlock)(void);
-(void)startTimer;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,274 @@
//
// QXRoomAuctionResultView.m
// QXLive
//
// Created by on 2025/6/30.
//
#import "QXRoomAuctionResultView.h"
@interface QXRoomAuctionResultView()
@property (nonatomic,assign)BOOL isSuccess;
@property (nonatomic,assign)BOOL isRealLove;
@property (nonatomic,strong)QXRoomAuctionFailView *failView;
@property (nonatomic,strong)QXRoomAuctionSuccessView *successView;
@end
@implementation QXRoomAuctionResultView
-(instancetype)initWithStyle:(BOOL)isSuccess isRealLove:(BOOL)isRealLove{
self = [super init];
if (self) {
self.isSuccess = isSuccess;
self.isRealLove = isRealLove;
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.4];
MJWeakSelf
if (self.isSuccess) {
self.successView = [[QXRoomAuctionSuccessView alloc] initWithIsRealLove:self.isRealLove];
self.successView.alpha = 0;
self.successView.closeActionBlock = ^{
[weakSelf hide];
};
[self addSubview:self.successView];
}else{
self.failView = [[QXRoomAuctionFailView alloc] init];
self.failView.closeActionBlock = ^{
[weakSelf hide];
};
[self addSubview:self.failView];
}
}
-(void)setResultWithUser:(QXRoomAuctionUser *)user getUser:(QXRoomAuctionUser *)getUser{
[self.successView.leftHeaderView sd_setImageWithURL:[NSURL URLWithString:user.avatar]];
self.successView.leftNameLabel.text = user.nickname;
[self.successView.rightHeaderView sd_setImageWithURL:[NSURL URLWithString:getUser.avatar]];
self.successView.rightNameLabel.text = getUser.nickname;
self.successView.resultLabel.text = [NSString stringWithFormat:@"%@签约成功",user.relation_name];
}
-(void)showInView:(UIView *)view{
[view addSubview:self];
if (self.isSuccess) {
// self.successView.resultLabel.text = @"";
[UIView animateWithDuration:0.3 animations:^{
self.successView.alpha = 1;
} completion:^(BOOL finished) {
[self.successView startTimer];
}];
}else{
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.failView.y = (SCREEN_HEIGHT-ScaleWidth(238))/2.0;
} completion:^(BOOL finished) {
[self.failView startTimer];
}];
}
}
-(void)hide{
if (self.isSuccess) {
[UIView animateWithDuration:0.3 animations:^{
self.successView.alpha = 0;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}else{
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.failView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
}
@end
@implementation QXRoomAuctionFailView
- (instancetype)init
{
self = [super init];
if (self) {
CGFloat height = ScaleWidth(238);
self.frame = CGRectMake(15, -height, SCREEN_WIDTH-30, height);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.bgImageView = [[UIImageView alloc] initWithFrame:self.bounds];
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_bg"];
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:self.bgImageView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, self.width-32, 24)];
self.titleLabel.font = [UIFont boldSystemFontOfSize:14];
self.titleLabel.textColor = RGB16(0x333333);
self.titleLabel.text = @"竞拍结束";
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLabel];
self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom+32, self.width-32, 24)];
self.messageLabel.font = [UIFont boldSystemFontOfSize:14];
self.messageLabel.textColor = RGB16(0x333333);
self.messageLabel.text = @"本次竞拍已结束,期待您的下次参与";
self.messageLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.messageLabel];
self.closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(80, self.height-24-42, self.width-160, 42)];
[self.closeBtn addRoundedCornersWithRadius:21];
self.closeBtn.backgroundColor = QXConfig.themeColor;
[self.closeBtn setTitle:QXText(@"知道了") forState:(UIControlStateNormal)];
[self.closeBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.closeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.closeBtn];
}
-(void)startTimer{
__block int timeCount = 3;
MJWeakSelf
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
timeCount--;
if (timeCount<=0) {
[weakSelf closeAction];
}else{
[self->_closeBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"知道了"),timeCount] forState:(UIControlStateNormal)];
}
}];
}
-(void)closeAction{
[self->_timer invalidate];
self->_timer = nil;
if (self.closeActionBlock) {
self.closeActionBlock();
}
}
@end
@implementation QXRoomAuctionSuccessView
//- (instancetype)init
//{
// self = [super init];
// if (self) {
// self.frame = CGRectMake(0, ScaleWidth(219), 372, 306);
// [self initSubviews];
// }
// return self;
//}
- (instancetype)initWithIsRealLove:(BOOL)isRealLove
{
self = [super init];
if (self) {
_isRealLove = isRealLove;
if (isRealLove) {
self.frame = CGRectMake(0, ScaleWidth(219), 372, 306);
}else{
self.frame = CGRectMake(0, ScaleWidth(219), SCREEN_WIDTH, 402);
}
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_auction_result_suc"]];
self.bgImageView.frame = self.bounds;
[self addSubview:self.bgImageView];
self.leftHeaderView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 90, 57, 57)];
self.leftHeaderView.contentMode = UIViewContentModeScaleAspectFill;
self.leftHeaderView.clipsToBounds = YES;
[self.leftHeaderView addRoundedCornersWithRadius:23.5];
[self addSubview:self.leftHeaderView];
self.leftNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 16)];
self.leftNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
self.leftNameLabel.textColor = RGB16(0xFFE8B0);
self.leftNameLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.leftNameLabel];
self.rightHeaderView = [[UIImageView alloc] initWithFrame:CGRectMake(self.width-100-57, self.leftHeaderView.top, 57, 57)];
self.rightHeaderView.contentMode = UIViewContentModeScaleAspectFill;
self.rightHeaderView.clipsToBounds = YES;
[self.rightHeaderView addRoundedCornersWithRadius:23.5];
[self addSubview:self.rightHeaderView];
self.rightNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 16)];
self.rightNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
self.rightNameLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.rightNameLabel];
self.resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.rightNameLabel.bottom+18, self.width, 17)];
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:14];
self.resultLabel.textColor = UIColor.whiteColor;
// self.resultLabel.transform = CGAffineTransformMakeRotation(-6 * M_PI/180.0);
self.resultLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.resultLabel];
if (self.isRealLove) {
self.bgImageView.frame = self.bounds;
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_suc_real"];
self.leftHeaderView.frame = CGRectMake(100, 90, 57, 57);
self.rightHeaderView.frame = CGRectMake(self.width-100-57, self.leftHeaderView.top, 57, 57);
self.rightNameLabel.frame = CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 16);
self.leftNameLabel.frame = CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 16);
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
self.leftNameLabel.textColor = RGB16(0xFFE8B0);
self.rightNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
self.leftNameLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:12];
self.rightNameLabel.textColor = RGB16(0xFFE8B0);
self.resultLabel.frame = CGRectMake(0, self.rightNameLabel.bottom+18, self.width, 17);
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:14];
self.resultLabel.textColor = UIColor.whiteColor;
[self.rightHeaderView addRoundedCornersWithRadius:23.5];
[self.leftHeaderView addRoundedCornersWithRadius:23.5];
}else{
self.bgImageView.image = [UIImage imageNamed:@"room_auction_result_suc"];
self.bgImageView.frame = CGRectMake((self.width-302)/2, 0, 302, self.height);
self.leftHeaderView.frame = CGRectMake(self.width/2-68, self.height-73-68, 68, 68);
self.rightHeaderView.frame = CGRectMake(self.leftHeaderView.right, self.leftHeaderView.top, 68,68);
self.rightNameLabel.frame = CGRectMake(self.rightHeaderView.left, self.rightHeaderView.bottom+1, self.rightHeaderView.width, 21);
self.leftNameLabel.frame = CGRectMake(self.leftHeaderView.left, self.leftHeaderView.bottom+1, self.leftHeaderView.width, 21);
self.rightNameLabel.textColor = RGB16(0xFE435B);
self.leftNameLabel.textColor = RGB16(0xFE435B);
self.rightNameLabel.font = [UIFont systemFontOfSize:14];
self.leftNameLabel.font = [UIFont systemFontOfSize:14];
self.resultLabel.frame = CGRectMake(0, 19, self.width, 42);
self.resultLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:32];
self.resultLabel.textColor = RGB16(0xFFA4C8);
[self.rightHeaderView addRoundedCornersWithRadius:34];
[self.leftHeaderView addRoundedCornersWithRadius:34];
}
}
-(void)startTimer{
__block int timeCount = 3;
MJWeakSelf
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
timeCount--;
if (timeCount<=0) {
[weakSelf closeAction];
}
}];
}
-(void)closeAction{
[self->_timer invalidate];
self->_timer = nil;
if (self.closeActionBlock) {
self.closeActionBlock();
}
}
@end

View File

@@ -0,0 +1,31 @@
//
// QXSelectAuctionInfoView.h
// QXLive
//
// Created by 启星 on 2025/6/27.
//
#import <UIKit/UIKit.h>
#import "QXRoomRelationModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface QXSelectAuctionInfoView : UIView
/// 是否是真爱拍
@property (nonatomic,assign)BOOL isRealLove;
@property (nonatomic,strong)NSString *roomId;
@property (nonatomic,strong)NSString *userId;
-(void)showInView:(UIView *)view;
-(void)hide;
@end
@interface QXSelectAuctionInfoHeaderView : UICollectionReusableView
@property (nonatomic,strong) UILabel *titleLabel;
@end
@interface QXSelectAuctionInfoCell : UICollectionViewCell
@property (nonatomic,strong) QXRoomRelationModel *model;
@property (nonatomic,strong) QXRoomRelationModel *timeModel;
@property (nonatomic,strong) UIButton *selectedBtn;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,428 @@
//
// QXSelectAuctionInfoView.m
// QXLive
//
// Created by on 2025/6/27.
//
#import "QXSelectAuctionInfoView.h"
#import "QXGiftCell.h"
#import "QXMineNetwork.h"
@interface QXSelectAuctionInfoView()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UIGestureRecognizerDelegate>
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)UILabel *titleLabel;
//@property (nonatomic,strong)UILabel *contenLabel;
@property (nonatomic,strong)UICollectionView *collectionView;
@property (nonatomic,strong)UIButton *commitBtn;
@property (nonatomic,strong)NSMutableArray *relationshipArray;
@property (nonatomic,strong)NSMutableArray *timeArray;
@property (nonatomic,strong)NSMutableArray *giftArray;
@property (nonatomic,strong)QXRoomRelationModel *relationModel;
@property (nonatomic,strong)QXRoomRelationModel *timeModel;
@property (nonatomic,assign)QXGiftModel *giftModel;
@property (nonatomic,assign)NSInteger giftSelctedIndex;
@end
@implementation QXSelectAuctionInfoView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
// tap.delegate = self;
// [self addGestureRecognizer:tap];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom)];
[self addSubview:self.bgView];
self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bgView.width, self.bgView.height)];
self.bgImageView.image = [UIImage imageNamed:@"room_sound_bg"];
[self.bgView addSubview:self.bgImageView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, self.bgView.width-32, 24)];
self.titleLabel.font = [UIFont systemFontOfSize:16];
self.titleLabel.textColor = UIColor.whiteColor;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.text = @"选择内容";
[self.bgView addSubview:self.titleLabel];
// self.contenLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom, self.bgView.width-32, 24)];
// self.contenLabel.font = [UIFont systemFontOfSize:14];
// self.contenLabel.textColor = UIColor.whiteColor;
// [self.bgView addSubview:self.contenLabel];
self.commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.bgView.height-kSafeAreaBottom-12-42, self.bgView.width-76, 42)];
[self.commitBtn setTitle:@"确定" forState:(UIControlStateNormal)];
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.commitBtn.backgroundColor = QXConfig.themeColor;
[self.commitBtn addRoundedCornersWithRadius:21];
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.commitBtn];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 12;
layout.minimumInteritemSpacing = 12;
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom, self.bgView.width, self.commitBtn.top-self.titleLabel.bottom-10) collectionViewLayout:layout];
[self.collectionView registerNib:[UINib nibWithNibName:@"QXGiftCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXGiftCell"];
[self.collectionView registerClass:[QXSelectAuctionInfoCell class] forCellWithReuseIdentifier:@"QXSelectAuctionInfoCell"];
[self.collectionView registerClass:[QXSelectAuctionInfoHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXSelectAuctionInfoHeaderView"];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.bounces = NO;
self.collectionView.backgroundColor = [UIColor clearColor];
[self.bgView addSubview:self.collectionView];
}
-(void)commitAction{
if (self.relationModel == nil) {
showToast(@"请选择关系");
return;
}
if (!self.isRealLove) {
if (self.timeModel == nil) {
showToast(@"请选择时间");
return;
}
}
if (self.giftModel == nil) {
showToast(@"请选择礼物");
return;
}
MJWeakSelf
[QXMineNetwork roomAuctionStartWithRoomId:self.roomId user_id:self.userId gift_id:self.giftModel.gift_id relation_id:self.relationModel.relation_id auction_type:self.isRealLove?@"1":@"2" time_day:self.timeModel.relation_id successBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf hide];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)getRelationShipList{
MJWeakSelf
[QXMineNetwork roomRelationListWithType:self.isRealLove?@"1":@"2" successBlock:^(NSArray<QXRoomRelationModel *> * _Nonnull list) {
[weakSelf.relationshipArray removeAllObjects];
[weakSelf.relationshipArray addObjectsFromArray:list];
[weakSelf.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)getGiftList{
MJWeakSelf
[QXMineNetwork giftListWithLabel:@"99" roomId:self.roomId successBlock:^(NSArray<QXGiftModel *> * _Nonnull list) {
[weakSelf.giftArray removeAllObjects];
[weakSelf.giftArray addObjectsFromArray:list];
[weakSelf.collectionView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
//-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
// return touch.view == self;
//}
-(void)setIsRealLove:(BOOL)isRealLove{
self.giftModel = nil;
self.relationModel = nil;
self.timeModel = nil;
_timeArray = nil;
self.giftSelctedIndex = -1;
_isRealLove = isRealLove;
[self getRelationShipList];
[self getGiftList];
[self.collectionView reloadData];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
if (self.isRealLove) {
return 2;
}else{
return 3;
}
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
if (section == 0) {
return self.relationshipArray.count;
}else if(section == 1){
if (self.isRealLove) {
return self.giftArray.count;
}else{
return self.timeArray.count;
}
}else{
return self.giftArray.count;
}
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
QXSelectAuctionInfoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSelectAuctionInfoCell" forIndexPath:indexPath];
cell.model = self.relationshipArray[indexPath.row];
return cell;
}else if(indexPath.section == 1){
if (self.isRealLove) {
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
cell.cellType = QXGiftCellTypeLive;
cell.roomGiftModel = self.giftArray[indexPath.row];
if (self.giftSelctedIndex == indexPath.row) {
cell.selecteBtn.selected = YES;
}else{
cell.selecteBtn.selected = NO;
}
return cell;
}else{
QXSelectAuctionInfoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSelectAuctionInfoCell" forIndexPath:indexPath];
cell.model = self.timeArray[indexPath.row];
return cell;
}
}else{
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
cell.cellType = QXGiftCellTypeLive;
cell.roomGiftModel = self.giftArray[indexPath.row];
if (self.giftSelctedIndex == indexPath.row) {
cell.selecteBtn.selected = YES;
}else{
cell.selecteBtn.selected = NO;
}
return cell;
}
}
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
QXSelectAuctionInfoHeaderView *header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"QXSelectAuctionInfoHeaderView" forIndexPath:indexPath];
if (indexPath.section == 0) {
header.titleLabel.text = @"关系";
}else if(indexPath.section == 1){
if (self.isRealLove) {
header.titleLabel.text = @"礼物";
}else{
header.titleLabel.text = @"时间";
}
}else{
header.titleLabel.text = @"礼物";
}
return header;
}
return nil;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
return CGSizeMake(SCREEN_WIDTH, 30);
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
CGFloat width = (SCREEN_WIDTH-16*2-12*3)/4;
return CGSizeMake(width, 44);
}else if(indexPath.section == 1){
if (self.isRealLove) {
CGFloat width = (SCREEN_WIDTH-16*2-12*3)/4;
return CGSizeMake(width, ScaleWidth(119));
}else{
CGFloat width = (SCREEN_WIDTH-16*2-12*3)/4;
return CGSizeMake(width, 44);
}
}else{
CGFloat width = (SCREEN_WIDTH-16*2-12*3)/4;
return CGSizeMake(width, ScaleWidth(119));
}
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
QXRoomRelationModel *model = self.relationshipArray[indexPath.row];
if (model.isSelected) {
return;
}
self.relationModel.isSelected = NO;
model.isSelected = YES;
self.relationModel = model;
[collectionView reloadData];
}else if(indexPath.section == 1){
if (self.isRealLove) {
QXGiftModel *model = self.giftArray[indexPath.row];
self.giftSelctedIndex = indexPath.row;
self.giftModel = model;
[collectionView reloadData];
}else{
QXRoomRelationModel *model = self.timeArray[indexPath.row];
if (model.isSelected) {
return;
}
self.timeModel.isSelected = NO;
model.isSelected = YES;
self.timeModel = model;
[collectionView reloadData];
}
}else{
QXGiftModel *model = self.giftArray[indexPath.row];
self.giftSelctedIndex = indexPath.row;
self.giftModel = model;
[collectionView reloadData];
}
}
-(void)showInView:(UIView *)view{
self.bgView.y = SCREEN_HEIGHT;
[view addSubview:self];
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429)-kSafeAreaBottom;
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
-(NSMutableArray *)relationshipArray{
if (!_relationshipArray) {
_relationshipArray = [NSMutableArray array];
}
return _relationshipArray;
}
-(NSMutableArray *)timeArray{
if (!_timeArray) {
QXRoomRelationModel *md = [[QXRoomRelationModel alloc] init];
md.name = @"1天";
md.relation_id = @"24";
QXRoomRelationModel *md1 = [[QXRoomRelationModel alloc] init];
md1.name = @"3天";
md1.relation_id = @"72";
QXRoomRelationModel *md2 = [[QXRoomRelationModel alloc] init];
md2.name = @"5天";
md2.relation_id = @"120";
QXRoomRelationModel *md3 = [[QXRoomRelationModel alloc] init];
md3.name = @"10天";
md3.relation_id = @"240";
QXRoomRelationModel *md4 = [[QXRoomRelationModel alloc] init];
md4.name = @"15天";
md4.relation_id = @"360";
QXRoomRelationModel *md5 = [[QXRoomRelationModel alloc] init];
md5.name = @"20天";
md5.relation_id = @"480";
QXRoomRelationModel *md6 = [[QXRoomRelationModel alloc] init];
md6.name = @"25天";
md6.relation_id = @"600";
QXRoomRelationModel *md7 = [[QXRoomRelationModel alloc] init];
md7.name = @"30天";
md7.relation_id = @"720";
_timeArray = [NSMutableArray arrayWithArray:@[
md,md1,md2,md3,md4,md5,md6,md7
]];
}
return _timeArray;
}
-(NSMutableArray *)giftArray{
if (!_giftArray) {
_giftArray = [NSMutableArray array];
}
return _giftArray;
}
@end
@implementation QXSelectAuctionInfoHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, SCREEN_WIDTH-32, 30)];
titleLabel.textColor = UIColor.whiteColor;
titleLabel.font = [UIFont systemFontOfSize:13];
// if (indexPath.section == 0) {
// titleLabel.text = @"关系";
// }else if(indexPath.section == 1){
// if (self.isRealLove) {
// titleLabel.text = @"礼物";
// }else{
// titleLabel.text = @"时间";
// }
// }else{
// titleLabel.text = @"礼物";
// }
[self addSubview:titleLabel];
self.titleLabel = titleLabel;
}
@end
@implementation QXSelectAuctionInfoCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)setModel:(QXRoomRelationModel *)model{
_model = model;
[self.selectedBtn setTitle:model.name forState:(UIControlStateNormal)];
self.selectedBtn.selected = model.isSelected;
}
-(void)setTimeModel:(QXRoomRelationModel *)timeModel{
_timeModel = timeModel;
[self.selectedBtn setTitleColor:QXConfig.themeColor forState:(UIControlStateSelected)];
[self.selectedBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
[self.selectedBtn setTitle:timeModel.name forState:(UIControlStateNormal)];
self.selectedBtn.layer.borderColor = RGB16(0xF1F2F3).CGColor;
self.selectedBtn.layer.borderWidth = 1;
self.selectedBtn.selected = timeModel.isSelected;
}
-(void)initSubviews{
self.selectedBtn = [[UIButton alloc] init];
[self.selectedBtn setBackgroundImage:[UIImage imageNamed:@"room_sound_sel"] forState:(UIControlStateSelected)];
[self.selectedBtn setBackgroundImage:[UIImage imageWithColor:RGB16A(0xE9E9E9, 0.2)] forState:(UIControlStateNormal)];
[self.selectedBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
[self.selectedBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateSelected)];
self.selectedBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.selectedBtn addRoundedCornersWithRadius:12];
self.selectedBtn.userInteractionEnabled = NO;
[self.contentView addSubview:self.selectedBtn];
[self.selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.right.left.equalTo(self.contentView);
}];
// self.titleLabel = [[UILabel alloc] init];
// self.titleLabel
}
@end