Files
yuyin_ios/SweetParty/主类/Mine/Wallet/SPWalletZuanshiVC.m
2025-08-08 11:05:33 +08:00

121 lines
3.8 KiB
Objective-C
Executable File

//
// SPWalletZuanshiVC.m
// SweetParty
//
// Created by bj_szd on 2022/6/10.
//
#import "SPWalletZuanshiVC.h"
#import "SPWalletModel.h"
#import "SPWalletRecordListVC.h"
#import "SPWalletTixianVC.h"
@interface SPWalletZuanshiVC ()
@property (weak, nonatomic) IBOutlet UIView *balanceBgV;
@property (weak, nonatomic) IBOutlet UILabel *balanceLab;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property (weak, nonatomic) IBOutlet UITextField *zuanshiTF;
@property (weak, nonatomic) IBOutlet UITextField *jinbiTF;
@property (nonatomic, strong) SPWalletModel *model;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topLayout;
@end
@implementation SPWalletZuanshiVC
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self fetchData];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self createUI];
// [ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-65-10, yb_StatusBar_H+7, 60, 30) text:@"明细" font:YBMediumFont(13) color:HEXCOLOR(0x111111) backguoundColor:nil imageName:nil target:self action:@selector(onRightClick)];
}
- (void)fetchData {
NSDictionary *params = @{};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/get_user_money" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
SPWalletModel *model = [SPWalletModel mj_objectWithKeyValues:responseDic[@"data"]];
self.model = model;
self.balanceLab.text = [NSString stringWithFormat:@"%.2f", [model.money doubleValue]];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)createUI {
// self.balanceBgV.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(ScreenWidth-14*2, 130) direction:FXGradientChangeDirectionHorizontal startColor:HEXCOLOR(0x7E9AF9) endColor:HEXCOLOR(0x6B42F0)];
UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"home_bg")];
[self.view addSubview:bgImgV];
[self.view sendSubviewToBack:bgImgV];
[bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
make.height.mas_equalTo(ScreenWidth/375*812);
}];
[self showNaviBarWithTitle:@"兑换"];
self.topLayout.constant = yb_NavigationBar_H+10;
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)];
[self.zuanshiTF addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textFieldChanged:(UITextField*)tf {
NSInteger zuanshi = [tf.text integerValue];
self.jinbiTF.text = [NSString stringWithFormat:@"%ld", zuanshi*10];
}
- (void)onRightClick
{
SPWalletRecordListVC *vc = [[SPWalletRecordListVC alloc] init];
vc.type = 5;
[vc pushSelf];
}
- (IBAction)onMingxi:(id)sender {
SPWalletRecordListVC *vc = [[SPWalletRecordListVC alloc] init];
vc.type = 5;
[vc pushSelf];
}
- (IBAction)onTixian:(id)sender {
SPWalletTixianVC *vc = [[SPWalletTixianVC alloc] init];
[vc pushSelf];
}
- (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;
}
NSDictionary *params = @{@"money":self.zuanshiTF.text, @"trade_password":@""};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/exchange" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
[self fetchData];
} Failure:^(id _Nonnull errorData) {
}];
}
#pragma mark - JXCategoryListContentViewDelegate
- (UIView *)listView {
return self.view;
}
@end