YMMyEarningsViewController.m 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // YMMyEarningsViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/27.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMyEarningsViewController.h"
  9. #import "YMMyEarningsViewModel.h"
  10. #import "YMMyEarningsInfoView.h"
  11. #import "YMMyEarningsWithdrawalAmountView.h"
  12. #import "YMMyEarningsBindAccountView.h"
  13. #import "YMMyEarningsWithdrawalNotesView.h"
  14. @interface YMMyEarningsViewController ()<UIScrollViewDelegate>
  15. /// 我的收益VM
  16. @property (nonatomic, strong) YMMyEarningsViewModel *viewModel;
  17. /// 容器滚动视图
  18. @property (nonatomic, strong) UIScrollView *contentScrollView;
  19. /// 容器视图
  20. @property (nonatomic, strong) UIView *contentView;
  21. /// 我的收益信息视图
  22. @property (nonatomic, strong) YMMyEarningsInfoView *myEarningsInfoView;
  23. /// 我的收益提现金额视图
  24. @property (nonatomic, strong) YMMyEarningsWithdrawalAmountView *myEarningsWithdrawalAmountView;
  25. /// 我的收益绑定账户视图
  26. @property (nonatomic, strong) YMMyEarningsBindAccountView *myEarningsBindAccountView;
  27. /// 我的收益提现说明视图
  28. @property (nonatomic, strong) YMMyEarningsWithdrawalNotesView *myEarningsWithdrawalNotesView;
  29. /// 立即充值按钮
  30. @property (nonatomic, strong) UIButton *withdrawalBtn;
  31. /// 收支明细按钮
  32. @property (nonatomic, strong) UIButton *incomeBreakdownBtn;
  33. @end
  34. @implementation YMMyEarningsViewController
  35. @dynamic viewModel;
  36. - (void)viewDidLoad {
  37. [super viewDidLoad];
  38. self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow;
  39. self.view.backgroundColor = HexColorFromRGB(0x2E2466);
  40. }
  41. -(void)viewWillAppear:(BOOL)animated{
  42. [super viewWillAppear:animated];
  43. [self.viewModel getMyEarningsInfoData];
  44. }
  45. - (UIStatusBarStyle)preferredStatusBarStyle {
  46. return UIStatusBarStyleLightContent;
  47. }
  48. - (void)ym_setupViews{
  49. [self setRightBarButtonWithCustomView:self.incomeBreakdownBtn];
  50. [self.view addSubview:self.contentScrollView];
  51. [self.view sendSubviewToBack:self.contentScrollView];
  52. [self.contentScrollView addSubview:self.contentView];
  53. [self.contentView addSubview:self.myEarningsInfoView];
  54. WS(weakSelf)
  55. [[[self.incomeBreakdownBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  56. [weakSelf.viewModel gotoIncomeBreakdown];
  57. }];
  58. [self.contentView addSubview:self.myEarningsWithdrawalAmountView];
  59. [self.contentView addSubview:self.myEarningsBindAccountView];
  60. [self.contentView addSubview:self.myEarningsWithdrawalNotesView];
  61. [self.view addSubview:self.withdrawalBtn];
  62. [self.view setNeedsUpdateConstraints];
  63. [self.view updateConstraintsIfNeeded];
  64. UIView *wbg = [[UIView alloc] init];
  65. wbg.backgroundColor = UIColor.whiteColor;
  66. [self.view insertSubview:wbg belowSubview:self.contentScrollView];
  67. [wbg mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(self.view);
  69. make.right.equalTo(self.view);
  70. make.bottom.equalTo(self.view);
  71. make.height.mas_equalTo(kScreenHeight * 2 / 5.0);
  72. }];
  73. }
  74. - (void)updateViewConstraints{
  75. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.equalTo(self.view).offset(kYMNavHeight);
  77. make.left.equalTo(self.view);
  78. make.right.equalTo(self.view);
  79. make.bottom.equalTo(self.view);
  80. }];
  81. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.edges.equalTo(self.contentScrollView);
  83. make.width.equalTo(self.contentScrollView.mas_width);
  84. }];
  85. [self.myEarningsInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.equalTo(self.contentView);
  87. make.left.equalTo(self.contentView);
  88. make.right.equalTo(self.contentView);
  89. }];
  90. [self.myEarningsWithdrawalAmountView mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.equalTo(self.myEarningsInfoView.mas_bottom);
  92. make.left.equalTo(self.contentView);
  93. make.right.equalTo(self.contentView);
  94. }];
  95. [self.myEarningsBindAccountView mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.top.equalTo(self.myEarningsWithdrawalAmountView.mas_bottom);
  97. make.left.equalTo(self.contentView);
  98. make.right.equalTo(self.contentView);
  99. }];
  100. [self.myEarningsWithdrawalNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.top.equalTo(self.myEarningsBindAccountView.mas_bottom);
  102. make.left.equalTo(self.contentView);
  103. make.right.equalTo(self.contentView);
  104. make.bottom.equalTo(self.contentView).offset(adapt(0));
  105. }];
  106. [self.withdrawalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.equalTo(self.view).offset(adapt(32));
  108. make.right.equalTo(self.view).offset(adapt(-32));
  109. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  110. make.height.mas_equalTo(adapt(50));
  111. }];
  112. [super updateViewConstraints];
  113. }
  114. - (void)ym_bindViewModel{
  115. [self.myEarningsInfoView ym_bindViewModel:self.viewModel];
  116. [self.myEarningsWithdrawalAmountView ym_bindViewModel:self.viewModel];
  117. [self.myEarningsBindAccountView ym_bindViewModel:self.viewModel];
  118. [self.myEarningsWithdrawalNotesView ym_bindViewModel:self.viewModel];
  119. // [self.viewModel getMyEarningsInfoData];
  120. }
  121. - (UIScrollView *)contentScrollView{
  122. if (!_contentScrollView) {
  123. _contentScrollView = [[UIScrollView alloc]init];
  124. _contentScrollView.delegate = self;
  125. _contentScrollView.alwaysBounceVertical = YES;
  126. _contentScrollView.showsVerticalScrollIndicator = NO;
  127. _contentScrollView.showsHorizontalScrollIndicator = NO;
  128. _contentScrollView.backgroundColor = UIColor.clearColor;
  129. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  130. }
  131. return _contentScrollView;
  132. }
  133. - (UIView *)contentView{
  134. if (!_contentView) {
  135. _contentView = [[UIView alloc]init];
  136. }
  137. return _contentView;
  138. }
  139. - (YMMyEarningsInfoView *)myEarningsInfoView{
  140. if (!_myEarningsInfoView) {
  141. _myEarningsInfoView = [[YMMyEarningsInfoView alloc]init];
  142. }
  143. return _myEarningsInfoView;
  144. }
  145. - (YMMyEarningsWithdrawalAmountView *)myEarningsWithdrawalAmountView{
  146. if (!_myEarningsWithdrawalAmountView) {
  147. _myEarningsWithdrawalAmountView = [[YMMyEarningsWithdrawalAmountView alloc]init];
  148. _myEarningsWithdrawalAmountView.backgroundColor = UIColor.whiteColor;
  149. }
  150. return _myEarningsWithdrawalAmountView;
  151. }
  152. - (YMMyEarningsBindAccountView *)myEarningsBindAccountView{
  153. if (!_myEarningsBindAccountView) {
  154. _myEarningsBindAccountView = [[YMMyEarningsBindAccountView alloc]init];
  155. _myEarningsBindAccountView.backgroundColor = UIColor.whiteColor;
  156. }
  157. return _myEarningsBindAccountView;
  158. }
  159. - (YMMyEarningsWithdrawalNotesView *)myEarningsWithdrawalNotesView{
  160. if (!_myEarningsWithdrawalNotesView) {
  161. _myEarningsWithdrawalNotesView = [[YMMyEarningsWithdrawalNotesView alloc]init];
  162. _myEarningsWithdrawalNotesView.backgroundColor = UIColor.whiteColor;
  163. //[_myEarningsWithdrawalNotesView addRectCorner:UIRectCornerBottomLeft|UIRectCornerBottomRight radius:adapt(20)];
  164. }
  165. return _myEarningsWithdrawalNotesView;
  166. }
  167. - (UIButton *)incomeBreakdownBtn{
  168. if (!_incomeBreakdownBtn) {
  169. _incomeBreakdownBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  170. _incomeBreakdownBtn.titleLabel.font = LCFont(13);
  171. [_incomeBreakdownBtn setTitle:@"收支明细" forState:UIControlStateNormal];
  172. [_incomeBreakdownBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  173. _incomeBreakdownBtn.backgroundColor = UIColor.clearColor;
  174. _incomeBreakdownBtn.layer.cornerRadius = adapt(8);
  175. _incomeBreakdownBtn.layer.masksToBounds = YES;
  176. }
  177. return _incomeBreakdownBtn;
  178. }
  179. - (UIButton *)withdrawalBtn{
  180. if (!_withdrawalBtn) {
  181. _withdrawalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  182. _withdrawalBtn.titleLabel.font = LCBoldFont(18);
  183. [_withdrawalBtn setTitle:@"立即提现" forState:UIControlStateNormal];
  184. [_withdrawalBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  185. //_withdrawalBtn.backgroundColor = HexColorFromRGB(0x4E76FD);
  186. [_withdrawalBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  187. _withdrawalBtn.layer.cornerRadius = adapt(50) / 2.0;
  188. _withdrawalBtn.layer.masksToBounds = YES;
  189. WS(weakSelf)
  190. [[[_withdrawalBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  191. if ([weakSelf.viewModel.withdrawalAccount isEqualToString:@"请绑定账号"]) {
  192. [ZCHUDHelper showTitle:@"请绑定账户" showtime:1.5];
  193. return;
  194. }
  195. if (weakSelf.viewModel.withdrawalAmount <= 0) {
  196. [ZCHUDHelper showTitle:@"请选择提现金额" showtime:1.5];
  197. return;
  198. }
  199. [weakSelf.viewModel submitWithdrawalInfo];
  200. }];
  201. }
  202. return _withdrawalBtn;
  203. }
  204. #pragma mark - UIScrollViewDelegate
  205. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  206. CGFloat offsetY = scrollView.contentOffset.y;
  207. if (offsetY >= scrollView.contentSize.height) {
  208. scrollView.contentOffset = CGPointMake(0, scrollView.contentSize.height);
  209. }
  210. }
  211. @end