| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- //
- // MerchantBusinessLicenseView.m
- // merchant
- //
- // Created by qitewei on 2025/8/14.
- // Copyright © 2025 xfg. All rights reserved.
- //
- #import "MerchantBusinessLicenseView.h"
- #import "UIView+Extention.h"
- @implementation MerchantBusinessLicenseView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- [self setupConstraints];
-
- }
- return self;
- }
- - (void)setupUI {
- self.backgroundColor = [UIColor clearColor];
-
- // 添加公司名称区域
- [self setupCompanyNameSection];
-
- // 添加统一社会信用代码区域
- [self setupCreditCodeSection];
-
- // 添加营业执照扫描件区域
- [self setupLicenseImageSection];
-
- }
- - (void)setupCompanyNameSection {
- [self.contentView addSubview:self.companyNameLabel];
- [self.contentView addSubview:self.companyNameTextField];
- }
- - (void)setupCreditCodeSection {
- [self.contentView addSubview:self.creditCodeLabel];
- [self.contentView addSubview:self.creditCodeTextField];
- }
- - (void)setupLicenseImageSection {
- [self.contentView addSubview:self.licenseImageLabel];
- [self.contentView addSubview:self.licenseUploadView];
- [self.licenseUploadView addSubview:self.uploadIconImageView];
- [self.licenseUploadView addSubview:self.uploadTipLabel];
- }
- - (void)setupConstraints {
-
- // 公司名称
- [self.companyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(kRealValue(24));
- make.top.equalTo(self.contentView).offset(kRealValue(20));
- }];
-
- [self.companyNameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.companyNameLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.companyNameLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(48));
- }];
-
- // 统一社会信用代码
- [self.creditCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.companyNameLabel);
- make.top.equalTo(self.companyNameTextField.mas_bottom).offset(kRealValue(24));
- }];
-
- [self.creditCodeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.creditCodeLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.creditCodeLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(48));
- }];
-
- // 营业执照扫描件
- [self.licenseImageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.companyNameLabel);
- make.top.equalTo(self.creditCodeTextField.mas_bottom).offset(kRealValue(24));
- }];
-
- [self.licenseUploadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.licenseImageLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.licenseImageLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(200));
- make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
- }];
-
- [self.uploadIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.licenseUploadView);
- make.centerY.equalTo(self.licenseUploadView).offset(-kRealValue(20));
- make.width.height.mas_equalTo(kRealValue(40));
- }];
-
- [self.uploadTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.licenseUploadView);
- make.top.equalTo(self.uploadIconImageView.mas_bottom).offset(kRealValue(16));
- }];
-
- }
- #pragma mark - Actions
- - (void)licenseUploadTapped:(UITapGestureRecognizer *)gesture {
- // TODO: 实现营业执照图片选择功能
- NSLog(@"License upload tapped");
- }
- #pragma mark - Lazy Loading
- - (UILabel *)companyNameLabel {
- if (!_companyNameLabel) {
- _companyNameLabel = [[UILabel alloc] init];
- _companyNameLabel.text = ASLocalizedString(@"公司名称");
- _companyNameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _companyNameLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_companyNameLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _companyNameLabel.attributedText = attributedText;
- }
- return _companyNameLabel;
- }
- - (UITextField *)companyNameTextField {
- if (!_companyNameTextField) {
- _companyNameTextField = [[UITextField alloc] init];
- _companyNameTextField.placeholder = ASLocalizedString(@"请输入公司名称");
- _companyNameTextField.font = [UIFont systemFontOfSize:16];
- _companyNameTextField.textColor = [UIColor blackColor];
- _companyNameTextField.backgroundColor = [UIColor whiteColor];
- _companyNameTextField.layer.cornerRadius = kRealValue(8);
- _companyNameTextField.layer.borderWidth = 1;
- _companyNameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
-
- // 设置内边距
- UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _companyNameTextField.leftView = leftView;
- _companyNameTextField.leftViewMode = UITextFieldViewModeAlways;
-
- UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _companyNameTextField.rightView = rightView;
- _companyNameTextField.rightViewMode = UITextFieldViewModeAlways;
- }
- return _companyNameTextField;
- }
- - (UILabel *)creditCodeLabel {
- if (!_creditCodeLabel) {
- _creditCodeLabel = [[UILabel alloc] init];
- _creditCodeLabel.text = ASLocalizedString(@"统一社会信用代码");
- _creditCodeLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _creditCodeLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_creditCodeLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _creditCodeLabel.attributedText = attributedText;
- }
- return _creditCodeLabel;
- }
- - (UITextField *)creditCodeTextField {
- if (!_creditCodeTextField) {
- _creditCodeTextField = [[UITextField alloc] init];
- _creditCodeTextField.placeholder = ASLocalizedString(@"请输入统一社会信用代码");
- _creditCodeTextField.font = [UIFont systemFontOfSize:16];
- _creditCodeTextField.textColor = [UIColor blackColor];
- _creditCodeTextField.backgroundColor = [UIColor whiteColor];
- _creditCodeTextField.layer.cornerRadius = kRealValue(8);
- _creditCodeTextField.layer.borderWidth = 1;
- _creditCodeTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
-
- // 设置内边距
- UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _creditCodeTextField.leftView = leftView;
- _creditCodeTextField.leftViewMode = UITextFieldViewModeAlways;
-
- UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _creditCodeTextField.rightView = rightView;
- _creditCodeTextField.rightViewMode = UITextFieldViewModeAlways;
- }
- return _creditCodeTextField;
- }
- - (UILabel *)licenseImageLabel {
- if (!_licenseImageLabel) {
- _licenseImageLabel = [[UILabel alloc] init];
- _licenseImageLabel.text = ASLocalizedString(@"营业执照扫描件");
- _licenseImageLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _licenseImageLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_licenseImageLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _licenseImageLabel.attributedText = attributedText;
- }
- return _licenseImageLabel;
- }
- - (UIView *)licenseUploadView {
- if (!_licenseUploadView) {
- _licenseUploadView = [[UIView alloc] init];
- _licenseUploadView.backgroundColor = [UIColor whiteColor];
- _licenseUploadView.layer.cornerRadius = kRealValue(8);
- _licenseUploadView.layer.borderWidth = 1;
- _licenseUploadView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
-
- // 添加点击手势
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(licenseUploadTapped:)];
- [_licenseUploadView addGestureRecognizer:tapGesture];
- }
- return _licenseUploadView;
- }
- - (UIImageView *)uploadIconImageView {
- if (!_uploadIconImageView) {
- _uploadIconImageView = [[UIImageView alloc] init];
- _uploadIconImageView.image = [UIImage imageNamed:@"store_upload"];
- _uploadIconImageView.contentMode = UIViewContentModeScaleAspectFit;
- _uploadIconImageView.tintColor = [UIColor colorWithHexString:@"#CCCCCC"];
- }
- return _uploadIconImageView;
- }
- - (UILabel *)uploadTipLabel {
- if (!_uploadTipLabel) {
- _uploadTipLabel = [[UILabel alloc] init];
- _uploadTipLabel.text = ASLocalizedString(@"上传图片");
- _uploadTipLabel.font = [UIFont systemFontOfSize:14];
- _uploadTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
- _uploadTipLabel.textAlignment = NSTextAlignmentCenter;
- }
- return _uploadTipLabel;
- }
- @end
|