2023-07-14 18:50:55 +08:00
|
|
|
//
|
|
|
|
// YMIAPRechargeCollectionViewCell.m
|
|
|
|
// YUMI
|
|
|
|
//
|
|
|
|
// Created by XY on 2023/2/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPIAPRechargeCollectionViewCell.h"
|
|
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
#import <Masonry.h>
|
|
|
|
|
|
|
|
#import "RechargeListModel.h"
|
2025-06-26 11:08:21 +08:00
|
|
|
#import "FirstRechargeManager.h"
|
|
|
|
#import "MoliMoneyLabel.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
|
|
@interface XPIAPRechargeCollectionViewCell()
|
|
|
|
|
|
|
|
/// 背景
|
|
|
|
@property (nonatomic, strong) UIView *bgView;
|
2024-05-29 17:14:02 +08:00
|
|
|
@property(nonatomic,strong) UIView *bgPriceView;
|
2023-07-14 18:50:55 +08:00
|
|
|
/// 价格
|
|
|
|
@property (nonatomic, strong) UILabel *priceLabel;
|
|
|
|
/// 💎
|
|
|
|
@property (nonatomic, strong) UIImageView *iconImageView;
|
|
|
|
/// 数量
|
|
|
|
@property (nonatomic, strong) UILabel *numLabel;
|
|
|
|
|
2025-06-26 11:08:21 +08:00
|
|
|
@property (nonatomic, strong) UIView *extBG;
|
|
|
|
@property (nonatomic, strong) MoliMoneyLabel *moneyLabel;
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation XPIAPRechargeCollectionViewCell
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
|
|
[self createUI];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)createUI {
|
|
|
|
[self.contentView addSubview:self.bgView];
|
2024-05-29 17:14:02 +08:00
|
|
|
[self.bgView addSubview:self.bgPriceView];
|
|
|
|
[self.bgPriceView addSubview:self.priceLabel];
|
2023-09-12 17:48:18 +08:00
|
|
|
[self.bgView addSubview:self.iconImageView];
|
|
|
|
[self.bgView addSubview:self.numLabel];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-05-29 17:14:02 +08:00
|
|
|
make.edges.equalTo(self.contentView);
|
2023-09-12 17:48:18 +08:00
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
}];
|
2024-05-29 17:14:02 +08:00
|
|
|
|
2023-09-12 17:48:18 +08:00
|
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-05-29 17:14:02 +08:00
|
|
|
make.top.mas_equalTo(kGetScaleWidth(13));
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(55));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(48));
|
|
|
|
make.centerX.equalTo(self.bgView);
|
2023-07-14 18:50:55 +08:00
|
|
|
}];
|
|
|
|
[self.numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-05-29 17:14:02 +08:00
|
|
|
make.leading.trailing.equalTo(self.bgView).inset(kGetScaleWidth(0));
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(66));
|
2023-07-14 18:50:55 +08:00
|
|
|
}];
|
2024-05-29 17:14:02 +08:00
|
|
|
[self.bgPriceView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.leading.trailing.bottom.equalTo(self.bgView);
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(26));
|
|
|
|
}];
|
|
|
|
[self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.edges.equalTo(self.bgPriceView);
|
|
|
|
}];
|
|
|
|
|
2025-06-26 11:08:21 +08:00
|
|
|
[self.contentView addSubview:self.extBG];
|
|
|
|
[self.extBG mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.trailing.mas_equalTo(self.bgView);
|
|
|
|
make.size.mas_equalTo(CGSizeMake(64, 20));
|
|
|
|
}];
|
2023-09-12 17:48:18 +08:00
|
|
|
|
2025-06-26 11:08:21 +08:00
|
|
|
[self.contentView addSubview:self.moneyLabel];
|
|
|
|
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.centerY.mas_equalTo(self.extBG);
|
|
|
|
make.trailing.mas_equalTo(self.extBG).offset(-5);
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setRechargeModel:(RechargeListModel *)rechargeModel {
|
|
|
|
_rechargeModel = rechargeModel;
|
2023-07-19 14:41:04 +08:00
|
|
|
NSMutableAttributedString *priceStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"$%.2f",rechargeModel.money.floatValue]];
|
2023-07-14 18:50:55 +08:00
|
|
|
self.priceLabel.attributedText = priceStr;
|
2025-07-02 15:52:48 +08:00
|
|
|
self.numLabel.text = [NSString stringWithFormat:@"%ld",
|
|
|
|
(long)rechargeModel.chargeGoldNum];
|
2025-07-03 19:35:17 +08:00
|
|
|
self.extBG.hidden = YES;
|
|
|
|
self.moneyLabel.hidden = YES;
|
2025-06-26 11:08:21 +08:00
|
|
|
FirstRechargeModel *model = [FirstRechargeManager.sharedManager loadCurrentModel];
|
|
|
|
if (model && model.chargeStatus == NO) {
|
|
|
|
for (FirstRechargeLevelModel *levelModel in model.levelCharge) {
|
2025-07-02 15:52:48 +08:00
|
|
|
if (levelModel.exp == rechargeModel.chargeGoldNum) {
|
2025-06-26 11:08:21 +08:00
|
|
|
[self.moneyLabel updateContent: [NSString stringWithFormat:@"+ %@", @(levelModel.awardNum)]];
|
2025-07-03 19:35:17 +08:00
|
|
|
self.extBG.hidden = NO;
|
|
|
|
self.moneyLabel.hidden = NO;
|
2025-06-26 11:08:21 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setSelectedStyle:(BOOL)selectedStyle {
|
|
|
|
_selectedStyle = selectedStyle;
|
2024-05-29 17:14:02 +08:00
|
|
|
_bgView.layer.borderWidth = _selectedStyle ? 1 : 0;
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
|
|
|
|
- (UIView *)bgView {
|
|
|
|
if (!_bgView) {
|
|
|
|
_bgView = [[UIView alloc] init];
|
2024-05-29 17:14:02 +08:00
|
|
|
_bgView.backgroundColor = UIColorFromRGB(0xF3F0E6);
|
|
|
|
_bgView.layer.cornerRadius = kGetScaleWidth(9);
|
2023-09-12 17:48:18 +08:00
|
|
|
_bgView.layer.masksToBounds = YES;
|
2024-05-29 17:14:02 +08:00
|
|
|
_bgView.layer.borderColor = UIColorFromRGB(0xFFB05E).CGColor;
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
return _bgView;
|
|
|
|
}
|
|
|
|
|
2024-05-29 17:14:02 +08:00
|
|
|
- (UIView *)bgPriceView{
|
|
|
|
if(!_bgPriceView){
|
|
|
|
_bgPriceView = [UIView new];
|
|
|
|
_bgPriceView.backgroundColor = UIColorFromRGB(0xFFF09C);
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
2024-05-29 17:14:02 +08:00
|
|
|
return _bgPriceView;
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)priceLabel {
|
|
|
|
if (!_priceLabel) {
|
|
|
|
_priceLabel = [[UILabel alloc] init];
|
2024-05-29 17:14:02 +08:00
|
|
|
_priceLabel.textColor = UIColorFromRGB(0x513C0B);
|
|
|
|
_priceLabel.font = kFontBold(12);
|
|
|
|
_priceLabel.textAlignment = NSTextAlignmentCenter;
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
return _priceLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIImageView *)iconImageView {
|
|
|
|
if (!_iconImageView) {
|
|
|
|
_iconImageView = [[UIImageView alloc] init];
|
|
|
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
2024-05-29 17:14:02 +08:00
|
|
|
_iconImageView.image = [UIImage imageNamed:@"ms_mine_recharge_coin"];
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
return _iconImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)numLabel {
|
|
|
|
if (!_numLabel) {
|
|
|
|
_numLabel = [[UILabel alloc] init];
|
2024-05-29 17:14:02 +08:00
|
|
|
_numLabel.textColor = UIColorFromRGB(0x8A4B00);
|
|
|
|
_numLabel.font = kFontBold(15);
|
2023-07-14 18:50:55 +08:00
|
|
|
_numLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
}
|
|
|
|
return _numLabel;
|
|
|
|
}
|
|
|
|
|
2025-06-26 11:08:21 +08:00
|
|
|
- (UIView *)extBG {
|
|
|
|
if (!_extBG) {
|
|
|
|
_extBG = [[UIView alloc] init];
|
|
|
|
[_extBG addGradientBackgroundWithColors:@[
|
|
|
|
UIColorFromRGB(0xFFE347),
|
|
|
|
UIColorFromRGB(0xFF9A51),
|
|
|
|
] startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5) cornerRadius:4];
|
|
|
|
[_extBG setCornerWithLeftTopCorner:4 rightTopCorner:kGetScaleWidth(9) bottomLeftCorner:4 bottomRightCorner:4 size:CGSizeMake(64, 20)];
|
|
|
|
}
|
|
|
|
return _extBG;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MoliMoneyLabel *)moneyLabel {
|
|
|
|
if (!_moneyLabel) {
|
|
|
|
_moneyLabel = [MoliMoneyLabel moneyLabelWithTextColot:UIColorFromRGB(0x582B00) font:kFontMedium(13) moneyPostion:2 moneySize:CGSizeMake(14, 14)];
|
|
|
|
}
|
|
|
|
return _moneyLabel;
|
|
|
|
}
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
@end
|