// // YMMyEarningsViewController.m // MSYOUPAI // // Created by YoMi on 2024/2/27. // Copyright © 2024 MS. All rights reserved. // #import "YMMyEarningsViewController.h" #import "YMMyEarningsViewModel.h" #import "YMMyEarningsInfoView.h" #import "YMMyEarningsWithdrawalAmountView.h" #import "YMMyEarningsBindAccountView.h" #import "YMMyEarningsWithdrawalNotesView.h" @interface YMMyEarningsViewController () /// 我的收益VM @property (nonatomic, strong) YMMyEarningsViewModel *viewModel; /// 容器滚动视图 @property (nonatomic, strong) UIScrollView *contentScrollView; /// 容器视图 @property (nonatomic, strong) UIView *contentView; /// 我的收益信息视图 @property (nonatomic, strong) YMMyEarningsInfoView *myEarningsInfoView; /// 我的收益提现金额视图 @property (nonatomic, strong) YMMyEarningsWithdrawalAmountView *myEarningsWithdrawalAmountView; /// 我的收益绑定账户视图 @property (nonatomic, strong) YMMyEarningsBindAccountView *myEarningsBindAccountView; /// 我的收益提现说明视图 @property (nonatomic, strong) YMMyEarningsWithdrawalNotesView *myEarningsWithdrawalNotesView; /// 立即充值按钮 @property (nonatomic, strong) UIButton *withdrawalBtn; /// 收支明细按钮 @property (nonatomic, strong) UIButton *incomeBreakdownBtn; @end @implementation YMMyEarningsViewController @dynamic viewModel; - (void)viewDidLoad { [super viewDidLoad]; self.ym_navigationStyle = YMBaseNavigationStyleClearBgWhiteBackArrow; self.view.backgroundColor = HexColorFromRGB(0xFFFFFF); } - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_account_balance_nav_bg"]]; topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, adapt(233)); [self.view insertSubview:topBgImgv atIndex:0]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.viewModel getMyEarningsInfoData]; } - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; } - (void)ym_setupViews{ //[self setRightBarButtonWithCustomView:self.incomeBreakdownBtn]; [self.view addSubview:self.contentScrollView]; [self.view sendSubviewToBack:self.contentScrollView]; [self.contentScrollView addSubview:self.contentView]; [self.contentView addSubview:self.myEarningsInfoView]; WS(weakSelf) [[[self.incomeBreakdownBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel gotoIncomeBreakdown]; }]; [self.contentView addSubview:self.myEarningsWithdrawalAmountView]; [self.contentView addSubview:self.myEarningsBindAccountView]; [self.contentView addSubview:self.myEarningsWithdrawalNotesView]; [self.view addSubview:self.withdrawalBtn]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; UIView *wbg = [[UIView alloc] init]; wbg.backgroundColor = UIColor.whiteColor; [self.view insertSubview:wbg belowSubview:self.contentScrollView]; [wbg mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view); make.right.equalTo(self.view); make.bottom.equalTo(self.view); make.height.mas_equalTo(kScreenHeight * 2 / 5.0); }]; } - (void)updateViewConstraints{ [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view).offset(kYMNavHeight); make.left.equalTo(self.view); make.right.equalTo(self.view); make.bottom.equalTo(self.view); }]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentScrollView); make.width.equalTo(self.contentScrollView.mas_width); }]; [self.myEarningsInfoView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.myEarningsWithdrawalAmountView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.myEarningsInfoView.mas_bottom); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.myEarningsBindAccountView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.myEarningsWithdrawalAmountView.mas_bottom); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.myEarningsWithdrawalNotesView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.myEarningsBindAccountView.mas_bottom); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView).offset(adapt(0)); }]; [self.withdrawalBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view).offset(adapt(32)); make.right.equalTo(self.view).offset(adapt(-32)); make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12)); make.height.mas_equalTo(adapt(50)); }]; [super updateViewConstraints]; } - (void)ym_bindViewModel{ [self.myEarningsInfoView ym_bindViewModel:self.viewModel]; [self.myEarningsWithdrawalAmountView ym_bindViewModel:self.viewModel]; [self.myEarningsBindAccountView ym_bindViewModel:self.viewModel]; [self.myEarningsWithdrawalNotesView ym_bindViewModel:self.viewModel]; // [self.viewModel getMyEarningsInfoData]; } - (UIScrollView *)contentScrollView{ if (!_contentScrollView) { _contentScrollView = [[UIScrollView alloc]init]; _contentScrollView.delegate = self; _contentScrollView.alwaysBounceVertical = YES; _contentScrollView.showsVerticalScrollIndicator = NO; _contentScrollView.showsHorizontalScrollIndicator = NO; _contentScrollView.backgroundColor = UIColor.clearColor; _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; } return _contentScrollView; } - (UIView *)contentView{ if (!_contentView) { _contentView = [[UIView alloc]init]; } return _contentView; } - (YMMyEarningsInfoView *)myEarningsInfoView{ if (!_myEarningsInfoView) { _myEarningsInfoView = [[YMMyEarningsInfoView alloc]init]; } return _myEarningsInfoView; } - (YMMyEarningsWithdrawalAmountView *)myEarningsWithdrawalAmountView{ if (!_myEarningsWithdrawalAmountView) { _myEarningsWithdrawalAmountView = [[YMMyEarningsWithdrawalAmountView alloc]init]; _myEarningsWithdrawalAmountView.backgroundColor = UIColor.clearColor; } return _myEarningsWithdrawalAmountView; } - (YMMyEarningsBindAccountView *)myEarningsBindAccountView{ if (!_myEarningsBindAccountView) { _myEarningsBindAccountView = [[YMMyEarningsBindAccountView alloc]init]; _myEarningsBindAccountView.backgroundColor = UIColor.whiteColor; } return _myEarningsBindAccountView; } - (YMMyEarningsWithdrawalNotesView *)myEarningsWithdrawalNotesView{ if (!_myEarningsWithdrawalNotesView) { _myEarningsWithdrawalNotesView = [[YMMyEarningsWithdrawalNotesView alloc]init]; _myEarningsWithdrawalNotesView.backgroundColor = UIColor.whiteColor; //[_myEarningsWithdrawalNotesView addRectCorner:UIRectCornerBottomLeft|UIRectCornerBottomRight radius:adapt(20)]; } return _myEarningsWithdrawalNotesView; } - (UIButton *)incomeBreakdownBtn{ if (!_incomeBreakdownBtn) { _incomeBreakdownBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _incomeBreakdownBtn.titleLabel.font = LCFont(13); [_incomeBreakdownBtn setTitle:@"收支明细" forState:UIControlStateNormal]; [_incomeBreakdownBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal]; _incomeBreakdownBtn.backgroundColor = UIColor.clearColor; _incomeBreakdownBtn.layer.cornerRadius = adapt(8); _incomeBreakdownBtn.layer.masksToBounds = YES; } return _incomeBreakdownBtn; } - (UIButton *)withdrawalBtn{ if (!_withdrawalBtn) { _withdrawalBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _withdrawalBtn.titleLabel.font = LCBoldFont(18); [_withdrawalBtn setTitle:@"立即提现" forState:UIControlStateNormal]; [_withdrawalBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal]; //_withdrawalBtn.backgroundColor = HexColorFromRGB(0x4E76FD); [_withdrawalBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP]; _withdrawalBtn.layer.cornerRadius = adapt(25); _withdrawalBtn.layer.masksToBounds = YES; WS(weakSelf) [[[_withdrawalBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if ([weakSelf.viewModel.withdrawalAccount isEqualToString:@"请绑定账号"]) { [ZCHUDHelper showTitle:@"请绑定账户" showtime:1.5]; return; } if (weakSelf.viewModel.withdrawalAmount <= 0) { [ZCHUDHelper showTitle:@"请选择提现金额" showtime:1.5]; return; } [weakSelf.viewModel submitWithdrawalInfo]; }]; } return _withdrawalBtn; } #pragma mark - UIScrollViewDelegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat offsetY = scrollView.contentOffset.y; if (offsetY >= scrollView.contentSize.height) { scrollView.contentOffset = CGPointMake(0, scrollView.contentSize.height); } } @end