MerchantEnrollViewController.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. //
  2. // MerchantEnrollViewController.m
  3. // BuguLive
  4. //
  5. // Created by qitewei on 2025/8/11.
  6. // Copyright © 2025 xfg. All rights reserved.
  7. //
  8. #import "MerchantEnrollViewController.h"
  9. #import "MerchantEnrollGuideView.h"
  10. #import "MerchantEnrollCheckListView.h"
  11. #import "MerchantStoreInfoView.h"
  12. #import "MerchantBusinessLicenseView.h"
  13. #import "MerchantLegalInfoView.h"
  14. #import "MerchantBankInfoView.h"
  15. #import "MerchantAdminSetupView.h"
  16. #import "MerchantPaymentView.h"
  17. #import "MerchantEnrollResultView.h"
  18. #import "NavigationBarView.h"
  19. #import "MerchantBaseEnrollContentView.h"
  20. #import "UIButton+Layout.h"
  21. @interface MerchantEnrollViewController ()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate, MerchantEnrollContentViewDelegate>
  22. @property (nonatomic, assign) MerchantEnrollStep currentStep;
  23. @property (nonatomic, strong) NavigationBarView *navBar;
  24. @property (nonatomic, strong) UIImageView *bgImageView;
  25. @property (nonatomic, strong) UILabel *titleLabel;
  26. @property (nonatomic, strong) UIStackView *stepsStackView;
  27. @property (nonatomic, strong) UIView *step1View;
  28. @property (nonatomic, strong) UIView *step2View;
  29. @property (nonatomic, strong) UIView *step3View;
  30. @property (nonatomic, strong) UIImageView *line1ImageView;
  31. @property (nonatomic, strong) UIImageView *line2ImageView;
  32. @property (nonatomic, strong) NSMutableArray<UIButton *> *buttons;
  33. @property (nonatomic, strong) JXCategoryTitleView *categoryView;
  34. @property (nonatomic, strong) JXCategoryListContainerView *containerView;
  35. @property (nonatomic, copy) NSArray *list;
  36. @property (nonatomic, strong, nullable) MerchantEnrollGuideView *guideView;
  37. @property (nonatomic, strong, nullable) MerchantEnrollCheckListView *checkListView;
  38. @property (nonatomic, strong, nullable) MerchantEnrollResultView *resultView;
  39. @end
  40. @implementation MerchantEnrollViewController
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. self.view.backgroundColor = [UIColor whiteColor];
  44. [self setupNavigationBar];
  45. [self setupStepsUI];
  46. [self showCurrentStep];
  47. }
  48. - (void)viewWillAppear:(BOOL)animated {
  49. [super viewWillAppear:animated];
  50. self.navigationController.navigationBar.hidden = YES;
  51. }
  52. - (void)viewWillDisappear:(BOOL)animated {
  53. [super viewWillDisappear:animated];
  54. self.navigationController.navigationBar.hidden = NO;
  55. }
  56. #pragma mark - UI Setup
  57. - (void)setupNavigationBar {
  58. self.title = ASLocalizedString(@"商家入驻");
  59. [self.view addSubview:self.bgImageView];
  60. [self.view addSubview:self.navBar];
  61. self.navBar.titleLabel.text = self.title;
  62. [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.right.top.mas_offset(0);
  64. make.height.mas_equalTo(self.bgImageView.height);
  65. }];
  66. [self.navBar mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.top.right.left.mas_offset(0);
  68. make.height.mas_equalTo(self.navBar.height);
  69. }];
  70. }
  71. #pragma mark - Steps UI Setup
  72. - (void)setupStepsUI {
  73. [self.view addSubview:self.categoryView];
  74. [self.view addSubview:self.stepsStackView];
  75. [self.view addSubview:self.containerView];
  76. // 创建步骤视图
  77. [self.stepsStackView addArrangedSubview:self.step1View];
  78. [self.stepsStackView addArrangedSubview:self.step2View];
  79. [self.stepsStackView addArrangedSubview:self.step3View];
  80. [self.view addSubview:self.line1ImageView];
  81. [self.view addSubview:self.line2ImageView];
  82. // 设置步骤1(选中状态)
  83. [self setupStepView:self.step1View withNumber:@"1" title:ASLocalizedString(@"提交材料") isSelected:YES];
  84. // 设置步骤2(未选中状态)
  85. [self setupStepView:self.step2View withNumber:@"2" title:ASLocalizedString(@"平台审核") isSelected:NO];
  86. // 设置步骤3(未选中状态)
  87. [self setupStepView:self.step3View withNumber:@"3" title:ASLocalizedString(@"完成入驻") isSelected:NO];
  88. [self.stepsStackView mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.equalTo(self.navBar.mas_bottom).offset(kRealValue(20));
  90. make.centerX.mas_offset(0);
  91. make.left.right.mas_offset(0);
  92. make.height.mas_equalTo(kRealValue(80));
  93. }];
  94. [self.categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.edges.mas_equalTo(self.stepsStackView);
  96. }];
  97. [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.right.bottom.mas_offset(0);
  99. make.top.equalTo(self.stepsStackView.mas_bottom);
  100. }];
  101. [self.line1ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.size.mas_equalTo(CGSizeMake(kRealValue(70), kRealValue(8)));
  103. make.left.mas_offset(kRealValue(90));
  104. make.centerY.equalTo(self.stepsStackView).mas_offset(-kRealValue(20));
  105. }];
  106. [self.line2ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.size.mas_equalTo(CGSizeMake(kRealValue(70), kRealValue(8)));
  108. make.right.mas_offset(kRealValue(-90));
  109. make.centerY.equalTo(self.line1ImageView);
  110. }];
  111. }
  112. - (void)setupStepView:(UIView *)stepView withNumber:(NSString *)number title:(NSString *)title isSelected:(BOOL)isSelected {
  113. NSString *imageName = [NSString stringWithFormat:@"store_step_%@", number];
  114. NSString *selImageName = [NSString stringWithFormat:@"store_step_%@_sel", number];
  115. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  116. [button setTitle:title forState:UIControlStateNormal];
  117. button.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
  118. [button setTitleColor:[UIColor colorWithHexString:@"#777777"] forState:UIControlStateNormal];
  119. [button setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
  120. [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
  121. [button setImage:[UIImage imageNamed:selImageName] forState:UIControlStateSelected];
  122. button.selected = isSelected;
  123. [button layoutImageTopSpace:3];
  124. // 添加视图
  125. [stepView addSubview:button];
  126. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.edges.mas_offset(0);
  128. }];
  129. button.tag = [number integerValue];
  130. [self.buttons addObject:button];
  131. }
  132. - (void)showCurrentStep {
  133. if (self.guideView) {
  134. [self.guideView removeFromSuperview];
  135. self.guideView = nil;
  136. }
  137. if (self.checkListView) {
  138. [self.checkListView removeFromSuperview];
  139. self.guideView = nil;
  140. }
  141. if (self.currentStep <= MerchantEnrollStepCheckList) {
  142. self.stepsStackView.hidden = YES;
  143. self.containerView.hidden = YES;
  144. self.line1ImageView.hidden = YES;
  145. self.line2ImageView.hidden = YES;
  146. MerchantBaseEnrollContentView *contentView;
  147. switch (self.currentStep) {
  148. case MerchantEnrollStepGuide:
  149. self.guideView = [[MerchantEnrollGuideView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-self.bgImageView.height+kRealValue(60))];
  150. contentView = self.guideView;
  151. break;
  152. case MerchantEnrollStepCheckList:
  153. self.checkListView = [[MerchantEnrollCheckListView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-self.bgImageView.height+kRealValue(100))];
  154. contentView = self.checkListView;
  155. break;
  156. default:
  157. break;
  158. }
  159. if (contentView) {
  160. contentView.currentStep = self.currentStep;
  161. contentView.delegate = self;
  162. [self.view addSubview:contentView];
  163. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.size.mas_equalTo(contentView.size);
  165. make.bottom.inset(0);
  166. make.centerX.mas_offset(0);
  167. }];
  168. }
  169. } else {
  170. self.line1ImageView.hidden = NO;
  171. self.line2ImageView.hidden = NO;
  172. if (self.buttons.count > 1) {
  173. UIButton *second = self.buttons[1];
  174. second.selected = self.currentStep >= MerchantEnrollStepWatingForReview;
  175. }
  176. NSString *name = self.currentStep >= MerchantEnrollStepWatingForReview ? @"store_line_blue" : @"store_line_gray(1)";
  177. self.line2ImageView.image = [UIImage imageNamed:name];
  178. UIButton *last = self.buttons.lastObject;
  179. last.selected = self.currentStep >= MerchantEnrollStepComplete;
  180. if (self.currentStep > MerchantEnrollStepCheckList && self.currentStep < MerchantEnrollStepWatingForReview) {
  181. self.stepsStackView.hidden = NO;
  182. self.containerView.hidden = NO;
  183. [self.categoryView selectItemAtIndex:self.currentStep-2];
  184. } else {
  185. self.stepsStackView.hidden = NO;
  186. self.containerView.hidden = YES;
  187. switch (self.currentStep) {
  188. case MerchantEnrollStepWatingForReview:
  189. [self showEnrollResult:MerchantEnrollResultPending];
  190. break;
  191. case MerchantEnrollStepReviewFail:
  192. [self showEnrollResult:MerchantEnrollResultFailed];
  193. break;
  194. case MerchantEnrollStepComplete:
  195. [self showEnrollResult:MerchantEnrollResultSuccess];
  196. break;
  197. default:
  198. break;
  199. }
  200. }
  201. }
  202. }
  203. - (void)backButtonClicked:(UIButton *)sender {
  204. [self.navigationController popViewControllerAnimated:YES];
  205. }
  206. - (void)helpButtonClicked:(UIButton *)sender {
  207. // TODO: 显示帮助页面
  208. NSLog(@"Help button clicked");
  209. }
  210. - (void)showEnrollResult:(MerchantEnrollResultType)resultType {
  211. if (_resultView) {
  212. [_resultView removeFromSuperview];
  213. _resultView = nil;
  214. }
  215. // 添加结果页面
  216. MerchantEnrollResultView *resultView = [[MerchantEnrollResultView alloc]
  217. initWithResultType:resultType
  218. frame:CGRectMake(0, 0, SCREEN_WIDTH-24, SCREEN_HEIGHT-self.bgImageView.height+kRealValue(16))];
  219. [self.view addSubview:resultView];
  220. resultView.delegate = self;
  221. _resultView = resultView;
  222. [resultView mas_makeConstraints:^(MASConstraintMaker *make) {
  223. make.size.mas_equalTo(resultView.size);
  224. make.bottom.inset(0);
  225. make.centerX.mas_offset(0);
  226. }];
  227. }
  228. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  229. }
  230. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
  231. MerchantBaseEnrollContentView *contentView;
  232. MerchantEnrollStep step = index + 2;
  233. CGFloat height = SCREEN_HEIGHT-self.bgImageView.height+kRealValue(16);
  234. CGFloat width = SCREEN_WIDTH;
  235. CGRect frame = CGRectMake(0, 0, width, height);
  236. switch (step) {
  237. case MerchantEnrollStepStoreInfo:
  238. contentView = [[MerchantStoreInfoView alloc] initWithFrame:frame];
  239. break;
  240. case MerchantEnrollStepBusinessLicense:
  241. contentView = [[MerchantBusinessLicenseView alloc] initWithFrame:frame];
  242. break;
  243. case MerchantEnrollStepLegalInfo:
  244. contentView = [[MerchantLegalInfoView alloc] initWithFrame:frame];
  245. break;
  246. case MerchantEnrollStepBank:
  247. contentView = [[MerchantBankInfoView alloc] initWithFrame:frame];
  248. break;
  249. case MerchantEnrollStepSetAdmin:
  250. contentView = [[MerchantAdminSetupView alloc] initWithFrame:frame];
  251. break;
  252. case MerchantEnrollStepPay:
  253. contentView = [[MerchantPaymentView alloc] initWithFrame:frame];
  254. break;
  255. default:
  256. break;
  257. }
  258. contentView.delegate = self;
  259. contentView.currentStep = step;
  260. return contentView;
  261. }
  262. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
  263. return self.list.count;
  264. }
  265. #pragma mark - MerchantEnrollContentViewDelegate
  266. - (void)onMerchantEnrollGotoNextButtonClick {
  267. self.currentStep++;
  268. [self showCurrentStep];
  269. }
  270. - (void)onMerchantEnrollResultNextButtonClick:(MerchantEnrollResultType)type {
  271. switch (type) {
  272. case MerchantEnrollResultPending:
  273. [self.navigationController popViewControllerAnimated:YES];
  274. break;
  275. case MerchantEnrollResultFailed:
  276. self.currentStep = MerchantEnrollStepStoreInfo;
  277. [self showCurrentStep];
  278. break;
  279. case MerchantEnrollResultSuccess:
  280. [self.navigationController popViewControllerAnimated:YES];
  281. break;
  282. }
  283. }
  284. - (NavigationBarView *)navBar {
  285. if (!_navBar) {
  286. _navBar = [[NavigationBarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, STATUS_BAR_HEIGHT+44)];
  287. _navBar.backgroundColor = UIColor.clearColor;
  288. _navBar.contentView.backgroundColor = UIColor.clearColor;
  289. }
  290. return _navBar;
  291. }
  292. - (UIImageView *)bgImageView {
  293. if (!_bgImageView) {
  294. _bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kRealValue(200))];
  295. _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
  296. _bgImageView.image = [UIImage imageNamed:@"store_header_bg"];
  297. }
  298. return _bgImageView;
  299. }
  300. - (UIStackView *)stepsStackView {
  301. if (!_stepsStackView) {
  302. UIStackView *stackView = [[UIStackView alloc] init];
  303. stackView.axis = UILayoutConstraintAxisHorizontal;
  304. stackView.distribution = UIStackViewDistributionFill;
  305. stackView.alignment = UIStackViewAlignmentCenter;
  306. stackView.spacing = 0;
  307. _stepsStackView = stackView;
  308. }
  309. return _stepsStackView;
  310. }
  311. - (UIView *)step1View {
  312. if (!_step1View) {
  313. _step1View = [[UIView alloc] init];
  314. }
  315. return _step1View;
  316. }
  317. - (UIView *)step2View {
  318. if (!_step2View) {
  319. _step2View = [[UIView alloc] init];
  320. }
  321. return _step2View;
  322. }
  323. - (UIView *)step3View {
  324. if (!_step3View) {
  325. _step3View = [[UIView alloc] init];
  326. }
  327. return _step3View;
  328. }
  329. - (UIImageView *)line1ImageView {
  330. if (!_line1ImageView) {
  331. _line1ImageView = [[UIImageView alloc] init];
  332. _line1ImageView.image = [UIImage imageNamed:@"store_line_blue"];
  333. _line1ImageView.contentMode = UIViewContentModeScaleAspectFit;
  334. }
  335. return _line1ImageView;
  336. }
  337. - (UIImageView *)line2ImageView {
  338. if (!_line2ImageView) {
  339. _line2ImageView = [[UIImageView alloc] init];
  340. _line2ImageView.image = [UIImage imageNamed:@"store_line_gray(1)"];
  341. _line2ImageView.contentMode = UIViewContentModeScaleAspectFit;
  342. }
  343. return _line2ImageView;
  344. }
  345. - (JXCategoryTitleView *)categoryView {
  346. if (!_categoryView) {
  347. NSMutableArray *array = [NSMutableArray array];
  348. for (NSNumber *num in self.list) {
  349. [array addObject:[NSString stringWithFormat:@"%ld", [num integerValue]]];
  350. }
  351. _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
  352. _categoryView.delegate = self;
  353. _categoryView.titles = array;
  354. _categoryView.listContainer = self.containerView;
  355. _categoryView.hidden = YES;
  356. }
  357. return _categoryView;
  358. }
  359. - (JXCategoryListContainerView *)containerView {
  360. if (!_containerView) {
  361. _containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
  362. }
  363. return _containerView;
  364. }
  365. - (NSArray *)list {
  366. if (!_list) {
  367. _list = @[
  368. @(MerchantEnrollStepStoreInfo),
  369. @(MerchantEnrollStepBusinessLicense),
  370. @(MerchantEnrollStepLegalInfo),
  371. @(MerchantEnrollStepBank),
  372. @(MerchantEnrollStepSetAdmin),
  373. @(MerchantEnrollStepPay)
  374. ];
  375. }
  376. return _list;
  377. }
  378. - (NSMutableArray<UIButton *> *)buttons {
  379. if (!_buttons) {
  380. _buttons = [NSMutableArray array];
  381. }
  382. return _buttons;
  383. }
  384. @end