| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- //
- // MerchantStoreInfoView.m
- // merchant
- //
- // Created by qitewei on 2025/8/14.
- // Copyright © 2025 xfg. All rights reserved.
- //
- #import "MerchantStoreInfoView.h"
- #import "UIView+Extention.h"
- @implementation MerchantStoreInfoView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- [self setupConstraints];
- }
- return self;
- }
- - (void)setupUI {
- self.backgroundColor = [UIColor clearColor];
-
-
-
- // 添加店铺名称区域
- [self setupStoreNameSection];
-
- // 添加店铺Logo区域
- [self setupLogoSection];
-
- // 添加经营类别区域
- [self setupCategorySection];
-
- // 添加店铺地址区域
- [self setupAddressSection];
-
- // 添加下一步按钮
- [self addSubview:self.nextButton];
- }
- - (void)setupStoreNameSection {
- [self.contentView addSubview:self.storeNameLabel];
- [self.contentView addSubview:self.storeNameTextField];
- [self.contentView addSubview:self.storeNameStatusLabel];
- }
- - (void)setupLogoSection {
- [self.contentView addSubview:self.logoLabel];
- [self.contentView addSubview:self.logoUploadView];
- [self.logoUploadView addSubview:self.logoImageView];
- [self.logoUploadView addSubview:self.logoCloseButton];
- [self.contentView addSubview:self.logoTipLabel];
- }
- - (void)setupCategorySection {
- [self.contentView addSubview:self.categoryLabel];
- [self.contentView addSubview:self.categoryButton];
- [self.contentView addSubview:self.categoryStatusLabel];
- [self.contentView addSubview:self.categoryTipLabel];
- }
- - (void)setupAddressSection {
- [self.contentView addSubview:self.addressLabel];
- [self.contentView addSubview:self.addressTextField];
- }
- - (void)setupConstraints {
-
- // 店铺名称
- [self.storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(kRealValue(24));
- make.top.equalTo(self.contentView).offset(kRealValue(20));
- }];
-
- [self.storeNameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.storeNameLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.storeNameLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(48));
- }];
-
- [self.storeNameStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.storeNameTextField);
- make.top.equalTo(self.storeNameTextField.mas_bottom).offset(kRealValue(8));
- }];
-
- // 店铺Logo
- [self.logoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.storeNameLabel);
- make.top.equalTo(self.storeNameStatusLabel.mas_bottom).offset(kRealValue(24));
- }];
-
- [self.logoUploadView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.logoLabel);
- make.top.equalTo(self.logoLabel.mas_bottom).offset(kRealValue(12));
- make.width.height.mas_equalTo(kRealValue(100));
- }];
-
- [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.logoUploadView);
- }];
-
- [self.logoCloseButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.equalTo(self.logoUploadView);
- make.width.height.mas_equalTo(kRealValue(20));
- }];
-
- [self.logoTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.logoUploadView);
- make.top.equalTo(self.logoUploadView.mas_bottom).offset(kRealValue(8));
- }];
-
- // 经营类别
- [self.categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.storeNameLabel);
- make.top.equalTo(self.logoTipLabel.mas_bottom).offset(kRealValue(24));
- }];
-
- [self.categoryButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.categoryLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(48));
- }];
-
- [self.categoryStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryButton);
- make.top.equalTo(self.categoryButton.mas_bottom).offset(kRealValue(8));
- }];
-
- [self.categoryTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.categoryStatusLabel);
- make.right.mas_offset(-16);
- make.top.equalTo(self.categoryStatusLabel.mas_bottom).offset(kRealValue(4));
- }];
-
- // 店铺地址
- [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.storeNameLabel);
- make.top.equalTo(self.categoryTipLabel.mas_bottom).offset(kRealValue(24));
- }];
-
- [self.addressTextField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.addressLabel);
- make.right.equalTo(self.contentView).offset(-kRealValue(24));
- make.top.equalTo(self.addressLabel.mas_bottom).offset(kRealValue(12));
- make.height.mas_equalTo(kRealValue(48));
- make.bottom.equalTo(self.contentView).offset(-kRealValue(20));
- }];
-
- // 下一步按钮
- [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(self.nextButton.size);
- make.bottom.mas_offset(kRealValue(-20));
- }];
- }
- #pragma mark - Actions
- - (void)logoUploadTapped:(UITapGestureRecognizer *)gesture {
- // TODO: 实现图片选择功能
- NSLog(@"Logo upload tapped");
- }
- - (void)logoCloseButtonTapped:(UIButton *)sender {
- // TODO: 移除已选择的图片
- NSLog(@"Logo close button tapped");
- }
- - (void)categoryButtonTapped:(UIButton *)sender {
- // TODO: 实现类别选择功能
- NSLog(@"Category button tapped");
- }
- - (void)storeNameTextFieldChanged:(UITextField *)textField {
- // 实时验证店铺名称
- NSString *text = textField.text;
- if (text.length > 0) {
- // 这里模拟检查名称可用性
- self.storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
- self.storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
- } else {
- self.storeNameStatusLabel.text = @"";
- }
- }
- #pragma mark - Lazy Loading
- - (UILabel *)storeNameLabel {
- if (!_storeNameLabel) {
- _storeNameLabel = [[UILabel alloc] init];
- _storeNameLabel.text = ASLocalizedString(@"店铺名称");
- _storeNameLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _storeNameLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_storeNameLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _storeNameLabel.attributedText = attributedText;
- }
- return _storeNameLabel;
- }
- - (UITextField *)storeNameTextField {
- if (!_storeNameTextField) {
- _storeNameTextField = [[UITextField alloc] init];
- _storeNameTextField.placeholder = ASLocalizedString(@"请输入店铺名称");
- _storeNameTextField.font = [UIFont systemFontOfSize:16];
- _storeNameTextField.textColor = [UIColor blackColor];
- _storeNameTextField.backgroundColor = [UIColor whiteColor];
- _storeNameTextField.layer.cornerRadius = kRealValue(8);
- _storeNameTextField.layer.borderWidth = 1;
- _storeNameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
-
- // 设置内边距
- UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _storeNameTextField.leftView = leftView;
- _storeNameTextField.leftViewMode = UITextFieldViewModeAlways;
-
- UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _storeNameTextField.rightView = rightView;
- _storeNameTextField.rightViewMode = UITextFieldViewModeAlways;
-
- [_storeNameTextField addTarget:self action:@selector(storeNameTextFieldChanged:) forControlEvents:UIControlEventEditingChanged];
-
- // 设置默认文本
- _storeNameTextField.text = ASLocalizedString(@"跳跳自营农场");
- }
- return _storeNameTextField;
- }
- - (UILabel *)storeNameStatusLabel {
- if (!_storeNameStatusLabel) {
- _storeNameStatusLabel = [[UILabel alloc] init];
- _storeNameStatusLabel.font = [UIFont systemFontOfSize:12];
- _storeNameStatusLabel.text = ASLocalizedString(@"✓ 名称可使用");
- _storeNameStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
- }
- return _storeNameStatusLabel;
- }
- - (UILabel *)logoLabel {
- if (!_logoLabel) {
- _logoLabel = [[UILabel alloc] init];
- _logoLabel.text = ASLocalizedString(@"店铺Logo");
- _logoLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _logoLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_logoLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _logoLabel.attributedText = attributedText;
- }
- return _logoLabel;
- }
- - (UIView *)logoUploadView {
- if (!_logoUploadView) {
- _logoUploadView = [[UIView alloc] init];
- _logoUploadView.backgroundColor = [UIColor clearColor];
- _logoUploadView.layer.cornerRadius = kRealValue(8);
- _logoUploadView.clipsToBounds = YES;
-
- // 添加点击手势
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(logoUploadTapped:)];
- [_logoUploadView addGestureRecognizer:tapGesture];
- }
- return _logoUploadView;
- }
- - (UIImageView *)logoImageView {
- if (!_logoImageView) {
- _logoImageView = [[UIImageView alloc] init];
- _logoImageView.contentMode = UIViewContentModeScaleAspectFill;
- _logoImageView.clipsToBounds = YES;
- // 这里使用一个默认的示例图片
- _logoImageView.image = [UIImage imageNamed:@"store_header_icon"]; // 临时使用现有图片
- }
- return _logoImageView;
- }
- - (UIButton *)logoCloseButton {
- if (!_logoCloseButton) {
- _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);
- }
- return _logoCloseButton;
- }
- - (UILabel *)logoTipLabel {
- if (!_logoTipLabel) {
- _logoTipLabel = [[UILabel alloc] init];
- _logoTipLabel.text = ASLocalizedString(@"不大于10M的jpg或png格式的图片");
- _logoTipLabel.font = [UIFont systemFontOfSize:12];
- _logoTipLabel.textColor = [UIColor colorWithHexString:@"#999999"];
- }
- return _logoTipLabel;
- }
- - (UILabel *)categoryLabel {
- if (!_categoryLabel) {
- _categoryLabel = [[UILabel alloc] init];
- _categoryLabel.text = ASLocalizedString(@"经营类别");
- _categoryLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _categoryLabel.textColor = [UIColor blackColor];
-
- // 添加红色星号
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:_categoryLabel.text];
- NSAttributedString *redStar = [[NSAttributedString alloc] initWithString:@" *" attributes:@{
- NSForegroundColorAttributeName: [UIColor redColor],
- NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]
- }];
- [attributedText appendAttributedString:redStar];
- _categoryLabel.attributedText = attributedText;
- }
- return _categoryLabel;
- }
- - (UIButton *)categoryButton {
- if (!_categoryButton) {
- _categoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_categoryButton setTitle:ASLocalizedString(@"服饰") forState:UIControlStateNormal];
- [_categoryButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- _categoryButton.titleLabel.font = [UIFont systemFontOfSize:16];
- _categoryButton.backgroundColor = [UIColor whiteColor];
- _categoryButton.layer.cornerRadius = kRealValue(8);
- _categoryButton.layer.borderWidth = 1;
- _categoryButton.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
- _categoryButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- _categoryButton.contentEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, kRealValue(16));
-
- // 添加下拉箭头
- [_categoryButton setImage:[UIImage imageNamed:@"store_arrow_down"] forState:UIControlStateNormal];
- _categoryButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
- _categoryButton.imageEdgeInsets = UIEdgeInsetsMake(0, kRealValue(16), 0, 0);
-
- [_categoryButton addTarget:self action:@selector(categoryButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _categoryButton;
- }
- - (UILabel *)categoryStatusLabel {
- if (!_categoryStatusLabel) {
- _categoryStatusLabel = [[UILabel alloc] init];
- _categoryStatusLabel.text = ASLocalizedString(@"✓ 已选 服饰");
- _categoryStatusLabel.font = [UIFont systemFontOfSize:12];
- _categoryStatusLabel.textColor = [UIColor colorWithHexString:@"#00C853"];
- }
- return _categoryStatusLabel;
- }
- - (UILabel *)categoryTipLabel {
- if (!_categoryTipLabel) {
- _categoryTipLabel = [[UILabel alloc] init];
-
- 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)];
-
- // 设置金额和百分比的颜色
- NSRange moneyRange = [text rangeOfString:@"¥6000.00"];
- NSRange percentRange = [text rangeOfString:@"15%"];
-
- 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];
- }
-
- _categoryTipLabel.attributedText = attributedText;
- _categoryTipLabel.numberOfLines = 0;
- }
- return _categoryTipLabel;
- }
- - (UILabel *)addressLabel {
- if (!_addressLabel) {
- _addressLabel = [[UILabel alloc] init];
- _addressLabel.text = ASLocalizedString(@"店铺地址");
- _addressLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- _addressLabel.textColor = [UIColor blackColor];
- _addressLabel.numberOfLines = 0;
- }
- return _addressLabel;
- }
- - (UITextField *)addressTextField {
- if (!_addressTextField) {
- _addressTextField = [[UITextField alloc] init];
- _addressTextField.placeholder = ASLocalizedString(@"请输入店铺地址");
- _addressTextField.font = [UIFont systemFontOfSize:16];
- _addressTextField.textColor = [UIColor blackColor];
- _addressTextField.backgroundColor = [UIColor whiteColor];
- _addressTextField.layer.cornerRadius = kRealValue(8);
- _addressTextField.layer.borderWidth = 1;
- _addressTextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
-
- // 设置内边距
- UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _addressTextField.leftView = leftView;
- _addressTextField.leftViewMode = UITextFieldViewModeAlways;
-
- UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kRealValue(16), kRealValue(48))];
- _addressTextField.rightView = rightView;
- _addressTextField.rightViewMode = UITextFieldViewModeAlways;
- }
- return _addressTextField;
- }
- @end
|