123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- //
- // LDWithdrawViewController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/31.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRWithdrawController.h"
- #import "DRWithdrawUserView.h"
- #import "DRWithdrawTextView.h"
- #import "DRLinkAliPayViewController.h"
- @interface DRWithdrawController ()
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic, strong) DRWithdrawUserView *userView;
- @property (nonatomic, strong) DRWithdrawTextView *textView;;
- @end
- @implementation DRWithdrawController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self request];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configNavigationBar];
- [self configScrollView];
- [self request];
- self.view.backgroundColor =[UIColor backgroudColor];
- }
- - (void)configNavigationBar {
- [self.navigationBar setNavTitle:@"支付宝提现"];
- self.navigationBar.backgroundColor = [UIColor changeColor];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)configScrollView {
- [self.view addSubview:self.scrollView];
-
- __weak typeof(self) weakSelf = self;
- self.userView = [[DRWithdrawUserView alloc] init];
-
- self.userView.updateAction = ^{
- DRLinkAliPayViewController *link = [[DRLinkAliPayViewController alloc] init];
- link.isUpdate = YES;
- [weakSelf.navigationController pushViewController:link animated:YES];
- };
- [self.scrollView addSubview:self.userView];
- [self.userView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(15);
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(Fitsize(60));
- }];
-
- // UIView *line1 = [[UIView alloc] init];
- // line1.backgroundColor = [UIColor yhGrayColor];
- // [self.scrollView addSubview:line1];
- // [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.mas_equalTo(self.userView.mas_bottom);
- // make.width.mas_equalTo(SCREEN_WIDTH);
- // make.height.mas_equalTo(20);
- // }];
-
- self.textView = [[DRWithdrawTextView alloc] init];
- self.textView.backgroundColor =[UIColor whiteColor];
- self.textView.moneyStr = self.moneyStr;
- [self.scrollView addSubview:self.textView];
- [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(self.userView.mas_bottom).offset(FITSIZE(20));
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(Fitsize(144));
- }];
-
- UIView *line2 = [[UIView alloc] init];
- line2.backgroundColor = [UIColor yhGrayColor];
- [self.scrollView addSubview:line2];
- [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.textView.mas_bottom);
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(5);
- }];
-
- UIButton *withdrawButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [withdrawButton setTitle:@"申请提现" forState:UIControlStateNormal];
- withdrawButton.backgroundColor = [UIColor homeRedColor];
- withdrawButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(18)];
- [withdrawButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- withdrawButton.layer.cornerRadius = Fitsize(4);
- [withdrawButton addTarget:self action:@selector(withdrawAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.scrollView addSubview:withdrawButton];
- [withdrawButton mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.mas_equalTo(FITSIZE(16));
- make.right.mas_equalTo(-FITSIZE(16));
- make.height.mas_equalTo(Fitsize(42));
- make.top.mas_equalTo(line2.mas_bottom).mas_offset(Fitsize(37));
- make.centerX.mas_equalTo(self.textView.mas_centerX);
- }];
-
- UILabel *text = [[UILabel alloc] init];
- text.textColor = [UIColor YHColorWithHex:0x999999];
- text.font = [UIFont systemFontOfSize:Fitsize(11)];
- text.textAlignment = NSTextAlignmentCenter;
- text.text = @"每月25日可提现上个月已结算佣金";
- [self.scrollView addSubview:text];
- [text mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(withdrawButton.mas_bottom).mas_offset(Fitsize(5));
- make.centerX.mas_equalTo(self.textView.mas_centerX);
- }];
-
- }
- /**
- 提现申请
- */
- - (void)withdrawAction:(UIButton *)sender {
-
-
- NSString *moneyStr = [self.textView getMoneyFieldText];
- if (moneyStr.length == 0) {
- [MBProgressHUD showMessage:@"请输入提现金额"];
- return;
- }
-
- if (moneyStr.floatValue > self.moneyStr.floatValue) {
- [MBProgressHUD showMessage:@"提现金额超出最大提现金额"];
- return;
- }
-
- if (moneyStr.floatValue < 0.1) {
- [MBProgressHUD showMessage:@"提现金额不能低于0.1元"];
- return;
- }
-
- sender.backgroundColor = [UIColor lightGrayColor];
- sender.enabled = NO;
- [SVProgressHUD showWithStatus:@"提现申请中"];
-
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/users/alipayGetMoney",BaseURL];
- NSDictionary *para = @{@"money":moneyStr};
- [DRHttp post:url params:para success:^(id json) {
- [SVProgressHUD dismiss];
- [MBProgressHUD showMessage:json[@"msg"]];
- sender.backgroundColor = [UIColor homeRedColor];
- sender.enabled = YES;
-
- if ([json[@"flag"] isEqual:@1]) {
-
- NSNotification *noti = [[NSNotification alloc] initWithName:RefreshWithDrawHistory object:nil userInfo:nil];
- [[NSNotificationCenter defaultCenter] postNotification:noti];
- [self.navigationController popViewControllerAnimated:YES];
- }
-
-
- } failure:^(NSError *error) {
- [SVProgressHUD dismiss];
- [MBProgressHUD showMessage:@"加载失败,请稍后重试"];
- sender.backgroundColor = [UIColor homeRedColor];
- sender.enabled = YES;
- }];
- }
- /**
- 加载支付宝信息
- */
- - (void)request {
- NSString *url = [NSString stringWithFormat:@"%@/api/v2/users/alipayGetMoneyPage",BaseURL];
- [DRHttp post:url params:nil success:^(id json) {
-
- NSDictionary *dict = json[@"data"];
- [self.userView setUserInfo:dict];
-
- } failure:^(NSError *error) {
-
- }];
- }
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
- _scrollView.backgroundColor = [UIColor backgroudColor];
- _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight+1);
- _scrollView.showsVerticalScrollIndicator = NO;
- _scrollView.bounces = YES;
- }
- return _scrollView;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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
|