99 lines
3.2 KiB
Mathematica
99 lines
3.2 KiB
Mathematica
![]() |
//
|
||
|
// XPExchangeDiamondsVC.m
|
||
|
// YuMi
|
||
|
//
|
||
|
// Created by YuMi on 2022/11/17.
|
||
|
//
|
||
|
|
||
|
#import "XPExchangeDiamondsVC.h"
|
||
|
///Third
|
||
|
#import <Masonry/Masonry.h>
|
||
|
///view
|
||
|
#import "XPExchangeDiamondsView.h"
|
||
|
#import "XPMineConfirmGiveDiamondView.h"
|
||
|
#import "TTPopup.h"
|
||
|
///Present
|
||
|
#import "XPIncomeRecordPresent.h"
|
||
|
///Protocol
|
||
|
#import "XPIncomeRecordProtocol.h"
|
||
|
///model
|
||
|
#import "XPExchangeDiamondsModel.h"
|
||
|
|
||
|
@interface XPExchangeDiamondsVC ()<XPExchangeDiamondsViewDelegate,XPIncomeRecordProtocol,XPMineConfirmGiveDiamondViewDelegate>
|
||
|
@property (nonatomic,strong) XPExchangeDiamondsView *exchangeView;
|
||
|
@property (nonatomic,copy) NSString *diamond;
|
||
|
@property (nonatomic,copy) NSString *gold;
|
||
|
@end
|
||
|
|
||
|
@implementation XPExchangeDiamondsVC
|
||
|
- (XPIncomeRecordPresent *)createPresenter {
|
||
|
return [[XPIncomeRecordPresent alloc] init];
|
||
|
}
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
[self initSubViews];
|
||
|
[self initSubViewConstraints];
|
||
|
if(self.model != nil){
|
||
|
self.exchangeView.model = self.model;
|
||
|
return;
|
||
|
}
|
||
|
[self showLoading];
|
||
|
[self.presenter getExchangeDiamondInformation];
|
||
|
}
|
||
|
#pragma mark - XPIncomeRecordProtocol
|
||
|
-(void)getExchangeDiamondInformation:(XPExchangeDiamondsModel *)model{
|
||
|
[self hideHUD];
|
||
|
self.model = model;
|
||
|
self.exchangeView.model = self.model;
|
||
|
}
|
||
|
- (void)confirmExchangeDiamondSuccessWithDiamondNum:(NSString *)diamondNum goldNum:(NSString *)goldNum{
|
||
|
[self hideHUD];
|
||
|
if(self.delegate && [self.delegate respondsToSelector:@selector(confirmExchangeDiamondsWithDiamondSuccess:gold:)]){
|
||
|
[self.delegate confirmExchangeDiamondsWithDiamondSuccess:diamondNum gold:goldNum];
|
||
|
}
|
||
|
[self showSuccessToast:YMLocalizedString(@"XPExchangeDiamondsView5")];
|
||
|
[self.navigationController popViewControllerAnimated:YES];
|
||
|
}
|
||
|
- (void)confirmExchangeDiamondFail{
|
||
|
[self.presenter getExchangeDiamondInformation];
|
||
|
}
|
||
|
#pragma mark - XPMineConfirmGiveDiamondViewDelegate
|
||
|
- (void)xpMineConfirmGiveDiamondViewComplete{
|
||
|
[self showLoading];
|
||
|
[self.presenter confirmExchangeDiamondWithGoldNum:self.gold diamondNum:self.diamond currency:@"1"];
|
||
|
}
|
||
|
#pragma mark - XPExchangeDiamondsViewDelegate
|
||
|
-(void)confirmExchangeDiamondsWithDiamond:(NSString *)diamond gold:(NSString *)gold currency:(NSString *)currency{
|
||
|
self.diamond = diamond;
|
||
|
self.gold = [NSString stringWithFormat:@"%.0f",ceilf(diamond.doubleValue / self.model.rate)];
|
||
|
XPMineConfirmGiveDiamondView *confirmView = [[XPMineConfirmGiveDiamondView alloc]initWithFrame:CGRectZero];
|
||
|
confirmView.type = 2;
|
||
|
confirmView.goldNum = self.gold.integerValue;
|
||
|
confirmView.inputDiamonds = self.diamond.integerValue;
|
||
|
confirmView.delegate = self;
|
||
|
[TTPopup popupView:confirmView style:TTPopupStyleAlert];
|
||
|
}
|
||
|
#pragma mark - Private Method
|
||
|
- (void)initSubViews {
|
||
|
self.title = YMLocalizedString(@"XPExchangeDiamondsView0");
|
||
|
[self.view addSubview:self.exchangeView];
|
||
|
|
||
|
|
||
|
}
|
||
|
- (void)initSubViewConstraints {
|
||
|
[self.exchangeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.equalTo(self.view);
|
||
|
}];
|
||
|
}
|
||
|
#pragma mark -懒加载
|
||
|
- (XPExchangeDiamondsView *)exchangeView{
|
||
|
if (!_exchangeView){
|
||
|
_exchangeView = [[XPExchangeDiamondsView alloc]initWithFrame:CGRectZero];
|
||
|
_exchangeView.delegate = self;
|
||
|
}
|
||
|
return _exchangeView;
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|