YMMyEarningsViewController.m 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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(0xFFFFFF);
  40. }
  41. - (void)viewDidLayoutSubviews {
  42. [super viewDidLayoutSubviews];
  43. UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_account_balance_nav_bg"]];
  44. topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, adapt(233));
  45. [self.view insertSubview:topBgImgv atIndex:0];
  46. }
  47. -(void)viewWillAppear:(BOOL)animated{
  48. [super viewWillAppear:animated];
  49. [self.viewModel getMyEarningsInfoData];
  50. }
  51. - (UIStatusBarStyle)preferredStatusBarStyle {
  52. return UIStatusBarStyleDefault;
  53. }
  54. - (void)ym_setupViews{
  55. //[self setRightBarButtonWithCustomView:self.incomeBreakdownBtn];
  56. [self.view addSubview:self.contentScrollView];
  57. [self.view sendSubviewToBack:self.contentScrollView];
  58. [self.contentScrollView addSubview:self.contentView];
  59. [self.contentView addSubview:self.myEarningsInfoView];
  60. WS(weakSelf)
  61. [[[self.incomeBreakdownBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  62. [weakSelf.viewModel gotoIncomeBreakdown];
  63. }];
  64. [self.contentView addSubview:self.myEarningsWithdrawalAmountView];
  65. [self.contentView addSubview:self.myEarningsBindAccountView];
  66. [self.contentView addSubview:self.myEarningsWithdrawalNotesView];
  67. [self.view addSubview:self.withdrawalBtn];
  68. [self.view setNeedsUpdateConstraints];
  69. [self.view updateConstraintsIfNeeded];
  70. UIView *wbg = [[UIView alloc] init];
  71. wbg.backgroundColor = UIColor.whiteColor;
  72. [self.view insertSubview:wbg belowSubview:self.contentScrollView];
  73. [wbg mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(self.view);
  75. make.right.equalTo(self.view);
  76. make.bottom.equalTo(self.view);
  77. make.height.mas_equalTo(kScreenHeight * 2 / 5.0);
  78. }];
  79. }
  80. - (void)updateViewConstraints{
  81. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.top.equalTo(self.view).offset(kYMNavHeight);
  83. make.left.equalTo(self.view);
  84. make.right.equalTo(self.view);
  85. make.bottom.equalTo(self.view);
  86. }];
  87. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.edges.equalTo(self.contentScrollView);
  89. make.width.equalTo(self.contentScrollView.mas_width);
  90. }];
  91. [self.myEarningsInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.equalTo(self.contentView);
  93. make.left.equalTo(self.contentView);
  94. make.right.equalTo(self.contentView);
  95. }];
  96. [self.myEarningsWithdrawalAmountView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.top.equalTo(self.myEarningsInfoView.mas_bottom);
  98. make.left.equalTo(self.contentView);
  99. make.right.equalTo(self.contentView);
  100. }];
  101. [self.myEarningsBindAccountView mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.top.equalTo(self.myEarningsWithdrawalAmountView.mas_bottom);
  103. make.left.equalTo(self.contentView);
  104. make.right.equalTo(self.contentView);
  105. }];
  106. [self.myEarningsWithdrawalNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(self.myEarningsBindAccountView.mas_bottom);
  108. make.left.equalTo(self.contentView);
  109. make.right.equalTo(self.contentView);
  110. make.bottom.equalTo(self.contentView).offset(adapt(0));
  111. }];
  112. [self.withdrawalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.left.equalTo(self.view).offset(adapt(32));
  114. make.right.equalTo(self.view).offset(adapt(-32));
  115. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  116. make.height.mas_equalTo(adapt(50));
  117. }];
  118. [super updateViewConstraints];
  119. }
  120. - (void)ym_bindViewModel{
  121. [self.myEarningsInfoView ym_bindViewModel:self.viewModel];
  122. [self.myEarningsWithdrawalAmountView ym_bindViewModel:self.viewModel];
  123. [self.myEarningsBindAccountView ym_bindViewModel:self.viewModel];
  124. [self.myEarningsWithdrawalNotesView ym_bindViewModel:self.viewModel];
  125. // [self.viewModel getMyEarningsInfoData];
  126. }
  127. - (UIScrollView *)contentScrollView{
  128. if (!_contentScrollView) {
  129. _contentScrollView = [[UIScrollView alloc]init];
  130. _contentScrollView.delegate = self;
  131. _contentScrollView.alwaysBounceVertical = YES;
  132. _contentScrollView.showsVerticalScrollIndicator = NO;
  133. _contentScrollView.showsHorizontalScrollIndicator = NO;
  134. _contentScrollView.backgroundColor = UIColor.clearColor;
  135. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  136. }
  137. return _contentScrollView;
  138. }
  139. - (UIView *)contentView{
  140. if (!_contentView) {
  141. _contentView = [[UIView alloc]init];
  142. }
  143. return _contentView;
  144. }
  145. - (YMMyEarningsInfoView *)myEarningsInfoView{
  146. if (!_myEarningsInfoView) {
  147. _myEarningsInfoView = [[YMMyEarningsInfoView alloc]init];
  148. }
  149. return _myEarningsInfoView;
  150. }
  151. - (YMMyEarningsWithdrawalAmountView *)myEarningsWithdrawalAmountView{
  152. if (!_myEarningsWithdrawalAmountView) {
  153. _myEarningsWithdrawalAmountView = [[YMMyEarningsWithdrawalAmountView alloc]init];
  154. _myEarningsWithdrawalAmountView.backgroundColor = UIColor.clearColor;
  155. }
  156. return _myEarningsWithdrawalAmountView;
  157. }
  158. - (YMMyEarningsBindAccountView *)myEarningsBindAccountView{
  159. if (!_myEarningsBindAccountView) {
  160. _myEarningsBindAccountView = [[YMMyEarningsBindAccountView alloc]init];
  161. _myEarningsBindAccountView.backgroundColor = UIColor.whiteColor;
  162. }
  163. return _myEarningsBindAccountView;
  164. }
  165. - (YMMyEarningsWithdrawalNotesView *)myEarningsWithdrawalNotesView{
  166. if (!_myEarningsWithdrawalNotesView) {
  167. _myEarningsWithdrawalNotesView = [[YMMyEarningsWithdrawalNotesView alloc]init];
  168. _myEarningsWithdrawalNotesView.backgroundColor = UIColor.whiteColor;
  169. //[_myEarningsWithdrawalNotesView addRectCorner:UIRectCornerBottomLeft|UIRectCornerBottomRight radius:adapt(20)];
  170. }
  171. return _myEarningsWithdrawalNotesView;
  172. }
  173. - (UIButton *)incomeBreakdownBtn{
  174. if (!_incomeBreakdownBtn) {
  175. _incomeBreakdownBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  176. _incomeBreakdownBtn.titleLabel.font = LCFont(13);
  177. [_incomeBreakdownBtn setTitle:@"收支明细" forState:UIControlStateNormal];
  178. [_incomeBreakdownBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  179. _incomeBreakdownBtn.backgroundColor = UIColor.clearColor;
  180. _incomeBreakdownBtn.layer.cornerRadius = adapt(8);
  181. _incomeBreakdownBtn.layer.masksToBounds = YES;
  182. }
  183. return _incomeBreakdownBtn;
  184. }
  185. - (UIButton *)withdrawalBtn{
  186. if (!_withdrawalBtn) {
  187. _withdrawalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  188. _withdrawalBtn.titleLabel.font = LCBoldFont(18);
  189. [_withdrawalBtn setTitle:@"立即提现" forState:UIControlStateNormal];
  190. [_withdrawalBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  191. //_withdrawalBtn.backgroundColor = HexColorFromRGB(0x4E76FD);
  192. [_withdrawalBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  193. _withdrawalBtn.layer.cornerRadius = adapt(25);
  194. _withdrawalBtn.layer.masksToBounds = YES;
  195. WS(weakSelf)
  196. [[[_withdrawalBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  197. if ([weakSelf.viewModel.withdrawalAccount isEqualToString:@"请绑定账号"]) {
  198. [ZCHUDHelper showTitle:@"请绑定账户" showtime:1.5];
  199. return;
  200. }
  201. if (weakSelf.viewModel.withdrawalAmount <= 0) {
  202. [ZCHUDHelper showTitle:@"请选择提现金额" showtime:1.5];
  203. return;
  204. }
  205. [weakSelf.viewModel submitWithdrawalInfo];
  206. }];
  207. }
  208. return _withdrawalBtn;
  209. }
  210. #pragma mark - UIScrollViewDelegate
  211. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  212. CGFloat offsetY = scrollView.contentOffset.y;
  213. if (offsetY >= scrollView.contentSize.height) {
  214. scrollView.contentOffset = CGPointMake(0, scrollView.contentSize.height);
  215. }
  216. }
  217. @end