YMMyEarningsViewController.m 11 KB

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