MerchantBaseEnrollContentView.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //
  2. // MerchantBaseEnrollContentView.m
  3. // merchant
  4. //
  5. // Created by qitewei on 2025/8/18.
  6. //
  7. #import "MerchantBaseEnrollContentView.h"
  8. #import "UIView+Extention.h"
  9. @interface MerchantBaseEnrollContentView ()
  10. @property (nonatomic, copy) DidPickImageAction pickImageAction;
  11. @end
  12. @implementation MerchantBaseEnrollContentView
  13. - (instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. self.backgroundColor = UIColor.clearColor;
  18. [self addGradientLayerWithColors:@[
  19. [UIColor colorWithHexString:@"#ECF4FF"],
  20. [UIColor colorWithHexString:@"#ffffff"],
  21. ] direction:GradientLayerDirection_V
  22. frame:CGRectMake(12, 0, frame.size.width-24, frame.size.height)
  23. roundingCorners:UIRectCornerAllCorners
  24. cornerRadii:16];
  25. // 添加标题
  26. [self addSubview:self.titleLabel];
  27. // 添加scrollView
  28. [self addSubview:self.scrollView];
  29. [self addSubview:self.nextButton];
  30. [self.scrollView addSubview:self.contentView];
  31. // 标题
  32. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.mas_offset(kRealValue(30));
  34. make.centerX.mas_offset(0);
  35. }];
  36. // ScrollView
  37. [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.centerX.equalTo(self);
  39. make.width.mas_equalTo(self.width-24);
  40. make.bottom.equalTo(self.nextButton.mas_top).mas_offset(-kRealValue(20));
  41. make.top.equalTo(self.titleLabel.mas_bottom).offset(kRealValue(10));
  42. }];
  43. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.edges.equalTo(self.scrollView);
  45. make.width.equalTo(self.scrollView);
  46. }];
  47. // 提交按钮
  48. [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.centerX.mas_offset(0);
  50. make.size.mas_equalTo(self.nextButton.size);
  51. make.bottom.mas_offset(kRealValue(-20));
  52. }];
  53. }
  54. return self;
  55. }
  56. - (void)nextButtonTapped:(UIButton *)sender {
  57. [self goNext];
  58. }
  59. - (void)goNext {
  60. if (self.delegate && [self.delegate respondsToSelector:@selector(onMerchantEnrollGotoNextButtonClick)]) {
  61. [self.delegate onMerchantEnrollGotoNextButtonClick];
  62. }
  63. }
  64. - (UIView *)listView {
  65. return self;
  66. }
  67. - (void)setCurrentStep:(MerchantEnrollStep)currentStep {
  68. _currentStep = currentStep;
  69. switch (currentStep) {
  70. case MerchantEnrollStepGuide:
  71. self.titleLabel.text = ASLocalizedString(@"商家入驻");
  72. [self.nextButton setTitle:ASLocalizedString(@"立即入驻") forState:UIControlStateNormal];
  73. break;
  74. case MerchantEnrollStepCheckList:
  75. self.titleLabel.text = ASLocalizedString(@"提交材料清单");
  76. [self.nextButton setTitle:ASLocalizedString(@"已准备好以上资料,立即入驻") forState:UIControlStateNormal];
  77. break;
  78. case MerchantEnrollStepStoreInfo:
  79. _titleLabel.text = ASLocalizedString(@"店铺信息");
  80. [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  81. break;
  82. case MerchantEnrollStepBusinessLicense:
  83. _titleLabel.text = ASLocalizedString(@"营业执照");
  84. [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  85. break;
  86. case MerchantEnrollStepLegalInfo:
  87. _titleLabel.text = ASLocalizedString(@"法人信息");
  88. [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  89. break;
  90. case MerchantEnrollStepBank:
  91. _titleLabel.text = ASLocalizedString(@"银行卡账户信息");
  92. [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  93. break;
  94. case MerchantEnrollStepSetAdmin:
  95. _titleLabel.text = ASLocalizedString(@"设置管理员");
  96. [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  97. break;
  98. case MerchantEnrollStepPay:
  99. _titleLabel.text = ASLocalizedString(@"支付保证金");
  100. [_nextButton setTitle:ASLocalizedString(@"已完成支付,下一步") forState:UIControlStateNormal];
  101. break;
  102. case MerchantEnrollStepWatingForReview:
  103. break;
  104. case MerchantEnrollStepReviewFail:
  105. break;
  106. case MerchantEnrollStepComplete:
  107. break;
  108. }
  109. }
  110. - (void)uploadImage:(UIImage *)image completion:(void(^)(NSString *url))completion {
  111. [[BGHUDHelper sharedInstance] syncLoading];
  112. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  113. [parmDict setObject:@"avatar" forKey:@"ctl"];
  114. [parmDict setObject:@"uploadImage" forKey:@"act"];
  115. NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
  116. [self.netManager POSTWithDict:parmDict andFileData:imageData AndFileName:@"logo.png" SuccessBlock:^(NSDictionary *responseJson) {
  117. [[BGHUDHelper sharedInstance] syncStopLoading];
  118. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传成功")];
  119. NSString *url = responseJson[@"server_full_path"];
  120. if (completion) {
  121. completion(url);
  122. }
  123. } FailureBlock:^(NSError *error) {
  124. [[BGHUDHelper sharedInstance] syncStopLoading];
  125. [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
  126. }];
  127. }
  128. #pragma mark - UINavigationControllerDelegate,UIImagePickerControllerDelegate
  129. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
  130. UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
  131. [picker dismissViewControllerAnimated:YES completion:^{
  132. if (self.pickImageAction) {
  133. self.pickImageAction(image);
  134. }
  135. }];
  136. }
  137. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
  138. [picker dismissViewControllerAnimated:YES completion:nil];
  139. }
  140. - (void)pickImageWithCompletion:(DidPickImageAction)completion {
  141. self.pickImageAction = completion;
  142. if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
  143. {
  144. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  145. picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  146. picker.delegate = self;
  147. picker.modalPresentationStyle = UIModalPresentationFullScreen;
  148. [self.viewController presentViewController:picker animated:YES completion:nil];
  149. }
  150. }
  151. - (UILabel *)titleLabel {
  152. if (!_titleLabel) {
  153. _titleLabel = [[UILabel alloc] init];
  154. _titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  155. _titleLabel.textColor = UIColor.blackColor;
  156. _titleLabel.text = ASLocalizedString(@"店铺信息");
  157. }
  158. return _titleLabel;
  159. }
  160. - (UIScrollView *)scrollView {
  161. if (!_scrollView) {
  162. UIScrollView *scrollView = [[UIScrollView alloc] init];
  163. scrollView.showsVerticalScrollIndicator = NO;
  164. scrollView.showsHorizontalScrollIndicator = NO;
  165. scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  166. scrollView.backgroundColor = UIColor.clearColor;
  167. _scrollView = scrollView;
  168. }
  169. return _scrollView;
  170. }
  171. - (UIView *)contentView {
  172. if (!_contentView) {
  173. UIView *contentView = [[UIView alloc] init];
  174. contentView.backgroundColor = [UIColor clearColor];
  175. _contentView = contentView;
  176. }
  177. return _contentView;
  178. }
  179. - (UIButton *)nextButton {
  180. if (!_nextButton) {
  181. UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
  182. nextButton.size = CGSizeMake(kRealValue(351), kRealValue(50));
  183. [nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
  184. [nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  185. nextButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  186. nextButton.backgroundColor = [UIColor colorWithHexString:@"#1A65FF"];
  187. [nextButton addTarget:self action:@selector(nextButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
  188. _nextButton = nextButton;
  189. [nextButton configShadow:kRealValue(25)
  190. shadowColor:[UIColor colorWithHexString:@"#1A65FF"]
  191. size:nextButton.size];
  192. }
  193. return _nextButton;
  194. }
  195. - (NetHttpsManager *)netManager {
  196. if (!_netManager) {
  197. _netManager = [NetHttpsManager manager];
  198. }
  199. return _netManager;
  200. }
  201. - (UIViewController *)viewController {
  202. return (UIViewController *)self.delegate;
  203. }
  204. - (NSDictionary *)getMerchantEnrollParameters {
  205. return @{};
  206. }
  207. @end