Files
yuyin_ios/SweetParty/主类/音悦新增/仲夏夜梦曲/ZXYBuyView.m

95 lines
2.5 KiB
Mathematica
Raw Normal View History

2025-08-08 11:05:33 +08:00
//
// ZXYBuyView.m
// SweetParty
//
// Created by MAC on 2024/5/6.
//
#import "ZXYBuyView.h"
@interface ZXYBuyView ()
@property (nonatomic, assign) NSInteger sprite_price;//
@property (nonatomic, assign) NSInteger integral;//
@end
@implementation ZXYBuyView
- (void)awakeFromNib {
[super awakeFromNib];
[self createUI];
//
[self.numTF addTarget:self action:@selector(textFieldChanged:) forControlEvents:UIControlEventEditingChanged];
}
- (void)textFieldChanged:(UITextField*)textField {
[self onUpdatePriceLab];
}
- (void)createUI {
WEAK_SELF
[self.touchImgV dg_Tapped:^{
[weakSelf removeFromSuperview];
}];
}
- (void)setRid:(NSString *)rid {
_rid = rid;
NSDictionary *params = @{};
[AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/Sprite/choice_amount_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
self.integral = [responseDic[@"data"] safeIntForKey:@"integral"];
self.sprite_price = [responseDic[@"data"] safeIntForKey:@"sprite_price"];
[self onUpdatePriceLab];
} Failure:^(id _Nonnull errorData) {
}];
}
- (void)onUpdatePriceLab {
NSInteger num = [self.numTF.text integerValue];
self.priceLab.text = [NSString stringWithFormat:@"%ld/%ld", self.sprite_price*num, self.integral];
}
- (IBAction)onLess:(id)sender {
NSInteger num = [self.numTF.text integerValue];
if (num <= 1) {
return;
}
num -= 1;
self.numTF.text = [NSString stringWithFormat:@"%ld", num];
[self onUpdatePriceLab];
}
- (IBAction)onMore:(id)sender {
NSInteger num = [self.numTF.text integerValue];
num += 1;
self.numTF.text = [NSString stringWithFormat:@"%ld", num];
[self onUpdatePriceLab];
}
- (IBAction)onCancel:(id)sender {
[self removeFromSuperview];
}
- (IBAction)onConfirm:(id)sender {
if ([self.numTF.text integerValue] <= 0) {
return;
}
NSInteger num = [self.numTF.text integerValue];
NSDictionary *params = @{@"rid":C_string(self.rid), @"num":@(num)};
[AFNetworkRequset.shared postRequestWithParams:params Path:@"/api/Sprite/exchange_airship" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) {
if (self.onBuySuccessBlock) {
self.onBuySuccessBlock([responseDic[@"data"] safeStringForKey:@"integral"], [responseDic[@"data"] safeStringForKey:@"airship"]);
}
[self removeFromSuperview];
} Failure:^(id _Nonnull errorData) {
}];
}
@end