|
|
@@ -8,15 +8,42 @@
|
|
|
|
|
|
#import "MerchantStoreInfoView.h"
|
|
|
#import "UIView+Extention.h"
|
|
|
+#import "IndustryCategoryModel.h"
|
|
|
+#import "CategoryPickerView.h"
|
|
|
+
|
|
|
+@interface MerchantStoreInfoView ()<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
|
|
|
+@property (nonatomic, copy, nullable) NSString *logoURL;
|
|
|
+@end
|
|
|
|
|
|
@implementation MerchantStoreInfoView
|
|
|
|
|
|
+- (void)dealloc {
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
+}
|
|
|
+
|
|
|
+- (NSDictionary *)getMerchantEnrollParameters {
|
|
|
+ // 获取店铺简介内容,排除占位符文本
|
|
|
+ NSString *description = @"";
|
|
|
+ if (![self.descriptionTextView.text isEqualToString:ASLocalizedString(@"请输入店铺简介")]) {
|
|
|
+ description = self.descriptionTextView.text ?: @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ return @{
|
|
|
+ @"shop_name": self.storeNameTextField.text ?: @"",
|
|
|
+ @"shop_logo": self.logoURL ?: @"",
|
|
|
+ @"shop_desc": description,
|
|
|
+ @"cate_id":@(self.selectedCategory.categoryId),
|
|
|
+ @"shop_address":self.addressTextField.text ?: @""
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
|
{
|
|
|
self = [super initWithFrame:frame];
|
|
|
if (self) {
|
|
|
[self setupUI];
|
|
|
[self setupConstraints];
|
|
|
+ [self initData];
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
@@ -35,6 +62,9 @@
|
|
|
// 添加经营类别区域
|
|
|
[self setupCategorySection];
|
|
|
|
|
|
+ // 添加店铺简介区域
|
|
|
+ [self setupDescriptionSection];
|
|
|
+
|
|
|
// 添加店铺地址区域
|
|
|
[self setupAddressSection];
|
|
|
|
|
|
@@ -63,6 +93,12 @@
|
|
|
[self.contentView addSubview:self.categoryTipLabel];
|
|
|
}
|
|
|
|
|
|
+- (void)setupDescriptionSection {
|
|
|
+ [self.contentView addSubview:self.descriptionLabel];
|
|
|
+ [self.contentView addSubview:self.descriptionTextView];
|
|
|
+ [self.contentView addSubview:self.descriptionCountLabel];
|
|
|
+}
|
|
|
+
|
|
|
- (void)setupAddressSection {
|
|
|
[self.contentView addSubview:self.addressLabel];
|
|
|
[self.contentView addSubview:self.addressTextField];
|
|
|
@@ -138,10 +174,28 @@
|
|
|
make.top.equalTo(self.categoryStatusLabel.mas_bottom).offset(kRealValue(4));
|
|
|
}];
|
|
|
|
|
|
+ // 店铺简介
|
|
|
+ [self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.storeNameLabel);
|
|
|
+ make.top.equalTo(self.categoryTipLabel.mas_bottom).offset(kRealValue(24));
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.descriptionTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.descriptionLabel);
|
|
|
+ make.right.equalTo(self.contentView).offset(-kRealValue(24));
|
|
|
+ make.top.equalTo(self.descriptionLabel.mas_bottom).offset(kRealValue(12));
|
|
|
+ make.height.mas_equalTo(kRealValue(100));
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.descriptionCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.equalTo(self.descriptionTextView);
|
|
|
+ make.top.equalTo(self.descriptionTextView.mas_bottom).offset(kRealValue(8));
|
|
|
+ }];
|
|
|
+
|
|
|
// 店铺地址
|
|
|
[self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.equalTo(self.storeNameLabel);
|
|
|
- make.top.equalTo(self.categoryTipLabel.mas_bottom).offset(kRealValue(24));
|
|
|
+ make.top.equalTo(self.descriptionCountLabel.mas_bottom).offset(kRealValue(24));
|
|
|
}];
|
|
|
|
|
|
[self.addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
@@ -160,21 +214,121 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)initData {
|
|
|
+ NSString *path = @"/industrycategory";
|
|
|
+ [self.netManager storeGETWithPath:path SuccessBlock:^(NSDictionary *responseJson) {
|
|
|
+ // 解析接口返回数据
|
|
|
+ if ([responseJson[@"code"] integerValue] == 1) {
|
|
|
+ NSArray *dataArray = responseJson[@"data"];
|
|
|
+ if ([dataArray isKindOfClass:[NSArray class]]) {
|
|
|
+ self.categories = [IndustryCategoryModel mj_objectArrayWithKeyValuesArray:dataArray];
|
|
|
+
|
|
|
+ // 如果有数据,默认选择第一个
|
|
|
+ if (self.categories.count > 0) {
|
|
|
+ self.selectedCategory = self.categories.firstObject;
|
|
|
+ [self updateCategoryDisplay];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } FailureBlock:^(NSError *error) {
|
|
|
+ NSLog(@"获取行业分类失败: %@", error.localizedDescription);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)checkShopNameIsCanUse {
|
|
|
+
|
|
|
+ [[BGHUDHelper sharedInstance] syncLoading];
|
|
|
+ NSString *path = @"/checkShopNameIsCanUse";
|
|
|
+ NSMutableDictionary *dict = @{
|
|
|
+ @"shop_name":self.storeNameTextField.text
|
|
|
+ }.mutableCopy;
|
|
|
+ [self.netManager storePOSTWithPath:path paramDict:dict SuccessBlock:^(NSDictionary *responseJson) {
|
|
|
+ [[BGHUDHelper sharedInstance] syncStopLoading];
|
|
|
+ NSInteger is_can_use = [responseJson[@"is_can_use"] integerValue];
|
|
|
+ if (is_can_use == 1) {
|
|
|
+ [self goNext];
|
|
|
+ } else {
|
|
|
+ [self makeToast:@""];
|
|
|
+ }
|
|
|
+
|
|
|
+ } FailureBlock:^(NSError *error) {
|
|
|
+ [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)uploadImage:(UIImage *)image {
|
|
|
+
|
|
|
+ [[BGHUDHelper sharedInstance] syncLoading];
|
|
|
+ NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
|
|
|
+ [parmDict setObject:@"avatar" forKey:@"ctl"];
|
|
|
+ [parmDict setObject:@"uploadImage" forKey:@"act"];
|
|
|
+ NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
|
|
|
+ [self.netManager POSTWithDict:parmDict andFileData:imageData AndFileName:@"logo.png" SuccessBlock:^(NSDictionary *responseJson) {
|
|
|
+ [[BGHUDHelper sharedInstance] syncStopLoading];
|
|
|
+ [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传成功")];
|
|
|
+ self.logoURL = responseJson[@"server_full_path"];
|
|
|
+ } FailureBlock:^(NSError *error) {
|
|
|
+ [[BGHUDHelper sharedInstance] syncStopLoading];
|
|
|
+ [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Actions
|
|
|
|
|
|
+- (void)goNext {
|
|
|
+ NSString *shop_name = self.storeNameTextField.text;
|
|
|
+ NSString *address = self.addressTextField.text;
|
|
|
+
|
|
|
+ if (shop_name.length == 0) {
|
|
|
+ [self makeToast:self.storeNameTextField.placeholder];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (![self.logoURL hasPrefix:@"http"]) {
|
|
|
+ [self makeToast:ASLocalizedString(@"请上传图片")];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (address.length == 0) {
|
|
|
+ [self makeToast:self.addressTextField.placeholder];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [self checkShopNameIsCanUse];
|
|
|
+}
|
|
|
+
|
|
|
- (void)logoUploadTapped:(UITapGestureRecognizer *)gesture {
|
|
|
- // TODO: 实现图片选择功能
|
|
|
- NSLog(@"Logo upload tapped");
|
|
|
+ if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
|
|
|
+ {
|
|
|
+ UIImagePickerController *picker = [[UIImagePickerController alloc] init];
|
|
|
+ picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
|
|
+ picker.delegate = self;
|
|
|
+ picker.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
+ [self.viewController presentViewController:picker animated:YES completion:nil];
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)logoCloseButtonTapped:(UIButton *)sender {
|
|
|
- // TODO: 移除已选择的图片
|
|
|
- NSLog(@"Logo close button tapped");
|
|
|
+ self.logoImageView.image = nil;
|
|
|
+ sender.hidden = YES;
|
|
|
}
|
|
|
|
|
|
- (void)categoryButtonTapped:(UIButton *)sender {
|
|
|
- // TODO: 实现类别选择功能
|
|
|
- NSLog(@"Category button tapped");
|
|
|
+ if (self.categories.count == 0) {
|
|
|
+ NSLog(@"暂无行业分类数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示类别选择器
|
|
|
+ if (!self.categoryPickerView) {
|
|
|
+ self.categoryPickerView = [[CategoryPickerView alloc] init];
|
|
|
+ self.categoryPickerView.delegate = self;
|
|
|
+ }
|
|
|
+
|
|
|
+ self.categoryPickerView.categories = self.categories;
|
|
|
+ [self.categoryPickerView showInView:self.superview fromRect:sender.frame];
|
|
|
}
|
|
|
|
|
|
- (void)storeNameTextFieldChanged:(UITextField *)textField {
|
|
|
@@ -189,6 +343,112 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)descriptionTextViewDidChange:(NSNotification *)notification {
|
|
|
+ UITextView *textView = notification.object;
|
|
|
+ NSString *text = textView.text;
|
|
|
+ NSInteger currentLength = text.length;
|
|
|
+ NSInteger maxLength = 200;
|
|
|
+
|
|
|
+ // 限制字数不超过200字
|
|
|
+ if (currentLength > maxLength) {
|
|
|
+ textView.text = [text substringToIndex:maxLength];
|
|
|
+ currentLength = maxLength;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新字数显示
|
|
|
+ self.descriptionCountLabel.text = [NSString stringWithFormat:@"%ld/200", (long)currentLength];
|
|
|
+
|
|
|
+ // 根据字数变化颜色
|
|
|
+ if (currentLength >= maxLength) {
|
|
|
+ self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#FF5722"];
|
|
|
+ } else {
|
|
|
+ self.descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#999999"];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)descriptionTextViewDidBeginEditing:(NSNotification *)notification {
|
|
|
+ UITextView *textView = notification.object;
|
|
|
+ if ([textView.text isEqualToString:ASLocalizedString(@"请输入店铺简介")]) {
|
|
|
+ textView.text = @"";
|
|
|
+ textView.textColor = [UIColor blackColor];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)descriptionTextViewDidEndEditing:(NSNotification *)notification {
|
|
|
+ UITextView *textView = notification.object;
|
|
|
+ if (textView.text.length == 0) {
|
|
|
+ textView.text = ASLocalizedString(@"请输入店铺简介");
|
|
|
+ textView.textColor = [UIColor colorWithHexString:@"#999999"];
|
|
|
+ self.descriptionCountLabel.text = @"0/200";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)updateCategoryDisplay {
|
|
|
+ if (self.selectedCategory) {
|
|
|
+ // 更新按钮显示
|
|
|
+ [self.categoryButton setTitle:self.selectedCategory.name forState:UIControlStateNormal];
|
|
|
+ [self.categoryButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
+
|
|
|
+ // 更新状态标签
|
|
|
+ self.categoryStatusLabel.text = [NSString stringWithFormat:ASLocalizedString(@"✓ 已选 %@"), self.selectedCategory.name];
|
|
|
+ self.categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
|
|
|
+
|
|
|
+ // 更新提示标签
|
|
|
+ NSString *depositText = [NSString stringWithFormat:@"%.2f", [self.selectedCategory.depositAmount floatValue]];
|
|
|
+ NSString *commissionText = [NSString stringWithFormat:@"%.0f%%", [self.selectedCategory.commissionRate floatValue] * 100];
|
|
|
+
|
|
|
+ NSString *tipText = [NSString stringWithFormat:ASLocalizedString(@"该类目保证金为: ¥%@,佣金比例为: %@。"), depositText, commissionText];
|
|
|
+ NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:tipText];
|
|
|
+
|
|
|
+ // 设置整体样式
|
|
|
+ [attributedText addAttribute:NSFontAttributeName
|
|
|
+ value:[UIFont systemFontOfSize:12]
|
|
|
+ range:NSMakeRange(0, tipText.length)];
|
|
|
+ [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
+ value:[UIColor colorWithHexString:@"#FF9800"]
|
|
|
+ range:NSMakeRange(0, tipText.length)];
|
|
|
+
|
|
|
+ // 设置金额和百分比的颜色
|
|
|
+ NSRange moneyRange = [tipText rangeOfString:[NSString stringWithFormat:@"¥%@", depositText]];
|
|
|
+ NSRange percentRange = [tipText rangeOfString:commissionText];
|
|
|
+
|
|
|
+ if (moneyRange.location != NSNotFound) {
|
|
|
+ [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
+ value:[UIColor colorWithHexString:@"#FF5722"]
|
|
|
+ range:moneyRange];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (percentRange.location != NSNotFound) {
|
|
|
+ [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
+ value:[UIColor colorWithHexString:@"#FF5722"]
|
|
|
+ range:percentRange];
|
|
|
+ }
|
|
|
+
|
|
|
+ self.categoryTipLabel.attributedText = attributedText;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - UINavigationControllerDelegate,UIImagePickerControllerDelegate
|
|
|
+- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
|
|
|
+ UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
|
+ self.logoImageView.image = image;
|
|
|
+ self.logoCloseButton.hidden = NO;
|
|
|
+ [picker dismissViewControllerAnimated:YES completion:^{
|
|
|
+ [self uploadImage:image];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
|
|
|
+ [picker dismissViewControllerAnimated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - CategoryPickerViewDelegate
|
|
|
+
|
|
|
+- (void)categoryPickerView:(UIView *)pickerView didSelectCategory:(IndustryCategoryModel *)category {
|
|
|
+ self.selectedCategory = category;
|
|
|
+ [self updateCategoryDisplay];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Lazy Loading
|
|
|
|
|
|
- (UILabel *)storeNameLabel {
|
|
|
@@ -232,8 +492,6 @@
|
|
|
|
|
|
[_storeNameTextField addTarget:self action:@selector(storeNameTextFieldChanged:) forControlEvents:UIControlEventEditingChanged];
|
|
|
|
|
|
- // 设置默认文本
|
|
|
- _storeNameTextField.text = ASLocalizedString(@"跳跳自营农场");
|
|
|
}
|
|
|
return _storeNameTextField;
|
|
|
}
|
|
|
@@ -270,7 +528,7 @@
|
|
|
- (UIView *)logoUploadView {
|
|
|
if (!_logoUploadView) {
|
|
|
_logoUploadView = [[UIView alloc] init];
|
|
|
- _logoUploadView.backgroundColor = [UIColor clearColor];
|
|
|
+ _logoUploadView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8];
|
|
|
_logoUploadView.layer.cornerRadius = kRealValue(8);
|
|
|
_logoUploadView.clipsToBounds = YES;
|
|
|
|
|
|
@@ -286,8 +544,6 @@
|
|
|
_logoImageView = [[UIImageView alloc] init];
|
|
|
_logoImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
_logoImageView.clipsToBounds = YES;
|
|
|
- // 这里使用一个默认的示例图片
|
|
|
- _logoImageView.image = [UIImage imageNamed:@"store_header_icon"]; // 临时使用现有图片
|
|
|
}
|
|
|
return _logoImageView;
|
|
|
}
|
|
|
@@ -297,8 +553,7 @@
|
|
|
_logoCloseButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
[_logoCloseButton setImage:[UIImage imageNamed:@"store_close"] forState:UIControlStateNormal];
|
|
|
[_logoCloseButton addTarget:self action:@selector(logoCloseButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
- _logoCloseButton.backgroundColor = [UIColor whiteColor];
|
|
|
- _logoCloseButton.layer.cornerRadius = kRealValue(10);
|
|
|
+ _logoCloseButton.hidden = YES;
|
|
|
}
|
|
|
return _logoCloseButton;
|
|
|
}
|
|
|
@@ -335,8 +590,8 @@
|
|
|
- (UIButton *)categoryButton {
|
|
|
if (!_categoryButton) {
|
|
|
_categoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
- [_categoryButton setTitle:ASLocalizedString(@"服饰") forState:UIControlStateNormal];
|
|
|
- [_categoryButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
+ [_categoryButton setTitle:ASLocalizedString(@"请选择经营类别") forState:UIControlStateNormal];
|
|
|
+ [_categoryButton setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
|
|
|
_categoryButton.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
|
_categoryButton.backgroundColor = [UIColor whiteColor];
|
|
|
_categoryButton.layer.cornerRadius = kRealValue(8);
|
|
|
@@ -358,7 +613,7 @@
|
|
|
- (UILabel *)categoryStatusLabel {
|
|
|
if (!_categoryStatusLabel) {
|
|
|
_categoryStatusLabel = [[UILabel alloc] init];
|
|
|
- _categoryStatusLabel.text = ASLocalizedString(@"✓ 已选 服饰");
|
|
|
+ _categoryStatusLabel.text = @""; // 初始为空,等待选择后更新
|
|
|
_categoryStatusLabel.font = [UIFont systemFontOfSize:12];
|
|
|
_categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
|
|
|
}
|
|
|
@@ -368,38 +623,78 @@
|
|
|
- (UILabel *)categoryTipLabel {
|
|
|
if (!_categoryTipLabel) {
|
|
|
_categoryTipLabel = [[UILabel alloc] init];
|
|
|
+ _categoryTipLabel.text = @""; // 初始为空,等待选择后更新
|
|
|
+ _categoryTipLabel.font = [UIFont systemFontOfSize:12];
|
|
|
+ _categoryTipLabel.textColor = [UIColor colorWithHexString:@"#FF9800"];
|
|
|
+ _categoryTipLabel.numberOfLines = 0;
|
|
|
+ }
|
|
|
+ return _categoryTipLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)descriptionLabel {
|
|
|
+ if (!_descriptionLabel) {
|
|
|
+ _descriptionLabel = [[UILabel alloc] init];
|
|
|
+ _descriptionLabel.text = ASLocalizedString(@"店铺简介");
|
|
|
+ _descriptionLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
|
+ _descriptionLabel.textColor = [UIColor blackColor];
|
|
|
|
|
|
- NSString *text = ASLocalizedString(@"该类目保证金为: ¥6000.00,佣金比例为: 15%。");
|
|
|
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text];
|
|
|
-
|
|
|
- // 设置整体样式
|
|
|
- [attributedText addAttribute:NSFontAttributeName
|
|
|
- value:[UIFont systemFontOfSize:12]
|
|
|
- range:NSMakeRange(0, text.length)];
|
|
|
- [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
- value:[UIColor colorWithHexString:@"#FF9800"]
|
|
|
- range:NSMakeRange(0, text.length)];
|
|
|
+ // 添加红色星号
|
|
|
+ NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_descriptionLabel.text];
|
|
|
+ NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
|
|
|
+ NSForegroundColorAttributeName: [UIColor redColor],
|
|
|
+ NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
|
|
|
+ }];
|
|
|
+ [attributedText appendAttributedString:redStar];
|
|
|
+ _descriptionLabel.attributedText = attributedText;
|
|
|
+ }
|
|
|
+ return _descriptionLabel;
|
|
|
+}
|
|
|
+
|
|
|
+- (UITextView *)descriptionTextView {
|
|
|
+ if (!_descriptionTextView) {
|
|
|
+ _descriptionTextView = [[UITextView alloc] init];
|
|
|
+ _descriptionTextView.font = [UIFont systemFontOfSize:16];
|
|
|
+ _descriptionTextView.textColor = [UIColor blackColor];
|
|
|
+ _descriptionTextView.backgroundColor = [UIColor whiteColor];
|
|
|
+ _descriptionTextView.layer.cornerRadius = kRealValue(8);
|
|
|
+ _descriptionTextView.layer.borderWidth = 1;
|
|
|
+ _descriptionTextView.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
|
|
|
+ _descriptionTextView.textContainerInset = UIEdgeInsetsMake(kRealValue(12), kRealValue(12), kRealValue(12), kRealValue(12));
|
|
|
+ _descriptionTextView.showsVerticalScrollIndicator = YES;
|
|
|
|
|
|
- // 设置金额和百分比的颜色
|
|
|
- NSRange moneyRange = [text rangeOfString:@"¥6000.00"];
|
|
|
- NSRange percentRange = [text rangeOfString:@"15%"];
|
|
|
+ // 设置占位符
|
|
|
+ _descriptionTextView.text = ASLocalizedString(@"请输入店铺简介");
|
|
|
+ _descriptionTextView.textColor = [UIColor colorWithHexString:@"#999999"];
|
|
|
|
|
|
- if (moneyRange.location != NSNotFound) {
|
|
|
- [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
- value:[UIColor colorWithHexString:@"#FF5722"]
|
|
|
- range:moneyRange];
|
|
|
- }
|
|
|
+ // 添加文本变化监听
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
+ selector:@selector(descriptionTextViewDidChange:)
|
|
|
+ name:UITextViewTextDidChangeNotification
|
|
|
+ object:_descriptionTextView];
|
|
|
|
|
|
- if (percentRange.location != NSNotFound) {
|
|
|
- [attributedText addAttribute:NSForegroundColorAttributeName
|
|
|
- value:[UIColor colorWithHexString:@"#FF5722"]
|
|
|
- range:percentRange];
|
|
|
- }
|
|
|
+ // 添加开始和结束编辑监听
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
+ selector:@selector(descriptionTextViewDidBeginEditing:)
|
|
|
+ name:UITextViewTextDidBeginEditingNotification
|
|
|
+ object:_descriptionTextView];
|
|
|
|
|
|
- _categoryTipLabel.attributedText = attributedText;
|
|
|
- _categoryTipLabel.numberOfLines = 0;
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
+ selector:@selector(descriptionTextViewDidEndEditing:)
|
|
|
+ name:UITextViewTextDidEndEditingNotification
|
|
|
+ object:_descriptionTextView];
|
|
|
}
|
|
|
- return _categoryTipLabel;
|
|
|
+ return _descriptionTextView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)descriptionCountLabel {
|
|
|
+ if (!_descriptionCountLabel) {
|
|
|
+ _descriptionCountLabel = [[UILabel alloc] init];
|
|
|
+ _descriptionCountLabel.text = @"0/200";
|
|
|
+ _descriptionCountLabel.font = [UIFont systemFontOfSize:12];
|
|
|
+ _descriptionCountLabel.textColor = [UIColor colorWithHexString:@"#999999"];
|
|
|
+ _descriptionCountLabel.textAlignment = NSTextAlignmentRight;
|
|
|
+ }
|
|
|
+ return _descriptionCountLabel;
|
|
|
}
|
|
|
|
|
|
- (UILabel *)addressLabel {
|
|
|
@@ -409,6 +704,15 @@
|
|
|
_addressLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
|
_addressLabel.textColor = [UIColor blackColor];
|
|
|
_addressLabel.numberOfLines = 0;
|
|
|
+
|
|
|
+ // 添加红色星号
|
|
|
+ NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_addressLabel.text];
|
|
|
+ NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
|
|
|
+ NSForegroundColorAttributeName: [UIColor redColor],
|
|
|
+ NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
|
|
|
+ }];
|
|
|
+ [attributedText appendAttributedString:redStar];
|
|
|
+ _addressLabel.attributedText = attributedText;
|
|
|
}
|
|
|
return _addressLabel;
|
|
|
}
|