MerchantPaymentView.m 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //
  2. // MerchantPaymentView.m
  3. // merchant
  4. //
  5. // Created by qitewei on 2025/8/14.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantPaymentView.h"
  9. #import "UIView+Extention.h"
  10. @implementation MerchantPaymentView
  11. - (instancetype)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. [self setupUI];
  16. [self setupConstraints];
  17. }
  18. return self;
  19. }
  20. - (void)setupUI {
  21. self.backgroundColor = [UIColor clearColor];
  22. // 添加经营类别信息区域
  23. [self setupCategoryInfoSection];
  24. // 添加保证金信息区域
  25. [self setupDepositInfoSection];
  26. // 添加支付方式区域
  27. [self setupPaymentMethodSection];
  28. }
  29. - (void)setupCategoryInfoSection {
  30. [self.contentView addSubview:self.categoryInfoLabel];
  31. [self.contentView addSubview:self.selectedCategoryLabel];
  32. }
  33. - (void)setupDepositInfoSection {
  34. [self.contentView addSubview:self.depositAmountLabel];
  35. [self.contentView addSubview:self.depositRulesView];
  36. [self.depositRulesView addSubview:self.depositRulesIcon];
  37. [self.depositRulesView addSubview:self.depositRulesLabel];
  38. }
  39. - (void)setupPaymentMethodSection {
  40. [self.contentView addSubview:self.paymentMethodLabel];
  41. [self.contentView addSubview:self.applePayImageView];
  42. [self.contentView addSubview:self.googlePayImageView];
  43. }
  44. - (void)setupConstraints {
  45. // 经营类别信息
  46. [self.categoryInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.left.equalTo(self.contentView).offset(kRealValue(24));
  48. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  49. make.top.equalTo(self.contentView).offset(kRealValue(20));
  50. }];
  51. [self.selectedCategoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.equalTo(self.categoryInfoLabel);
  53. make.top.equalTo(self.categoryInfoLabel.mas_bottom).offset(kRealValue(16));
  54. }];
  55. // 保证金金额
  56. [self.depositAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.equalTo(self.categoryInfoLabel);
  58. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  59. make.top.equalTo(self.selectedCategoryLabel.mas_bottom).offset(kRealValue(24));
  60. }];
  61. // 保证金规则提示
  62. [self.depositRulesView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(self.categoryInfoLabel);
  64. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  65. make.top.equalTo(self.depositAmountLabel.mas_bottom).offset(kRealValue(12));
  66. make.height.mas_equalTo(kRealValue(32));
  67. }];
  68. [self.depositRulesIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.equalTo(self.depositRulesView).offset(kRealValue(8));
  70. make.centerY.equalTo(self.depositRulesView);
  71. make.size.mas_equalTo(CGSizeMake(kRealValue(14), kRealValue(14)));
  72. }];
  73. [self.depositRulesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.equalTo(self.depositRulesIcon.mas_right).offset(kRealValue(6));
  75. make.right.equalTo(self.depositRulesView).offset(-kRealValue(8));
  76. make.centerY.equalTo(self.depositRulesView);
  77. }];
  78. // 支付方式标题
  79. [self.paymentMethodLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.equalTo(self.categoryInfoLabel);
  81. make.top.equalTo(self.depositRulesView.mas_bottom).offset(kRealValue(32));
  82. }];
  83. // Apple Pay
  84. [self.applePayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.equalTo(self.categoryInfoLabel);
  86. make.top.equalTo(self.paymentMethodLabel.mas_bottom).offset(kRealValue(20));
  87. }];
  88. // Google Pay
  89. [self.googlePayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.left.right.equalTo(self.applePayImageView);
  91. make.top.equalTo(self.applePayImageView.mas_bottom).offset(kRealValue(16));
  92. make.bottom.mas_offset(-kRealValue(20));
  93. }];
  94. }
  95. #pragma mark - Actions
  96. - (void)applePayTapped:(UIButton *)gesture {
  97. // TODO: 实现Apple Pay支付功能
  98. NSLog(@"Apple Pay tapped");
  99. }
  100. - (void)googlePayTapped:(UIButton *)gesture {
  101. // TODO: 实现Google Pay支付功能
  102. NSLog(@"Google Pay tapped");
  103. }
  104. - (void)depositRulesTapped:(UITapGestureRecognizer *)gesture {
  105. // TODO: 显示保证金规则详情
  106. NSLog(@"Deposit rules tapped");
  107. }
  108. #pragma mark - Lazy Loading
  109. - (UILabel *)categoryInfoLabel {
  110. if (!_categoryInfoLabel) {
  111. _categoryInfoLabel = [[UILabel alloc] init];
  112. _categoryInfoLabel.text = ASLocalizedString(@"您选择的经营类别如下:");
  113. _categoryInfoLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  114. _categoryInfoLabel.textColor = [UIColor blackColor];
  115. _categoryInfoLabel.numberOfLines = 0;
  116. }
  117. return _categoryInfoLabel;
  118. }
  119. - (UILabel *)selectedCategoryLabel {
  120. if (!_selectedCategoryLabel) {
  121. _selectedCategoryLabel = [[UILabel alloc] init];
  122. _selectedCategoryLabel.text = ASLocalizedString(@"✓ 已选 服饰");
  123. _selectedCategoryLabel.font = [UIFont systemFontOfSize:14];
  124. _selectedCategoryLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"];
  125. }
  126. return _selectedCategoryLabel;
  127. }
  128. - (UILabel *)depositAmountLabel {
  129. if (!_depositAmountLabel) {
  130. _depositAmountLabel = [[UILabel alloc] init];
  131. // 创建富文本,突出显示金额
  132. NSString *fullText = ASLocalizedString(@"对应类目的保证金为:6000元");
  133. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:fullText];
  134. // 设置基础样式
  135. [attributedText addAttribute:NSFontAttributeName
  136. value:[UIFont systemFontOfSize:16]
  137. range:NSMakeRange(0, fullText.length)];
  138. [attributedText addAttribute:NSForegroundColorAttributeName
  139. value:[UIColor blackColor]
  140. range:NSMakeRange(0, fullText.length)];
  141. // 查找并高亮显示金额部分
  142. NSRange amountRange = [fullText rangeOfString:@"6000元"];
  143. if (amountRange.location != NSNotFound) {
  144. [attributedText addAttribute:NSFontAttributeName
  145. value:[UIFont systemFontOfSize:20 weight:UIFontWeightBold]
  146. range:amountRange];
  147. [attributedText addAttribute:NSForegroundColorAttributeName
  148. value:[UIColor colorWithHexString:@"#1A65FF"]
  149. range:amountRange];
  150. }
  151. _depositAmountLabel.attributedText = attributedText;
  152. _depositAmountLabel.numberOfLines = 0;
  153. }
  154. return _depositAmountLabel;
  155. }
  156. - (UIView *)depositRulesView {
  157. if (!_depositRulesView) {
  158. _depositRulesView = [[UIView alloc] init];
  159. _depositRulesView.backgroundColor = [UIColor clearColor];
  160. // 添加点击手势
  161. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(depositRulesTapped:)];
  162. [_depositRulesView addGestureRecognizer:tapGesture];
  163. }
  164. return _depositRulesView;
  165. }
  166. - (UIImageView *)depositRulesIcon {
  167. if (!_depositRulesIcon) {
  168. _depositRulesIcon = [[UIImageView alloc] init];
  169. UIImage *infoImage = [UIImage imageNamed:@"store_bank_tips"];
  170. if (!infoImage) {
  171. if (@available(iOS 13.0, *)) {
  172. infoImage = [UIImage systemImageNamed:@"info.circle"];
  173. }
  174. }
  175. _depositRulesIcon.image = infoImage;
  176. _depositRulesIcon.contentMode = UIViewContentModeScaleAspectFit;
  177. _depositRulesIcon.tintColor = [UIColor colorWithHexString:@"#1A65FF"];
  178. }
  179. return _depositRulesIcon;
  180. }
  181. - (UILabel *)depositRulesLabel {
  182. if (!_depositRulesLabel) {
  183. _depositRulesLabel = [[UILabel alloc] init];
  184. _depositRulesLabel.text = ASLocalizedString(@"不记得保证金规则,点此查看。");
  185. _depositRulesLabel.font = [UIFont systemFontOfSize:12];
  186. _depositRulesLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"];
  187. _depositRulesLabel.numberOfLines = 0;
  188. }
  189. return _depositRulesLabel;
  190. }
  191. - (UILabel *)paymentMethodLabel {
  192. if (!_paymentMethodLabel) {
  193. _paymentMethodLabel = [[UILabel alloc] init];
  194. _paymentMethodLabel.text = ASLocalizedString(@"去支付:");
  195. _paymentMethodLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  196. _paymentMethodLabel.textColor = [UIColor blackColor];
  197. }
  198. return _paymentMethodLabel;
  199. }
  200. - (UIButton *)applePayImageView {
  201. if (!_applePayImageView) {
  202. _applePayImageView = [UIButton buttonWithType:UIButtonTypeCustom];
  203. [_applePayImageView setImage:[UIImage imageNamed:@"store_pay_apple"] forState:UIControlStateNormal];
  204. [_applePayImageView addTarget:self action:@selector(applePayTapped:) forControlEvents:UIControlEventTouchUpInside];
  205. }
  206. return _applePayImageView;
  207. }
  208. - (UIButton *)googlePayImageView {
  209. if (!_googlePayImageView) {
  210. _googlePayImageView = [UIButton buttonWithType:UIButtonTypeCustom];
  211. [_googlePayImageView setImage:[UIImage imageNamed:@"store_pay_google"] forState:UIControlStateNormal];
  212. [_googlePayImageView addTarget:self action:@selector(googlePayTapped:) forControlEvents:UIControlEventTouchUpInside];
  213. }
  214. return _googlePayImageView;
  215. }
  216. @end