YMMyEarningsViewController.m 11 KB

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