| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- //
- // MerchantPaymentView.m
- // merchant
- //
- // Created by qitewei on 2025/8/14.
- // Copyright © 2025 xfg. All rights reserved.
- //
- #import "MerchantPaymentView.h"
- #import "UIView+Extention.h"
- @implementation MerchantPaymentView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- [self setupConstraints];
-
- }
- return self;
- }
- - (void)setupUI {
- self.backgroundColor = [UIColor clearColor];
-
- // 添加经营类别信息区域
- [self setupCategoryInfoSection];
-
- // 添加保证金信息区域
- [self setupDepositInfoSection];
-
- // 添加支付方式区域
- [self setupPaymentMethodSection];
-
- }
- - (void)setupCategoryInfoSection {
- [self.contentView addSubview:self.categoryInfoLabel];
- [self.contentView addSubview:self.selectedCategoryLabel];
- }
- - (void)setupDepositInfoSection {
- [self.contentView addSubview:self.depositAmountLabel];
- [self.contentView addSubview:self.depositRulesView];
- [self.depositRulesView addSubview:self.depositRulesIcon];
- [self.depositRulesView addSubview:self.depositRulesLabel];
- }
- - (void)setupPaymentMethodSection {
- [self.contentView addSubview:self.paymentMethodLabel];
- [self.contentView addSubview:self.applePayImageView];
- [self.contentView addSubview:self.googlePayImageView];
- }
- - (void)setupConstraints {
-
- // 经营类别信息
- [self.categoryInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(kRealValue(24));
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.contentView).offset(kRealValue(20));
- }];
-
- [self.selectedCategoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryInfoLabel);
- make.top.equalTo(self.categoryInfoLabel.mas_bottom).offset(kRealValue(16));
- }];
-
- // 保证金金额
- [self.depositAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryInfoLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.selectedCategoryLabel.mas_bottom).offset(kRealValue(24));
- }];
-
- // 保证金规则提示
- [self.depositRulesView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryInfoLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.depositAmountLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(32));
- }];
-
- [self.depositRulesIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.depositRulesView).offset(kRealValue(8));
- make.centerY.equalTo(self.depositRulesView);
- make.size.mas_equalTo(CGSizeMake(kRealValue(14), kRealValue(14)));
- }];
-
- [self.depositRulesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.depositRulesIcon.mas_right).offset(kRealValue(6));
- make.right.equalTo(self.depositRulesView).offset(-kRealValue(8));
- make.centerY.equalTo(self.depositRulesView);
- }];
-
- // 支付方式标题
- [self.paymentMethodLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryInfoLabel);
- make.top.equalTo(self.depositRulesView.mas_bottom).offset(kRealValue(32));
- }];
-
- // Apple Pay
- [self.applePayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryInfoLabel);
- make.top.equalTo(self.paymentMethodLabel.mas_bottom).offset(kRealValue(20));
- }];
-
- // Google Pay
- [self.googlePayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.applePayImageView);
- make.top.equalTo(self.applePayImageView.mas_bottom).offset(kRealValue(16));
- make.bottom.mas_offset(-kRealValue(20));
- }];
-
- }
- #pragma mark - Actions
- - (void)applePayTapped:(UIButton *)gesture {
- // TODO: 实现Apple Pay支付功能
- NSLog(@"Apple Pay tapped");
- }
- - (void)googlePayTapped:(UIButton *)gesture {
- // TODO: 实现Google Pay支付功能
- NSLog(@"Google Pay tapped");
- }
- - (void)depositRulesTapped:(UITapGestureRecognizer *)gesture {
- // TODO: 显示保证金规则详情
- NSLog(@"Deposit rules tapped");
- }
- #pragma mark - Lazy Loading
- - (UILabel *)categoryInfoLabel {
- if (!_categoryInfoLabel) {
- _categoryInfoLabel = [[UILabel alloc] init];
- _categoryInfoLabel.text = ASLocalizedString(@"您选择的经营类别如下:");
- _categoryInfoLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _categoryInfoLabel.textColor = [UIColor blackColor];
- _categoryInfoLabel.numberOfLines = 0;
- }
- return _categoryInfoLabel;
- }
- - (UILabel *)selectedCategoryLabel {
- if (!_selectedCategoryLabel) {
- _selectedCategoryLabel = [[UILabel alloc] init];
- _selectedCategoryLabel.text = ASLocalizedString(@"✓ 已选 服饰");
- _selectedCategoryLabel.font = [UIFont systemFontOfSize:14];
- _selectedCategoryLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"];
- }
- return _selectedCategoryLabel;
- }
- - (UILabel *)depositAmountLabel {
- if (!_depositAmountLabel) {
- _depositAmountLabel = [[UILabel alloc] init];
-
- // 创建富文本,突出显示金额
- NSString *fullText = ASLocalizedString(@"对应类目的保证金为:6000元");
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:fullText];
-
- // 设置基础样式
- [attributedText addAttribute:NSFontAttributeName
- value:[UIFont systemFontOfSize:16]
- range:NSMakeRange(0, fullText.length)];
- [attributedText addAttribute:NSForegroundColorAttributeName
- value:[UIColor blackColor]
- range:NSMakeRange(0, fullText.length)];
-
- // 查找并高亮显示金额部分
- NSRange amountRange = [fullText rangeOfString:@"6000元"];
- if (amountRange.location != NSNotFound) {
- [attributedText addAttribute:NSFontAttributeName
- value:[UIFont systemFontOfSize:20 weight:UIFontWeightBold]
- range:amountRange];
- [attributedText addAttribute:NSForegroundColorAttributeName
- value:[UIColor colorWithHexString:@"#1A65FF"]
- range:amountRange];
- }
-
- _depositAmountLabel.attributedText = attributedText;
- _depositAmountLabel.numberOfLines = 0;
- }
- return _depositAmountLabel;
- }
- - (UIView *)depositRulesView {
- if (!_depositRulesView) {
- _depositRulesView = [[UIView alloc] init];
- _depositRulesView.backgroundColor = [UIColor clearColor];
-
- // 添加点击手势
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(depositRulesTapped:)];
- [_depositRulesView addGestureRecognizer:tapGesture];
- }
- return _depositRulesView;
- }
- - (UIImageView *)depositRulesIcon {
- if (!_depositRulesIcon) {
- _depositRulesIcon = [[UIImageView alloc] init];
- UIImage *infoImage = [UIImage imageNamed:@"store_bank_tips"];
- if (!infoImage) {
- if (@available(iOS 13.0, *)) {
- infoImage = [UIImage systemImageNamed:@"info.circle"];
- }
- }
- _depositRulesIcon.image = infoImage;
- _depositRulesIcon.contentMode = UIViewContentModeScaleAspectFit;
- _depositRulesIcon.tintColor = [UIColor colorWithHexString:@"#1A65FF"];
- }
- return _depositRulesIcon;
- }
- - (UILabel *)depositRulesLabel {
- if (!_depositRulesLabel) {
- _depositRulesLabel = [[UILabel alloc] init];
- _depositRulesLabel.text = ASLocalizedString(@"不记得保证金规则,点此查看。");
- _depositRulesLabel.font = [UIFont systemFontOfSize:12];
- _depositRulesLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"];
- _depositRulesLabel.numberOfLines = 0;
- }
- return _depositRulesLabel;
- }
- - (UILabel *)paymentMethodLabel {
- if (!_paymentMethodLabel) {
- _paymentMethodLabel = [[UILabel alloc] init];
- _paymentMethodLabel.text = ASLocalizedString(@"去支付:");
- _paymentMethodLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _paymentMethodLabel.textColor = [UIColor blackColor];
- }
- return _paymentMethodLabel;
- }
- - (UIButton *)applePayImageView {
- if (!_applePayImageView) {
- _applePayImageView = [UIButton buttonWithType:UIButtonTypeCustom];
- [_applePayImageView setImage:[UIImage imageNamed:@"store_pay_apple"] forState:UIControlStateNormal];
- [_applePayImageView addTarget:self action:@selector(applePayTapped:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _applePayImageView;
- }
- - (UIButton *)googlePayImageView {
- if (!_googlePayImageView) {
- _googlePayImageView = [UIButton buttonWithType:UIButtonTypeCustom];
- [_googlePayImageView setImage:[UIImage imageNamed:@"store_pay_google"] forState:UIControlStateNormal];
- [_googlePayImageView addTarget:self action:@selector(googlePayTapped:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _googlePayImageView;
- }
- @end
|