// // MerchantLegalInfoView.m // merchant // // Created by qitewei on 2025/8/14. // Copyright © 2025 xfg. All rights reserved. // #import "MerchantLegalInfoView.h" #import "UIView+Extention.h" @implementation MerchantLegalInfoView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupUI]; [self setupConstraints]; } return self; } - (void)setupUI { self.backgroundColor = [UIColor clearColor]; // 添加姓名区域 [self setupNameSection]; // 添加身份证号码区域 [self setupIdNumberSection]; // 添加身份证上传区域 [self setupIdCardSection]; } - (void)setupNameSection { [self.contentView addSubview:self.nameLabel]; [self.contentView addSubview:self.nameTextField]; } - (void)setupIdNumberSection { [self.contentView addSubview:self.idNumberLabel]; [self.contentView addSubview:self.idNumberTextField]; } - (void)setupIdCardSection { [self.contentView addSubview:self.idCardLabel]; [self.contentView addSubview:self.frontCardView]; [self.contentView addSubview:self.backCardView]; // 正面 [self.frontCardView addSubview:self.frontCardTitleLabel]; [self.frontCardView addSubview:self.frontCardSubtitleLabel]; [self.frontCardView addSubview:self.frontCardImageView]; // 反面 [self.backCardView addSubview:self.backCardTitleLabel]; [self.backCardView addSubview:self.backCardSubtitleLabel]; [self.backCardView addSubview:self.backCardImageView]; } - (void)setupConstraints { // 姓名 [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView).offset(kRealValue(24)); make.top.equalTo(self.contentView).offset(kRealValue(20)); }]; [self.nameTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.nameLabel); make.right.equalTo(self.contentView).offset(-kRealValue(24)); make.top.equalTo(self.nameLabel.mas_bottom).offset(kRealValue(12)); make.height.mas_equalTo(kRealValue(48)); }]; // 身份证号码 [self.idNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.nameLabel); make.top.equalTo(self.nameTextField.mas_bottom).offset(kRealValue(24)); }]; [self.idNumberTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.idNumberLabel); make.right.equalTo(self.contentView).offset(-kRealValue(24)); make.top.equalTo(self.idNumberLabel.mas_bottom).offset(kRealValue(12)); make.height.mas_equalTo(kRealValue(48)); }]; // 请上传身份证 [self.idCardLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.nameLabel); make.top.equalTo(self.idNumberTextField.mas_bottom).offset(kRealValue(24)); }]; // 正面 [self.frontCardView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.idCardLabel); make.right.equalTo(self.idNumberTextField); make.top.equalTo(self.idCardLabel.mas_bottom).offset(kRealValue(12)); make.height.mas_equalTo(kRealValue(152)); }]; [self.frontCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.frontCardView).offset(kRealValue(12)); make.top.equalTo(self.frontCardView).offset(kRealValue(12)); }]; [self.frontCardSubtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.frontCardTitleLabel); make.right.equalTo(self.frontCardImageView.mas_left).mas_offset(-8); make.top.equalTo(self.frontCardTitleLabel.mas_bottom).offset(kRealValue(4)); }]; [self.frontCardImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.frontCardView).inset(kRealValue(16)); make.centerY.equalTo(self.frontCardView); make.height.mas_equalTo(kRealValue(120)); make.width.mas_equalTo(kRealValue(185)); }]; // 反面 [self.backCardView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.frontCardView); make.top.equalTo(self.frontCardView.mas_bottom).offset(kRealValue(16)); make.height.mas_equalTo(kRealValue(152)); make.bottom.equalTo(self.contentView).offset(-kRealValue(20)); }]; [self.backCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backCardView).offset(kRealValue(12)); make.top.equalTo(self.backCardView).offset(kRealValue(12)); }]; [self.backCardSubtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backCardTitleLabel); make.right.equalTo(self.backCardImageView.mas_left).mas_offset(-8); make.top.equalTo(self.backCardTitleLabel.mas_bottom).offset(kRealValue(4)); }]; [self.backCardImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.backCardView).inset(kRealValue(16)); make.centerY.equalTo(self.backCardView); make.size.mas_equalTo(self.frontCardImageView); }]; } #pragma mark - Actions - (void)frontCardTapped:(UITapGestureRecognizer *)gesture { // TODO: 实现身份证正面图片选择功能 NSLog(@"Front card upload tapped"); } - (void)backCardTapped:(UITapGestureRecognizer *)gesture { // TODO: 实现身份证反面图片选择功能 NSLog(@"Back card upload tapped"); } #pragma mark - Lazy Loading - (UILabel *)nameLabel { if (!_nameLabel) { _nameLabel = [[UILabel alloc] init]; _nameLabel.text = ASLocalizedString(@"姓名"); _nameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; _nameLabel.textColor = [UIColor blackColor]; // 添加红色星号 NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_nameLabel.text]; NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{ NSForegroundColorAttributeName: [UIColor redColor], NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium] }]; [attributedText appendAttributedString:redStar]; _nameLabel.attributedText = attributedText; } return _nameLabel; } - (UITextField *)nameTextField { if (!_nameTextField) { _nameTextField = [[UITextField alloc] init]; _nameTextField.placeholder = ASLocalizedString(@"请输入法人姓名"); _nameTextField.font = [UIFont systemFontOfSize:16]; _nameTextField.textColor = [UIColor blackColor]; _nameTextField.backgroundColor = [UIColor whiteColor]; _nameTextField.layer.cornerRadius = kRealValue(8); _nameTextField.layer.borderWidth = 1; _nameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor; // 设置内边距 UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))]; _nameTextField.leftView = leftView; _nameTextField.leftViewMode = UITextFieldViewModeAlways; UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))]; _nameTextField.rightView = rightView; _nameTextField.rightViewMode = UITextFieldViewModeAlways; } return _nameTextField; } - (UILabel *)idNumberLabel { if (!_idNumberLabel) { _idNumberLabel = [[UILabel alloc] init]; _idNumberLabel.text = ASLocalizedString(@"身份证号码"); _idNumberLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; _idNumberLabel.textColor = [UIColor blackColor]; // 添加红色星号 NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_idNumberLabel.text]; NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{ NSForegroundColorAttributeName: [UIColor redColor], NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium] }]; [attributedText appendAttributedString:redStar]; _idNumberLabel.attributedText = attributedText; } return _idNumberLabel; } - (UITextField *)idNumberTextField { if (!_idNumberTextField) { _idNumberTextField = [[UITextField alloc] init]; _idNumberTextField.placeholder = ASLocalizedString(@"请输入法人身份证号码"); _idNumberTextField.font = [UIFont systemFontOfSize:16]; _idNumberTextField.textColor = [UIColor blackColor]; _idNumberTextField.backgroundColor = [UIColor whiteColor]; _idNumberTextField.layer.cornerRadius = kRealValue(8); _idNumberTextField.layer.borderWidth = 1; _idNumberTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor; // 设置内边距 UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))]; _idNumberTextField.leftView = leftView; _idNumberTextField.leftViewMode = UITextFieldViewModeAlways; UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))]; _idNumberTextField.rightView = rightView; _idNumberTextField.rightViewMode = UITextFieldViewModeAlways; } return _idNumberTextField; } - (UILabel *)idCardLabel { if (!_idCardLabel) { _idCardLabel = [[UILabel alloc] init]; _idCardLabel.text = ASLocalizedString(@"请上传身份证"); _idCardLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; _idCardLabel.textColor = [UIColor blackColor]; // 添加红色星号 NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_idCardLabel.text]; NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{ NSForegroundColorAttributeName: [UIColor redColor], NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium] }]; [attributedText appendAttributedString:redStar]; _idCardLabel.attributedText = attributedText; } return _idCardLabel; } - (UIView *)frontCardView { if (!_frontCardView) { _frontCardView = [[UIView alloc] init]; _frontCardView.backgroundColor = [UIColor whiteColor]; _frontCardView.layer.cornerRadius = kRealValue(8); _frontCardView.layer.borderWidth = 1; _frontCardView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor; // 添加点击手势 UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(frontCardTapped:)]; [_frontCardView addGestureRecognizer:tapGesture]; } return _frontCardView; } - (UILabel *)frontCardTitleLabel { if (!_frontCardTitleLabel) { _frontCardTitleLabel = [[UILabel alloc] init]; _frontCardTitleLabel.text = ASLocalizedString(@"正面"); _frontCardTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; _frontCardTitleLabel.textColor = [UIColor blackColor]; } return _frontCardTitleLabel; } - (UILabel *)frontCardSubtitleLabel { if (!_frontCardSubtitleLabel) { _frontCardSubtitleLabel = [[UILabel alloc] init]; _frontCardSubtitleLabel.text = ASLocalizedString(@"上传身份证正面"); _frontCardSubtitleLabel.font = [UIFont systemFontOfSize:12]; _frontCardSubtitleLabel.textColor = [UIColor colorWithHexString:@"#999999"]; _frontCardSubtitleLabel.numberOfLines = 2; } return _frontCardSubtitleLabel; } - (UIImageView *)frontCardImageView { if (!_frontCardImageView) { _frontCardImageView = [[UIImageView alloc] init]; _frontCardImageView.image = [UIImage imageNamed:@"store_ID_front"]; _frontCardImageView.contentMode = UIViewContentModeScaleAspectFit; } return _frontCardImageView; } - (UIView *)backCardView { if (!_backCardView) { _backCardView = [[UIView alloc] init]; _backCardView.backgroundColor = [UIColor whiteColor]; _backCardView.layer.cornerRadius = kRealValue(8); _backCardView.layer.borderWidth = 1; _backCardView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor; // 添加点击手势 UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backCardTapped:)]; [_backCardView addGestureRecognizer:tapGesture]; } return _backCardView; } - (UILabel *)backCardTitleLabel { if (!_backCardTitleLabel) { _backCardTitleLabel = [[UILabel alloc] init]; _backCardTitleLabel.text = ASLocalizedString(@"反面"); _backCardTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; _backCardTitleLabel.textColor = [UIColor blackColor]; } return _backCardTitleLabel; } - (UILabel *)backCardSubtitleLabel { if (!_backCardSubtitleLabel) { _backCardSubtitleLabel = [[UILabel alloc] init]; _backCardSubtitleLabel.text = ASLocalizedString(@"上传身份证反面"); _backCardSubtitleLabel.font = [UIFont systemFontOfSize:12]; _backCardSubtitleLabel.textColor = [UIColor colorWithHexString:@"#999999"]; _backCardSubtitleLabel.numberOfLines = 2; } return _backCardSubtitleLabel; } - (UIImageView *)backCardImageView { if (!_backCardImageView) { _backCardImageView = [[UIImageView alloc] init]; _backCardImageView.image = [UIImage imageNamed:@"store_ID_back"]; _backCardImageView.contentMode = UIViewContentModeScaleAspectFit; } return _backCardImageView; } @end