123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- //
- // 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 ()<UIScrollViewDelegate>
- /// 我的收益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
|