| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- //
- // 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
|