MerchantStoreInfoView.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. //
  2. // MerchantStoreInfoView.m
  3. // merchant
  4. //
  5. // Created by qitewei on 2025/8/14.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantStoreInfoView.h"
  9. #import "UIView+Extention.h"
  10. @implementation MerchantStoreInfoView
  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 setupStoreNameSection];
  24. // 添加店铺Logo区域
  25. [self setupLogoSection];
  26. // 添加经营类别区域
  27. [self setupCategorySection];
  28. // 添加店铺地址区域
  29. [self setupAddressSection];
  30. // 添加下一步按钮
  31. [self addSubview:self.nextButton];
  32. }
  33. - (void)setupStoreNameSection {
  34. [self.contentView addSubview:self.storeNameLabel];
  35. [self.contentView addSubview:self.storeNameTextField];
  36. [self.contentView addSubview:self.storeNameStatusLabel];
  37. }
  38. - (void)setupLogoSection {
  39. [self.contentView addSubview:self.logoLabel];
  40. [self.contentView addSubview:self.logoUploadView];
  41. [self.logoUploadView addSubview:self.logoImageView];
  42. [self.logoUploadView addSubview:self.logoCloseButton];
  43. [self.contentView addSubview:self.logoTipLabel];
  44. }
  45. - (void)setupCategorySection {
  46. [self.contentView addSubview:self.categoryLabel];
  47. [self.contentView addSubview:self.categoryButton];
  48. [self.contentView addSubview:self.categoryStatusLabel];
  49. [self.contentView addSubview:self.categoryTipLabel];
  50. }
  51. - (void)setupAddressSection {
  52. [self.contentView addSubview:self.addressLabel];
  53. [self.contentView addSubview:self.addressTextField];
  54. }
  55. - (void)setupConstraints {
  56. // 店铺名称
  57. [self.storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.contentView).offset(kRealValue(24));
  59. make.top.equalTo(self.contentView).offset(kRealValue(20));
  60. }];
  61. [self.storeNameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.equalTo(self.storeNameLabel);
  63. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  64. make.top.equalTo(self.storeNameLabel.mas_bottom).offset(kRealValue(12));
  65. make.height.mas_equalTo(kRealValue(48));
  66. }];
  67. [self.storeNameStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(self.storeNameTextField);
  69. make.top.equalTo(self.storeNameTextField.mas_bottom).offset(kRealValue(8));
  70. }];
  71. // 店铺Logo
  72. [self.logoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(self.storeNameLabel);
  74. make.top.equalTo(self.storeNameStatusLabel.mas_bottom).offset(kRealValue(24));
  75. }];
  76. [self.logoUploadView mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.left.equalTo(self.logoLabel);
  78. make.top.equalTo(self.logoLabel.mas_bottom).offset(kRealValue(12));
  79. make.width.height.mas_equalTo(kRealValue(100));
  80. }];
  81. [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.edges.equalTo(self.logoUploadView);
  83. }];
  84. [self.logoCloseButton mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.top.right.equalTo(self.logoUploadView);
  86. make.width.height.mas_equalTo(kRealValue(20));
  87. }];
  88. [self.logoTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.equalTo(self.logoUploadView);
  90. make.top.equalTo(self.logoUploadView.mas_bottom).offset(kRealValue(8));
  91. }];
  92. // 经营类别
  93. [self.categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.equalTo(self.storeNameLabel);
  95. make.top.equalTo(self.logoTipLabel.mas_bottom).offset(kRealValue(24));
  96. }];
  97. [self.categoryButton mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.equalTo(self.categoryLabel);
  99. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  100. make.top.equalTo(self.categoryLabel.mas_bottom).offset(kRealValue(12));
  101. make.height.mas_equalTo(kRealValue(48));
  102. }];
  103. [self.categoryStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.left.equalTo(self.categoryButton);
  105. make.top.equalTo(self.categoryButton.mas_bottom).offset(kRealValue(8));
  106. }];
  107. [self.categoryTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.equalTo(self.categoryStatusLabel);
  109. make.right.mas_offset(-16);
  110. make.top.equalTo(self.categoryStatusLabel.mas_bottom).offset(kRealValue(4));
  111. }];
  112. // 店铺地址
  113. [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.left.equalTo(self.storeNameLabel);
  115. make.top.equalTo(self.categoryTipLabel.mas_bottom).offset(kRealValue(24));
  116. }];
  117. [self.addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.left.equalTo(self.addressLabel);
  119. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  120. make.top.equalTo(self.addressLabel.mas_bottom).offset(kRealValue(12));
  121. make.height.mas_equalTo(kRealValue(48));
  122. make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
  123. }];
  124. // 下一步按钮
  125. [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.centerX.mas_offset(0);
  127. make.size.mas_equalTo(self.nextButton.size);
  128. make.bottom.mas_offset(kRealValue(-20));
  129. }];
  130. }
  131. #pragma mark - Actions
  132. - (void)logoUploadTapped:(UITapGestureRecognizer *)gesture {
  133. // TODO: 实现图片选择功能
  134. NSLog(@"Logo upload tapped");
  135. }
  136. - (void)logoCloseButtonTapped:(UIButton *)sender {
  137. // TODO: 移除已选择的图片
  138. NSLog(@"Logo close button tapped");
  139. }
  140. - (void)categoryButtonTapped:(UIButton *)sender {
  141. // TODO: 实现类别选择功能
  142. NSLog(@"Category button tapped");
  143. }
  144. - (void)storeNameTextFieldChanged:(UITextField *)textField {
  145. // 实时验证店铺名称
  146. NSString *text = textField.text;
  147. if (text.length > 0) {
  148. // 这里模拟检查名称可用性
  149. self.storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
  150. self.storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  151. } else {
  152. self.storeNameStatusLabel.text = @"";
  153. }
  154. }
  155. #pragma mark - Lazy Loading
  156. - (UILabel *)storeNameLabel {
  157. if (!_storeNameLabel) {
  158. _storeNameLabel = [[UILabel alloc] init];
  159. _storeNameLabel.text = ASLocalizedString(@"店铺名称");
  160. _storeNameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  161. _storeNameLabel.textColor = [UIColor blackColor];
  162. // 添加红色星号
  163. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_storeNameLabel.text];
  164. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  165. NSForegroundColorAttributeName: [UIColor redColor],
  166. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  167. }];
  168. [attributedText appendAttributedString:redStar];
  169. _storeNameLabel.attributedText = attributedText;
  170. }
  171. return _storeNameLabel;
  172. }
  173. - (UITextField *)storeNameTextField {
  174. if (!_storeNameTextField) {
  175. _storeNameTextField = [[UITextField alloc] init];
  176. _storeNameTextField.placeholder = ASLocalizedString(@"请输入店铺名称");
  177. _storeNameTextField.font = [UIFont systemFontOfSize:16];
  178. _storeNameTextField.textColor = [UIColor blackColor];
  179. _storeNameTextField.backgroundColor = [UIColor whiteColor];
  180. _storeNameTextField.layer.cornerRadius = kRealValue(8);
  181. _storeNameTextField.layer.borderWidth = 1;
  182. _storeNameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  183. // 设置内边距
  184. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  185. _storeNameTextField.leftView = leftView;
  186. _storeNameTextField.leftViewMode = UITextFieldViewModeAlways;
  187. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  188. _storeNameTextField.rightView = rightView;
  189. _storeNameTextField.rightViewMode = UITextFieldViewModeAlways;
  190. [_storeNameTextField addTarget:self action:@selector(storeNameTextFieldChanged:) forControlEvents:UIControlEventEditingChanged];
  191. // 设置默认文本
  192. _storeNameTextField.text = ASLocalizedString(@"跳跳自营农场");
  193. }
  194. return _storeNameTextField;
  195. }
  196. - (UILabel *)storeNameStatusLabel {
  197. if (!_storeNameStatusLabel) {
  198. _storeNameStatusLabel = [[UILabel alloc] init];
  199. _storeNameStatusLabel.font = [UIFont systemFontOfSize:12];
  200. _storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
  201. _storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  202. }
  203. return _storeNameStatusLabel;
  204. }
  205. - (UILabel *)logoLabel {
  206. if (!_logoLabel) {
  207. _logoLabel = [[UILabel alloc] init];
  208. _logoLabel.text = ASLocalizedString(@"店铺Logo");
  209. _logoLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  210. _logoLabel.textColor = [UIColor blackColor];
  211. // 添加红色星号
  212. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_logoLabel.text];
  213. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  214. NSForegroundColorAttributeName: [UIColor redColor],
  215. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  216. }];
  217. [attributedText appendAttributedString:redStar];
  218. _logoLabel.attributedText = attributedText;
  219. }
  220. return _logoLabel;
  221. }
  222. - (UIView *)logoUploadView {
  223. if (!_logoUploadView) {
  224. _logoUploadView = [[UIView alloc] init];
  225. _logoUploadView.backgroundColor = [UIColor clearColor];
  226. _logoUploadView.layer.cornerRadius = kRealValue(8);
  227. _logoUploadView.clipsToBounds = YES;
  228. // 添加点击手势
  229. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(logoUploadTapped:)];
  230. [_logoUploadView addGestureRecognizer:tapGesture];
  231. }
  232. return _logoUploadView;
  233. }
  234. - (UIImageView *)logoImageView {
  235. if (!_logoImageView) {
  236. _logoImageView = [[UIImageView alloc] init];
  237. _logoImageView.contentMode = UIViewContentModeScaleAspectFill;
  238. _logoImageView.clipsToBounds = YES;
  239. // 这里使用一个默认的示例图片
  240. _logoImageView.image = [UIImage imageNamed:@"store_header_icon"]; // 临时使用现有图片
  241. }
  242. return _logoImageView;
  243. }
  244. - (UIButton *)logoCloseButton {
  245. if (!_logoCloseButton) {
  246. _logoCloseButton = [UIButton buttonWithType:UIButtonTypeCustom];
  247. [_logoCloseButton setImage:[UIImage imageNamed:@"store_close"] forState:UIControlStateNormal];
  248. [_logoCloseButton addTarget:self action:@selector(logoCloseButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  249. _logoCloseButton.backgroundColor = [UIColor whiteColor];
  250. _logoCloseButton.layer.cornerRadius = kRealValue(10);
  251. }
  252. return _logoCloseButton;
  253. }
  254. - (UILabel *)logoTipLabel {
  255. if (!_logoTipLabel) {
  256. _logoTipLabel = [[UILabel alloc] init];
  257. _logoTipLabel.text = ASLocalizedString(@"不大于10M的jpg或png格式的图片");
  258. _logoTipLabel.font = [UIFont systemFontOfSize:12];
  259. _logoTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  260. }
  261. return _logoTipLabel;
  262. }
  263. - (UILabel *)categoryLabel {
  264. if (!_categoryLabel) {
  265. _categoryLabel = [[UILabel alloc] init];
  266. _categoryLabel.text = ASLocalizedString(@"经营类别");
  267. _categoryLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  268. _categoryLabel.textColor = [UIColor blackColor];
  269. // 添加红色星号
  270. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_categoryLabel.text];
  271. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  272. NSForegroundColorAttributeName: [UIColor redColor],
  273. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  274. }];
  275. [attributedText appendAttributedString:redStar];
  276. _categoryLabel.attributedText = attributedText;
  277. }
  278. return _categoryLabel;
  279. }
  280. - (UIButton *)categoryButton {
  281. if (!_categoryButton) {
  282. _categoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
  283. [_categoryButton setTitle:ASLocalizedString(@"服饰") forState:UIControlStateNormal];
  284. [_categoryButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  285. _categoryButton.titleLabel.font = [UIFont systemFontOfSize:16];
  286. _categoryButton.backgroundColor = [UIColor whiteColor];
  287. _categoryButton.layer.cornerRadius = kRealValue(8);
  288. _categoryButton.layer.borderWidth = 1;
  289. _categoryButton.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  290. _categoryButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  291. _categoryButton.contentEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, kRealValue(16));
  292. // 添加下拉箭头
  293. [_categoryButton setImage:[UIImage imageNamed:@"store_arrow_down"] forState:UIControlStateNormal];
  294. _categoryButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
  295. _categoryButton.imageEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, 0);
  296. [_categoryButton addTarget:self action:@selector(categoryButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  297. }
  298. return _categoryButton;
  299. }
  300. - (UILabel *)categoryStatusLabel {
  301. if (!_categoryStatusLabel) {
  302. _categoryStatusLabel = [[UILabel alloc] init];
  303. _categoryStatusLabel.text = ASLocalizedString(@"✓ 已选 服饰");
  304. _categoryStatusLabel.font = [UIFont systemFontOfSize:12];
  305. _categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  306. }
  307. return _categoryStatusLabel;
  308. }
  309. - (UILabel *)categoryTipLabel {
  310. if (!_categoryTipLabel) {
  311. _categoryTipLabel = [[UILabel alloc] init];
  312. NSString *text = ASLocalizedString(@"该类目保证金为: ¥6000.00,佣金比例为: 15%。");
  313. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text];
  314. // 设置整体样式
  315. [attributedText addAttribute:NSFontAttributeName
  316. value:[UIFont systemFontOfSize:12]
  317. range:NSMakeRange(0, text.length)];
  318. [attributedText addAttribute:NSForegroundColorAttributeName
  319. value:[UIColor colorWithHexString:@"#FF9800"]
  320. range:NSMakeRange(0, text.length)];
  321. // 设置金额和百分比的颜色
  322. NSRange moneyRange = [text rangeOfString:@"¥6000.00"];
  323. NSRange percentRange = [text rangeOfString:@"15%"];
  324. if (moneyRange.location != NSNotFound) {
  325. [attributedText addAttribute:NSForegroundColorAttributeName
  326. value:[UIColor colorWithHexString:@"#FF5722"]
  327. range:moneyRange];
  328. }
  329. if (percentRange.location != NSNotFound) {
  330. [attributedText addAttribute:NSForegroundColorAttributeName
  331. value:[UIColor colorWithHexString:@"#FF5722"]
  332. range:percentRange];
  333. }
  334. _categoryTipLabel.attributedText = attributedText;
  335. _categoryTipLabel.numberOfLines = 0;
  336. }
  337. return _categoryTipLabel;
  338. }
  339. - (UILabel *)addressLabel {
  340. if (!_addressLabel) {
  341. _addressLabel = [[UILabel alloc] init];
  342. _addressLabel.text = ASLocalizedString(@"店铺地址");
  343. _addressLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  344. _addressLabel.textColor = [UIColor blackColor];
  345. _addressLabel.numberOfLines = 0;
  346. }
  347. return _addressLabel;
  348. }
  349. - (UITextField *)addressTextField {
  350. if (!_addressTextField) {
  351. _addressTextField = [[UITextField alloc] init];
  352. _addressTextField.placeholder = ASLocalizedString(@"请输入店铺地址");
  353. _addressTextField.font = [UIFont systemFontOfSize:16];
  354. _addressTextField.textColor = [UIColor blackColor];
  355. _addressTextField.backgroundColor = [UIColor whiteColor];
  356. _addressTextField.layer.cornerRadius = kRealValue(8);
  357. _addressTextField.layer.borderWidth = 1;
  358. _addressTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  359. // 设置内边距
  360. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  361. _addressTextField.leftView = leftView;
  362. _addressTextField.leftViewMode = UITextFieldViewModeAlways;
  363. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  364. _addressTextField.rightView = rightView;
  365. _addressTextField.rightViewMode = UITextFieldViewModeAlways;
  366. }
  367. return _addressTextField;
  368. }
  369. @end