HJMyIntegralExchangePayViewController.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // HJMyIntegralExchangePayViewController.m
  3. // HappyJob
  4. //
  5. // Created by 张晓光 on 2019/9/9.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJMyIntegralExchangePayViewController.h"
  9. #import "HJMyIntegralExchangePayHeaderView.h"
  10. #import "HJMyIntegralExchangePayTypeView.h"
  11. #import "WechatPay.h"
  12. #import "AlipayPay.h"
  13. @interface HJMyIntegralExchangePayViewController ()<FBScrollLayoutViewDelegate,UIGestureRecognizerDelegate>
  14. @property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
  15. @property (nonatomic, strong) HJMyIntegralExchangePayHeaderView *headerView;
  16. @property (nonatomic, strong) HJMyIntegralExchangePayTypeView *walletPayView;
  17. @property (nonatomic, strong) HJMyIntegralExchangePayTypeView *WeChatPayView;
  18. @property (nonatomic, strong) HJMyIntegralExchangePayTypeView *AliPayView;
  19. @property (nonatomic, strong) UIButton *makeSureBtn;
  20. @end
  21. @implementation HJMyIntegralExchangePayViewController
  22. - (void)viewWillAppear:(BOOL)animated {
  23. [super viewWillAppear:animated];
  24. [self.navigationController setNavigationBarHidden:YES animated:animated];
  25. self.navigationController.interactivePopGestureRecognizer.delegate = self;
  26. }
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. [self.view addSubview:self.scrollLayoutView];
  30. [self.scrollLayoutView.contentView addSubview:self.headerView];
  31. [self.scrollLayoutView.contentView addSubview:self.walletPayView];
  32. [self.scrollLayoutView.contentView addSubview:self.WeChatPayView];
  33. [self.scrollLayoutView.contentView addSubview:self.AliPayView];
  34. [self.scrollLayoutView.footerView addSubview:self.makeSureBtn];
  35. [self.scrollLayoutView makeConstraints];
  36. }
  37. #pragma mark - FBScrollLayoutViewDelegate
  38. - (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
  39. [scrollLayoutView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.edges.equalTo(self.view);
  41. }];
  42. }
  43. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
  44. [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.top.equalTo(contentView.mas_top).offset(0);
  46. make.left.right.equalTo(contentView);
  47. }];
  48. [self.walletPayView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.equalTo(self.headerView.mas_bottom).offset(0);
  50. make.left.right.equalTo(contentView);
  51. }];
  52. [self.WeChatPayView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.right.equalTo(contentView);
  54. make.top.equalTo(self.walletPayView.mas_bottom).offset(0);
  55. }];
  56. [self.AliPayView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.right.equalTo(contentView);
  58. make.top.equalTo(self.WeChatPayView.mas_bottom).offset(0);
  59. }];
  60. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.bottom.equalTo(self.AliPayView.mas_bottom).with.offset(0);
  62. }];
  63. }
  64. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView footerView:(UIView *)footerView {
  65. [footerView mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.height.mas_equalTo(64);
  67. }];
  68. [self.makeSureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.edges.equalTo(footerView).with.insets(UIEdgeInsetsMake(10, 15, 10, 15));
  70. }];
  71. }
  72. #pragma mark - setter and getter
  73. - (void)backButtonClick:(UIButton *)btn {
  74. [self.navigationController popViewControllerAnimated:YES];
  75. }
  76. - (void)walletPayViewTapClick {
  77. self.walletPayView.selectBtn.selected = YES;
  78. self.WeChatPayView.selectBtn.selected = NO;
  79. self.AliPayView.selectBtn.selected = NO;
  80. [self.makeSureBtn az_setGradientBackgroundWithColors:@[COLOR_GRADIENT_START,COLOR_GRADIENT_END] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
  81. }
  82. - (void)weChatPayViewTapClick{
  83. self.walletPayView.selectBtn.selected = NO;
  84. self.WeChatPayView.selectBtn.selected = YES;
  85. self.AliPayView.selectBtn.selected = NO;
  86. [self.makeSureBtn az_setGradientBackgroundWithColors:@[COLOR_GRADIENT_START,COLOR_GRADIENT_END] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
  87. }
  88. - (void)AliPayViewTapClick {
  89. self.walletPayView.selectBtn.selected = NO;
  90. self.WeChatPayView.selectBtn.selected = NO;
  91. self.AliPayView.selectBtn.selected = YES;
  92. [self.makeSureBtn az_setGradientBackgroundWithColors:@[COLOR_GRADIENT_START,COLOR_GRADIENT_END] locations:@[@(0.0),@(1.0f)] startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
  93. }
  94. - (void)payClick:(UIButton *)btn {
  95. if (self.WeChatPayView.selectBtn.selected)
  96. {
  97. [[WechatPay shareWeChatPay] weixinPayOrderDict:@{} andPayResult:^(PayReultType reslutType) {
  98. }];
  99. }
  100. else if (self.AliPayView.selectBtn.selected)
  101. {
  102. [[AlipayPay shareAliPay] aliProductInfo:@"xjixsijjijijxsijisaija" andPayResult:^(PayReultType reslutType) {
  103. }];
  104. }
  105. }
  106. #pragma mark - setter and getter
  107. - (FBScrollLayoutView *)scrollLayoutView {
  108. if (_scrollLayoutView == nil)
  109. {
  110. _scrollLayoutView = [[FBScrollLayoutView alloc] init];
  111. _scrollLayoutView.delegate = self;
  112. // 去除顶部空白
  113. if (@available(iOS 11.0, *))
  114. {
  115. _scrollLayoutView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  116. }
  117. else
  118. {
  119. self.automaticallyAdjustsScrollViewInsets = NO;
  120. }
  121. }
  122. return _scrollLayoutView;
  123. }
  124. - (HJMyIntegralExchangePayHeaderView *)headerView {
  125. if (_headerView == nil)
  126. {
  127. _headerView = [[HJMyIntegralExchangePayHeaderView alloc]init];
  128. [_headerView.backBtn addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  129. }
  130. return _headerView;
  131. }
  132. - (HJMyIntegralExchangePayTypeView *)walletPayView {
  133. if (_walletPayView == nil)
  134. {
  135. _walletPayView = [[HJMyIntegralExchangePayTypeView alloc]init];
  136. _walletPayView.titleLabel.text = @"钱包支付";
  137. _walletPayView.rightLabel.text = @"余额:¥88.00";
  138. _walletPayView.icon.image = [UIImage imageNamed:@"wallet_pay"];
  139. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(walletPayViewTapClick)];
  140. [_walletPayView addGestureRecognizer:tap];
  141. }
  142. return _walletPayView;
  143. }
  144. - (HJMyIntegralExchangePayTypeView *)WeChatPayView {
  145. if (_WeChatPayView == nil)
  146. {
  147. _WeChatPayView = [[HJMyIntegralExchangePayTypeView alloc]init];
  148. _WeChatPayView.titleLabel.text = @"微信支付";
  149. _WeChatPayView.icon.image = [UIImage imageNamed:@"wechat_pay"];
  150. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(weChatPayViewTapClick)];
  151. [_WeChatPayView addGestureRecognizer:tap];
  152. }
  153. return _WeChatPayView;
  154. }
  155. - (HJMyIntegralExchangePayTypeView *)AliPayView {
  156. if (_AliPayView == nil)
  157. {
  158. _AliPayView = [[HJMyIntegralExchangePayTypeView alloc]init];
  159. _AliPayView.titleLabel.text = @"支付宝支付";
  160. _AliPayView.icon.image = [UIImage imageNamed:@"Ali_pay"];
  161. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(AliPayViewTapClick)];
  162. [_AliPayView addGestureRecognizer:tap];
  163. }
  164. return _AliPayView;
  165. }
  166. - (UIButton *)makeSureBtn {
  167. if (_makeSureBtn == nil)
  168. {
  169. _makeSureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  170. [_makeSureBtn setTitle:@"确认支付" forState:UIControlStateNormal];
  171. _makeSureBtn.titleLabel.font = [UIFont boldSystemFontOfSize:17];
  172. _makeSureBtn.backgroundColor = COLOR_BACKD8;
  173. _makeSureBtn.layer.cornerRadius = 5;
  174. _makeSureBtn.layer.masksToBounds = YES;
  175. [_makeSureBtn addTarget:self action:@selector(payClick:) forControlEvents:UIControlEventTouchUpInside];
  176. }
  177. return _makeSureBtn;
  178. }
  179. /*
  180. #pragma mark - Navigation
  181. // In a storyboard-based application, you will often want to do a little preparation before navigation
  182. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  183. // Get the new view controller using [segue destinationViewController].
  184. // Pass the selected object to the new view controller.
  185. }
  186. */
  187. @end