1
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
#import "KBEmailLoginVC.h"
|
||||
#import "KBEmailRegistVC.h"
|
||||
#import "KBForgetPwdVC.h"
|
||||
#import "KBLoginVM.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "BaseTabBarController.h"
|
||||
@interface KBEmailLoginVC () <UITextViewDelegate, UITextFieldDelegate>
|
||||
|
||||
// 背景与顶部装饰
|
||||
@@ -41,6 +44,7 @@
|
||||
@property (nonatomic, strong) UITextView *agreementTextView;
|
||||
@property (nonatomic, strong) UILabel *accountTipLabel; // “Don't Have An Account?”
|
||||
@property (nonatomic, strong) UIButton *signUpButton; // “Sign Up”
|
||||
@property (nonatomic, strong) KBLoginVM *loginVM; // Confirm
|
||||
|
||||
@end
|
||||
|
||||
@@ -49,6 +53,7 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// 与登录/注册页一致:隐藏通用导航栏,使用自定义背景 + 返回按钮
|
||||
self.loginVM = [[KBLoginVM alloc] init];
|
||||
self.kb_enableCustomNavBar = NO;
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
[self kb_addTapToDismissKeyboard];
|
||||
@@ -217,8 +222,27 @@
|
||||
|
||||
- (void)onTapSubmit {
|
||||
KBLOG(@"KBEmailLoginVC onTapSubmit, email=%@, pwdLen=%zd",
|
||||
self.emailTextField.text,
|
||||
self.emailTextField.text,
|
||||
self.passwordTextField.text.length);
|
||||
NSString *email = self.emailTextField.text ? self.emailTextField.text : @"";
|
||||
NSString *password = self.passwordTextField.text ? self.passwordTextField.text : @"";
|
||||
|
||||
[self.loginVM emailLoginEmail:email password:password WithCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (success) {
|
||||
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
AppDelegate *delegate = (AppDelegate *)appDelegate;
|
||||
// [delegate toMainTabbarVC];
|
||||
delegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
delegate.window.backgroundColor = [UIColor whiteColor];
|
||||
[delegate.window makeKeyAndVisible];
|
||||
UIViewController *rootVC = nil;
|
||||
rootVC = [[BaseTabBarController alloc] init];
|
||||
delegate.window.rootViewController = rootVC;
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)onTapForgotPassword {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "KBLoginVM.h"
|
||||
#import "KBUser.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "KBEmailLoginVC.h"
|
||||
|
||||
@interface KBRegistVerEmailVC ()
|
||||
|
||||
@@ -32,6 +33,11 @@
|
||||
[self kb_addTapToDismissKeyboard];
|
||||
|
||||
[self setupUI];
|
||||
// 获取验证码
|
||||
NSString *email = self.params[@"mailAddress"];
|
||||
[self.loginVM sendVerifyMailWithEmail:email withCompletion:^(BOOL success, NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
@@ -88,7 +94,7 @@
|
||||
return;
|
||||
}
|
||||
KBLOG(@"KBRegistVerEmailVC confirm with code=%@", code);
|
||||
self.params[@"code"] = code;
|
||||
self.params[@"verifyCode"] = code;
|
||||
NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
if (genderNumber != nil) {
|
||||
self.params[@"gender"] = genderNumber;
|
||||
@@ -98,11 +104,20 @@
|
||||
[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];
|
||||
}
|
||||
KBEmailLoginVC *vc = [[KBEmailLoginVC alloc] init];
|
||||
[KB_CURRENT_NAV pushViewController:vc animated:true];
|
||||
// id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
// if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
// AppDelegate *delegate = (AppDelegate *)appDelegate;
|
||||
//// [delegate toMainTabbarVC];
|
||||
// delegate.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
// delegate.window.backgroundColor = [UIColor whiteColor];
|
||||
// [delegate.window makeKeyAndVisible];
|
||||
// UIViewController *rootVC = nil;
|
||||
// rootVC = [[BaseTabBarController alloc] init];
|
||||
// self.window.rootViewController = rootVC;
|
||||
// }
|
||||
|
||||
});
|
||||
} else {
|
||||
NSString *msg = error.localizedDescription ?: KBLocalized(@"Sign-in failed");
|
||||
|
||||
@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 登录完成回调
|
||||
typedef void(^KBLoginCompletion)(BOOL success, NSError * _Nullable error);
|
||||
typedef void(^KBRegisterCompletion)(BOOL success, NSError * _Nullable error);
|
||||
typedef void(^KBVerifyMailCompletion)(BOOL success, NSError * _Nullable error);
|
||||
|
||||
@interface KBLoginVM : NSObject
|
||||
|
||||
@@ -30,6 +31,9 @@ typedef void(^KBRegisterCompletion)(BOOL success, NSError * _Nullable error);
|
||||
- (void)emailLoginEmail:(NSString *)email password:(NSString *)password WithCompletion:(KBLoginCompletion)completion;
|
||||
/// 邮箱注册
|
||||
- (void)emailRegisterParams:(NSDictionary *)params withCompletion:(KBRegisterCompletion)completion;
|
||||
/// 发送验证码
|
||||
- (void)sendVerifyMailWithEmail:(NSString *)email withCompletion:(KBVerifyMailCompletion)completion;
|
||||
|
||||
|
||||
/// 是否已登录:由 KBAuthManager 判断(是否存在有效 token)
|
||||
- (BOOL)isLoggedIn;
|
||||
|
||||
@@ -132,6 +132,20 @@
|
||||
}];
|
||||
}
|
||||
|
||||
/// 发送验证码
|
||||
- (void)sendVerifyMailWithEmail:(NSString *)email withCompletion:(KBVerifyMailCompletion)completion{
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (email.length) params[@"mailAddress"] = email;
|
||||
// [[KBNetworkManager shared] POST:API_EMAIL_REGISTER jsonBody:params headers:nil completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
// if (error) { if (completion) completion(NO, error); return; }
|
||||
// [];
|
||||
// completion(true,nil);
|
||||
// }];
|
||||
[[KBNetworkManager shared] POST:API_EMAIL_REGISTER jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
// 宽松解析:token / access_token / accessToken,支持顶层或 data/user 层
|
||||
|
||||
Reference in New Issue
Block a user