| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- //
- // MerchantEnrollGuideView.m
- // BuguLive
- //
- // Created by qitewei on 2025/8/11.
- // Copyright © 2025 xfg. All rights reserved.
- //
- #import "MerchantEnrollGuideView.h"
- #import "UIView+Extention.h"
- @implementation MerchantEnrollGuideView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self setupUI];
- [self setupConstraints];
- [self updateSubmitButtonState];
- }
- return self;
- }
- - (void)setupUI {
-
- // 添加头部背景和内容
- [self addSubview:self.headerImageView];
- [self.headerImageView addSubview:self.headerIconImageView];
- [self.headerImageView addSubview:self.textLabel];
- [self.headerImageView addSubview:self.subtitleLabel];
-
- // 添加scrollView
- [self addSubview:self.scrollView];
- [self.scrollView addSubview:self.contentView];
-
-
- // 添加步骤容器
- [self.contentView addSubview:self.stepsContainerView];
- [self setupStepsViews];
-
- // 添加协议和按钮
- [self setupAgreementViews];
- }
- - (void)setupStepsViews {
- [self.stepsContainerView addSubview:self.step1View];
- [self.stepsContainerView addSubview:self.step2View];
- [self.stepsContainerView addSubview:self.step3View];
-
- // 步骤1
- [self setupStepView:self.step1View
- stepIcon:@"store_01"
- stepNumber:@"01"
- stepTitle:ASLocalizedString(@"提交材料")
- stepDuration:ASLocalizedString(@"约30分钟")
- stepDesc:ASLocalizedString(@"上传营业执照、法定代表人身份证等\n相关资质资料")
- actionText:ASLocalizedString(@"查询材料")
- action:@selector(checkMaterialsClicked:)];
-
- // 步骤2
- [self setupStepView:self.step2View
- stepIcon:@"store_02"
- stepNumber:@"02"
- stepTitle:ASLocalizedString(@"平台审核")
- stepDuration:ASLocalizedString(@"约1-3个工作日")
- stepDesc:ASLocalizedString(@"平台进行资质审核")
- actionText:ASLocalizedString(@"查询结果")
- action:@selector(checkResultClicked:)];
-
- // 步骤3
- [self setupStepView:self.step3View
- stepIcon:@"store_03"
- stepNumber:@"03"
- stepTitle:ASLocalizedString(@"完成入驻")
- stepDuration:nil
- stepDesc:ASLocalizedString(@"可以去发布产品和视频/直播带货了")
- actionText:nil
- action:nil];
- }
- - (void)setupAgreementViews {
- [self addSubview:self.agreementCheckBox];
- [self addSubview:self.agreementLabel];
- }
- - (void)setupStepView:(UIView *)stepView
- stepIcon:(NSString *)iconName
- stepNumber:(NSString *)stepNumber
- stepTitle:(NSString *)stepTitle
- stepDuration:(NSString *)stepDuration
- stepDesc:(NSString *)stepDesc
- actionText:(NSString *)actionText
- action:(SEL)action {
-
- // 步骤图标
- UIImageView *iconImageView = [[UIImageView alloc] init];
- iconImageView.image = [UIImage imageNamed:iconName];
- [stepView addSubview:iconImageView];
-
- // // 步骤编号
- // UILabel *numberLabel = [[UILabel alloc] init];
- // numberLabel.text = stepNumber;
- // numberLabel.font = [UIFont boldSystemFontOfSize:24];
- // numberLabel.textColor = [UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0];
- // [stepView addSubview:numberLabel];
-
- // 步骤标题
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.text = stepTitle;
- titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- titleLabel.textColor = [UIColor blackColor];
- [stepView addSubview:titleLabel];
-
- // 步骤时长(如果有)
- UILabel *durationLabel = nil;
- if (stepDuration) {
- durationLabel = [[UILabel alloc] init];
- durationLabel.text = stepDuration;
- durationLabel.font = [UIFont systemFontOfSize:14];
- durationLabel.textColor = [UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0];
- [stepView addSubview:durationLabel];
- }
-
- // 连接线
- UIImageView *lineImageView = [[UIImageView alloc] init];
- lineImageView.contentMode = UIViewContentModeScaleAspectFit;
- if ([stepNumber isEqualToString:@"03"]) {
- // 第三步不需要连接线
- lineImageView.hidden = YES;
- } else {
- lineImageView.image = [UIImage imageNamed:@"store_01_line"];
- }
- [stepView addSubview:lineImageView];
-
- // 步骤描述
- UILabel *descLabel = [[UILabel alloc] init];
- descLabel.text = stepDesc;
- descLabel.font = [UIFont systemFontOfSize:14];
- descLabel.textColor = [UIColor grayColor];
- descLabel.numberOfLines = 0;
- [stepView addSubview:descLabel];
-
- // 操作按钮(如果有)
- UIButton *actionButton = nil;
- if (actionText && action) {
- actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [actionButton setTitle:actionText forState:UIControlStateNormal];
- [actionButton setTitleColor:[UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
- actionButton.titleLabel.font = [UIFont systemFontOfSize:14];
- [actionButton addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
- [stepView addSubview:actionButton];
- }
-
- // 设置约束
- [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(stepView).offset(kRealValue(24));
- make.top.equalTo(stepView).offset(kRealValue(20));
- make.size.mas_equalTo(CGSizeMake(kRealValue(28), kRealValue(24)));
- }];
-
- // [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(iconImageView.mas_right).offset(kRealValue(16));
- // make.top.equalTo(stepView).offset(kRealValue(20));
- // }];
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(iconImageView.mas_right).offset(kRealValue(12));
- make.centerY.equalTo(iconImageView);
- }];
-
- if (durationLabel) {
- [durationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(titleLabel.mas_right).offset(kRealValue(12));
- make.centerY.equalTo(titleLabel);
- }];
- }
-
- if (!lineImageView.hidden) {
- [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(iconImageView).offset(kRealValue(20));
- make.top.equalTo(iconImageView.mas_bottom).offset(kRealValue(8));
- make.width.equalTo(@(kRealValue(8)));
- make.height.equalTo(@(kRealValue(70)));
- }];
- }
-
- [descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(titleLabel);
- make.right.equalTo(stepView).offset(-kRealValue(24));
- make.top.equalTo(titleLabel.mas_bottom).offset(kRealValue(8));
- }];
-
- if (actionButton) {
- [actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(titleLabel);
- make.top.equalTo(descLabel.mas_bottom).offset(kRealValue(8));
- make.bottom.equalTo(stepView).offset(-kRealValue(20));
- }];
- } else {
- [descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(stepView).offset(-kRealValue(20));
- }];
- }
- }
- - (void)setupConstraints {
-
- [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(kRealValue(90));
- make.left.right.equalTo(self).inset(12);
- make.top.mas_offset(0);
- }];
-
- [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self).inset(12);
- make.bottom.equalTo(self.agreementCheckBox.mas_top).mas_offset(-kRealValue(10));
- make.top.equalTo(self.headerImageView.mas_bottom).offset(kRealValue(10));
- }];
-
- // 头部图标
- [self.headerIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_offset(0);
- make.top.mas_offset(kRealValue(-50));
- make.width.height.equalTo(@(kRealValue(160)));
- }];
-
- // 标题
- [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.headerIconImageView.mas_right);
- make.top.mas_offset(kRealValue(21));
- }];
-
- // 副标题
- [self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.textLabel);
- make.right.mas_offset(-8);
- make.top.equalTo(self.textLabel.mas_bottom).offset(kRealValue(10));
- }];
-
- // 步骤容器
- [self.stepsContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.contentView);
- make.top.mas_offset(0);
- make.bottom.mas_offset(0);
- }];
-
- // 步骤视图
- [self.step1View mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.equalTo(self.stepsContainerView);
- }];
-
- [self.step2View mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.stepsContainerView);
- make.top.equalTo(self.step1View.mas_bottom);
- }];
-
- [self.step3View mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.stepsContainerView);
- make.top.equalTo(self.step2View.mas_bottom);
- make.bottom.equalTo(self.stepsContainerView);
- }];
-
- // 协议复选框
- [self.agreementCheckBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nextButton).offset(kRealValue(24));
- make.bottom.equalTo(self.nextButton.mas_top).offset(kRealValue(-20));
- make.width.height.equalTo(@(kRealValue(20)));
- }];
-
- // 协议标签
- [self.agreementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.agreementCheckBox.mas_right).offset(kRealValue(8));
- make.right.mas_offset(-kRealValue(24));
- make.centerY.equalTo(self.agreementCheckBox);
- }];
-
- }
- #pragma mark - Actions
- - (void)checkMaterialsClicked:(UIButton *)sender {
- // TODO: 查看材料详情
- NSLog(@"Check materials clicked");
- }
- - (void)checkResultClicked:(UIButton *)sender {
- // TODO: 查看审核结果
- NSLog(@"Check result clicked");
- }
- - (void)agreementCheckBoxClicked:(UIButton *)sender {
- self.isAgreementChecked = !self.isAgreementChecked;
- [self updateAgreementCheckBox];
- [self updateSubmitButtonState];
- }
- - (void)goNext {
- if (!self.isAgreementChecked) {
- // TODO: 显示提示信息
- NSLog(@"Please agree to the agreement first");
- return;
- }
-
- [super goNext];
- }
- - (void)agreementLabelTapped:(UITapGestureRecognizer *)gesture {
- // TODO: 显示协议详情
- NSLog(@"Agreement tapped");
- }
- #pragma mark - Private Methods
- - (void)updateAgreementCheckBox {
- NSString *imageName = self.isAgreementChecked ? @"store_check" : @"store_uncheck";
- [self.agreementCheckBox setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
- }
- - (void)updateSubmitButtonState {
- self.nextButton.enabled = self.isAgreementChecked;
- self.nextButton.alpha = self.isAgreementChecked ? 1.0 : 0.5;
- }
- #pragma mark - Lazy Loading
- - (UIImageView *)headerIconImageView {
- if (!_headerIconImageView) {
- UIImageView *headerIconImageView = [[UIImageView alloc] init];
- headerIconImageView.image = [UIImage imageNamed:@"store_header_icon"];
- headerIconImageView.contentMode = UIViewContentModeScaleAspectFit;
- _headerIconImageView = headerIconImageView;
- }
- return _headerIconImageView;
- }
- - (UIImageView *)headerImageView {
- if (!_headerImageView) {
- _headerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"store_header"]];
- _headerImageView.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _headerImageView;
- }
- - (UILabel *)textLabel {
- if (!_textLabel) {
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.text = ASLocalizedString(@"商家入驻");
- titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
- titleLabel.textColor = [UIColor whiteColor];
- _textLabel = titleLabel;
- }
- return _textLabel;
- }
- - (UILabel *)subtitleLabel {
- if (!_subtitleLabel) {
- UILabel *subtitleLabel = [[UILabel alloc] init];
- subtitleLabel.text = ASLocalizedString(@"以下是商家入驻流程,请仔细阅读");
- subtitleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
- subtitleLabel.textColor = [UIColor colorWithWhite:1.0 alpha:1.0];
- subtitleLabel.numberOfLines = 2;
- _subtitleLabel = subtitleLabel;
- }
- return _subtitleLabel;
- }
- - (UIView *)stepsContainerView {
- if (!_stepsContainerView) {
- UIView *stepsContainerView = [[UIView alloc] init];
- stepsContainerView.backgroundColor = [UIColor clearColor];
- _stepsContainerView = stepsContainerView;
- }
- return _stepsContainerView;
- }
- - (UIView *)step1View {
- if (!_step1View) {
- UIView *step1View = [[UIView alloc] init];
- step1View.backgroundColor = [UIColor clearColor];
- _step1View = step1View;
- }
- return _step1View;
- }
- - (UIView *)step2View {
- if (!_step2View) {
- UIView *step2View = [[UIView alloc] init];
- step2View.backgroundColor = [UIColor clearColor];
- _step2View = step2View;
- }
- return _step2View;
- }
- - (UIView *)step3View {
- if (!_step3View) {
- UIView *step3View = [[UIView alloc] init];
- step3View.backgroundColor = [UIColor clearColor];
- _step3View = step3View;
- }
- return _step3View;
- }
- - (UIButton *)agreementCheckBox {
- if (!_agreementCheckBox) {
- UIButton *agreementCheckBox = [UIButton buttonWithType:UIButtonTypeCustom];
- [agreementCheckBox setImage:[UIImage imageNamed:@"store_uncheck"] forState:UIControlStateNormal];
- [agreementCheckBox addTarget:self action:@selector(agreementCheckBoxClicked:) forControlEvents:UIControlEventTouchUpInside];
- _agreementCheckBox = agreementCheckBox;
- }
- return _agreementCheckBox;
- }
- - (UILabel *)agreementLabel {
- if (!_agreementLabel) {
- UILabel *agreementLabel = [[UILabel alloc] init];
-
- NSString *text = [NSString stringWithFormat:@"%@ %@",
- ASLocalizedString(@"已阅读并同意签署"),
- ASLocalizedString(@"《入驻开店服务协议》")];
-
- NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text];
-
- // 设置整体样式
- [attributedText addAttribute:NSFontAttributeName
- value:[UIFont systemFontOfSize:14]
- range:NSMakeRange(0, text.length)];
- [attributedText addAttribute:NSForegroundColorAttributeName
- value:[UIColor grayColor]
- range:NSMakeRange(0, text.length)];
-
- // 设置协议链接样式
- NSRange linkRange = [text rangeOfString:ASLocalizedString(@"《入驻开店服务协议》")];
- if (linkRange.location != NSNotFound) {
- [attributedText addAttribute:NSForegroundColorAttributeName
- value:[UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0]
- range:linkRange];
- }
-
- agreementLabel.attributedText = attributedText;
- agreementLabel.userInteractionEnabled = YES;
- agreementLabel.numberOfLines = 2;
- // 添加点击手势
- UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(agreementLabelTapped:)];
- [agreementLabel addGestureRecognizer:tapGesture];
- _agreementLabel = agreementLabel;
- }
- return _agreementLabel;
- }
- @end
|