167 lines
6.2 KiB
Objective-C
167 lines
6.2 KiB
Objective-C
//
|
||
// QXWithDrawInputView.m
|
||
// QXLive
|
||
//
|
||
// Created by 启星 on 2025/5/26.
|
||
//
|
||
|
||
#import "QXWithDrawInputView.h"
|
||
@interface QXWithDrawInputView()<UITextFieldDelegate>
|
||
@property (nonatomic,strong)UILabel *titleLabel;
|
||
@property (nonatomic,strong)UILabel *feeLabel;
|
||
@end
|
||
@implementation QXWithDrawInputView
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame
|
||
{
|
||
self = [super initWithFrame:frame];
|
||
if (self) {
|
||
[self initSubviews];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
-(void)initSubviews{
|
||
self.titleLabel = [[UILabel alloc] init];
|
||
self.titleLabel.text = QXText(@"提现金额");
|
||
self.titleLabel.textColor = UIColor.blackColor;
|
||
self.titleLabel.font = [UIFont systemFontOfSize:12];
|
||
[self addSubview:self.titleLabel];
|
||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(16);
|
||
make.top.mas_equalTo(12);
|
||
make.height.mas_equalTo(18);
|
||
}];
|
||
|
||
|
||
self.unitLabel = [[UILabel alloc] init];
|
||
self.unitLabel.text = @"¥";
|
||
self.unitLabel.font = [UIFont boldSystemFontOfSize:18];
|
||
self.unitLabel.textColor = RGB16(0x333333);
|
||
[self addSubview:self.unitLabel];
|
||
[self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.titleLabel);
|
||
make.top.equalTo(self.titleLabel.mas_bottom).offset(12);
|
||
make.height.mas_equalTo(27);
|
||
make.width.mas_equalTo(25);
|
||
}];
|
||
|
||
self.unitImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"wallet_diamond"]];
|
||
self.unitImageView.clipsToBounds = YES;
|
||
[self addSubview:self.unitImageView];
|
||
[self.unitImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.titleLabel);
|
||
make.top.equalTo(self.titleLabel.mas_bottom).offset(12);
|
||
make.height.mas_equalTo(25);
|
||
make.width.mas_equalTo(25);
|
||
}];
|
||
|
||
|
||
self.allBtn = [[UIButton alloc] init];
|
||
self.allBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||
[self.allBtn setTitleColor:QXConfig.themeColor forState:(UIControlStateNormal)];
|
||
[self.allBtn setTitle:QXText(@"全部提现") forState:(UIControlStateNormal)];
|
||
[self.allBtn addTarget:self action:@selector(allAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||
self.allBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing;
|
||
[self addSubview:self.allBtn];
|
||
[self.allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.equalTo(self.unitLabel);
|
||
make.right.mas_equalTo(-16);
|
||
make.height.mas_equalTo(40);
|
||
make.width.mas_equalTo(65);
|
||
}];
|
||
|
||
|
||
self.textField = [[UITextField alloc] init];
|
||
self.textField.returnKeyType = UIReturnKeyDone;
|
||
self.textField.delegate = self;
|
||
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
||
self.textField.font = [UIFont boldSystemFontOfSize:18];
|
||
self.textField.textColor = RGB16(0x333333);
|
||
self.textField.placeholder = QXText(@"请输入提现金额");
|
||
[self addSubview:self.textField];
|
||
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.unitLabel.mas_right).offset(3);
|
||
make.centerY.equalTo(self.unitLabel);
|
||
make.height.mas_equalTo(40);
|
||
make.right.equalTo(self.allBtn.mas_left).offset(-5);
|
||
}];
|
||
|
||
|
||
self.bottomLine = [[UIView alloc] init];
|
||
self.bottomLine.backgroundColor = RGB16(0x999999);
|
||
[self addSubview:self.bottomLine];
|
||
[self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.bottom.equalTo(self.textField.mas_bottom);
|
||
make.left.mas_offset(16);
|
||
make.right.mas_offset(-16);
|
||
make.height.mas_equalTo(0.5);
|
||
}];
|
||
|
||
self.feeLabel = [[UILabel alloc] init];
|
||
// self.feeLabel.text = [NSString stringWithFormat:@"%@:%@",QXText(@"提现手续服务费"),@"6%"];
|
||
self.feeLabel.font = [UIFont systemFontOfSize:12];
|
||
self.feeLabel.textColor = RGB16(0xff2727);
|
||
[self addSubview:self.feeLabel];
|
||
[self.feeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(16);
|
||
make.top.equalTo(self.bottomLine.mas_bottom).offset(5);
|
||
make.right.mas_equalTo(-16);
|
||
make.height.mas_equalTo(18);
|
||
}];
|
||
}
|
||
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
|
||
[textField resignFirstResponder];
|
||
return YES;
|
||
}
|
||
-(void)setFee:(NSString *)fee{
|
||
_fee = fee;
|
||
switch (self.type) {
|
||
case QXWithDrawInputViewTypeWithDraw:{
|
||
self.feeLabel.text = [NSString stringWithFormat:@"%@:%@%%",QXText(@"提现手续服务费"),fee];
|
||
}
|
||
break;
|
||
case QXWithDrawInputViewTypeExchangeCorn:{
|
||
self.feeLabel.text = [NSString stringWithFormat:@"1钻石=%@个金币",fee];
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
-(void)setType:(QXWithDrawInputViewType)type{
|
||
_type = type;
|
||
switch (type) {
|
||
case QXWithDrawInputViewTypeWithDraw:{
|
||
self.unitLabel.hidden = NO;
|
||
self.unitImageView.hidden = YES;
|
||
self.textField.placeholder = QXText(@"请输入提现金额");
|
||
if (QXGlobal.shareGlobal.withdrawal_service_fee.length > 0 ) {
|
||
self.feeLabel.text = [NSString stringWithFormat:@"%@:%@%%",QXText(@"提现手续服务费"),QXGlobal.shareGlobal.withdrawal_service_fee];
|
||
}
|
||
[self.allBtn setTitle:QXText(@"全部提现") forState:(UIControlStateNormal)];
|
||
}
|
||
break;
|
||
case QXWithDrawInputViewTypeExchangeCorn:{
|
||
self.unitLabel.hidden = YES;
|
||
self.unitImageView.hidden = NO;
|
||
self.titleLabel.text = QXText(@"兑换金额");
|
||
self.textField.placeholder = QXText(@"请输入钻石数量");
|
||
if (QXGlobal.shareGlobal.coin_exchange_rate.length > 0 ) {
|
||
self.feeLabel.text = [NSString stringWithFormat:@"1钻石=%@个金币",QXGlobal.shareGlobal.coin_exchange_rate];
|
||
}
|
||
|
||
[self.allBtn setTitle:QXText(@"全部兑换") forState:(UIControlStateNormal)];
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
-(void)allAction{
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickAll)]) {
|
||
[self.delegate didClickAll];
|
||
}
|
||
}
|
||
@end
|