417 lines
17 KiB
Objective-C
417 lines
17 KiB
Objective-C
//
|
|
// QXAgePraizeRecordView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/8/26.
|
|
//
|
|
|
|
#import "QXAgePraizeRecordView.h"
|
|
|
|
|
|
@interface QXAgePraizeRecordView()<UIGestureRecognizerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>
|
|
@property(nonatomic,strong)UIView* bgView;
|
|
@property(nonatomic,strong)UIImageView* ruleImageView;
|
|
@property(nonatomic,strong)UIImageView* bgImageView;
|
|
|
|
@property(nonatomic,strong)UIView* bgCoverView;
|
|
|
|
@property(nonatomic,strong)UIButton* myRecordBtn;
|
|
@property(nonatomic,strong)UIButton* allRecordBtn;
|
|
@property(nonatomic,strong)UICollectionView* collectionView;
|
|
@property(nonatomic,strong)UITableView* tableView;
|
|
@property(nonatomic,strong)NSMutableArray* myRecordArray;
|
|
@property(nonatomic,strong)NSMutableArray* allRecordArray;
|
|
@property(nonatomic,assign)NSInteger page;
|
|
@end
|
|
@implementation QXAgePraizeRecordView
|
|
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
|
return touch.view == self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
|
tap.delegate = self;
|
|
[self addGestureRecognizer:tap];
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
|
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663))];
|
|
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
[self addSubview:self.bgView];
|
|
|
|
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_rule_bg"]];
|
|
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
|
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
|
[self.bgView addSubview:self.bgImageView];
|
|
|
|
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_record_icon"]];
|
|
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
|
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
|
[self.bgView addSubview:self.ruleImageView];
|
|
|
|
self.bgCoverView = [[UIView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.bgView.width-32, self.bgView.height-self.ruleImageView.bottom-24)];
|
|
self.bgCoverView.backgroundColor = RGB16A(0x000000, 0.5);
|
|
[self.bgView addSubview:self.bgCoverView];
|
|
|
|
self.myRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 75, 40)];
|
|
self.myRecordBtn.selected = YES;
|
|
[self.myRecordBtn setTitle:@"我的记录" forState:(UIControlStateNormal)];
|
|
[self.myRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
|
[self.myRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
|
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
[self.myRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgCoverView addSubview:self.myRecordBtn];
|
|
|
|
self.allRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.myRecordBtn.right+5, 5, 75, 40)];
|
|
[self.allRecordBtn setTitle:@"全服记录" forState:(UIControlStateNormal)];
|
|
[self.allRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
|
[self.allRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
|
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.allRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgCoverView addSubview:self.allRecordBtn];
|
|
|
|
|
|
[self.bgCoverView addSubview:self.collectionView];
|
|
[self.bgCoverView addSubview:self.tableView];
|
|
}
|
|
|
|
-(void)recordAction:(UIButton*)sender{
|
|
if (sender == self.myRecordBtn) {
|
|
if (self.myRecordBtn.selected) {
|
|
return;
|
|
}else{
|
|
self.myRecordBtn.selected = YES;
|
|
self.allRecordBtn.selected = NO;
|
|
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
}
|
|
}else{
|
|
if (self.allRecordBtn.selected) {
|
|
return;
|
|
}else{
|
|
self.allRecordBtn.selected = YES;
|
|
self.myRecordBtn.selected = NO;
|
|
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
}
|
|
}
|
|
[self getRecordList];
|
|
}
|
|
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
|
_giftModel = giftModel;
|
|
self.page = 1;
|
|
[self getRecordList];
|
|
}
|
|
|
|
-(void)getRecordList{
|
|
if (![self.giftModel.gift_bag isExist]) {
|
|
return;
|
|
}
|
|
if (![self.roomId isExist]) {
|
|
return;
|
|
}
|
|
MJWeakSelf
|
|
NSDictionary *parameters = @{
|
|
@"gift_bag_id":self.giftModel.gift_bag,
|
|
@"page":[NSNumber numberWithInteger:self.page]
|
|
};
|
|
NSString *url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
|
if (self.myRecordBtn.selected) {
|
|
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
|
}else{
|
|
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_all_record"];
|
|
}
|
|
[[QXRequset shareInstance] postWithUrl:url parameters:parameters needCache:NO success:^(id responseObject) {
|
|
if (weakSelf.myRecordBtn.selected == YES) {
|
|
weakSelf.collectionView.hidden = NO;
|
|
weakSelf.tableView.hidden = YES;
|
|
if (weakSelf.page == 1) {
|
|
[weakSelf.myRecordArray removeAllObjects];
|
|
}
|
|
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
|
[weakSelf.myRecordArray addObjectsFromArray:arr];
|
|
[weakSelf.collectionView reloadData];
|
|
if (arr.count == 0) {
|
|
weakSelf.collectionView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
}else{
|
|
[weakSelf.collectionView.mj_footer endRefreshing];
|
|
}
|
|
[weakSelf.collectionView.mj_header endRefreshing];
|
|
|
|
}else{
|
|
weakSelf.collectionView.hidden = YES;
|
|
weakSelf.tableView.hidden = NO;
|
|
if (weakSelf.page == 1) {
|
|
[weakSelf.allRecordArray removeAllObjects];
|
|
}
|
|
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
|
[weakSelf.allRecordArray addObjectsFromArray:arr];
|
|
[weakSelf.tableView reloadData];
|
|
if (arr.count == 0) {
|
|
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
|
}else{
|
|
[weakSelf.tableView.mj_footer endRefreshing];
|
|
}
|
|
[weakSelf.tableView.mj_header endRefreshing];
|
|
}
|
|
|
|
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
|
[weakSelf.collectionView.mj_footer endRefreshing];
|
|
[weakSelf.collectionView.mj_header endRefreshing];
|
|
}];
|
|
}
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
[view addSubview:self];
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
|
}];
|
|
}
|
|
-(void)hide{
|
|
// [self stopSlowAnimate];
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
// if (self.myRecordBtn.selected) {
|
|
return self.myRecordArray.count;
|
|
// }else{
|
|
// return self.allRecordArray.count;
|
|
// }
|
|
|
|
}
|
|
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXAgeRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXAgeRecordCell" forIndexPath:indexPath];
|
|
// if (self.myRecordBtn.selected) {
|
|
cell.model = self.myRecordArray[indexPath.row];
|
|
// }else{
|
|
// cell.model = self.allRecordArray[indexPath.row];
|
|
// }
|
|
return cell;
|
|
}
|
|
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
return self.allRecordArray.count;
|
|
}
|
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXAgeAllRecordCell *cell = [QXAgeAllRecordCell cellWithTableView:tableView];
|
|
cell.model = self.allRecordArray[indexPath.row];
|
|
return cell;
|
|
}
|
|
|
|
-(UICollectionView *)collectionView{
|
|
if (!_collectionView) {
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.minimumLineSpacing = 16;
|
|
layout.minimumInteritemSpacing = 16;
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12);
|
|
layout.itemSize = CGSizeMake((self.bgCoverView.width-12*2-16*2-1)/3, ScaleWidth(123));
|
|
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) collectionViewLayout:layout];
|
|
_collectionView.delegate = self;
|
|
_collectionView.dataSource = self;
|
|
_collectionView.showsHorizontalScrollIndicator = NO;
|
|
_collectionView.showsVerticalScrollIndicator = NO;
|
|
_collectionView.backgroundColor = [UIColor clearColor];
|
|
[_collectionView registerClass:[QXAgeRecordCell class] forCellWithReuseIdentifier:@"QXAgeRecordCell"];
|
|
MJWeakSelf
|
|
_collectionView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
|
weakSelf.page++;
|
|
[weakSelf getRecordList];
|
|
}];
|
|
_collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
weakSelf.page = 1;
|
|
[weakSelf getRecordList];
|
|
}];
|
|
}
|
|
return _collectionView;
|
|
}
|
|
-(UITableView *)tableView{
|
|
if (!_tableView) {
|
|
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) style:(UITableViewStylePlain)];
|
|
_tableView.delegate = self;
|
|
_tableView.dataSource = self;
|
|
_tableView.hidden = YES;
|
|
_tableView.rowHeight = 70;
|
|
_tableView.backgroundColor = [UIColor clearColor];
|
|
MJWeakSelf
|
|
_tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
|
weakSelf.page++;
|
|
[weakSelf getRecordList];
|
|
}];
|
|
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
|
weakSelf.page = 1;
|
|
[weakSelf getRecordList];
|
|
}];
|
|
}
|
|
return _tableView;
|
|
}
|
|
-(NSMutableArray *)myRecordArray{
|
|
if (!_myRecordArray) {
|
|
_myRecordArray =[NSMutableArray array];
|
|
}
|
|
return _myRecordArray;
|
|
}
|
|
- (NSMutableArray *)allRecordArray{
|
|
if (!_allRecordArray) {
|
|
_allRecordArray = [NSMutableArray array];
|
|
}
|
|
return _allRecordArray;
|
|
}
|
|
@end
|
|
|
|
|
|
@implementation QXAgeRecordCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)setModel:(QXActivityRecordModel *)model{
|
|
_model = model;
|
|
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
|
self.recieveInfoLabel.text = [NSString stringWithFormat:@"赠予%@",model.nickname];
|
|
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
|
self.timeLabel.text = model.createtime;
|
|
}
|
|
-(void)initSubviews{
|
|
self.giftImageView = [[UIImageView alloc] init];
|
|
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
[self.contentView addSubview:self.giftImageView];
|
|
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.contentView);
|
|
make.left.equalTo(self.contentView).offset(8);
|
|
make.right.equalTo(self.contentView).offset(-8);
|
|
make.height.equalTo(self.giftImageView.mas_width);
|
|
}];
|
|
|
|
self.giftInfoLabel = [[UILabel alloc] init];
|
|
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
|
self.giftInfoLabel.font = [UIFont systemFontOfSize:12];
|
|
[self.contentView addSubview:self.giftInfoLabel];
|
|
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.right.equalTo(self.contentView);
|
|
}];
|
|
|
|
self.recieveInfoLabel = [[UILabel alloc] init];
|
|
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
|
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.contentView addSubview:self.recieveInfoLabel];
|
|
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
|
make.left.right.equalTo(self.contentView);
|
|
make.height.mas_equalTo(21);
|
|
}];
|
|
|
|
self.timeLabel = [[UILabel alloc] init];
|
|
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
|
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
|
[self.contentView addSubview:self.timeLabel];
|
|
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.contentView);
|
|
make.left.right.equalTo(self.contentView);
|
|
}];
|
|
|
|
}
|
|
@end
|
|
|
|
|
|
@implementation QXAgeAllRecordCell
|
|
|
|
+(instancetype)cellWithTableView:(UITableView*)tableView{
|
|
static NSString *cellId = @"QXAgeAllRecordCell";
|
|
QXAgeAllRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
|
if (!cell) {
|
|
cell = [[QXAgeAllRecordCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
|
|
cell.backgroundColor = [UIColor clearColor];
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
}
|
|
return cell;
|
|
}
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)setModel:(QXActivityRecordModel *)model{
|
|
_model = model;
|
|
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
|
self.recieveInfoLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
|
|
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
|
self.timeLabel.text = model.createtime;
|
|
}
|
|
-(void)initSubviews{
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
|
self.recieveInfoLabel = [[UILabel alloc] init];
|
|
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
|
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.contentView addSubview:self.recieveInfoLabel];
|
|
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(12);
|
|
make.left.mas_equalTo(12);
|
|
make.height.mas_equalTo(24);
|
|
}];
|
|
|
|
self.timeLabel = [[UILabel alloc] init];
|
|
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
|
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
|
[self.contentView addSubview:self.timeLabel];
|
|
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.contentView).offset(-12);
|
|
make.left.mas_equalTo(12);
|
|
make.height.mas_equalTo(17);
|
|
}];
|
|
|
|
self.giftImageView = [[UIImageView alloc] init];
|
|
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
[self.contentView addSubview:self.giftImageView];
|
|
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(self.contentView).offset(-12);
|
|
make.height.width.mas_equalTo(21);
|
|
make.centerY.equalTo(self.recieveInfoLabel);
|
|
}];
|
|
|
|
self.giftInfoLabel = [[UILabel alloc] init];
|
|
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
|
self.giftInfoLabel.font = [UIFont systemFontOfSize:16];
|
|
[self.contentView addSubview:self.giftInfoLabel];
|
|
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(self.giftImageView.mas_left);
|
|
make.centerY.equalTo(self.recieveInfoLabel);
|
|
}];
|
|
|
|
self.bottomLine = [[UIView alloc] init];
|
|
self.bottomLine.backgroundColor = RGB16(0xffffff);
|
|
[self.contentView addSubview:self.bottomLine];
|
|
[self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.contentView);
|
|
make.left.mas_equalTo(12);
|
|
make.right.mas_equalTo(-12);
|
|
make.height.mas_equalTo(1);
|
|
}];
|
|
}
|
|
|
|
@end
|