《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRWithdrawController.m 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. //
  2. // LDWithdrawViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/31.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRWithdrawController.h"
  9. #import "DRWithdrawUserView.h"
  10. #import "DRWithdrawTextView.h"
  11. #import "DRLinkAliPayViewController.h"
  12. @interface DRWithdrawController ()
  13. @property (nonatomic, strong) UIScrollView *scrollView;
  14. @property (nonatomic, strong) DRWithdrawUserView *userView;
  15. @property (nonatomic, strong) DRWithdrawTextView *textView;;
  16. @end
  17. @implementation DRWithdrawController
  18. - (void)viewWillAppear:(BOOL)animated {
  19. [super viewWillAppear:animated];
  20. [self request];
  21. }
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self configNavigationBar];
  25. [self configScrollView];
  26. [self request];
  27. self.view.backgroundColor =[UIColor backgroudColor];
  28. }
  29. - (void)configNavigationBar {
  30. [self.navigationBar setNavTitle:@"支付宝提现"];
  31. self.navigationBar.backgroundColor = [UIColor changeColor];
  32. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  33. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  34. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  35. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  36. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  37. }
  38. - (void)backAction {
  39. [self.navigationController popViewControllerAnimated:YES];
  40. }
  41. - (void)configScrollView {
  42. [self.view addSubview:self.scrollView];
  43. __weak typeof(self) weakSelf = self;
  44. self.userView = [[DRWithdrawUserView alloc] init];
  45. self.userView.updateAction = ^{
  46. DRLinkAliPayViewController *link = [[DRLinkAliPayViewController alloc] init];
  47. link.isUpdate = YES;
  48. [weakSelf.navigationController pushViewController:link animated:YES];
  49. };
  50. [self.scrollView addSubview:self.userView];
  51. [self.userView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.mas_equalTo(15);
  53. make.width.mas_equalTo(SCREEN_WIDTH);
  54. make.height.mas_equalTo(Fitsize(60));
  55. }];
  56. // UIView *line1 = [[UIView alloc] init];
  57. // line1.backgroundColor = [UIColor yhGrayColor];
  58. // [self.scrollView addSubview:line1];
  59. // [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
  60. // make.top.mas_equalTo(self.userView.mas_bottom);
  61. // make.width.mas_equalTo(SCREEN_WIDTH);
  62. // make.height.mas_equalTo(20);
  63. // }];
  64. self.textView = [[DRWithdrawTextView alloc] init];
  65. self.textView.backgroundColor =[UIColor whiteColor];
  66. self.textView.moneyStr = self.moneyStr;
  67. [self.scrollView addSubview:self.textView];
  68. [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(0);
  70. make.top.mas_equalTo(self.userView.mas_bottom).offset(FITSIZE(20));
  71. make.width.mas_equalTo(SCREEN_WIDTH);
  72. make.height.mas_equalTo(Fitsize(144));
  73. }];
  74. UIView *line2 = [[UIView alloc] init];
  75. line2.backgroundColor = [UIColor yhGrayColor];
  76. [self.scrollView addSubview:line2];
  77. [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.mas_equalTo(self.textView.mas_bottom);
  79. make.width.mas_equalTo(SCREEN_WIDTH);
  80. make.height.mas_equalTo(5);
  81. }];
  82. UIButton *withdrawButton = [UIButton buttonWithType:UIButtonTypeCustom];
  83. [withdrawButton setTitle:@"申请提现" forState:UIControlStateNormal];
  84. withdrawButton.backgroundColor = [UIColor homeRedColor];
  85. withdrawButton.titleLabel.font = [UIFont systemFontOfSize:Fitsize(18)];
  86. [withdrawButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  87. withdrawButton.layer.cornerRadius = Fitsize(4);
  88. [withdrawButton addTarget:self action:@selector(withdrawAction:) forControlEvents:UIControlEventTouchUpInside];
  89. [self.scrollView addSubview:withdrawButton];
  90. [withdrawButton mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.mas_equalTo(FITSIZE(16));
  92. make.right.mas_equalTo(-FITSIZE(16));
  93. make.height.mas_equalTo(Fitsize(42));
  94. make.top.mas_equalTo(line2.mas_bottom).mas_offset(Fitsize(37));
  95. make.centerX.mas_equalTo(self.textView.mas_centerX);
  96. }];
  97. UILabel *text = [[UILabel alloc] init];
  98. text.textColor = [UIColor YHColorWithHex:0x999999];
  99. text.font = [UIFont systemFontOfSize:Fitsize(11)];
  100. text.textAlignment = NSTextAlignmentCenter;
  101. text.text = @"每月25日可提现上个月已结算佣金";
  102. [self.scrollView addSubview:text];
  103. [text mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.top.mas_equalTo(withdrawButton.mas_bottom).mas_offset(Fitsize(5));
  105. make.centerX.mas_equalTo(self.textView.mas_centerX);
  106. }];
  107. }
  108. /**
  109. 提现申请
  110. */
  111. - (void)withdrawAction:(UIButton *)sender {
  112. NSString *moneyStr = [self.textView getMoneyFieldText];
  113. if (moneyStr.length == 0) {
  114. [MBProgressHUD showMessage:@"请输入提现金额"];
  115. return;
  116. }
  117. if (moneyStr.floatValue > self.moneyStr.floatValue) {
  118. [MBProgressHUD showMessage:@"提现金额超出最大提现金额"];
  119. return;
  120. }
  121. if (moneyStr.floatValue < 0.1) {
  122. [MBProgressHUD showMessage:@"提现金额不能低于0.1元"];
  123. return;
  124. }
  125. sender.backgroundColor = [UIColor lightGrayColor];
  126. sender.enabled = NO;
  127. [SVProgressHUD showWithStatus:@"提现申请中"];
  128. NSString *url = [NSString stringWithFormat:@"%@/api/v2/users/alipayGetMoney",BaseURL];
  129. NSDictionary *para = @{@"money":moneyStr};
  130. [DRHttp post:url params:para success:^(id json) {
  131. [SVProgressHUD dismiss];
  132. [MBProgressHUD showMessage:json[@"msg"]];
  133. sender.backgroundColor = [UIColor homeRedColor];
  134. sender.enabled = YES;
  135. if ([json[@"flag"] isEqual:@1]) {
  136. NSNotification *noti = [[NSNotification alloc] initWithName:RefreshWithDrawHistory object:nil userInfo:nil];
  137. [[NSNotificationCenter defaultCenter] postNotification:noti];
  138. [self.navigationController popViewControllerAnimated:YES];
  139. }
  140. } failure:^(NSError *error) {
  141. [SVProgressHUD dismiss];
  142. [MBProgressHUD showMessage:@"加载失败,请稍后重试"];
  143. sender.backgroundColor = [UIColor homeRedColor];
  144. sender.enabled = YES;
  145. }];
  146. }
  147. /**
  148. 加载支付宝信息
  149. */
  150. - (void)request {
  151. NSString *url = [NSString stringWithFormat:@"%@/api/v2/users/alipayGetMoneyPage",BaseURL];
  152. [DRHttp post:url params:nil success:^(id json) {
  153. NSDictionary *dict = json[@"data"];
  154. [self.userView setUserInfo:dict];
  155. } failure:^(NSError *error) {
  156. }];
  157. }
  158. - (UIScrollView *)scrollView {
  159. if (!_scrollView) {
  160. _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
  161. _scrollView.backgroundColor = [UIColor backgroudColor];
  162. _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight+1);
  163. _scrollView.showsVerticalScrollIndicator = NO;
  164. _scrollView.bounces = YES;
  165. }
  166. return _scrollView;
  167. }
  168. - (void)didReceiveMemoryWarning {
  169. [super didReceiveMemoryWarning];
  170. // Dispose of any resources that can be recreated.
  171. }
  172. /*
  173. #pragma mark - Navigation
  174. // In a storyboard-based application, you will often want to do a little preparation before navigation
  175. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  176. // Get the new view controller using [segue destinationViewController].
  177. // Pass the selected object to the new view controller.
  178. }
  179. */
  180. @end