MerchantStoreInfoView.m 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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. #import "IndustryCategoryModel.h"
  11. #import "CategoryPickerView.h"
  12. #import "MerchantEnrollDataManager.h"
  13. @interface MerchantStoreInfoView ()
  14. @property (nonatomic, copy, nullable) NSString *logoURL;
  15. @end
  16. @implementation MerchantStoreInfoView
  17. - (void)dealloc {
  18. [[NSNotificationCenter defaultCenter] removeObserver:self];
  19. }
  20. - (NSDictionary *)getMerchantEnrollParameters {
  21. // 获取店铺简介内容,排除占位符文本
  22. NSString *description = @"";
  23. if (![self.descriptionTextView.text isEqualToString:ASLocalizedString(@"请输入店铺简介")]) {
  24. description = self.descriptionTextView.text ?: @"";
  25. }
  26. return @{
  27. @"shop_name": self.storeNameTextField.text ?: @"",
  28. @"shop_logo": self.logoURL ?: @"",
  29. @"shop_desc": description,
  30. @"cate_id":@(self.selectedCategory.categoryId),
  31. @"shop_address":self.addressTextField.text ?: @""
  32. };
  33. }
  34. - (instancetype)initWithFrame:(CGRect)frame
  35. {
  36. self = [super initWithFrame:frame];
  37. if (self) {
  38. [self setupUI];
  39. [self setupConstraints];
  40. [self initData];
  41. }
  42. return self;
  43. }
  44. - (void)setupUI {
  45. self.backgroundColor = [UIColor clearColor];
  46. // 添加店铺名称区域
  47. [self setupStoreNameSection];
  48. // 添加店铺Logo区域
  49. [self setupLogoSection];
  50. // 添加经营类别区域
  51. [self setupCategorySection];
  52. // 添加店铺简介区域
  53. [self setupDescriptionSection];
  54. // 添加店铺地址区域
  55. [self setupAddressSection];
  56. // 添加下一步按钮
  57. [self addSubview:self.nextButton];
  58. }
  59. - (void)setupStoreNameSection {
  60. [self.contentView addSubview:self.storeNameLabel];
  61. [self.contentView addSubview:self.storeNameTextField];
  62. [self.contentView addSubview:self.storeNameStatusLabel];
  63. }
  64. - (void)setupLogoSection {
  65. [self.contentView addSubview:self.logoLabel];
  66. [self.contentView addSubview:self.logoUploadView];
  67. [self.logoUploadView addSubview:self.logoImageView];
  68. [self.logoUploadView addSubview:self.logoCloseButton];
  69. [self.contentView addSubview:self.logoTipLabel];
  70. }
  71. - (void)setupCategorySection {
  72. [self.contentView addSubview:self.categoryLabel];
  73. [self.contentView addSubview:self.categoryButton];
  74. [self.contentView addSubview:self.categoryStatusLabel];
  75. [self.contentView addSubview:self.categoryTipLabel];
  76. }
  77. - (void)setupDescriptionSection {
  78. [self.contentView addSubview:self.descriptionLabel];
  79. [self.contentView addSubview:self.descriptionTextView];
  80. [self.contentView addSubview:self.descriptionCountLabel];
  81. }
  82. - (void)setupAddressSection {
  83. [self.contentView addSubview:self.addressLabel];
  84. [self.contentView addSubview:self.addressTextField];
  85. }
  86. - (void)setupConstraints {
  87. // 店铺名称
  88. [self.storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.left.equalTo(self.contentView).offset(kRealValue(24));
  90. make.top.equalTo(self.contentView).offset(kRealValue(20));
  91. }];
  92. [self.storeNameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.left.equalTo(self.storeNameLabel);
  94. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  95. make.top.equalTo(self.storeNameLabel.mas_bottom).offset(kRealValue(12));
  96. make.height.mas_equalTo(kRealValue(48));
  97. }];
  98. [self.storeNameStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.left.equalTo(self.storeNameTextField);
  100. make.top.equalTo(self.storeNameTextField.mas_bottom).offset(kRealValue(8));
  101. }];
  102. // 店铺Logo
  103. [self.logoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.left.equalTo(self.storeNameLabel);
  105. make.top.equalTo(self.storeNameStatusLabel.mas_bottom).offset(kRealValue(24));
  106. }];
  107. [self.logoUploadView mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.equalTo(self.logoLabel);
  109. make.top.equalTo(self.logoLabel.mas_bottom).offset(kRealValue(12));
  110. make.width.height.mas_equalTo(kRealValue(100));
  111. }];
  112. [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.edges.equalTo(self.logoUploadView);
  114. }];
  115. [self.logoCloseButton mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.top.right.equalTo(self.logoUploadView);
  117. make.width.height.mas_equalTo(kRealValue(20));
  118. }];
  119. [self.logoTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  120. make.left.equalTo(self.logoUploadView);
  121. make.top.equalTo(self.logoUploadView.mas_bottom).offset(kRealValue(8));
  122. }];
  123. // 经营类别
  124. [self.categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.left.equalTo(self.storeNameLabel);
  126. make.top.equalTo(self.logoTipLabel.mas_bottom).offset(kRealValue(24));
  127. }];
  128. [self.categoryButton mas_makeConstraints:^(MASConstraintMaker *make) {
  129. make.left.equalTo(self.categoryLabel);
  130. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  131. make.top.equalTo(self.categoryLabel.mas_bottom).offset(kRealValue(12));
  132. make.height.mas_equalTo(kRealValue(48));
  133. }];
  134. [self.categoryStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  135. make.left.equalTo(self.categoryButton);
  136. make.top.equalTo(self.categoryButton.mas_bottom).offset(kRealValue(8));
  137. }];
  138. [self.categoryTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.left.equalTo(self.categoryStatusLabel);
  140. make.right.mas_offset(-16);
  141. make.top.equalTo(self.categoryStatusLabel.mas_bottom).offset(kRealValue(4));
  142. }];
  143. // 店铺简介
  144. [self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.left.equalTo(self.storeNameLabel);
  146. make.top.equalTo(self.categoryTipLabel.mas_bottom).offset(kRealValue(24));
  147. }];
  148. [self.descriptionTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  149. make.left.equalTo(self.descriptionLabel);
  150. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  151. make.top.equalTo(self.descriptionLabel.mas_bottom).offset(kRealValue(12));
  152. make.height.mas_equalTo(kRealValue(100));
  153. }];
  154. [self.descriptionCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  155. make.right.equalTo(self.descriptionTextView);
  156. make.top.equalTo(self.descriptionTextView.mas_bottom).offset(kRealValue(8));
  157. }];
  158. // 店铺地址
  159. [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.left.equalTo(self.storeNameLabel);
  161. make.top.equalTo(self.descriptionCountLabel.mas_bottom).offset(kRealValue(24));
  162. }];
  163. [self.addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.left.equalTo(self.addressLabel);
  165. make.right.equalTo(self.contentView).offset(-kRealValue(24));
  166. make.top.equalTo(self.addressLabel.mas_bottom).offset(kRealValue(12));
  167. make.height.mas_equalTo(kRealValue(48));
  168. make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
  169. }];
  170. // 下一步按钮
  171. [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.centerX.mas_offset(0);
  173. make.size.mas_equalTo(self.nextButton.size);
  174. make.bottom.mas_offset(kRealValue(-20));
  175. }];
  176. }
  177. - (void)initData {
  178. NSString *path = @"/industrycategory";
  179. [self.netManager storeGETWithPath:path SuccessBlock:^(NSDictionary *responseJson) {
  180. // 解析接口返回数据
  181. if ([responseJson[@"code"] integerValue] == 1) {
  182. NSArray *dataArray = responseJson[@"data"];
  183. if ([dataArray isKindOfClass:[NSArray class]]) {
  184. self.categories = [IndustryCategoryModel mj_objectArrayWithKeyValuesArray:dataArray];
  185. // 如果有数据,默认选择第一个
  186. if (self.categories.count > 0) {
  187. self.selectedCategory = self.categories.firstObject;
  188. [self updateCategoryDisplay];
  189. }
  190. // 加载行业分类后,自动填充之前保存的数据
  191. [self loadSavedData];
  192. }
  193. }
  194. } FailureBlock:^(NSError *error) {
  195. NSLog(@"获取行业分类失败: %@", error.localizedDescription);
  196. }];
  197. }
  198. - (void)checkShopNameIsCanUse {
  199. [[BGHUDHelper sharedInstance] syncLoading];
  200. NSString *path = @"/checkShopNameIsCanUse";
  201. NSMutableDictionary *dict = @{
  202. @"shop_name":self.storeNameTextField.text
  203. }.mutableCopy;
  204. [self.netManager storePOSTWithPath:path paramDict:dict SuccessBlock:^(NSDictionary *responseJson) {
  205. [[BGHUDHelper sharedInstance] syncStopLoading];
  206. NSInteger is_can_use = [responseJson[@"is_can_use"] integerValue];
  207. if (is_can_use == 1) {
  208. [self goNext];
  209. } else {
  210. [self makeToast:@""];
  211. }
  212. } FailureBlock:^(NSError *error) {
  213. [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
  214. }];
  215. }
  216. - (void)uploadImage:(UIImage *)image {
  217. WeakSelf
  218. [self uploadImage:image completion:^(NSString * _Nonnull url) {
  219. weakSelf.logoURL = url;
  220. }];
  221. }
  222. #pragma mark - Actions
  223. - (void)goNext {
  224. NSString *shop_name = self.storeNameTextField.text;
  225. NSString *address = self.addressTextField.text;
  226. if (shop_name.length == 0) {
  227. [self makeToast:self.storeNameTextField.placeholder];
  228. return;
  229. }
  230. if (![self.logoURL hasPrefix:@"http"]) {
  231. [self makeToast:ASLocalizedString(@"请上传图片")];
  232. return;
  233. }
  234. if (address.length == 0) {
  235. [self makeToast:self.addressTextField.placeholder];
  236. return;
  237. }
  238. [self checkShopNameIsCanUse];
  239. }
  240. - (void)logoUploadTapped:(UITapGestureRecognizer *)gesture {
  241. WeakSelf
  242. [self pickImageWithCompletion:^(UIImage * _Nonnull image) {
  243. weakSelf.logoImageView.image = image;
  244. weakSelf.logoCloseButton.hidden = NO;
  245. [weakSelf uploadImage:image];
  246. }];
  247. }
  248. - (void)logoCloseButtonTapped:(UIButton *)sender {
  249. self.logoImageView.image = nil;
  250. sender.hidden = YES;
  251. }
  252. - (void)categoryButtonTapped:(UIButton *)sender {
  253. if (self.categories.count == 0) {
  254. NSLog(@"暂无行业分类数据");
  255. return;
  256. }
  257. // 显示类别选择器
  258. if (!self.categoryPickerView) {
  259. self.categoryPickerView = [[CategoryPickerView alloc] init];
  260. self.categoryPickerView.delegate = self;
  261. }
  262. self.categoryPickerView.categories = self.categories;
  263. [self.categoryPickerView showInView:self.superview fromRect:sender.frame];
  264. }
  265. - (void)storeNameTextFieldChanged:(UITextField *)textField {
  266. // 实时验证店铺名称
  267. NSString *text = textField.text;
  268. if (text.length > 0) {
  269. // 这里模拟检查名称可用性
  270. self.storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
  271. self.storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  272. } else {
  273. self.storeNameStatusLabel.text = @"";
  274. }
  275. }
  276. - (void)descriptionTextViewDidChange:(NSNotification *)notification {
  277. UITextView *textView = notification.object;
  278. NSString *text = textView.text;
  279. NSInteger currentLength = text.length;
  280. NSInteger maxLength = 200;
  281. // 限制字数不超过200字
  282. if (currentLength > maxLength) {
  283. textView.text = [text substringToIndex:maxLength];
  284. currentLength = maxLength;
  285. }
  286. // 更新字数显示
  287. self.descriptionCountLabel.text = [NSString stringWithFormat:@"%ld/200", (long)currentLength];
  288. // 根据字数变化颜色
  289. if (currentLength >= maxLength) {
  290. self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#FF5722"];
  291. } else {
  292. self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  293. }
  294. }
  295. - (void)descriptionTextViewDidBeginEditing:(NSNotification *)notification {
  296. UITextView *textView = notification.object;
  297. if ([textView.text isEqualToString:ASLocalizedString(@"请输入店铺简介")]) {
  298. textView.text = @"";
  299. textView.textColor = [UIColor blackColor];
  300. }
  301. }
  302. - (void)descriptionTextViewDidEndEditing:(NSNotification *)notification {
  303. UITextView *textView = notification.object;
  304. if (textView.text.length == 0) {
  305. textView.text = ASLocalizedString(@"请输入店铺简介");
  306. textView.textColor = [UIColor colorWithHexString:@"#999999"];
  307. self.descriptionCountLabel.text = @"0/200";
  308. }
  309. }
  310. - (void)updateCategoryDisplay {
  311. if (self.selectedCategory) {
  312. // 更新按钮显示
  313. [self.categoryButton setTitle:self.selectedCategory.name forState:UIControlStateNormal];
  314. [self.categoryButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  315. // 更新状态标签
  316. self.categoryStatusLabel.text = [NSString stringWithFormat:ASLocalizedString(@"✓ 已选 %@"), self.selectedCategory.name];
  317. self.categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  318. // 更新提示标签
  319. NSString *depositText = [NSString stringWithFormat:@"%.2f", [self.selectedCategory.depositAmount floatValue]];
  320. NSString *commissionText = [NSString stringWithFormat:@"%.0f%%", [self.selectedCategory.commissionRate floatValue] * 100];
  321. NSString *tipText = [NSString stringWithFormat:ASLocalizedString(@"该类目保证金为: ¥%@,佣金比例为: %@。"), depositText, commissionText];
  322. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:tipText];
  323. // 设置整体样式
  324. [attributedText addAttribute:NSFontAttributeName
  325. value:[UIFont systemFontOfSize:12]
  326. range:NSMakeRange(0, tipText.length)];
  327. [attributedText addAttribute:NSForegroundColorAttributeName
  328. value:[UIColor colorWithHexString:@"#FF9800"]
  329. range:NSMakeRange(0, tipText.length)];
  330. // 设置金额和百分比的颜色
  331. NSRange moneyRange = [tipText rangeOfString:[NSString stringWithFormat:@"¥%@", depositText]];
  332. NSRange percentRange = [tipText rangeOfString:commissionText];
  333. if (moneyRange.location != NSNotFound) {
  334. [attributedText addAttribute:NSForegroundColorAttributeName
  335. value:[UIColor colorWithHexString:@"#FF5722"]
  336. range:moneyRange];
  337. }
  338. if (percentRange.location != NSNotFound) {
  339. [attributedText addAttribute:NSForegroundColorAttributeName
  340. value:[UIColor colorWithHexString:@"#FF5722"]
  341. range:percentRange];
  342. }
  343. self.categoryTipLabel.attributedText = attributedText;
  344. }
  345. }
  346. #pragma mark - CategoryPickerViewDelegate
  347. - (void)categoryPickerView:(UIView *)pickerView didSelectCategory:(IndustryCategoryModel *)category {
  348. self.selectedCategory = category;
  349. [self updateCategoryDisplay];
  350. }
  351. #pragma mark - 数据自动填充
  352. - (void)loadSavedData {
  353. NSDictionary *savedData = [[MerchantEnrollDataManager sharedManager] getStoreInfoData];
  354. if (savedData) {
  355. [self fillWithData:savedData];
  356. }
  357. }
  358. - (void)fillWithData:(NSDictionary *)data {
  359. if (!data || ![data isKindOfClass:[NSDictionary class]]) {
  360. return;
  361. }
  362. // 填充店铺名称
  363. NSString *shopName = data[@"shop_name"];
  364. if (shopName && [shopName isKindOfClass:[NSString class]]) {
  365. self.storeNameTextField.text = shopName;
  366. [self storeNameTextFieldChanged:self.storeNameTextField];
  367. }
  368. // 填充店铺Logo
  369. NSString *shopLogo = data[@"shop_logo"];
  370. if (shopLogo && [shopLogo isKindOfClass:[NSString class]] && [shopLogo hasPrefix:@"http"]) {
  371. self.logoURL = shopLogo;
  372. [self.logoImageView setImageURL:[NSURL URLWithString:shopLogo]];
  373. self.logoCloseButton.hidden = NO;
  374. }
  375. // 填充店铺简介
  376. NSString *shopDesc = data[@"shop_desc"];
  377. if (shopDesc && [shopDesc isKindOfClass:[NSString class]] && shopDesc.length > 0) {
  378. self.descriptionTextView.text = shopDesc;
  379. self.descriptionTextView.textColor = [UIColor blackColor];
  380. // 更新字数统计
  381. NSInteger currentLength = shopDesc.length;
  382. self.descriptionCountLabel.text = [NSString stringWithFormat:@"%ld/200", (long)currentLength];
  383. if (currentLength >= 200) {
  384. self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#FF5722"];
  385. } else {
  386. self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  387. }
  388. }
  389. // 填充经营类别
  390. NSNumber *cateId = data[@"cate_id"];
  391. if (cateId && [cateId isKindOfClass:[NSNumber class]] && self.categories.count > 0) {
  392. NSInteger categoryId = [cateId integerValue];
  393. for (IndustryCategoryModel *category in self.categories) {
  394. if (category.categoryId == categoryId) {
  395. self.selectedCategory = category;
  396. [self updateCategoryDisplay];
  397. break;
  398. }
  399. }
  400. }
  401. // 填充店铺地址
  402. NSString *shopAddress = data[@"shop_address"];
  403. if (shopAddress && [shopAddress isKindOfClass:[NSString class]]) {
  404. self.addressTextField.text = shopAddress;
  405. }
  406. }
  407. #pragma mark - Lazy Loading
  408. - (UILabel *)storeNameLabel {
  409. if (!_storeNameLabel) {
  410. _storeNameLabel = [[UILabel alloc] init];
  411. _storeNameLabel.text = ASLocalizedString(@"店铺名称");
  412. _storeNameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  413. _storeNameLabel.textColor = [UIColor blackColor];
  414. // 添加红色星号
  415. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_storeNameLabel.text];
  416. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  417. NSForegroundColorAttributeName: [UIColor redColor],
  418. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  419. }];
  420. [attributedText appendAttributedString:redStar];
  421. _storeNameLabel.attributedText = attributedText;
  422. }
  423. return _storeNameLabel;
  424. }
  425. - (UITextField *)storeNameTextField {
  426. if (!_storeNameTextField) {
  427. _storeNameTextField = [[UITextField alloc] init];
  428. _storeNameTextField.placeholder = ASLocalizedString(@"请输入店铺名称");
  429. _storeNameTextField.font = [UIFont systemFontOfSize:16];
  430. _storeNameTextField.textColor = [UIColor blackColor];
  431. _storeNameTextField.backgroundColor = [UIColor whiteColor];
  432. _storeNameTextField.layer.cornerRadius = kRealValue(8);
  433. _storeNameTextField.layer.borderWidth = 1;
  434. _storeNameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  435. // 设置内边距
  436. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  437. _storeNameTextField.leftView = leftView;
  438. _storeNameTextField.leftViewMode = UITextFieldViewModeAlways;
  439. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  440. _storeNameTextField.rightView = rightView;
  441. _storeNameTextField.rightViewMode = UITextFieldViewModeAlways;
  442. [_storeNameTextField addTarget:self action:@selector(storeNameTextFieldChanged:) forControlEvents:UIControlEventEditingChanged];
  443. }
  444. return _storeNameTextField;
  445. }
  446. - (UILabel *)storeNameStatusLabel {
  447. if (!_storeNameStatusLabel) {
  448. _storeNameStatusLabel = [[UILabel alloc] init];
  449. _storeNameStatusLabel.font = [UIFont systemFontOfSize:12];
  450. _storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
  451. _storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  452. }
  453. return _storeNameStatusLabel;
  454. }
  455. - (UILabel *)logoLabel {
  456. if (!_logoLabel) {
  457. _logoLabel = [[UILabel alloc] init];
  458. _logoLabel.text = ASLocalizedString(@"店铺Logo");
  459. _logoLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  460. _logoLabel.textColor = [UIColor blackColor];
  461. // 添加红色星号
  462. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_logoLabel.text];
  463. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  464. NSForegroundColorAttributeName: [UIColor redColor],
  465. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  466. }];
  467. [attributedText appendAttributedString:redStar];
  468. _logoLabel.attributedText = attributedText;
  469. }
  470. return _logoLabel;
  471. }
  472. - (UIView *)logoUploadView {
  473. if (!_logoUploadView) {
  474. _logoUploadView = [[UIView alloc] init];
  475. _logoUploadView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
  476. _logoUploadView.layer.cornerRadius = kRealValue(8);
  477. _logoUploadView.clipsToBounds = YES;
  478. // 添加点击手势
  479. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(logoUploadTapped:)];
  480. [_logoUploadView addGestureRecognizer:tapGesture];
  481. }
  482. return _logoUploadView;
  483. }
  484. - (UIImageView *)logoImageView {
  485. if (!_logoImageView) {
  486. _logoImageView = [[UIImageView alloc] init];
  487. _logoImageView.contentMode = UIViewContentModeScaleAspectFill;
  488. _logoImageView.clipsToBounds = YES;
  489. }
  490. return _logoImageView;
  491. }
  492. - (UIButton *)logoCloseButton {
  493. if (!_logoCloseButton) {
  494. _logoCloseButton = [UIButton buttonWithType:UIButtonTypeCustom];
  495. [_logoCloseButton setImage:[UIImage imageNamed:@"store_close"] forState:UIControlStateNormal];
  496. [_logoCloseButton addTarget:self action:@selector(logoCloseButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  497. _logoCloseButton.hidden = YES;
  498. }
  499. return _logoCloseButton;
  500. }
  501. - (UILabel *)logoTipLabel {
  502. if (!_logoTipLabel) {
  503. _logoTipLabel = [[UILabel alloc] init];
  504. _logoTipLabel.text = ASLocalizedString(@"不大于10M的jpg或png格式的图片");
  505. _logoTipLabel.font = [UIFont systemFontOfSize:12];
  506. _logoTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  507. }
  508. return _logoTipLabel;
  509. }
  510. - (UILabel *)categoryLabel {
  511. if (!_categoryLabel) {
  512. _categoryLabel = [[UILabel alloc] init];
  513. _categoryLabel.text = ASLocalizedString(@"经营类别");
  514. _categoryLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  515. _categoryLabel.textColor = [UIColor blackColor];
  516. // 添加红色星号
  517. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_categoryLabel.text];
  518. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  519. NSForegroundColorAttributeName: [UIColor redColor],
  520. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  521. }];
  522. [attributedText appendAttributedString:redStar];
  523. _categoryLabel.attributedText = attributedText;
  524. }
  525. return _categoryLabel;
  526. }
  527. - (UIButton *)categoryButton {
  528. if (!_categoryButton) {
  529. _categoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
  530. [_categoryButton setTitle:ASLocalizedString(@"请选择经营类别") forState:UIControlStateNormal];
  531. [_categoryButton setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
  532. _categoryButton.titleLabel.font = [UIFont systemFontOfSize:16];
  533. _categoryButton.backgroundColor = [UIColor whiteColor];
  534. _categoryButton.layer.cornerRadius = kRealValue(8);
  535. _categoryButton.layer.borderWidth = 1;
  536. _categoryButton.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  537. _categoryButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  538. _categoryButton.contentEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, kRealValue(16));
  539. // 添加下拉箭头
  540. [_categoryButton setImage:[UIImage imageNamed:@"store_arrow_down"] forState:UIControlStateNormal];
  541. _categoryButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
  542. _categoryButton.imageEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, 0);
  543. [_categoryButton addTarget:self action:@selector(categoryButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  544. }
  545. return _categoryButton;
  546. }
  547. - (UILabel *)categoryStatusLabel {
  548. if (!_categoryStatusLabel) {
  549. _categoryStatusLabel = [[UILabel alloc] init];
  550. _categoryStatusLabel.text = @""; // 初始为空,等待选择后更新
  551. _categoryStatusLabel.font = [UIFont systemFontOfSize:12];
  552. _categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
  553. }
  554. return _categoryStatusLabel;
  555. }
  556. - (UILabel *)categoryTipLabel {
  557. if (!_categoryTipLabel) {
  558. _categoryTipLabel = [[UILabel alloc] init];
  559. _categoryTipLabel.text = @""; // 初始为空,等待选择后更新
  560. _categoryTipLabel.font = [UIFont systemFontOfSize:12];
  561. _categoryTipLabel.textColor = [UIColor colorWithHexString:@"#FF9800"];
  562. _categoryTipLabel.numberOfLines = 0;
  563. }
  564. return _categoryTipLabel;
  565. }
  566. - (UILabel *)descriptionLabel {
  567. if (!_descriptionLabel) {
  568. _descriptionLabel = [[UILabel alloc] init];
  569. _descriptionLabel.text = ASLocalizedString(@"店铺简介");
  570. _descriptionLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  571. _descriptionLabel.textColor = [UIColor blackColor];
  572. // 添加红色星号
  573. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_descriptionLabel.text];
  574. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  575. NSForegroundColorAttributeName: [UIColor redColor],
  576. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  577. }];
  578. [attributedText appendAttributedString:redStar];
  579. _descriptionLabel.attributedText = attributedText;
  580. }
  581. return _descriptionLabel;
  582. }
  583. - (UITextView *)descriptionTextView {
  584. if (!_descriptionTextView) {
  585. _descriptionTextView = [[UITextView alloc] init];
  586. _descriptionTextView.font = [UIFont systemFontOfSize:16];
  587. _descriptionTextView.textColor = [UIColor blackColor];
  588. _descriptionTextView.backgroundColor = [UIColor whiteColor];
  589. _descriptionTextView.layer.cornerRadius = kRealValue(8);
  590. _descriptionTextView.layer.borderWidth = 1;
  591. _descriptionTextView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  592. _descriptionTextView.textContainerInset = UIEdgeInsetsMake(kRealValue(12), kRealValue(12), kRealValue(12), kRealValue(12));
  593. _descriptionTextView.showsVerticalScrollIndicator = YES;
  594. // 设置占位符
  595. _descriptionTextView.text = ASLocalizedString(@"请输入店铺简介");
  596. _descriptionTextView.textColor = [UIColor colorWithHexString:@"#999999"];
  597. // 添加文本变化监听
  598. [[NSNotificationCenter defaultCenter] addObserver:self
  599. selector:@selector(descriptionTextViewDidChange:)
  600. name:UITextViewTextDidChangeNotification
  601. object:_descriptionTextView];
  602. // 添加开始和结束编辑监听
  603. [[NSNotificationCenter defaultCenter] addObserver:self
  604. selector:@selector(descriptionTextViewDidBeginEditing:)
  605. name:UITextViewTextDidBeginEditingNotification
  606. object:_descriptionTextView];
  607. [[NSNotificationCenter defaultCenter] addObserver:self
  608. selector:@selector(descriptionTextViewDidEndEditing:)
  609. name:UITextViewTextDidEndEditingNotification
  610. object:_descriptionTextView];
  611. }
  612. return _descriptionTextView;
  613. }
  614. - (UILabel *)descriptionCountLabel {
  615. if (!_descriptionCountLabel) {
  616. _descriptionCountLabel = [[UILabel alloc] init];
  617. _descriptionCountLabel.text = @"0/200";
  618. _descriptionCountLabel.font = [UIFont systemFontOfSize:12];
  619. _descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#999999"];
  620. _descriptionCountLabel.textAlignment = NSTextAlignmentRight;
  621. }
  622. return _descriptionCountLabel;
  623. }
  624. - (UILabel *)addressLabel {
  625. if (!_addressLabel) {
  626. _addressLabel = [[UILabel alloc] init];
  627. _addressLabel.text = ASLocalizedString(@"店铺地址");
  628. _addressLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  629. _addressLabel.textColor = [UIColor blackColor];
  630. _addressLabel.numberOfLines = 0;
  631. // 添加红色星号
  632. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_addressLabel.text];
  633. NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
  634. NSForegroundColorAttributeName: [UIColor redColor],
  635. NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
  636. }];
  637. [attributedText appendAttributedString:redStar];
  638. _addressLabel.attributedText = attributedText;
  639. }
  640. return _addressLabel;
  641. }
  642. - (UITextField *)addressTextField {
  643. if (!_addressTextField) {
  644. _addressTextField = [[UITextField alloc] init];
  645. _addressTextField.placeholder = ASLocalizedString(@"请输入店铺地址");
  646. _addressTextField.font = [UIFont systemFontOfSize:16];
  647. _addressTextField.textColor = [UIColor blackColor];
  648. _addressTextField.backgroundColor = [UIColor whiteColor];
  649. _addressTextField.layer.cornerRadius = kRealValue(8);
  650. _addressTextField.layer.borderWidth = 1;
  651. _addressTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
  652. // 设置内边距
  653. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  654. _addressTextField.leftView = leftView;
  655. _addressTextField.leftViewMode = UITextFieldViewModeAlways;
  656. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
  657. _addressTextField.rightView = rightView;
  658. _addressTextField.rightViewMode = UITextFieldViewModeAlways;
  659. }
  660. return _addressTextField;
  661. }
  662. @end