121 lines
4.2 KiB
Objective-C
121 lines
4.2 KiB
Objective-C
//
|
|
// QXDiamondViewController.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/26.
|
|
//
|
|
|
|
#import "QXDiamondViewController.h"
|
|
#import "QXWalletTopView.h"
|
|
#import "QXWithDrawInputView.h"
|
|
#import "QXMineNetwork.h"
|
|
|
|
@interface QXDiamondViewController ()<QXWithDrawInputViewDelegate>
|
|
@property (nonatomic,strong)QXWalletTopView *topView;
|
|
@property (nonatomic,strong)QXWithDrawInputView *withDrawInputView;
|
|
@property (nonatomic,strong)UIButton *commitBtn;
|
|
@end
|
|
|
|
@implementation QXDiamondViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
-(void)setNavgationItems{
|
|
[super setNavgationItems];
|
|
self.navigationItem.title = QXText(@"钻石兑币");
|
|
}
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
|
[self getPrice];
|
|
}
|
|
- (void)initSubViews{
|
|
[self.view addSubview:self.topView];
|
|
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.mas_equalTo(NavContentHeight+12);
|
|
make.height.mas_equalTo(ScaleWidth(112));
|
|
}];
|
|
|
|
[self.view addSubview:self.withDrawInputView];
|
|
[self.withDrawInputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.equalTo(self.topView.mas_bottom).offset(12);
|
|
make.height.mas_equalTo(95);
|
|
}];
|
|
|
|
self.commitBtn = [[UIButton alloc] init];
|
|
[self.commitBtn setTitle:QXText(@"确认兑换") forState:(UIControlStateNormal)];
|
|
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];;
|
|
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
[self.commitBtn addRoundedCornersWithRadius:21];
|
|
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.commitBtn addTarget:self action:@selector(commitAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.view addSubview:self.commitBtn];
|
|
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(38);
|
|
make.right.mas_equalTo(-38);
|
|
make.height.mas_equalTo(42);
|
|
make.bottom.mas_equalTo(-(kSafeAreaBottom));
|
|
}];
|
|
}
|
|
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
|
[self.view endEditing:YES];
|
|
}
|
|
-(void)getPrice{
|
|
MJWeakSelf
|
|
[QXMineNetwork getWalletInfoSuccessBlock:^(NSString * _Nonnull coin, NSString * _Nonnull earnings, NSString * _Nonnull title, NSString * _Nonnull url) {
|
|
weakSelf.topView.coin = earnings;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
|
|
[QXMineNetwork getWalletConfigSuccessBlock:^(NSString * _Nonnull coin_exchange_rate, NSString * _Nonnull withdrawal_service_fee, NSString * _Nonnull rmb_coin_ratio) {
|
|
weakSelf.withDrawInputView.fee = coin_exchange_rate;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
#pragma mark - QXWithDrawInputViewDelegate
|
|
-(void)didClickAll{
|
|
if (self.topView.coin.intValue == 0) {
|
|
self.withDrawInputView.textField.text = @"0";
|
|
}else{
|
|
self.withDrawInputView.textField.text = [NSString stringWithFormat:@"%ld",self.topView.coin.longValue];
|
|
}
|
|
}
|
|
|
|
-(void)commitAction:(UIButton*)sender{
|
|
MJWeakSelf
|
|
showLoadingInView(self.view);
|
|
[QXMineNetwork roomCoinExchangeWithEarningsNum:self.withDrawInputView.textField.text successBlock:^(NSDictionary * _Nonnull dict) {
|
|
hideLoadingInView(self.view);
|
|
showToast(@"兑换成功");
|
|
[weakSelf getPrice];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
hideLoadingInView(self.view);
|
|
showToast(msg);
|
|
}];
|
|
}
|
|
|
|
-(QXWalletTopView *)topView{
|
|
if (!_topView) {
|
|
_topView = [[QXWalletTopView alloc] init];
|
|
_topView.type = QXWalletTopViewTypeDiamond;
|
|
}
|
|
return _topView;
|
|
}
|
|
-(QXWithDrawInputView *)withDrawInputView{
|
|
if (!_withDrawInputView) {
|
|
_withDrawInputView = [[QXWithDrawInputView alloc] init];
|
|
_withDrawInputView.delegate = self;
|
|
_withDrawInputView.type = QXWithDrawInputViewTypeExchangeCorn;
|
|
}
|
|
return _withDrawInputView;
|
|
}
|
|
@end
|