| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- //
- // MerchantBaseEnrollContentView.m
- // merchant
- //
- // Created by qitewei on 2025/8/18.
- //
- #import "MerchantBaseEnrollContentView.h"
- #import "UIView+Extention.h"
- @interface MerchantBaseEnrollContentView ()
- @property (nonatomic, copy) DidPickImageAction pickImageAction;
- @end
- @implementation MerchantBaseEnrollContentView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = UIColor.clearColor;
- [self addGradientLayerWithColors:@[
- [UIColor colorWithHexString:@"#ECF4FF"],
- [UIColor colorWithHexString:@"#ffffff"],
- ] direction:GradientLayerDirection_V
- frame:CGRectMake(12, 0, frame.size.width-24, frame.size.height)
- roundingCorners:UIRectCornerAllCorners
- cornerRadii:16];
-
-
- // 添加标题
- [self addSubview:self.titleLabel];
-
- // 添加scrollView
- [self addSubview:self.scrollView];
- [self addSubview:self.nextButton];
- [self.scrollView addSubview:self.contentView];
-
- // 标题
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(kRealValue(30));
- make.centerX.mas_offset(0);
- }];
-
- // ScrollView
- [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.width.mas_equalTo(self.width-24);
- make.bottom.equalTo(self.nextButton.mas_top).mas_offset(-kRealValue(20));
- make.top.equalTo(self.titleLabel.mas_bottom).offset(kRealValue(10));
- }];
-
- [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.scrollView);
- make.width.equalTo(self.scrollView);
- }];
-
- // 提交按钮
- [self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(self.nextButton.size);
- make.bottom.mas_offset(kRealValue(-20));
- }];
-
- }
- return self;
- }
- - (void)nextButtonTapped:(UIButton *)sender {
- [self goNext];
- }
- - (void)goNext {
- if (self.delegate && [self.delegate respondsToSelector:@selector(onMerchantEnrollGotoNextButtonClick)]) {
- [self.delegate onMerchantEnrollGotoNextButtonClick];
- }
- }
- - (UIView *)listView {
- return self;
- }
- - (void)setCurrentStep:(MerchantEnrollStep)currentStep {
- _currentStep = currentStep;
- switch (currentStep) {
- case MerchantEnrollStepGuide:
- self.titleLabel.text = ASLocalizedString(@"商家入驻");
- [self.nextButton setTitle:ASLocalizedString(@"立即入驻") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepCheckList:
- self.titleLabel.text = ASLocalizedString(@"提交材料清单");
- [self.nextButton setTitle:ASLocalizedString(@"已准备好以上资料,立即入驻") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepStoreInfo:
- _titleLabel.text = ASLocalizedString(@"店铺信息");
- [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepBusinessLicense:
- _titleLabel.text = ASLocalizedString(@"营业执照");
- [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepLegalInfo:
- _titleLabel.text = ASLocalizedString(@"法人信息");
- [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepBank:
- _titleLabel.text = ASLocalizedString(@"银行卡账户信息");
- [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepSetAdmin:
- _titleLabel.text = ASLocalizedString(@"设置管理员");
- [_nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepPay:
- _titleLabel.text = ASLocalizedString(@"支付保证金");
- [_nextButton setTitle:ASLocalizedString(@"已完成支付,下一步") forState:UIControlStateNormal];
- break;
- case MerchantEnrollStepWatingForReview:
-
- break;
- case MerchantEnrollStepReviewFail:
-
- break;
- case MerchantEnrollStepComplete:
-
- break;
- }
- }
- - (void)uploadImage:(UIImage *)image completion:(void(^)(NSString *url))completion {
- [[BGHUDHelper sharedInstance] syncLoading];
- NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
- [parmDict setObject:@"avatar" forKey:@"ctl"];
- [parmDict setObject:@"uploadImage" forKey:@"act"];
- NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
- [self.netManager POSTWithDict:parmDict andFileData:imageData AndFileName:@"logo.png" SuccessBlock:^(NSDictionary *responseJson) {
- [[BGHUDHelper sharedInstance] syncStopLoading];
- [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"上传成功")];
- NSString *url = responseJson[@"server_full_path"];
- if (completion) {
- completion(url);
- }
- } FailureBlock:^(NSError *error) {
- [[BGHUDHelper sharedInstance] syncStopLoading];
- [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
- }];
-
- }
- #pragma mark - UINavigationControllerDelegate,UIImagePickerControllerDelegate
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info {
- UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
- [picker dismissViewControllerAnimated:YES completion:^{
- if (self.pickImageAction) {
- self.pickImageAction(image);
- }
- }];
- }
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)pickImageWithCompletion:(DidPickImageAction)completion {
- self.pickImageAction = completion;
- if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
- {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- picker.delegate = self;
- picker.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.viewController presentViewController:picker animated:YES completion:nil];
- }
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
- _titleLabel.textColor = UIColor.blackColor;
- _titleLabel.text = ASLocalizedString(@"店铺信息");
- }
- return _titleLabel;
- }
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- UIScrollView *scrollView = [[UIScrollView alloc] init];
- scrollView.showsVerticalScrollIndicator = NO;
- scrollView.showsHorizontalScrollIndicator = NO;
- scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- scrollView.backgroundColor = UIColor.clearColor;
- _scrollView = scrollView;
- }
- return _scrollView;
- }
- - (UIView *)contentView {
- if (!_contentView) {
- UIView *contentView = [[UIView alloc] init];
- contentView.backgroundColor = [UIColor clearColor];
- _contentView = contentView;
- }
- return _contentView;
- }
- - (UIButton *)nextButton {
- if (!_nextButton) {
- UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
- nextButton.size = CGSizeMake(kRealValue(351), kRealValue(50));
- [nextButton setTitle:ASLocalizedString(@"下一步") forState:UIControlStateNormal];
- [nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- nextButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
- nextButton.backgroundColor = [UIColor colorWithHexString:@"#1A65FF"];
- [nextButton addTarget:self action:@selector(nextButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
-
- _nextButton = nextButton;
- [nextButton configShadow:kRealValue(25)
- shadowColor:[UIColor colorWithHexString:@"#1A65FF"]
- size:nextButton.size];
- }
- return _nextButton;
- }
- - (NetHttpsManager *)netManager {
- if (!_netManager) {
- _netManager = [NetHttpsManager manager];
- }
- return _netManager;
- }
- - (UIViewController *)viewController {
- return (UIViewController *)self.delegate;
- }
- - (NSDictionary *)getMerchantEnrollParameters {
- return @{};
- }
- @end
|