MerchantEnrollGuideView.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. //
  2. // MerchantEnrollGuideView.m
  3. // BuguLive
  4. //
  5. // Created by qitewei on 2025/8/11.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantEnrollGuideView.h"
  9. #import "UIView+Extention.h"
  10. @implementation MerchantEnrollGuideView
  11. - (instancetype)initWithFrame:(CGRect)frame
  12. {
  13. self = [super initWithFrame:frame];
  14. if (self) {
  15. [self setupUI];
  16. [self setupConstraints];
  17. [self updateSubmitButtonState];
  18. }
  19. return self;
  20. }
  21. - (void)setupUI {
  22. // 添加头部背景和内容
  23. [self addSubview:self.headerImageView];
  24. [self.headerImageView addSubview:self.headerIconImageView];
  25. [self.headerImageView addSubview:self.textLabel];
  26. [self.headerImageView addSubview:self.subtitleLabel];
  27. // 添加scrollView
  28. [self addSubview:self.scrollView];
  29. [self.scrollView addSubview:self.contentView];
  30. // 添加步骤容器
  31. [self.contentView addSubview:self.stepsContainerView];
  32. [self setupStepsViews];
  33. // 添加协议和按钮
  34. [self setupAgreementViews];
  35. }
  36. - (void)setupStepsViews {
  37. [self.stepsContainerView addSubview:self.step1View];
  38. [self.stepsContainerView addSubview:self.step2View];
  39. [self.stepsContainerView addSubview:self.step3View];
  40. // 步骤1
  41. [self setupStepView:self.step1View
  42. stepIcon:@"store_01"
  43. stepNumber:@"01"
  44. stepTitle:ASLocalizedString(@"提交材料")
  45. stepDuration:ASLocalizedString(@"约30分钟")
  46. stepDesc:ASLocalizedString(@"上传营业执照、法定代表人身份证等\n相关资质资料")
  47. actionText:ASLocalizedString(@"查询材料")
  48. action:@selector(checkMaterialsClicked:)];
  49. // 步骤2
  50. [self setupStepView:self.step2View
  51. stepIcon:@"store_02"
  52. stepNumber:@"02"
  53. stepTitle:ASLocalizedString(@"平台审核")
  54. stepDuration:ASLocalizedString(@"约1-3个工作日")
  55. stepDesc:ASLocalizedString(@"平台进行资质审核")
  56. actionText:ASLocalizedString(@"查询结果")
  57. action:@selector(checkResultClicked:)];
  58. // 步骤3
  59. [self setupStepView:self.step3View
  60. stepIcon:@"store_03"
  61. stepNumber:@"03"
  62. stepTitle:ASLocalizedString(@"完成入驻")
  63. stepDuration:nil
  64. stepDesc:ASLocalizedString(@"可以去发布产品和视频/直播带货了")
  65. actionText:nil
  66. action:nil];
  67. }
  68. - (void)setupAgreementViews {
  69. [self addSubview:self.agreementCheckBox];
  70. [self addSubview:self.agreementLabel];
  71. }
  72. - (void)setupStepView:(UIView *)stepView
  73. stepIcon:(NSString *)iconName
  74. stepNumber:(NSString *)stepNumber
  75. stepTitle:(NSString *)stepTitle
  76. stepDuration:(NSString *)stepDuration
  77. stepDesc:(NSString *)stepDesc
  78. actionText:(NSString *)actionText
  79. action:(SEL)action {
  80. // 步骤图标
  81. UIImageView *iconImageView = [[UIImageView alloc] init];
  82. iconImageView.image = [UIImage imageNamed:iconName];
  83. [stepView addSubview:iconImageView];
  84. // // 步骤编号
  85. // UILabel *numberLabel = [[UILabel alloc] init];
  86. // numberLabel.text = stepNumber;
  87. // numberLabel.font = [UIFont boldSystemFontOfSize:24];
  88. // numberLabel.textColor = [UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0];
  89. // [stepView addSubview:numberLabel];
  90. // 步骤标题
  91. UILabel *titleLabel = [[UILabel alloc] init];
  92. titleLabel.text = stepTitle;
  93. titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  94. titleLabel.textColor = [UIColor blackColor];
  95. [stepView addSubview:titleLabel];
  96. // 步骤时长(如果有)
  97. UILabel *durationLabel = nil;
  98. if (stepDuration) {
  99. durationLabel = [[UILabel alloc] init];
  100. durationLabel.text = stepDuration;
  101. durationLabel.font = [UIFont systemFontOfSize:14];
  102. durationLabel.textColor = [UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0];
  103. [stepView addSubview:durationLabel];
  104. }
  105. // 连接线
  106. UIImageView *lineImageView = [[UIImageView alloc] init];
  107. if ([stepNumber isEqualToString:@"03"]) {
  108. // 第三步不需要连接线
  109. lineImageView.hidden = YES;
  110. } else {
  111. lineImageView.image = [UIImage imageNamed:@"store_line_blue"];
  112. }
  113. [stepView addSubview:lineImageView];
  114. // 步骤描述
  115. UILabel *descLabel = [[UILabel alloc] init];
  116. descLabel.text = stepDesc;
  117. descLabel.font = [UIFont systemFontOfSize:14];
  118. descLabel.textColor = [UIColor grayColor];
  119. descLabel.numberOfLines = 0;
  120. [stepView addSubview:descLabel];
  121. // 操作按钮(如果有)
  122. UIButton *actionButton = nil;
  123. if (actionText && action) {
  124. actionButton = [UIButton buttonWithType:UIButtonTypeCustom];
  125. [actionButton setTitle:actionText forState:UIControlStateNormal];
  126. [actionButton setTitleColor:[UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
  127. actionButton.titleLabel.font = [UIFont systemFontOfSize:14];
  128. [actionButton addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
  129. [stepView addSubview:actionButton];
  130. }
  131. // 设置约束
  132. [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.left.equalTo(stepView).offset(kRealValue(24));
  134. make.top.equalTo(stepView).offset(kRealValue(20));
  135. make.size.mas_equalTo(CGSizeMake(kRealValue(28), kRealValue(24)));
  136. }];
  137. // [numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  138. // make.left.equalTo(iconImageView.mas_right).offset(kRealValue(16));
  139. // make.top.equalTo(stepView).offset(kRealValue(20));
  140. // }];
  141. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.left.equalTo(iconImageView.mas_right).offset(kRealValue(12));
  143. make.centerY.equalTo(iconImageView);
  144. }];
  145. if (durationLabel) {
  146. [durationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  147. make.left.equalTo(titleLabel.mas_right).offset(kRealValue(12));
  148. make.centerY.equalTo(titleLabel);
  149. }];
  150. }
  151. if (!lineImageView.hidden) {
  152. [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  153. make.left.equalTo(iconImageView).offset(kRealValue(20));
  154. make.top.equalTo(iconImageView.mas_bottom).offset(kRealValue(8));
  155. make.width.equalTo(@(kRealValue(2)));
  156. make.height.equalTo(@(kRealValue(40)));
  157. }];
  158. }
  159. [descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.left.equalTo(titleLabel);
  161. make.right.equalTo(stepView).offset(-kRealValue(24));
  162. make.top.equalTo(titleLabel.mas_bottom).offset(kRealValue(8));
  163. }];
  164. if (actionButton) {
  165. [actionButton mas_makeConstraints:^(MASConstraintMaker *make) {
  166. make.left.equalTo(titleLabel);
  167. make.top.equalTo(descLabel.mas_bottom).offset(kRealValue(8));
  168. make.bottom.equalTo(stepView).offset(-kRealValue(20));
  169. }];
  170. } else {
  171. [descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.bottom.equalTo(stepView).offset(-kRealValue(20));
  173. }];
  174. }
  175. }
  176. - (void)setupConstraints {
  177. [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.height.mas_equalTo(kRealValue(90));
  179. make.left.right.equalTo(self).inset(12);
  180. make.top.mas_offset(0);
  181. }];
  182. [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
  183. make.left.right.equalTo(self).inset(12);
  184. make.bottom.equalTo(self.agreementCheckBox.mas_top).mas_offset(-kRealValue(10));
  185. make.top.equalTo(self.headerImageView.mas_bottom).offset(kRealValue(10));
  186. }];
  187. // 头部图标
  188. [self.headerIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  189. make.left.mas_offset(0);
  190. make.top.mas_offset(kRealValue(-50));
  191. make.width.height.equalTo(@(kRealValue(160)));
  192. }];
  193. // 标题
  194. [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  195. make.left.equalTo(self.headerIconImageView.mas_right);
  196. make.top.mas_offset(kRealValue(21));
  197. }];
  198. // 副标题
  199. [self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  200. make.left.equalTo(self.textLabel);
  201. make.right.mas_offset(-8);
  202. make.top.equalTo(self.textLabel.mas_bottom).offset(kRealValue(10));
  203. }];
  204. // 步骤容器
  205. [self.stepsContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  206. make.left.right.equalTo(self.contentView);
  207. make.top.mas_offset(0);
  208. make.bottom.mas_offset(0);
  209. }];
  210. // 步骤视图
  211. [self.step1View mas_makeConstraints:^(MASConstraintMaker *make) {
  212. make.left.right.top.equalTo(self.stepsContainerView);
  213. }];
  214. [self.step2View mas_makeConstraints:^(MASConstraintMaker *make) {
  215. make.left.right.equalTo(self.stepsContainerView);
  216. make.top.equalTo(self.step1View.mas_bottom);
  217. }];
  218. [self.step3View mas_makeConstraints:^(MASConstraintMaker *make) {
  219. make.left.right.equalTo(self.stepsContainerView);
  220. make.top.equalTo(self.step2View.mas_bottom);
  221. make.bottom.equalTo(self.stepsContainerView);
  222. }];
  223. // 协议复选框
  224. [self.agreementCheckBox mas_makeConstraints:^(MASConstraintMaker *make) {
  225. make.left.equalTo(self.nextButton).offset(kRealValue(24));
  226. make.bottom.equalTo(self.nextButton.mas_top).offset(kRealValue(-20));
  227. make.width.height.equalTo(@(kRealValue(20)));
  228. }];
  229. // 协议标签
  230. [self.agreementLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  231. make.left.equalTo(self.agreementCheckBox.mas_right).offset(kRealValue(8));
  232. make.right.mas_offset(-kRealValue(24));
  233. make.centerY.equalTo(self.agreementCheckBox);
  234. }];
  235. }
  236. #pragma mark - Actions
  237. - (void)checkMaterialsClicked:(UIButton *)sender {
  238. // TODO: 查看材料详情
  239. NSLog(@"Check materials clicked");
  240. }
  241. - (void)checkResultClicked:(UIButton *)sender {
  242. // TODO: 查看审核结果
  243. NSLog(@"Check result clicked");
  244. }
  245. - (void)agreementCheckBoxClicked:(UIButton *)sender {
  246. self.isAgreementChecked = !self.isAgreementChecked;
  247. [self updateAgreementCheckBox];
  248. [self updateSubmitButtonState];
  249. }
  250. - (void)nextButtonTapped:(UIButton *)sender {
  251. if (!self.isAgreementChecked) {
  252. // TODO: 显示提示信息
  253. NSLog(@"Please agree to the agreement first");
  254. return;
  255. }
  256. [super nextButtonTapped:sender];
  257. }
  258. - (void)agreementLabelTapped:(UITapGestureRecognizer *)gesture {
  259. // TODO: 显示协议详情
  260. NSLog(@"Agreement tapped");
  261. }
  262. #pragma mark - Private Methods
  263. - (void)updateAgreementCheckBox {
  264. NSString *imageName = self.isAgreementChecked ? @"store_check" : @"store_uncheck";
  265. [self.agreementCheckBox setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  266. }
  267. - (void)updateSubmitButtonState {
  268. self.nextButton.enabled = self.isAgreementChecked;
  269. self.nextButton.alpha = self.isAgreementChecked ? 1.0 : 0.5;
  270. }
  271. #pragma mark - Lazy Loading
  272. - (UIImageView *)headerIconImageView {
  273. if (!_headerIconImageView) {
  274. UIImageView *headerIconImageView = [[UIImageView alloc] init];
  275. headerIconImageView.image = [UIImage imageNamed:@"store_header_icon"];
  276. headerIconImageView.contentMode = UIViewContentModeScaleAspectFit;
  277. _headerIconImageView = headerIconImageView;
  278. }
  279. return _headerIconImageView;
  280. }
  281. - (UIImageView *)headerImageView {
  282. if (!_headerImageView) {
  283. _headerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"store_header"]];
  284. _headerImageView.contentMode = UIViewContentModeScaleAspectFill;
  285. }
  286. return _headerImageView;
  287. }
  288. - (UILabel *)textLabel {
  289. if (!_textLabel) {
  290. UILabel *titleLabel = [[UILabel alloc] init];
  291. titleLabel.text = ASLocalizedString(@"商家入驻");
  292. titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
  293. titleLabel.textColor = [UIColor whiteColor];
  294. _textLabel = titleLabel;
  295. }
  296. return _textLabel;
  297. }
  298. - (UILabel *)subtitleLabel {
  299. if (!_subtitleLabel) {
  300. UILabel *subtitleLabel = [[UILabel alloc] init];
  301. subtitleLabel.text = ASLocalizedString(@"以下是商家入驻流程,请仔细阅读");
  302. subtitleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
  303. subtitleLabel.textColor = [UIColor colorWithWhite:1.0 alpha:1.0];
  304. subtitleLabel.numberOfLines = 2;
  305. _subtitleLabel = subtitleLabel;
  306. }
  307. return _subtitleLabel;
  308. }
  309. - (UIView *)stepsContainerView {
  310. if (!_stepsContainerView) {
  311. UIView *stepsContainerView = [[UIView alloc] init];
  312. stepsContainerView.backgroundColor = [UIColor clearColor];
  313. _stepsContainerView = stepsContainerView;
  314. }
  315. return _stepsContainerView;
  316. }
  317. - (UIView *)step1View {
  318. if (!_step1View) {
  319. UIView *step1View = [[UIView alloc] init];
  320. step1View.backgroundColor = [UIColor clearColor];
  321. _step1View = step1View;
  322. }
  323. return _step1View;
  324. }
  325. - (UIView *)step2View {
  326. if (!_step2View) {
  327. UIView *step2View = [[UIView alloc] init];
  328. step2View.backgroundColor = [UIColor clearColor];
  329. _step2View = step2View;
  330. }
  331. return _step2View;
  332. }
  333. - (UIView *)step3View {
  334. if (!_step3View) {
  335. UIView *step3View = [[UIView alloc] init];
  336. step3View.backgroundColor = [UIColor clearColor];
  337. _step3View = step3View;
  338. }
  339. return _step3View;
  340. }
  341. - (UIButton *)agreementCheckBox {
  342. if (!_agreementCheckBox) {
  343. UIButton *agreementCheckBox = [UIButton buttonWithType:UIButtonTypeCustom];
  344. [agreementCheckBox setImage:[UIImage imageNamed:@"store_uncheck"] forState:UIControlStateNormal];
  345. [agreementCheckBox addTarget:self action:@selector(agreementCheckBoxClicked:) forControlEvents:UIControlEventTouchUpInside];
  346. _agreementCheckBox = agreementCheckBox;
  347. }
  348. return _agreementCheckBox;
  349. }
  350. - (UILabel *)agreementLabel {
  351. if (!_agreementLabel) {
  352. UILabel *agreementLabel = [[UILabel alloc] init];
  353. NSString *text = [NSString stringWithFormat:@"%@ %@",
  354. ASLocalizedString(@"已阅读并同意签署"),
  355. ASLocalizedString(@"《入驻开店服务协议》")];
  356. NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text];
  357. // 设置整体样式
  358. [attributedText addAttribute:NSFontAttributeName
  359. value:[UIFont systemFontOfSize:14]
  360. range:NSMakeRange(0, text.length)];
  361. [attributedText addAttribute:NSForegroundColorAttributeName
  362. value:[UIColor grayColor]
  363. range:NSMakeRange(0, text.length)];
  364. // 设置协议链接样式
  365. NSRange linkRange = [text rangeOfString:ASLocalizedString(@"《入驻开店服务协议》")];
  366. if (linkRange.location != NSNotFound) {
  367. [attributedText addAttribute:NSForegroundColorAttributeName
  368. value:[UIColor colorWithRed:0.26 green:0.46 blue:1.0 alpha:1.0]
  369. range:linkRange];
  370. }
  371. agreementLabel.attributedText = attributedText;
  372. agreementLabel.userInteractionEnabled = YES;
  373. agreementLabel.numberOfLines = 2;
  374. // 添加点击手势
  375. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(agreementLabelTapped:)];
  376. [agreementLabel addGestureRecognizer:tapGesture];
  377. _agreementLabel = agreementLabel;
  378. }
  379. return _agreementLabel;
  380. }
  381. @end