MerchantBusinessLicenseView.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. //
  2. // MerchantBusinessLicenseView.m
  3. // merchant
  4. //
  5. // Created by qitewei on 2025/8/14.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantBusinessLicenseView.h"
  9. #import "UIView+Extention.h"
  10. @implementation MerchantBusinessLicenseView
  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 setupCompanyNameSection];
  24. // 添加统一社会信用代码区域
  25. [self setupCreditCodeSection];
  26. // 添加营业执照扫描件区域
  27. [self setupLicenseImageSection];
  28. }
  29. - (void)setupCompanyNameSection {
  30. [self.contentView addSubview:self.companyNameLabel];
  31. [self.contentView addSubview:self.companyNameTextField];
  32. }
  33. - (void)setupCreditCodeSection {
  34. [self.contentView addSubview:self.creditCodeLabel];
  35. [self.contentView addSubview:self.creditCodeTextField];
  36. }
  37. - (void)setupLicenseImageSection {
  38. [self.contentView addSubview:self.licenseImageLabel];
  39. [self.contentView addSubview:self.licenseUploadView];
  40. [self.licenseUploadView addSubview:self.uploadIconImageView];
  41. [self.licenseUploadView addSubview:self.uploadTipLabel];
  42. }
  43. - (void)setupConstraints {
  44. // 公司名称
  45. [self.companyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.equalTo(self.contentView).offset(kRealValue(24));
  47. make.top.equalTo(self.contentView).offset(kRealValue(20));
  48. }];
  49. [self.companyNameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.equalTo(self.companyNameLabel);
  51. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  52. make.top.equalTo(self.companyNameLabel.mas_bottom).offset(kRealValue(12));
  53. make.height.mas_equalTo(kRealValue(48));
  54. }];
  55. // 统一社会信用代码
  56. [self.creditCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.equalTo(self.companyNameLabel);
  58. make.top.equalTo(self.companyNameTextField.mas_bottom).offset(kRealValue(24));
  59. }];
  60. [self.creditCodeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.equalTo(self.creditCodeLabel);
  62. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  63. make.top.equalTo(self.creditCodeLabel.mas_bottom).offset(kRealValue(12));
  64. make.height.mas_equalTo(kRealValue(48));
  65. }];
  66. // 营业执照扫描件
  67. [self.licenseImageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(self.companyNameLabel);
  69. make.top.equalTo(self.creditCodeTextField.mas_bottom).offset(kRealValue(24));
  70. }];
  71. [self.licenseUploadView mas_makeConstraints:^(MASConstraintMaker *make) {
  72. make.left.equalTo(self.licenseImageLabel);
  73. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  74. make.top.equalTo(self.licenseImageLabel.mas_bottom).offset(kRealValue(12));
  75. make.height.mas_equalTo(kRealValue(200));
  76. make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
  77. }];
  78. [self.uploadIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.centerX.equalTo(self.licenseUploadView);
  80. make.centerY.equalTo(self.licenseUploadView).offset(-kRealValue(20));
  81. make.width.height.mas_equalTo(kRealValue(40));
  82. }];
  83. [self.uploadTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.centerX.equalTo(self.licenseUploadView);
  85. make.top.equalTo(self.uploadIconImageView.mas_bottom).offset(kRealValue(16));
  86. }];
  87. }
  88. #pragma mark - Actions
  89. - (void)licenseUploadTapped:(UITapGestureRecognizer *)gesture {
  90. // TODO: 实现营业执照图片选择功能
  91. NSLog(@"License upload tapped");
  92. }
  93. #pragma mark - Lazy Loading
  94. - (UILabel *)companyNameLabel {
  95. if (!_companyNameLabel) {
  96. _companyNameLabel = [[UILabel alloc] init];
  97. _companyNameLabel.text = ASLocalizedString(@"公司名称");
  98. _companyNameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  99. _companyNameLabel.textColor = [UIColor blackColor];
  100. // 添加红色星号
  101. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_companyNameLabel.text];
  102. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  103. NSForegroundColorAttributeName: [UIColor redColor],
  104. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  105. }];
  106. [attributedText appendAttributedString:redStar];
  107. _companyNameLabel.attributedText = attributedText;
  108. }
  109. return _companyNameLabel;
  110. }
  111. - (UITextField *)companyNameTextField {
  112. if (!_companyNameTextField) {
  113. _companyNameTextField = [[UITextField alloc] init];
  114. _companyNameTextField.placeholder = ASLocalizedString(@"请输入公司名称");
  115. _companyNameTextField.font = [UIFont systemFontOfSize:16];
  116. _companyNameTextField.textColor = [UIColor blackColor];
  117. _companyNameTextField.backgroundColor = [UIColor whiteColor];
  118. _companyNameTextField.layer.cornerRadius = kRealValue(8);
  119. _companyNameTextField.layer.borderWidth = 1;
  120. _companyNameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  121. // 设置内边距
  122. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  123. _companyNameTextField.leftView = leftView;
  124. _companyNameTextField.leftViewMode = UITextFieldViewModeAlways;
  125. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  126. _companyNameTextField.rightView = rightView;
  127. _companyNameTextField.rightViewMode = UITextFieldViewModeAlways;
  128. }
  129. return _companyNameTextField;
  130. }
  131. - (UILabel *)creditCodeLabel {
  132. if (!_creditCodeLabel) {
  133. _creditCodeLabel = [[UILabel alloc] init];
  134. _creditCodeLabel.text = ASLocalizedString(@"统一社会信用代码");
  135. _creditCodeLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  136. _creditCodeLabel.textColor = [UIColor blackColor];
  137. // 添加红色星号
  138. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_creditCodeLabel.text];
  139. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  140. NSForegroundColorAttributeName: [UIColor redColor],
  141. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  142. }];
  143. [attributedText appendAttributedString:redStar];
  144. _creditCodeLabel.attributedText = attributedText;
  145. }
  146. return _creditCodeLabel;
  147. }
  148. - (UITextField *)creditCodeTextField {
  149. if (!_creditCodeTextField) {
  150. _creditCodeTextField = [[UITextField alloc] init];
  151. _creditCodeTextField.placeholder = ASLocalizedString(@"请输入统一社会信用代码");
  152. _creditCodeTextField.font = [UIFont systemFontOfSize:16];
  153. _creditCodeTextField.textColor = [UIColor blackColor];
  154. _creditCodeTextField.backgroundColor = [UIColor whiteColor];
  155. _creditCodeTextField.layer.cornerRadius = kRealValue(8);
  156. _creditCodeTextField.layer.borderWidth = 1;
  157. _creditCodeTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  158. // 设置内边距
  159. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  160. _creditCodeTextField.leftView = leftView;
  161. _creditCodeTextField.leftViewMode = UITextFieldViewModeAlways;
  162. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  163. _creditCodeTextField.rightView = rightView;
  164. _creditCodeTextField.rightViewMode = UITextFieldViewModeAlways;
  165. }
  166. return _creditCodeTextField;
  167. }
  168. - (UILabel *)licenseImageLabel {
  169. if (!_licenseImageLabel) {
  170. _licenseImageLabel = [[UILabel alloc] init];
  171. _licenseImageLabel.text = ASLocalizedString(@"营业执照扫描件");
  172. _licenseImageLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  173. _licenseImageLabel.textColor = [UIColor blackColor];
  174. // 添加红色星号
  175. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_licenseImageLabel.text];
  176. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  177. NSForegroundColorAttributeName: [UIColor redColor],
  178. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  179. }];
  180. [attributedText appendAttributedString:redStar];
  181. _licenseImageLabel.attributedText = attributedText;
  182. }
  183. return _licenseImageLabel;
  184. }
  185. - (UIView *)licenseUploadView {
  186. if (!_licenseUploadView) {
  187. _licenseUploadView = [[UIView alloc] init];
  188. _licenseUploadView.backgroundColor = [UIColor whiteColor];
  189. _licenseUploadView.layer.cornerRadius = kRealValue(8);
  190. _licenseUploadView.layer.borderWidth = 1;
  191. _licenseUploadView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  192. // 添加点击手势
  193. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(licenseUploadTapped:)];
  194. [_licenseUploadView addGestureRecognizer:tapGesture];
  195. }
  196. return _licenseUploadView;
  197. }
  198. - (UIImageView *)uploadIconImageView {
  199. if (!_uploadIconImageView) {
  200. _uploadIconImageView = [[UIImageView alloc] init];
  201. _uploadIconImageView.image = [UIImage imageNamed:@"store_upload"];
  202. _uploadIconImageView.contentMode = UIViewContentModeScaleAspectFit;
  203. _uploadIconImageView.tintColor = [UIColor colorWithHexString:@"#CCCCCC"];
  204. }
  205. return _uploadIconImageView;
  206. }
  207. - (UILabel *)uploadTipLabel {
  208. if (!_uploadTipLabel) {
  209. _uploadTipLabel = [[UILabel alloc] init];
  210. _uploadTipLabel.text = ASLocalizedString(@"上传图片");
  211. _uploadTipLabel.font = [UIFont systemFontOfSize:14];
  212. _uploadTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  213. _uploadTipLabel.textAlignment = NSTextAlignmentCenter;
  214. }
  215. return _uploadTipLabel;
  216. }
  217. @end