|
|
@@ -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
|