// // MerchantEnrollResultView.m // merchant // // Created by qitewei on 2025/8/14. // Copyright © 2025 xfg. All rights reserved. // #import "MerchantEnrollResultView.h" #import "UIView+Extention.h" @implementation MerchantEnrollResultView - (instancetype)initWithResultType:(MerchantEnrollResultType)resultType frame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.resultType = resultType; [self setupUI]; [self setupConstraints]; [self configureForResultType]; [self addGradientLayerWithColors:@[ [UIColor colorWithHexString:@"#ECF4FF"], [UIColor colorWithHexString:@"#ffffff"], ] direction:GradientLayerDirection_V frame:frame roundingCorners:UIRectCornerAllCorners cornerRadii:16]; } return self; } - (instancetype)initWithFrame:(CGRect)frame { return [self initWithResultType:MerchantEnrollResultSuccess frame:frame]; } - (void)setupUI { self.backgroundColor = [UIColor clearColor]; // 添加状态图标 [self.contentView addSubview:self.statusIconView]; // 添加主要文本 [self.contentView addSubview:self.mainMessageLabel]; // 添加副文本 [self.contentView addSubview:self.subMessageLabel]; // 添加失败原因标签(仅失败状态需要) [self.contentView addSubview:self.failureReasonLabel]; } - (void)setupConstraints { // 状态图标 [self.statusIconView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.top.equalTo(self.contentView).offset(kRealValue(80)); make.size.mas_equalTo(CGSizeMake(kRealValue(80), kRealValue(80))); }]; // 主要文本 [self.mainMessageLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.left.greaterThanOrEqualTo(self.contentView).offset(kRealValue(40)); make.right.lessThanOrEqualTo(self.contentView).offset(-kRealValue(40)); make.top.equalTo(self.statusIconView.mas_bottom).offset(kRealValue(32)); }]; // 副文本 [self.subMessageLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.left.greaterThanOrEqualTo(self.contentView).offset(kRealValue(40)); make.right.lessThanOrEqualTo(self.contentView).offset(-kRealValue(40)); make.top.equalTo(self.mainMessageLabel.mas_bottom).offset(kRealValue(16)); }]; // 失败原因标签 [self.failureReasonLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentView); make.left.greaterThanOrEqualTo(self.contentView).offset(kRealValue(40)); make.right.lessThanOrEqualTo(self.contentView).offset(-kRealValue(40)); make.top.equalTo(self.subMessageLabel.mas_bottom).offset(kRealValue(24)); make.bottom.equalTo(self.contentView).offset(-kRealValue(20)); }]; } - (void)configureForResultType { switch (self.resultType) { case MerchantEnrollResultSuccess: [self configureSuccessState]; break; case MerchantEnrollResultPending: [self configurePendingState]; break; case MerchantEnrollResultFailed: [self configureFailedState]; break; } } - (void)configureSuccessState { // 成功状态配置 self.statusIconView.image = [UIImage imageNamed:@"store_step_done"]; self.mainMessageLabel.text = ASLocalizedString(@"已通过审核,完成入驻!"); self.mainMessageLabel.textColor = [UIColor blackColor]; self.subMessageLabel.text = ASLocalizedString(@"立即去发布产品吧~"); self.subMessageLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"]; self.failureReasonLabel.hidden = YES; [self.nextButton setTitle:ASLocalizedString(@"去发布产品") forState:UIControlStateNormal]; self.nextButton.backgroundColor = [UIColor colorWithHexString:@"#1A65FF"]; } - (void)configurePendingState { // 等待审核状态配置 self.statusIconView.image = [UIImage imageNamed:@"img_store_wait"]; self.mainMessageLabel.text = ASLocalizedString(@"已提交成功,请耐心等待审核!"); self.mainMessageLabel.textColor = [UIColor blackColor]; self.subMessageLabel.text = ASLocalizedString(@"审核约1-3个工作日"); self.subMessageLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"]; self.failureReasonLabel.hidden = YES; [self.nextButton setTitle:ASLocalizedString(@"返回") forState:UIControlStateNormal]; self.nextButton.backgroundColor = [UIColor colorWithHexString:@"#999999"]; } - (void)configureFailedState { // 审核失败状态配置 self.statusIconView.image = [UIImage imageNamed:@"store_review_error"]; self.mainMessageLabel.text = ASLocalizedString(@"审核未通过!请修改以下资料:"); self.mainMessageLabel.textColor = [UIColor redColor]; self.subMessageLabel.hidden = YES; self.failureReasonLabel.hidden = NO; self.failureReasonLabel.text = [NSString stringWithFormat:@"%@\n%@", ASLocalizedString(@"1、资料不一致。"), ASLocalizedString(@"2、未收到保证金。")]; [self.nextButton setTitle:ASLocalizedString(@"去修改") forState:UIControlStateNormal]; self.nextButton.backgroundColor = [UIColor colorWithHexString:@"#1A65FF"]; } #pragma mark - Actions - (void)goNext { switch (self.resultType) { case MerchantEnrollResultSuccess: // TODO: 跳转到产品发布页面 NSLog(@"Go to publish product"); break; case MerchantEnrollResultPending: // TODO: 返回主页或关闭页面 NSLog(@"Return to main page"); break; case MerchantEnrollResultFailed: // TODO: 返回编辑资料页面 NSLog(@"Go to edit information"); break; } if (self.delegate && [self.delegate respondsToSelector:@selector(onMerchantEnrollResultNextButtonClick:)]) { [self.delegate onMerchantEnrollResultNextButtonClick:self.resultType]; } } #pragma mark - Lazy Loading - (UIImageView *)statusIconView { if (!_statusIconView) { _statusIconView = [[UIImageView alloc] init]; _statusIconView.contentMode = UIViewContentModeScaleAspectFit; } return _statusIconView; } - (UILabel *)mainMessageLabel { if (!_mainMessageLabel) { _mainMessageLabel = [[UILabel alloc] init]; _mainMessageLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium]; _mainMessageLabel.textColor = [UIColor blackColor]; _mainMessageLabel.textAlignment = NSTextAlignmentCenter; _mainMessageLabel.numberOfLines = 0; } return _mainMessageLabel; } - (UILabel *)subMessageLabel { if (!_subMessageLabel) { _subMessageLabel = [[UILabel alloc] init]; _subMessageLabel.font = [UIFont systemFontOfSize:16]; _subMessageLabel.textColor = [UIColor colorWithHexString:@"#1A65FF"]; _subMessageLabel.textAlignment = NSTextAlignmentCenter; _subMessageLabel.numberOfLines = 0; } return _subMessageLabel; } - (UILabel *)failureReasonLabel { if (!_failureReasonLabel) { _failureReasonLabel = [[UILabel alloc] init]; _failureReasonLabel.font = [UIFont systemFontOfSize:16]; _failureReasonLabel.textColor = [UIColor blackColor]; _failureReasonLabel.textAlignment = NSTextAlignmentLeft; _failureReasonLabel.numberOfLines = 0; _failureReasonLabel.hidden = YES; } return _failureReasonLabel; } @end