140 lines
4.4 KiB
Objective-C
140 lines
4.4 KiB
Objective-C
//
|
|
// DDMyWalletVC.m
|
|
// DingDangApp
|
|
//
|
|
// Created by apple on 2023/5/31.
|
|
//
|
|
|
|
#import "DDMyWalletVC.h"
|
|
#import "DDExchangeVC.h"
|
|
#import "DDMyRechargeVC.h"
|
|
#import "DDMyExchangeVC.h"
|
|
#import "Api.h"
|
|
@interface DDMyWalletVC ()
|
|
@property (weak, nonatomic) IBOutlet UIView *topView;
|
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topView_Y;
|
|
@property (weak, nonatomic) IBOutlet UILabel *diamondLabel;
|
|
@property (weak, nonatomic) IBOutlet UIButton *chongzhiBtn;
|
|
@property (weak, nonatomic) IBOutlet UIButton *duihuanBtn;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *bottomView;
|
|
@property (weak, nonatomic) IBOutlet UILabel *meiliLabel;
|
|
|
|
@end
|
|
|
|
@implementation DDMyWalletVC
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
//获取砖石数量
|
|
[self getDiamond];
|
|
//获取个人收益
|
|
// [self getIncome];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view from its nib.
|
|
|
|
[self set_attribute];
|
|
}
|
|
|
|
- (void)getDiamond {
|
|
@weakify(self);
|
|
NSString *uid = [[AccountInfoStorage instance]getUid];
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
@strongify(self)
|
|
if(code == 200){
|
|
AppUserModel * myModel = [AppUserModel DD_ModelWithDict:data.data];
|
|
[ToolsObject saveUserModel:myModel];
|
|
self.diamondLabel.text = [NSString stringWithFormat:@"%@",myModel.diamonds];
|
|
}
|
|
|
|
} uid:uid ticket:ticket];
|
|
|
|
return;
|
|
[NetworkRequest requestPOST:@"/finance/diamond" parameters:@{} block:^(BaseResponse * _Nonnull response) {
|
|
if (response.isSuccess) {
|
|
|
|
double diamod = [response.data[@"diamond"] doubleValue];
|
|
AppUserModel * myModel = [ToolsObject getUserModel];
|
|
myModel.diamond = diamod;
|
|
[ToolsObject saveUserModel:myModel];
|
|
|
|
self.diamondLabel.text = [NSString stringWithFormat:@"%ld",(long)[ToolsObject getUserModel].diamond];
|
|
[[AppMessageManager shareManager].delegate sendUpDataMyDiamond:[NSString stringWithFormat:@"%ld",myModel.diamond]];
|
|
|
|
} else {
|
|
|
|
[ToolsObject addPopVieToText:response.msg];
|
|
}
|
|
}];
|
|
}
|
|
|
|
- (void)getIncome {
|
|
|
|
[NetworkRequest requestPOST:@"/finance/income" parameters:@{} block:^(BaseResponse * _Nonnull response) {
|
|
if (response.isSuccess) {
|
|
if ([ToolsObject IsNullWithObject:response.data]) {
|
|
return;
|
|
}
|
|
double income = [response.data[@"income"] doubleValue];
|
|
AppUserModel * myModel = [ToolsObject getUserModel];
|
|
myModel.income = [NSString stringWithFormat:@"%.2f",income];
|
|
[ToolsObject saveUserModel:myModel];
|
|
self.meiliLabel.text = [NSString stringWithFormat:@"%@",[ToolsObject getUserModel].income];
|
|
} else {
|
|
|
|
[ToolsObject addPopVieToText:response.msg];
|
|
}
|
|
}];
|
|
}
|
|
|
|
- (void)set_attribute {
|
|
|
|
self.view.backgroundColor = DDHEXColor(0xF6F6F6);
|
|
[self defaultNavTitle:@"我的钱包" hideLine:YES];
|
|
self.customNavBar.backgroundColor = UIColor.clearColor;
|
|
self.customNavBar.barBackgroundColor = UIColor.clearColor;
|
|
|
|
self.topView_Y.constant = DDNavigationBarHeight() + KAdaptedHeight(10);
|
|
|
|
self.bottomView.layer.masksToBounds = YES;
|
|
self.bottomView.layer.cornerRadius = KAdaptedHeight(12);
|
|
|
|
self.chongzhiBtn.layer.masksToBounds = YES;
|
|
self.chongzhiBtn.layer.cornerRadius = 32/2;
|
|
|
|
self.duihuanBtn.layer.masksToBounds = YES;
|
|
self.duihuanBtn.layer.cornerRadius = 32/2;
|
|
}
|
|
|
|
//钻石充值
|
|
- (IBAction)diamondBtnClick:(id)sender {
|
|
|
|
DDMyRechargeVC *VC = [[DDMyRechargeVC alloc] init];
|
|
VC.walletType = 1;
|
|
[self.navigationController pushViewController:VC animated:YES];
|
|
}
|
|
|
|
//兑换魅力值
|
|
- (IBAction)meiliBtnClick:(id)sender {
|
|
|
|
DDMyExchangeVC *VC = [[DDMyExchangeVC alloc] init];
|
|
VC.walletType = 2;
|
|
[self.navigationController pushViewController:VC animated:YES];
|
|
}
|
|
|
|
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
@end
|