MerchantLegalInfoView.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. //
  2. // MerchantLegalInfoView.m
  3. // merchant
  4. //
  5. // Created by qitewei on 2025/8/14.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantLegalInfoView.h"
  9. #import "UIView+Extention.h"
  10. @implementation MerchantLegalInfoView
  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 setupNameSection];
  24. // 添加身份证号码区域
  25. [self setupIdNumberSection];
  26. // 添加身份证上传区域
  27. [self setupIdCardSection];
  28. }
  29. - (void)setupNameSection {
  30. [self.contentView addSubview:self.nameLabel];
  31. [self.contentView addSubview:self.nameTextField];
  32. }
  33. - (void)setupIdNumberSection {
  34. [self.contentView addSubview:self.idNumberLabel];
  35. [self.contentView addSubview:self.idNumberTextField];
  36. }
  37. - (void)setupIdCardSection {
  38. [self.contentView addSubview:self.idCardLabel];
  39. [self.contentView addSubview:self.frontCardView];
  40. [self.contentView addSubview:self.backCardView];
  41. // 正面
  42. [self.frontCardView addSubview:self.frontCardTitleLabel];
  43. [self.frontCardView addSubview:self.frontCardSubtitleLabel];
  44. [self.frontCardView addSubview:self.frontCardImageView];
  45. // 反面
  46. [self.backCardView addSubview:self.backCardTitleLabel];
  47. [self.backCardView addSubview:self.backCardSubtitleLabel];
  48. [self.backCardView addSubview:self.backCardImageView];
  49. }
  50. - (void)setupConstraints {
  51. // 姓名
  52. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(self.contentView).offset(kRealValue(24));
  54. make.top.equalTo(self.contentView).offset(kRealValue(20));
  55. }];
  56. [self.nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.equalTo(self.nameLabel);
  58. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  59. make.top.equalTo(self.nameLabel.mas_bottom).offset(kRealValue(12));
  60. make.height.mas_equalTo(kRealValue(48));
  61. }];
  62. // 身份证号码
  63. [self.idNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.left.equalTo(self.nameLabel);
  65. make.top.equalTo(self.nameTextField.mas_bottom).offset(kRealValue(24));
  66. }];
  67. [self.idNumberTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(self.idNumberLabel);
  69. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  70. make.top.equalTo(self.idNumberLabel.mas_bottom).offset(kRealValue(12));
  71. make.height.mas_equalTo(kRealValue(48));
  72. }];
  73. // 请上传身份证
  74. [self.idCardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.equalTo(self.nameLabel);
  76. make.top.equalTo(self.idNumberTextField.mas_bottom).offset(kRealValue(24));
  77. }];
  78. // 正面
  79. [self.frontCardView mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.equalTo(self.idCardLabel);
  81. make.right.equalTo(self.idNumberTextField);
  82. make.top.equalTo(self.idCardLabel.mas_bottom).offset(kRealValue(12));
  83. make.height.mas_equalTo(kRealValue(152));
  84. }];
  85. [self.frontCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.equalTo(self.frontCardView).offset(kRealValue(12));
  87. make.top.equalTo(self.frontCardView).offset(kRealValue(12));
  88. }];
  89. [self.frontCardSubtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.left.equalTo(self.frontCardTitleLabel);
  91. make.right.equalTo(self.frontCardImageView.mas_left).mas_offset(-8);
  92. make.top.equalTo(self.frontCardTitleLabel.mas_bottom).offset(kRealValue(4));
  93. }];
  94. [self.frontCardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.right.equalTo(self.frontCardView).inset(kRealValue(16));
  96. make.centerY.equalTo(self.frontCardView);
  97. make.height.mas_equalTo(kRealValue(120));
  98. make.width.mas_equalTo(kRealValue(185));
  99. }];
  100. // 反面
  101. [self.backCardView mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.left.right.equalTo(self.frontCardView);
  103. make.top.equalTo(self.frontCardView.mas_bottom).offset(kRealValue(16));
  104. make.height.mas_equalTo(kRealValue(152));
  105. make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
  106. }];
  107. [self.backCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.equalTo(self.backCardView).offset(kRealValue(12));
  109. make.top.equalTo(self.backCardView).offset(kRealValue(12));
  110. }];
  111. [self.backCardSubtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.equalTo(self.backCardTitleLabel);
  113. make.right.equalTo(self.backCardImageView.mas_left).mas_offset(-8);
  114. make.top.equalTo(self.backCardTitleLabel.mas_bottom).offset(kRealValue(4));
  115. }];
  116. [self.backCardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.right.equalTo(self.backCardView).inset(kRealValue(16));
  118. make.centerY.equalTo(self.backCardView);
  119. make.size.mas_equalTo(self.frontCardImageView);
  120. }];
  121. }
  122. #pragma mark - Actions
  123. - (void)frontCardTapped:(UITapGestureRecognizer *)gesture {
  124. // TODO: 实现身份证正面图片选择功能
  125. NSLog(@"Front card upload tapped");
  126. }
  127. - (void)backCardTapped:(UITapGestureRecognizer *)gesture {
  128. // TODO: 实现身份证反面图片选择功能
  129. NSLog(@"Back card upload tapped");
  130. }
  131. #pragma mark - Lazy Loading
  132. - (UILabel *)nameLabel {
  133. if (!_nameLabel) {
  134. _nameLabel = [[UILabel alloc] init];
  135. _nameLabel.text = ASLocalizedString(@"姓名");
  136. _nameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  137. _nameLabel.textColor = [UIColor blackColor];
  138. // 添加红色星号
  139. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_nameLabel.text];
  140. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  141. NSForegroundColorAttributeName: [UIColor redColor],
  142. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  143. }];
  144. [attributedText appendAttributedString:redStar];
  145. _nameLabel.attributedText = attributedText;
  146. }
  147. return _nameLabel;
  148. }
  149. - (UITextField *)nameTextField {
  150. if (!_nameTextField) {
  151. _nameTextField = [[UITextField alloc] init];
  152. _nameTextField.placeholder = ASLocalizedString(@"请输入法人姓名");
  153. _nameTextField.font = [UIFont systemFontOfSize:16];
  154. _nameTextField.textColor = [UIColor blackColor];
  155. _nameTextField.backgroundColor = [UIColor whiteColor];
  156. _nameTextField.layer.cornerRadius = kRealValue(8);
  157. _nameTextField.layer.borderWidth = 1;
  158. _nameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  159. // 设置内边距
  160. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  161. _nameTextField.leftView = leftView;
  162. _nameTextField.leftViewMode = UITextFieldViewModeAlways;
  163. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  164. _nameTextField.rightView = rightView;
  165. _nameTextField.rightViewMode = UITextFieldViewModeAlways;
  166. }
  167. return _nameTextField;
  168. }
  169. - (UILabel *)idNumberLabel {
  170. if (!_idNumberLabel) {
  171. _idNumberLabel = [[UILabel alloc] init];
  172. _idNumberLabel.text = ASLocalizedString(@"身份证号码");
  173. _idNumberLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  174. _idNumberLabel.textColor = [UIColor blackColor];
  175. // 添加红色星号
  176. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_idNumberLabel.text];
  177. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  178. NSForegroundColorAttributeName: [UIColor redColor],
  179. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  180. }];
  181. [attributedText appendAttributedString:redStar];
  182. _idNumberLabel.attributedText = attributedText;
  183. }
  184. return _idNumberLabel;
  185. }
  186. - (UITextField *)idNumberTextField {
  187. if (!_idNumberTextField) {
  188. _idNumberTextField = [[UITextField alloc] init];
  189. _idNumberTextField.placeholder = ASLocalizedString(@"请输入法人身份证号码");
  190. _idNumberTextField.font = [UIFont systemFontOfSize:16];
  191. _idNumberTextField.textColor = [UIColor blackColor];
  192. _idNumberTextField.backgroundColor = [UIColor whiteColor];
  193. _idNumberTextField.layer.cornerRadius = kRealValue(8);
  194. _idNumberTextField.layer.borderWidth = 1;
  195. _idNumberTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  196. // 设置内边距
  197. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  198. _idNumberTextField.leftView = leftView;
  199. _idNumberTextField.leftViewMode = UITextFieldViewModeAlways;
  200. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  201. _idNumberTextField.rightView = rightView;
  202. _idNumberTextField.rightViewMode = UITextFieldViewModeAlways;
  203. }
  204. return _idNumberTextField;
  205. }
  206. - (UILabel *)idCardLabel {
  207. if (!_idCardLabel) {
  208. _idCardLabel = [[UILabel alloc] init];
  209. _idCardLabel.text = ASLocalizedString(@"请上传身份证");
  210. _idCardLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  211. _idCardLabel.textColor = [UIColor blackColor];
  212. // 添加红色星号
  213. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_idCardLabel.text];
  214. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  215. NSForegroundColorAttributeName: [UIColor redColor],
  216. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  217. }];
  218. [attributedText appendAttributedString:redStar];
  219. _idCardLabel.attributedText = attributedText;
  220. }
  221. return _idCardLabel;
  222. }
  223. - (UIView *)frontCardView {
  224. if (!_frontCardView) {
  225. _frontCardView = [[UIView alloc] init];
  226. _frontCardView.backgroundColor = [UIColor whiteColor];
  227. _frontCardView.layer.cornerRadius = kRealValue(8);
  228. _frontCardView.layer.borderWidth = 1;
  229. _frontCardView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  230. // 添加点击手势
  231. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(frontCardTapped:)];
  232. [_frontCardView addGestureRecognizer:tapGesture];
  233. }
  234. return _frontCardView;
  235. }
  236. - (UILabel *)frontCardTitleLabel {
  237. if (!_frontCardTitleLabel) {
  238. _frontCardTitleLabel = [[UILabel alloc] init];
  239. _frontCardTitleLabel.text = ASLocalizedString(@"正面");
  240. _frontCardTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
  241. _frontCardTitleLabel.textColor = [UIColor blackColor];
  242. }
  243. return _frontCardTitleLabel;
  244. }
  245. - (UILabel *)frontCardSubtitleLabel {
  246. if (!_frontCardSubtitleLabel) {
  247. _frontCardSubtitleLabel = [[UILabel alloc] init];
  248. _frontCardSubtitleLabel.text = ASLocalizedString(@"上传身份证正面");
  249. _frontCardSubtitleLabel.font = [UIFont systemFontOfSize:12];
  250. _frontCardSubtitleLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  251. _frontCardSubtitleLabel.numberOfLines = 2;
  252. }
  253. return _frontCardSubtitleLabel;
  254. }
  255. - (UIImageView *)frontCardImageView {
  256. if (!_frontCardImageView) {
  257. _frontCardImageView = [[UIImageView alloc] init];
  258. _frontCardImageView.image = [UIImage imageNamed:@"store_ID_front"];
  259. _frontCardImageView.contentMode = UIViewContentModeScaleAspectFit;
  260. }
  261. return _frontCardImageView;
  262. }
  263. - (UIView *)backCardView {
  264. if (!_backCardView) {
  265. _backCardView = [[UIView alloc] init];
  266. _backCardView.backgroundColor = [UIColor whiteColor];
  267. _backCardView.layer.cornerRadius = kRealValue(8);
  268. _backCardView.layer.borderWidth = 1;
  269. _backCardView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  270. // 添加点击手势
  271. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backCardTapped:)];
  272. [_backCardView addGestureRecognizer:tapGesture];
  273. }
  274. return _backCardView;
  275. }
  276. - (UILabel *)backCardTitleLabel {
  277. if (!_backCardTitleLabel) {
  278. _backCardTitleLabel = [[UILabel alloc] init];
  279. _backCardTitleLabel.text = ASLocalizedString(@"反面");
  280. _backCardTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
  281. _backCardTitleLabel.textColor = [UIColor blackColor];
  282. }
  283. return _backCardTitleLabel;
  284. }
  285. - (UILabel *)backCardSubtitleLabel {
  286. if (!_backCardSubtitleLabel) {
  287. _backCardSubtitleLabel = [[UILabel alloc] init];
  288. _backCardSubtitleLabel.text = ASLocalizedString(@"上传身份证反面");
  289. _backCardSubtitleLabel.font = [UIFont systemFontOfSize:12];
  290. _backCardSubtitleLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  291. _backCardSubtitleLabel.numberOfLines = 2;
  292. }
  293. return _backCardSubtitleLabel;
  294. }
  295. - (UIImageView *)backCardImageView {
  296. if (!_backCardImageView) {
  297. _backCardImageView = [[UIImageView alloc] init];
  298. _backCardImageView.image = [UIImage imageNamed:@"store_ID_back"];
  299. _backCardImageView.contentMode = UIViewContentModeScaleAspectFit;
  300. }
  301. return _backCardImageView;
  302. }
  303. @end