Files
featherVoice/QXLive/Room(房间)/Controller/QXRedBagRecordViewController.m

263 lines
11 KiB
Mathematica
Raw Normal View History

2025-10-20 09:43:10 +08:00
//
// QXRedBagRecordViewController.m
// QXLive
//
// Created by on 2025/10/11.
//
#import "QXRedBagRecordViewController.h"
#import "QXMineNetwork.h"
@class QXRedBagRecordCell;
@interface QXRedBagRecordViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)UIView *topView;
@property (nonatomic,strong)UIImageView *topImageView;
@property (nonatomic,strong)UIImageView *senderHeaderImageView;
@property (nonatomic,strong)UILabel *senderNameLabel;
@property (nonatomic,strong)UILabel *remarkLabel;
@property (nonatomic,strong)UILabel *moneyLabel;
@property (nonatomic,strong)UILabel *bottomLabel;
@property (nonatomic,strong)UILabel *countLabel;
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)QXDrawRedPacketModel *model;
@end
@implementation QXRedBagRecordViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)initSubViews{
self.topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(308))];
self.topImageView = [[UIImageView alloc] init];
self.topImageView.image = [UIImage imageNamed:@"red_bag_record_top_bg"];
[self.topView addSubview:self.topImageView];
[self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.left.right.equalTo(self.topView);
}];
self.senderNameLabel = [[UILabel alloc] init];
self.senderNameLabel.textColor = RGB16(0xffffff);
self.senderNameLabel.font = [UIFont systemFontOfSize:18];
self.senderNameLabel.text = @"-";
[self.topView addSubview:self.senderNameLabel];
[self.senderNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.topView).offset(41-13);;
make.top.equalTo(self.topView).offset(92);
}];
self.senderHeaderImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.senderHeaderImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.senderHeaderImageView addRoundedCornersWithRadius:20.5];
[self.topView addSubview:self.senderHeaderImageView];
[self.senderHeaderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.senderNameLabel.mas_left).offset(-13);
make.centerY.equalTo(self.senderNameLabel);
make.width.height.mas_equalTo(41);
}];
self.remarkLabel = [[UILabel alloc] init];
self.remarkLabel.text = @"-";
self.remarkLabel.textColor = RGB16(0xffffff);
self.remarkLabel.font = [UIFont systemFontOfSize:13];
[self.topView addSubview:self.remarkLabel];
[self.remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.senderHeaderImageView.mas_bottom).offset(5);
make.height.mas_equalTo(26);
make.centerX.equalTo(self.topView);
}];
self.moneyLabel = [[UILabel alloc] init];
self.moneyLabel.font = [UIFont boldSystemFontOfSize:19];
self.moneyLabel.textColor = RGB16(0xffffff);
self.moneyLabel.text = @"0金币";
[self.topView addSubview:self.moneyLabel];
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.topView);
make.top.equalTo(self.remarkLabel.mas_bottom);
}];
self.bottomLabel = [[UILabel alloc] init];
self.bottomLabel.textColor = RGB16(0xffffff);
self.bottomLabel.text = @"已存入钱包";
self.bottomLabel.font = [UIFont systemFontOfSize:13];
[self.topView addSubview:self.bottomLabel];
[self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.topView);
make.top.equalTo(self.moneyLabel.mas_bottom);
}];
self.countLabel = [[UILabel alloc] init];
self.countLabel.textColor = RGB16(0x999999);
self.countLabel.font = [UIFont systemFontOfSize:13];
self.countLabel.text = @"已领取0/0";
[self.topView addSubview:self.countLabel];
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo (15);
make.bottom.mas_equalTo(-10);
}];
[self.view addSubview:self.topView];
[self.dataArray addObject:@""];
[self.dataArray addObject:@""];
[self.dataArray addObject:@""];
[self.dataArray addObject:@""];
[self.dataArray addObject:@""];
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStylePlain)];
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.backgroundColor = RGB16(0xffffff);
self.tableView.rowHeight = 67;
// self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
[self.view addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(self.view);
make.top.equalTo(self.topView.mas_bottom);
}];
UIButton*backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, kSafeAreaTop, 44, 44)];
[backBtn setImage:[[UIImage imageNamed:@"back"] imageByTintColor:UIColor.whiteColor] forState:(UIControlStateNormal)];
// backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading;
[backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.view addSubview:backBtn];
}
-(void)setRedbagId:(NSString *)redbagId{
_redbagId = redbagId;
MJWeakSelf
[QXMineNetwork getRedpacketRecordWithRedpacketId:redbagId successBlock:^(QXDrawRedPacketModel* model) {
weakSelf.model = model;
weakSelf.remarkLabel.text = model.redpacket_info.remark;
[weakSelf.senderHeaderImageView sd_setImageWithURL:[NSURL URLWithString:model.redpacket_info.avatar]];
weakSelf.senderNameLabel.text = [NSString stringWithFormat:@"%@的红包",model.redpacket_info.nickname];
NSString *coinStr = @"";
if (weakSelf.model.redpacket_info.coin_type.intValue == 1) {
weakSelf.bottomLabel.text = @"已存入金币";
coinStr = [NSString stringWithFormat:@"%@%@",model.my_record.amount?model.my_record.amount:@"0",@"金币"];
}else{
weakSelf.bottomLabel.text = @"已存入钻石";
coinStr = [NSString stringWithFormat:@"%@%@",model.my_record.amount?model.my_record.amount:@"0",@"钻石"];
}
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:coinStr];
[attr yy_setFont:[UIFont boldSystemFontOfSize:46] range:[coinStr rangeOfString:[NSString stringWithFormat:@"%@",model.my_record.amount?model.my_record.amount:@"0"]]];
weakSelf.moneyLabel.attributedText = attr;
weakSelf.countLabel.text = [NSString stringWithFormat:@"已领取%ld/%@",model.redpacket_info.total_count.integerValue-model.redpacket_info.left_count.integerValue,model.redpacket_info.total_count];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.model.records.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXRedBagRecordCell *cell = [QXRedBagRecordCell cellWithTabelView:tableView];
cell.recordModel = self.model.records[indexPath.row];
return cell;
}
-(void)backAction{
[self.navigationController popViewControllerAnimated:YES];
}
@end
@interface QXRedBagRecordCell()
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIImageView *userHeaderImageView;
@property (nonatomic,strong)UILabel *nameLabel;
@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong)UILabel *moneyLabel;
@end
@implementation QXRedBagRecordCell
+(instancetype)cellWithTabelView:(UITableView *)tableView{
static NSString *cellId = @"QXRedBagRecordCell";
QXRedBagRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) {
cell = [[QXRedBagRecordCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
}
return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
[self initSubviews];
}
return self;
}
-(void)setRecordModel:(QXDrawRedpacketRecordModel *)recordModel{
_recordModel = recordModel;
self.nameLabel.text = recordModel.nickname;
[self.userHeaderImageView sd_setImageWithURL:[NSURL URLWithString:recordModel.avatar]];
self.timeLabel.text = recordModel.createtime;
self.moneyLabel.text = recordModel.amount;
}
-(void)initSubviews{
self.bgView = [[UIView alloc] init];
[self.contentView addSubview:self.bgView];
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.right.mas_equalTo(-15);
make.height.mas_equalTo(52);
make.centerY.equalTo(self.contentView);
}];
self.userHeaderImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.userHeaderImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.userHeaderImageView addRoundedCornersWithRadius:24.5];
[self.bgView addSubview:self.userHeaderImageView];
[self.userHeaderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.centerY.equalTo(self.bgView);
make.width.height.mas_equalTo(49);
}];
self.nameLabel = [[UILabel alloc] init];
self.nameLabel.textColor = RGB16(0x666666);
self.nameLabel.text = @"大家好,我是傻狗涛";
self.nameLabel.font = [UIFont systemFontOfSize:14];
[self.bgView addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userHeaderImageView.mas_right).offset(13);
make.top.equalTo(self.userHeaderImageView);
make.height.mas_equalTo(26);
}];
self.timeLabel = [[UILabel alloc] init];
self.timeLabel.textColor = RGB16(0x999999);
self.timeLabel.font = [UIFont systemFontOfSize:14];
self.timeLabel.text = @"00:61";
[self.bgView addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userHeaderImageView.mas_right).offset(13);
make.bottom.equalTo(self.userHeaderImageView);
make.height.mas_equalTo(26);
}];
self.moneyLabel = [[UILabel alloc] init];
self.moneyLabel.textColor = RGB16(0x333333);
self.moneyLabel.text = @"0 金币";
self.moneyLabel.font = [UIFont systemFontOfSize:14];
[self.bgView addSubview:self.moneyLabel];
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.bgView);
make.centerY.equalTo(self.bgView);
}];
}
@end