YMAccountBalanceViewController.m 11 KB

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