85 lines
2.7 KiB
Objective-C
Executable File
85 lines
2.7 KiB
Objective-C
Executable File
//
|
|
// SPWalletDuihuanVC.m
|
|
// SweetParty
|
|
//
|
|
// Created by bj_szd on 2022/6/10.
|
|
//
|
|
|
|
#import "SPWalletDuihuanVC.h"
|
|
#import "SPWalletPsdAlert.h"
|
|
|
|
@interface SPWalletDuihuanVC ()
|
|
|
|
@property (weak, nonatomic) IBOutlet UILabel *banlanceLab;
|
|
@property (weak, nonatomic) IBOutlet UITextField *zuanshiTF;
|
|
@property (weak, nonatomic) IBOutlet UITextField *jinbiTF;
|
|
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
|
|
|
|
@property (nonatomic, copy) NSString *passwordStr;
|
|
|
|
@end
|
|
|
|
@implementation SPWalletDuihuanVC
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self showNaviBarWithTitle:@"兑换"];
|
|
|
|
[self createUI];
|
|
}
|
|
|
|
- (void)createUI {
|
|
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)];
|
|
|
|
self.zuanshiTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入兑换钻石数量" attributes:@{NSForegroundColorAttributeName:[kWhiteColor colorWithAlphaComponent:0.6]}];
|
|
|
|
[self.zuanshiTF addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged];
|
|
|
|
self.banlanceLab.text = [NSString stringWithFormat:@"%ld", [self.model.money integerValue]];
|
|
}
|
|
|
|
- (void)textFieldChanged:(UITextField*)tf {
|
|
NSInteger zuanshi = [tf.text integerValue];
|
|
self.jinbiTF.text = [NSString stringWithFormat:@"%ld", zuanshi*10];
|
|
}
|
|
|
|
- (IBAction)onAllDuihuan:(id)sender {
|
|
self.zuanshiTF.text = [NSString stringWithFormat:@"%ld", [self.model.money integerValue]];
|
|
NSInteger zuanshi = [self.zuanshiTF.text integerValue];
|
|
self.jinbiTF.text = [NSString stringWithFormat:@"%ld", zuanshi*10];
|
|
}
|
|
|
|
- (IBAction)onConfirm:(id)sender {
|
|
if (self.zuanshiTF.text.length <= 0) {
|
|
[HelpPageDefine showMessage:@"请输入兑换钻石数量"];
|
|
return;
|
|
}
|
|
|
|
[self onShowPsdAlert];
|
|
}
|
|
|
|
- (void)onDuihuanRequest {
|
|
NSDictionary *params = @{@"money":self.zuanshiTF.text, @"trade_password":self.passwordStr};
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/exchange" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
});
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)onShowPsdAlert {
|
|
SPWalletPsdAlert *alert = [[NSBundle mainBundle] loadNibNamed:@"SPWalletPsdAlert" owner:self options:nil].firstObject;
|
|
alert.frame = [UIScreen mainScreen].bounds;
|
|
[KEYWINDOW addSubview:alert];
|
|
WEAK_SELF
|
|
alert.onConfirmBlock = ^(NSString * _Nonnull str) {
|
|
weakSelf.passwordStr = str;
|
|
[weakSelf onDuihuanRequest];
|
|
};
|
|
}
|
|
|
|
@end
|