YMAccountBalanceViewController.m 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //
  2. // YMAccountBalanceViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/27.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAccountBalanceViewController.h"
  9. #import "YMAccountBalanceViewModel.h"
  10. #import "YMAccountBalanceInfoView.h"
  11. #import "YMAccountBalanceRechargeItemView.h"
  12. #import "YMAccountBalancePayMethodView.h"
  13. #import "YMAccountBalanceRechargeNotesView.h"
  14. @interface YMAccountBalanceViewController ()
  15. /// 账户余额VM
  16. @property (nonatomic, strong) YMAccountBalanceViewModel *viewModel;
  17. /// 容器滚动视图
  18. @property (nonatomic, strong) UIScrollView *contentScrollView;
  19. /// 容器视图
  20. @property (nonatomic, strong) UIView *contentView;
  21. /// 账户余额信息视图
  22. @property (nonatomic, strong) YMAccountBalanceInfoView *accountBalanceInfoView;
  23. /// 账户余额充值项目视图
  24. @property (nonatomic, strong) YMAccountBalanceRechargeItemView *accountBalanceRechargeItemView;
  25. /// 账户余额支付方式视图
  26. @property (nonatomic, strong) YMAccountBalancePayMethodView *accountBalancePayMethodView;
  27. /// 账户余额充值说明视图
  28. @property (nonatomic, strong) YMAccountBalanceRechargeNotesView *accountBalanceRechargeNotesView;
  29. /// 立即充值按钮
  30. @property (nonatomic, strong) UIButton *rechargeNowBtn;
  31. @end
  32. @implementation YMAccountBalanceViewController
  33. @dynamic viewModel;
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. //self.ym_customNavView.backgroundColor = UIColor.clearColor;
  37. //self.ym_customNavView.ym_customBackgroundImage.image = [UIImage new];
  38. //self.ym_customNavView.ym_customNavBar.backgroundColor = UIColor.clearColor;
  39. //[self.ym_customNavView.ym_customNavBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  40. //[self.ym_customNavView.ym_customNavBar setShadowImage:[UIImage new]];
  41. //self.ym_customNavView.ym_customNavBar.translucent = YES;
  42. //self.ym_customNavView.ym_customNavBar.backgroundColor = [UIColor clearColor];
  43. //self.ym_customNavView.ym_customNavBar.appearance = [UINavigationBarAppearance new];
  44. [self setNavHidden:YES];
  45. UIView *navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, adapt(44))];
  46. navView.backgroundColor = UIColor.clearColor;
  47. [self.view addSubview:navView];
  48. [navView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.equalTo(self.view).offset(kYMStatusBarHeight);
  50. make.left.equalTo(self.view);
  51. make.right.equalTo(self.view);
  52. make.height.mas_equalTo(44);
  53. }];
  54. UIButton *backButn = [UIButton buttonWithType:UIButtonTypeCustom];
  55. backButn.frame = CGRectMake(0, 0, adapt(44), adapt(44));
  56. [backButn setImage:[UIImage imageNamed:@"ym_navigation_white_icon"] forState:UIControlStateNormal];
  57. [backButn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  58. [navView addSubview:backButn];
  59. [backButn mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.equalTo(navView).offset(0);
  61. make.left.equalTo(navView).offset(10);
  62. make.width.height.mas_equalTo(44);
  63. }];
  64. UILabel *titleLabel = [[UILabel alloc] init];
  65. titleLabel.text = @"充值中心";
  66. titleLabel.textColor = UIColor.whiteColor;
  67. titleLabel.font = LCBoldFont(16);
  68. [navView addSubview:titleLabel];
  69. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.center.equalTo(navView);
  71. }];
  72. UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_account_balance_nav_bg"]];
  73. topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, adapt(233));
  74. [self.view insertSubview:topBgImgv atIndex:0];
  75. [OCNotificationCenter addObserver:self selector:@selector(weChatOrAlipayPaymentSuccess:) name:ALIPAY_SUCCESS_NOTIFICATION object:nil];
  76. [OCNotificationCenter addObserver:self selector:@selector(weChatOrAlipayPaymentSuccess:) name:WECHATPAY_SUCCESS_NOTIFICATION object:nil];
  77. }
  78. - (void)backAction {
  79. [self.navigationController popViewControllerAnimated:YES];
  80. }
  81. - (void)ym_setupViews{
  82. //[self setRightBarButtonWithCustomView:self.incomeBreakdownBtn];
  83. [self.view addSubview:self.contentScrollView];
  84. [self.contentScrollView addSubview:self.contentView];
  85. [self.contentView addSubview:self.accountBalanceInfoView];
  86. [self.contentView addSubview:self.accountBalanceRechargeItemView];
  87. [self.contentView addSubview:self.accountBalancePayMethodView];
  88. [self.contentView addSubview:self.accountBalanceRechargeNotesView];
  89. [self.view addSubview:self.rechargeNowBtn];
  90. [self.view setNeedsUpdateConstraints];
  91. [self.view updateConstraintsIfNeeded];
  92. }
  93. - (void)updateViewConstraints{
  94. // [self.incomeBreakdownBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  95. // make.width.equalTo(adapt(70));
  96. // make.height.equalTo(adapt(28));
  97. // }];
  98. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.equalTo(self.view).offset(kYMNavHeight);
  100. make.left.equalTo(self.view);
  101. make.right.equalTo(self.view);
  102. make.bottom.equalTo(self.view);
  103. }];
  104. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.edges.equalTo(self.contentScrollView);
  106. make.width.equalTo(self.contentScrollView.mas_width);
  107. }];
  108. [self.accountBalanceInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.top.equalTo(self.contentView).offset(adapt(10));
  110. make.left.equalTo(self.contentView).offset(adapt(0));
  111. make.right.equalTo(self.contentView).offset(adapt(0));
  112. }];
  113. [self.accountBalanceRechargeItemView mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.top.equalTo(self.accountBalanceInfoView.mas_bottom);
  115. make.left.equalTo(self.contentView).offset(adapt(10));
  116. make.right.equalTo(self.contentView).offset(adapt(-10));
  117. }];
  118. [self.accountBalancePayMethodView mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.top.equalTo(self.accountBalanceRechargeItemView.mas_bottom).offset(adapt(20));
  120. make.left.equalTo(self.contentView).offset(adapt(10));
  121. make.right.equalTo(self.contentView).offset(adapt(-10));
  122. }];
  123. [self.accountBalanceRechargeNotesView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.top.equalTo(self.accountBalancePayMethodView.mas_bottom).offset(adapt(20));
  125. make.left.equalTo(self.contentView).offset(adapt(10));
  126. make.right.equalTo(self.contentView).offset(adapt(-10));
  127. make.bottom.equalTo(self.contentView).offset(adapt(-90));
  128. }];
  129. [self.rechargeNowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.left.equalTo(self.view).offset(adapt(32));
  131. make.right.equalTo(self.view).offset(adapt(-32));
  132. make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  133. make.height.mas_equalTo(adapt(54));
  134. }];
  135. [super updateViewConstraints];
  136. }
  137. - (void)ym_bindViewModel{
  138. [self.accountBalanceInfoView ym_bindViewModel:self.viewModel];
  139. [self.accountBalanceRechargeItemView ym_bindViewModel:self.viewModel];
  140. [self.accountBalancePayMethodView ym_bindViewModel:self.viewModel];
  141. [self.accountBalanceRechargeNotesView ym_bindViewModel:self.viewModel];
  142. [[YMGlobalUtils shared] getConfig];
  143. [self.viewModel getAccountShowData];
  144. [self.viewModel getAccountBalanceInfoData];
  145. }
  146. - (void)weChatOrAlipayPaymentSuccess:(NSNotification *)notice{
  147. [self.viewModel getAccountBalanceInfoData];
  148. }
  149. - (UIScrollView *)contentScrollView{
  150. if (!_contentScrollView) {
  151. _contentScrollView = [[UIScrollView alloc]init];
  152. _contentScrollView.alwaysBounceVertical = YES;
  153. _contentScrollView.showsVerticalScrollIndicator = NO;
  154. _contentScrollView.showsHorizontalScrollIndicator = NO;
  155. _contentScrollView.backgroundColor = UIColor.clearColor;
  156. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  157. }
  158. return _contentScrollView;
  159. }
  160. - (UIView *)contentView{
  161. if (!_contentView) {
  162. _contentView = [[UIView alloc]init];
  163. }
  164. return _contentView;
  165. }
  166. - (YMAccountBalanceInfoView *)accountBalanceInfoView{
  167. if (!_accountBalanceInfoView) {
  168. _accountBalanceInfoView = [[YMAccountBalanceInfoView alloc]init];
  169. }
  170. return _accountBalanceInfoView;
  171. }
  172. - (YMAccountBalanceRechargeItemView *)accountBalanceRechargeItemView{
  173. if (!_accountBalanceRechargeItemView) {
  174. _accountBalanceRechargeItemView = [[YMAccountBalanceRechargeItemView alloc]init];
  175. }
  176. return _accountBalanceRechargeItemView;
  177. }
  178. - (YMAccountBalancePayMethodView *)accountBalancePayMethodView{
  179. if (!_accountBalancePayMethodView) {
  180. _accountBalancePayMethodView = [[YMAccountBalancePayMethodView alloc]init];
  181. }
  182. return _accountBalancePayMethodView;
  183. }
  184. - (YMAccountBalanceRechargeNotesView *)accountBalanceRechargeNotesView{
  185. if (!_accountBalanceRechargeNotesView) {
  186. _accountBalanceRechargeNotesView = [[YMAccountBalanceRechargeNotesView alloc]init];
  187. }
  188. return _accountBalanceRechargeNotesView;
  189. }
  190. - (UIButton *)rechargeNowBtn{
  191. if (!_rechargeNowBtn) {
  192. _rechargeNowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  193. _rechargeNowBtn.titleLabel.font = LCBoldFont(18);
  194. [_rechargeNowBtn setTitle:@"立即充值" forState:UIControlStateNormal];
  195. [_rechargeNowBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  196. //_rechargeNowBtn.backgroundColor = HexColorFromRGB(0x883FFB);
  197. [_rechargeNowBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  198. _rechargeNowBtn.layer.cornerRadius = adapt(27);
  199. _rechargeNowBtn.layer.masksToBounds = YES;
  200. WS(weakSelf)
  201. [[[_rechargeNowBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  202. [weakSelf.viewModel detectionAccountBalanceRechargeInfoData];
  203. }];
  204. }
  205. return _rechargeNowBtn;
  206. }
  207. @end