Browse Source

法人信息

zwp 8 months ago
parent
commit
abcfd1f61f

+ 3 - 1
BuguLive/Class/Sections/Store/View/MerchantLegalInfoView.h

@@ -11,7 +11,7 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface MerchantLegalInfoView : MerchantBaseEnrollContentView
+@interface MerchantLegalInfoView : MerchantBaseEnrollContentView<MerchantEnrollDataFillDelegate>
 
 // 姓名
 @property (nonatomic, strong) UILabel *nameLabel;
@@ -36,6 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) UILabel *backCardSubtitleLabel;
 @property (nonatomic, strong) UIImageView *backCardImageView;
 
+@property (nonatomic, copy, nullable) NSString *frontURL;
+@property (nonatomic, copy, nullable) NSString *backURL;
 
 @end
 

+ 64 - 4
BuguLive/Class/Sections/Store/View/MerchantLegalInfoView.m

@@ -11,6 +11,15 @@
 
 @implementation MerchantLegalInfoView
 
+- (NSDictionary *)getMerchantEnrollParameters {
+    return @{
+        @"username":self.nameTextField.text ?: @"",
+        @"identification_card":self.idNumberTextField.text ?: @"",
+        @"identity_front_photo":self.frontURL ?: @"",
+        @"identity_back_photo":self.backURL ?: @"",
+    };
+}
+
 - (instancetype)initWithFrame:(CGRect)frame
 {
     self = [super initWithFrame:frame];
@@ -149,16 +158,67 @@
     
 }
 
+#pragma mark - MerchantEnrollDataFillDelegate
+- (void)fillWithData:(NSDictionary *)data {
+    if (!data || ![data isKindOfClass:[NSDictionary class]]) {
+        return;
+    }
+    
+    self.nameTextField.text = data[@"username"];
+    self.idNumberTextField.text = data[@"identification_card"];
+    
+    self.frontURL = data[@"identity_front_photo"];
+    
+    self.backURL = data[@"identity_back_photo"];
+    
+    [self.frontCardImageView setImageURL:[NSURL URLWithString:self.frontURL]];
+    [self.backCardImageView setImageURL:[NSURL URLWithString:self.backURL]];
+}
+
 #pragma mark - Actions
 
+- (void)goNext {
+    if (self.nameTextField.text.length == 0) {
+        [self showToast:self.nameTextField.placeholder];
+        return;
+    }
+    
+    if (self.idNumberTextField.text.length == 0) {
+        [self showToast:self.idNumberTextField.placeholder];
+        return;
+    }
+    
+    if (self.frontURL.length == 0) {
+        [self showToast:self.frontCardSubtitleLabel.text];
+        return;
+    }
+    
+    if (self.backURL.length == 0) {
+        [self showToast:self.backCardSubtitleLabel.text];
+        return;
+    }
+    
+    [super goNext];
+}
+
 - (void)frontCardTapped:(UITapGestureRecognizer *)gesture {
-    // TODO: 实现身份证正面图片选择功能
-    NSLog(@"Front card upload tapped");
+    WeakSelf
+    [self pickImageWithCompletion:^(UIImage * _Nonnull image) {
+        weakSelf.frontCardImageView.image = image;
+        [weakSelf uploadImage:image completion:^(NSString * _Nonnull url) {
+            weakSelf.frontURL = url;
+        }];
+    }];
 }
 
 - (void)backCardTapped:(UITapGestureRecognizer *)gesture {
-    // TODO: 实现身份证反面图片选择功能
-    NSLog(@"Back card upload tapped");
+    WeakSelf
+    [self pickImageWithCompletion:^(UIImage * _Nonnull image) {
+        weakSelf.backCardImageView.image = image;
+        [weakSelf uploadImage:image completion:^(NSString * _Nonnull url) {
+            weakSelf.backURL = url;
+        }];
+    }];
 }
 
 #pragma mark - Lazy Loading