MerchantStoreInfoView.m 30 KB

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