1
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
|
||||
#import "KBRegistVerEmailVC.h"
|
||||
#import "CRBoxInputView.h"
|
||||
#import "KBLoginVM.h"
|
||||
#import "KBUser.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface KBRegistVerEmailVC ()
|
||||
|
||||
@@ -15,6 +18,7 @@
|
||||
@property (nonatomic, strong) CRBoxInputView *codeInputView;
|
||||
@property (nonatomic, strong) UILabel *descLabel; // 多行提示文案
|
||||
@property (nonatomic, strong) UIButton *confirmButton; // Confirm
|
||||
@property (nonatomic, strong) KBLoginVM *loginVM; // Confirm
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,6 +27,7 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
self.loginVM = [[KBLoginVM alloc] init];
|
||||
self.kb_titleLabel.text = KBLocalized(@"Verify Email");
|
||||
[self kb_addTapToDismissKeyboard];
|
||||
|
||||
@@ -83,8 +88,42 @@
|
||||
return;
|
||||
}
|
||||
KBLOG(@"KBRegistVerEmailVC confirm with code=%@", code);
|
||||
// TODO: 注册流程中验证邮箱验证码的逻辑
|
||||
[KBHUD showInfo:@"验证通过后跳转邮箱登录页面"];
|
||||
self.params[@"code"] = code;
|
||||
NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
if (genderNumber != nil) {
|
||||
self.params[@"gender"] = genderNumber;
|
||||
}
|
||||
[self.loginVM emailRegisterParams:self.params withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
[KBHUD showInfo:KBLocalized(@"Signed in successfully")];
|
||||
// 登录成功后切换到主 TabBar
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
AppDelegate *delegate = (AppDelegate *)appDelegate;
|
||||
[delegate toMainTabbarVC];
|
||||
}
|
||||
});
|
||||
} else {
|
||||
NSString *msg = error.localizedDescription ?: KBLocalized(@"Sign-in failed");
|
||||
[KBHUD showInfo:msg];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (nullable NSNumber *)kb_localGenderParamIfAvailable {
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
// 只有在用户真正看过性别选择页后,才认为本地的性别有效
|
||||
BOOL hasShownSexVC = [ud boolForKey:KBSexSelectShownKey];
|
||||
if (!hasShownSexVC) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSInteger value = [ud integerForKey:KBSexSelectedGenderKey];
|
||||
if (value < UserSexMan || value > UserSexTwoSex) {
|
||||
return nil;
|
||||
}
|
||||
return @(value);
|
||||
}
|
||||
|
||||
#pragma mark - Lazy UI
|
||||
@@ -152,8 +191,9 @@
|
||||
// 这里用 %@ 预留邮箱地址占位
|
||||
NSString *template = KBLocalized(@"We have already sent it to the email address %@. Please enter the 6-digit verification code from the email to verify your mailbox.");
|
||||
// 使用上个页面传入的邮箱;若为空则使用占位邮箱
|
||||
NSString *email = self.email.length > 0 ? self.email : @"example@mail.com";
|
||||
_descLabel.text = [NSString stringWithFormat:template, email];
|
||||
NSString *email = self.params[@"mailAddress"];
|
||||
NSString *reEmail = email.length > 0 ? email : @"example@mail.com";
|
||||
_descLabel.text = [NSString stringWithFormat:template, reEmail];
|
||||
}
|
||||
return _descLabel;
|
||||
}
|
||||
@@ -173,4 +213,10 @@
|
||||
return _confirmButton;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)params{
|
||||
if (!_params) {
|
||||
_params = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _params;
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user