123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- //
- // YMAccountBalanceViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/27.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAccountBalanceViewController.h"
- #import "YMAccountBalanceViewModel.h"
- #import "YMAccountBalanceInfoView.h"
- #import "YMAccountBalanceRechargeItemView.h"
- #import "YMAccountBalancePayMethodView.h"
- #import "YMAccountBalanceRechargeNotesView.h"
- @interface YMAccountBalanceViewController ()
- /// 账户余额VM
- @property (nonatomic, strong) YMAccountBalanceViewModel *viewModel;
- /// 容器滚动视图
- @property (nonatomic, strong) UIScrollView *contentScrollView;
- /// 容器视图
- @property (nonatomic, strong) UIView *contentView;
- /// 账户余额信息视图
- @property (nonatomic, strong) YMAccountBalanceInfoView *accountBalanceInfoView;
- /// 账户余额充值项目视图
- @property (nonatomic, strong) YMAccountBalanceRechargeItemView *accountBalanceRechargeItemView;
- /// 账户余额支付方式视图
- @property (nonatomic, strong) YMAccountBalancePayMethodView *accountBalancePayMethodView;
- /// 账户余额充值说明视图
- @property (nonatomic, strong) YMAccountBalanceRechargeNotesView *accountBalanceRechargeNotesView;
- /// 立即充值按钮
- @property (nonatomic, strong) UIButton *rechargeNowBtn;
- @end
- @implementation YMAccountBalanceViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- //self.ym_customNavView.backgroundColor = UIColor.clearColor;
- //self.ym_customNavView.ym_customBackgroundImage.image = [UIImage new];
- //self.ym_customNavView.ym_customNavBar.backgroundColor = UIColor.clearColor;
- //[self.ym_customNavView.ym_customNavBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
- //[self.ym_customNavView.ym_customNavBar setShadowImage:[UIImage new]];
- //self.ym_customNavView.ym_customNavBar.translucent = YES;
- //self.ym_customNavView.ym_customNavBar.backgroundColor = [UIColor clearColor];
- //self.ym_customNavView.ym_customNavBar.appearance = [UINavigationBarAppearance new];
- [self setNavHidden:YES];
-
- UIView *navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, adapt(44))];
- navView.backgroundColor = UIColor.clearColor;
- [self.view addSubview:navView];
- [navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(kYMStatusBarHeight);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- make.height.mas_equalTo(44);
- }];
-
- UIButton *backButn = [UIButton buttonWithType:UIButtonTypeCustom];
- backButn.frame = CGRectMake(0, 0, adapt(44), adapt(44));
- [backButn setImage:[UIImage imageNamed:@"ym_navigation_white_icon"] forState:UIControlStateNormal];
- [backButn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [navView addSubview:backButn];
- [backButn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(navView).offset(0);
- make.left.equalTo(navView).offset(10);
- make.width.height.mas_equalTo(44);
- }];
-
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.text = @"充值中心";
- titleLabel.textColor = UIColor.whiteColor;
- titleLabel.font = LCBoldFont(16);
- [navView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(navView);
- }];
-
-
- 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];
-
-
-
- [OCNotificationCenter addObserver:self selector:@selector(weChatOrAlipayPaymentSuccess:) name:ALIPAY_SUCCESS_NOTIFICATION object:nil];
-
- [OCNotificationCenter addObserver:self selector:@selector(weChatOrAlipayPaymentSuccess:) name:WECHATPAY_SUCCESS_NOTIFICATION object:nil];
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)ym_setupViews{
- //[self setRightBarButtonWithCustomView:self.incomeBreakdownBtn];
- [self.view addSubview:self.contentScrollView];
- [self.contentScrollView addSubview:self.contentView];
- [self.contentView addSubview:self.accountBalanceInfoView];
- [self.contentView addSubview:self.accountBalanceRechargeItemView];
- [self.contentView addSubview:self.accountBalancePayMethodView];
- [self.contentView addSubview:self.accountBalanceRechargeNotesView];
- [self.view addSubview:self.rechargeNowBtn];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- // [self.incomeBreakdownBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.width.equalTo(adapt(70));
- // make.height.equalTo(adapt(28));
- // }];
-
- [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.accountBalanceInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(adapt(10));
- make.left.equalTo(self.contentView).offset(adapt(0));
- make.right.equalTo(self.contentView).offset(adapt(0));
- }];
-
- [self.accountBalanceRechargeItemView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountBalanceInfoView.mas_bottom);
- make.left.equalTo(self.contentView).offset(adapt(10));
- make.right.equalTo(self.contentView).offset(adapt(-10));
- }];
-
- [self.accountBalancePayMethodView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountBalanceRechargeItemView.mas_bottom).offset(adapt(20));
- make.left.equalTo(self.contentView).offset(adapt(10));
- make.right.equalTo(self.contentView).offset(adapt(-10));
- }];
-
- [self.accountBalanceRechargeNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.accountBalancePayMethodView.mas_bottom).offset(adapt(20));
- make.left.equalTo(self.contentView).offset(adapt(10));
- make.right.equalTo(self.contentView).offset(adapt(-10));
- make.bottom.equalTo(self.contentView).offset(adapt(-90));
- }];
-
- [self.rechargeNowBtn 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(54));
- }];
-
- [super updateViewConstraints];
- }
- - (void)ym_bindViewModel{
- [self.accountBalanceInfoView ym_bindViewModel:self.viewModel];
- [self.accountBalanceRechargeItemView ym_bindViewModel:self.viewModel];
- [self.accountBalancePayMethodView ym_bindViewModel:self.viewModel];
- [self.accountBalanceRechargeNotesView ym_bindViewModel:self.viewModel];
-
- [[YMGlobalUtils shared] getConfig];
- [self.viewModel getAccountShowData];
- [self.viewModel getAccountBalanceInfoData];
-
- }
- - (void)weChatOrAlipayPaymentSuccess:(NSNotification *)notice{
- [self.viewModel getAccountBalanceInfoData];
-
- }
- - (UIScrollView *)contentScrollView{
- if (!_contentScrollView) {
- _contentScrollView = [[UIScrollView alloc]init];
- _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;
- }
- - (YMAccountBalanceInfoView *)accountBalanceInfoView{
- if (!_accountBalanceInfoView) {
- _accountBalanceInfoView = [[YMAccountBalanceInfoView alloc]init];
- }
- return _accountBalanceInfoView;
- }
- - (YMAccountBalanceRechargeItemView *)accountBalanceRechargeItemView{
- if (!_accountBalanceRechargeItemView) {
- _accountBalanceRechargeItemView = [[YMAccountBalanceRechargeItemView alloc]init];
- }
- return _accountBalanceRechargeItemView;
- }
- - (YMAccountBalancePayMethodView *)accountBalancePayMethodView{
- if (!_accountBalancePayMethodView) {
- _accountBalancePayMethodView = [[YMAccountBalancePayMethodView alloc]init];
- }
- return _accountBalancePayMethodView;
- }
- - (YMAccountBalanceRechargeNotesView *)accountBalanceRechargeNotesView{
- if (!_accountBalanceRechargeNotesView) {
- _accountBalanceRechargeNotesView = [[YMAccountBalanceRechargeNotesView alloc]init];
- }
- return _accountBalanceRechargeNotesView;
- }
- - (UIButton *)rechargeNowBtn{
- if (!_rechargeNowBtn) {
- _rechargeNowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _rechargeNowBtn.titleLabel.font = LCBoldFont(18);
- [_rechargeNowBtn setTitle:@"立即充值" forState:UIControlStateNormal];
- [_rechargeNowBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
- //_rechargeNowBtn.backgroundColor = HexColorFromRGB(0x883FFB);
- [_rechargeNowBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- _rechargeNowBtn.layer.cornerRadius = adapt(27);
- _rechargeNowBtn.layer.masksToBounds = YES;
- WS(weakSelf)
- [[[_rechargeNowBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel detectionAccountBalanceRechargeInfoData];
- }];
- }
- return _rechargeNowBtn;
- }
- @end
|