diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 0641021d..2d4ed527 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -59,9 +59,12 @@ 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; }; E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; }; E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; }; - E872309026E8D29300B90D4F /* LoginVerifCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */; }; E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.m */; }; - E8B825BA26E9A9D5009E8E9F /* BaseObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825B926E9A9D5009E8E9F /* BaseObject.m */; }; + E8B825B726E9A7D8009E8E9F /* BaseObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825B626E9A7D8009E8E9F /* BaseObject.m */; }; + E8B825BF26E9E57D009E8E9F /* LoginTicketInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825BE26E9E57D009E8E9F /* LoginTicketInfo.m */; }; + E8B825C226EA00DF009E8E9F /* LoginVerifCodePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825C126EA00DF009E8E9F /* LoginVerifCodePresent.m */; }; + E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E8B825C626EA0995009E8E9F /* LoginVerifCodeProtocol.h */; }; + E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B825C826EA1231009E8E9F /* LoginVerifCodeViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -169,12 +172,17 @@ E872308826E89BE000B90D4F /* LoginPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPhoneViewController.m; sourceTree = ""; }; E872308B26E89DAA00B90D4F /* LoginInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginInputView.h; sourceTree = ""; }; E872308C26E89DAA00B90D4F /* LoginInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginInputView.m; sourceTree = ""; }; - E872308E26E8D29300B90D4F /* LoginVerifCodeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeViewController.h; sourceTree = ""; }; - E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeViewController.m; sourceTree = ""; }; E872309126E8D31500B90D4F /* LoginVerifCodeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeView.h; sourceTree = ""; }; E872309226E8D31500B90D4F /* LoginVerifCodeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeView.m; sourceTree = ""; }; - E8B825B826E9A9D5009E8E9F /* BaseObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseObject.h; sourceTree = ""; }; - E8B825B926E9A9D5009E8E9F /* BaseObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseObject.m; sourceTree = ""; }; + E8B825B526E9A7D8009E8E9F /* BaseObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseObject.h; sourceTree = ""; }; + E8B825B626E9A7D8009E8E9F /* BaseObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseObject.m; sourceTree = ""; }; + E8B825BD26E9E57D009E8E9F /* LoginTicketInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginTicketInfo.h; sourceTree = ""; }; + E8B825BE26E9E57D009E8E9F /* LoginTicketInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginTicketInfo.m; sourceTree = ""; }; + E8B825C026EA00DF009E8E9F /* LoginVerifCodePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodePresent.h; sourceTree = ""; }; + E8B825C126EA00DF009E8E9F /* LoginVerifCodePresent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodePresent.m; sourceTree = ""; }; + E8B825C626EA0995009E8E9F /* LoginVerifCodeProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeProtocol.h; sourceTree = ""; }; + E8B825C826EA1231009E8E9F /* LoginVerifCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginVerifCodeViewController.m; sourceTree = ""; }; + E8B825C926EA1231009E8E9F /* LoginVerifCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginVerifCodeViewController.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -289,8 +297,8 @@ 187EEEEE26E89FE8002833B2 /* AccountInfoStorage.m */, 187EEEFD26E8A82C002833B2 /* NSObject+AutoCoding.h */, 187EEEFC26E8A82C002833B2 /* NSObject+AutoCoding.m */, - E8B825B826E9A9D5009E8E9F /* BaseObject.h */, - E8B825B926E9A9D5009E8E9F /* BaseObject.m */, + E8B825B526E9A7D8009E8E9F /* BaseObject.h */, + E8B825B626E9A7D8009E8E9F /* BaseObject.m */, ); path = Model; sourceTree = ""; @@ -308,8 +316,8 @@ 189DD56226DE460400AB55B1 /* Login */ = { isa = PBXGroup; children = ( + E8B825BC26E9E520009E8E9F /* Model */, 189DD75326E2211000AB55B1 /* Api */, - 189DD58926DF977D00AB55B1 /* Model */, 189DD58A26DF978700AB55B1 /* View */, 189DD58B26DF978F00AB55B1 /* Presenter */, 189DD59126DF97F600AB55B1 /* Protocol */, @@ -346,23 +354,16 @@ path = UI; sourceTree = ""; }; - 189DD58926DF977D00AB55B1 /* Model */ = { - isa = PBXGroup; - children = ( - ); - path = Model; - sourceTree = ""; - }; 189DD58A26DF978700AB55B1 /* View */ = { isa = PBXGroup; children = ( E872308A26E89D5100B90D4F /* CustomView */, - 189DD56326DE465A00AB55B1 /* LoginViewController.h */, - 189DD56426DE465A00AB55B1 /* LoginViewController.m */, E872308726E89BE000B90D4F /* LoginPhoneViewController.h */, E872308826E89BE000B90D4F /* LoginPhoneViewController.m */, - E872308E26E8D29300B90D4F /* LoginVerifCodeViewController.h */, - E872308F26E8D29300B90D4F /* LoginVerifCodeViewController.m */, + E8B825C926EA1231009E8E9F /* LoginVerifCodeViewController.h */, + E8B825C826EA1231009E8E9F /* LoginVerifCodeViewController.m */, + 189DD56326DE465A00AB55B1 /* LoginViewController.h */, + 189DD56426DE465A00AB55B1 /* LoginViewController.m */, ); path = View; sourceTree = ""; @@ -372,6 +373,8 @@ children = ( 189DD58D26DF97E700AB55B1 /* LoginPresenter.h */, 189DD58E26DF97E700AB55B1 /* LoginPresenter.m */, + E8B825C026EA00DF009E8E9F /* LoginVerifCodePresent.h */, + E8B825C126EA00DF009E8E9F /* LoginVerifCodePresent.m */, ); path = Presenter; sourceTree = ""; @@ -380,6 +383,7 @@ isa = PBXGroup; children = ( 189DD59426DF986300AB55B1 /* LoginProtocol.h */, + E8B825C626EA0995009E8E9F /* LoginVerifCodeProtocol.h */, ); path = Protocol; sourceTree = ""; @@ -525,6 +529,15 @@ path = CustomView; sourceTree = ""; }; + E8B825BC26E9E520009E8E9F /* Model */ = { + isa = PBXGroup; + children = ( + E8B825BD26E9E57D009E8E9F /* LoginTicketInfo.h */, + E8B825BE26E9E57D009E8E9F /* LoginTicketInfo.m */, + ); + path = Model; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -656,10 +669,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */, + E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */, 189DD76226E60DDC00AB55B1 /* Api+Login.m in Sources */, - E8B825BA26E9A9D5009E8E9F /* BaseObject.m in Sources */, 18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */, 189DD73E26E21C3F00AB55B1 /* YYUtility.m in Sources */, + E8B825B726E9A7D8009E8E9F /* BaseObject.m in Sources */, 189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */, 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, 189DD55A26DE39D200AB55B1 /* BaseMvpPresenter.m in Sources */, @@ -671,10 +686,12 @@ 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */, 189DD54B26DE338800AB55B1 /* BaseViewController.m in Sources */, 18E7B1B726E8B2D10064BC9B /* Api+Main.m in Sources */, + E8B825C226EA00DF009E8E9F /* LoginVerifCodePresent.m in Sources */, 18E7B1B226E8AF980064BC9B /* MainPresenter.m in Sources */, 189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */, 189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */, 189DD56526DE465A00AB55B1 /* LoginViewController.m in Sources */, + E8B825BF26E9E57D009E8E9F /* LoginTicketInfo.m in Sources */, 187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */, E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */, 189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */, @@ -682,7 +699,6 @@ 189DD74026E21C3F00AB55B1 /* YYUtility+App.m in Sources */, 189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */, 187EEEE126E89BFB002833B2 /* AccountModel.m in Sources */, - E872309026E8D29300B90D4F /* LoginVerifCodeViewController.m in Sources */, 189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */, E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */, 18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */, diff --git a/xplan-ios/Main/Login/Api/Api+Login.h b/xplan-ios/Main/Login/Api/Api+Login.h index 4daaf59e..27514213 100644 --- a/xplan-ios/Main/Login/Api/Api+Login.h +++ b/xplan-ios/Main/Login/Api/Api+Login.h @@ -18,6 +18,12 @@ NS_ASSUME_NONNULL_BEGIN /// @param mobile 手机号 /// @param type 类型 业务类型,必填,1注册,2登录,3重设密码,4绑定手机,5绑定xczAccount,6重设xcz密码,7解绑手机 + (void)phoneSmsCode:(HttpRequestHelperCompletion)completion mobile:(NSString *)mobile type:(NSString *)type; + +/// 手机验证码登录 +/// @param completion 完成 +/// @param phone 手机号 +/// @param code 验证码 ++ (void)loginWithCode:(HttpRequestHelperCompletion)completion phone:(NSString *)phone code:(NSString *)code client_secret:(NSString *)client_secret version:(NSString *)version client_id:(NSString *)client_id grant_type:(NSString *)grant_type; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Api/Api+Login.m b/xplan-ios/Main/Login/Api/Api+Login.m index 03e7a490..464b22a8 100644 --- a/xplan-ios/Main/Login/Api/Api+Login.m +++ b/xplan-ios/Main/Login/Api/Api+Login.m @@ -19,7 +19,15 @@ /// @param mobile 手机号 /// @param type 类型 业务类型,必填,1注册,2登录,3重设密码,4绑定手机,5绑定xczAccount,6重设xcz密码,7解绑手机 + (void)phoneSmsCode:(HttpRequestHelperCompletion)completion mobile:(NSString *)mobile type:(NSString *)type { - [self makeRequest:@"sms/getCode" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, mobile, type]; + [self makeRequest:@"sms/getCode" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, mobile, type, nil]; +} + +/// 手机验证码登录 +/// @param completion 完成 +/// @param phone 手机号 +/// @param code 验证码 ++ (void)loginWithCode:(HttpRequestHelperCompletion)completion phone:(NSString *)phone code:(NSString *)code client_secret:(NSString *)client_secret version:(NSString *)version client_id:(NSString *)client_id grant_type:(NSString *)grant_type { + [self makeRequest:@"oauth/token" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,phone,code,client_secret,version, client_id, grant_type, nil]; } @end diff --git a/xplan-ios/Main/Login/Model/LoginTicketInfo.h b/xplan-ios/Main/Login/Model/LoginTicketInfo.h new file mode 100644 index 00000000..9820515a --- /dev/null +++ b/xplan-ios/Main/Login/Model/LoginTicketInfo.h @@ -0,0 +1,20 @@ +// +// LoginTicketInfo.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/9. +// + +#import "BaseObject.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginTicketInfo : BaseObject + +@property(nonatomic, strong) NSString *issue_type; +///数组中的第一个 就是ticket 历史遗留问题 +@property(nonatomic, strong) NSArray* tickets; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Model/LoginTicketInfo.m b/xplan-ios/Main/Login/Model/LoginTicketInfo.m new file mode 100644 index 00000000..7006036e --- /dev/null +++ b/xplan-ios/Main/Login/Model/LoginTicketInfo.m @@ -0,0 +1,12 @@ +// +// LoginTicketInfo.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/9. +// + +#import "LoginTicketInfo.h" + +@implementation LoginTicketInfo + +@end diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.h b/xplan-ios/Main/Login/Presenter/LoginPresenter.h index e46e2447..e385d156 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.h +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.h @@ -13,14 +13,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)phoneQuickLogin:(NSString *)accessToken token:(NSString*) token; -/// 获取手机的验证码 -/// @param phone 手机号 -/// @param type 类型 -- (void)phoneSmsCode:(NSString *)phone type:(int)type; - -/// 开启一个倒计时 -/// @param total 倒计时的时间 -- (void)openCutDownWithTotal:(int)total; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Presenter/LoginPresenter.m b/xplan-ios/Main/Login/Presenter/LoginPresenter.m index 9cfea336..4b77d45f 100644 --- a/xplan-ios/Main/Login/Presenter/LoginPresenter.m +++ b/xplan-ios/Main/Login/Presenter/LoginPresenter.m @@ -11,6 +11,8 @@ #import "LoginProtocol.h" #import "Api+Login.h" #import "AccountInfoStorage.h" +///Model +#import "LoginTicketInfo.h" @implementation LoginPresenter @@ -26,37 +28,4 @@ // todo fail }] accessToken:accessToken token:token]; } - -/// 获取手机的验证码 -/// @param phone 手机号 -/// @param type 类型 -- (void)phoneSmsCode:(NSString *)phone type:(int)type { - [Api phoneSmsCode:[self createHttpCompletion:^(id _Nonnull data) { - [[self getView] phoneSmsCodeSuccess]; - ///开启一个倒计时60 - [self openCutDownWithTotal:60]; - } fail:^(NSInteger code, NSString * _Nullable msg) { - - } showLoading:NO errorToast:YES] mobile:phone type:[NSString stringWithFormat:@"%d", type]]; - - -} - - -/// 开启一个倒计时 -/// @param total 倒计时的时间 -- (void)openCutDownWithTotal:(int)total { - __block int blockTotle = total; - __block RACDisposable * disposable; - disposable = [[RACSignal interval:1 onScheduler:[RACScheduler mainThreadScheduler]] subscribeNext:^(NSDate * _Nullable) { - blockTotle--; - [[self getView] countDownWithCurrent:blockTotle]; - ///倒计时结束 停止监听 - if (blockTotle == 0) { - [[self getView] countDownFinish]; - [disposable dispose]; - } - }]; -} - @end diff --git a/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.h b/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.h new file mode 100644 index 00000000..58ce2a29 --- /dev/null +++ b/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.h @@ -0,0 +1,28 @@ +// +// LoginVerifCodePresent.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/9. +// + +#import "BaseMvpPresenter.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LoginVerifCodePresent : BaseMvpPresenter +/// 获取手机的验证码 +/// @param phone 手机号 +/// @param type 类型 +- (void)phoneSmsCode:(NSString *)phone type:(int)type; + +/// 使用手机号和验证码登录 +/// @param phone 手机号 +/// @param code 验证码 +- (void)loginWithPhone:(NSString *)phone code:(NSString *)code; + +/// 开启一个倒计时 +/// @param total 倒计时的时间 +- (void)openCutDownWithTotal:(int)total; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.m b/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.m new file mode 100644 index 00000000..45ee1cae --- /dev/null +++ b/xplan-ios/Main/Login/Presenter/LoginVerifCodePresent.m @@ -0,0 +1,73 @@ +// +// LoginVerifCodePresent.m +// xplan-ios +// +// Created by 冯硕 on 2021/9/9. +// + +#import "LoginVerifCodePresent.h" +///第三方 +#import +///Tool +#import "AccountInfoStorage.h" +///Api +#import "Api+Login.h" +///Presenter +#import "LoginVerifCodePresent.h" +///Protocol +#import "LoginVerifCodeProtocol.h" +///Model +#import "AccountModel.h" + +@implementation LoginVerifCodePresent + +- (id)getView { + return ((id) [super getView]); +} + +/// 获取手机的验证码 +/// @param phone 手机号 +/// @param type 类型 +- (void)phoneSmsCode:(NSString *)phone type:(int)type { + [Api phoneSmsCode:[self createHttpCompletion:^(id _Nonnull data) { + [[self getView] phoneSmsCodeSuccess]; + ///开启一个倒计时60 + [self openCutDownWithTotal:60]; + } fail:^(NSInteger code, NSString * _Nullable msg) { + + } showLoading:NO errorToast:YES] mobile:phone type:[NSString stringWithFormat:@"%d", type]]; +} + +/// 使用手机号和验证码登录 +/// @param phone 手机号 +/// @param code 验证码 +- (void)loginWithPhone:(NSString *)phone code:(NSString *)code { + [Api loginWithCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + AccountModel * accountModel = [AccountModel modelWithDictionary:data.data]; + if (accountModel && accountModel.access_token.length > 0) { + [[AccountInfoStorage instance] saveAccountInfo:accountModel]; + } + [[self getView] loginSuccess]; + } fail:^(NSInteger code, NSString * _Nullable msg) { + + }] phone:phone code:code client_secret:@"uyzjdhds" version:@"1" client_id:@"erban-client" grant_type:@"password"]; +} + + +/// 开启一个倒计时 +/// @param total 倒计时的时间 +- (void)openCutDownWithTotal:(int)total { + __block int blockTotle = total; + __block RACDisposable * disposable; + disposable = [[RACSignal interval:1 onScheduler:[RACScheduler mainThreadScheduler]] subscribeNext:^(NSDate * _Nullable x) { + blockTotle--; + [[self getView] countDownWithCurrent:blockTotle]; + ///倒计时结束 停止监听 + if (blockTotle == 0) { + [[self getView] countDownFinish]; + [disposable dispose]; + } + }]; +} + +@end diff --git a/xplan-ios/Main/Login/Protocol/LoginProtocol.h b/xplan-ios/Main/Login/Protocol/LoginProtocol.h index bbab75c0..a0979275 100644 --- a/xplan-ios/Main/Login/Protocol/LoginProtocol.h +++ b/xplan-ios/Main/Login/Protocol/LoginProtocol.h @@ -12,12 +12,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol LoginProtocol - (void)phoneQuickLoginSuccess; -///请求手机号的验证码成功 -- (void)phoneSmsCodeSuccess; -///倒计时进行中 -- (void)countDownWithCurrent:(int)current; -///倒计时结束 -- (void)countDownFinish; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/Protocol/LoginVerifCodeProtocol.h b/xplan-ios/Main/Login/Protocol/LoginVerifCodeProtocol.h new file mode 100644 index 00000000..5bc6441b --- /dev/null +++ b/xplan-ios/Main/Login/Protocol/LoginVerifCodeProtocol.h @@ -0,0 +1,23 @@ +// +// LoginVerifCodeProtocol.h +// xplan-ios +// +// Created by 冯硕 on 2021/9/9. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol LoginVerifCodeProtocol +///请求手机号的验证码成功 +- (void)phoneSmsCodeSuccess; +///倒计时进行中 +- (void)countDownWithCurrent:(int)current; +///倒计时结束 +- (void)countDownFinish; +///登录成功 +- (void)loginSuccess; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/CustomView/LoginInputView.m b/xplan-ios/Main/Login/View/CustomView/LoginInputView.m index dbda1a15..bfb66853 100644 --- a/xplan-ios/Main/Login/View/CustomView/LoginInputView.m +++ b/xplan-ios/Main/Login/View/CustomView/LoginInputView.m @@ -88,7 +88,7 @@ _textField.borderStyle = UITextBorderStyleNone; _textField.keyboardType = UIKeyboardTypeNumberPad; _textField.tintColor = ThemeBackgroundColor; - _textField.backgroundColor = [UIColor redColor]; + _textField.backgroundColor = [UIColor clearColor]; } return _textField; } diff --git a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h index 6c2f1058..25fc707d 100644 --- a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h +++ b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.h @@ -13,6 +13,8 @@ NS_ASSUME_NONNULL_BEGIN ///输入的验证码 有几位 @property (nonatomic,assign) int number; +///输入的字符串的 +@property (nonatomic,copy) void(^textFieldChangeBlock)(NSString *); @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m index d1089431..68d9cfc1 100644 --- a/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m +++ b/xplan-ios/Main/Login/View/CustomView/LoginVerifCodeView.m @@ -43,11 +43,39 @@ } - (void)initEvents { + @weakify(self); [[self.textField rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UITextField *textField) { - NSLog(@"text%@", textField.text); + @strongify(self); + [self updateLablesWithText:textField]; }]; } +- (void)updateLablesWithText:(UITextField *)textField { + if (textField.text.length > self.lableArray.count) { + textField.text = [textField.text substringToIndex:self.lableArray.count]; + } + + + + if (textField.text.length >= 5) { + [textField resignFirstResponder]; + if (_textFieldChangeBlock) { + _textFieldChangeBlock(textField.text); + } + } + + + + for (UILabel *pwLab in self.lableArray) { + if (pwLab.tag < (100 + textField.text.length)) { + NSRange range = NSMakeRange(pwLab.tag-100, 1); + pwLab.text = [textField.text substringWithRange:range]; + }else{ + pwLab.text = @""; + } + } +} + - (void)configLabelArray { CGFloat itemWidth = 45; CGFloat itemHeight = 45; @@ -60,6 +88,7 @@ label.backgroundColor = UIColorFromRGB(0x2A2A39); label.layer.masksToBounds = YES; label.layer.cornerRadius = 10; + label.tag = 100 + i; [self addSubview:label]; [label mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(itemWidth, itemHeight)); @@ -89,6 +118,9 @@ - (UITextField *)textField { if (!_textField) { _textField = [[UITextField alloc] init]; + _textField.tintColor = [UIColor clearColor]; + _textField.keyboardType = UIKeyboardTypeNumberPad; + [_textField becomeFirstResponder]; } return _textField; } diff --git a/xplan-ios/Main/Login/View/LoginPhoneViewController.m b/xplan-ios/Main/Login/View/LoginPhoneViewController.m index e8486f12..e388e7ba 100644 --- a/xplan-ios/Main/Login/View/LoginPhoneViewController.m +++ b/xplan-ios/Main/Login/View/LoginPhoneViewController.m @@ -17,8 +17,6 @@ #import "LoginVerifCodeViewController.h" @interface LoginPhoneViewController () -///返回按钮 -@property (nonatomic,strong) UIButton *backButton; ///密码登录 @property (nonatomic,strong) UIButton *passwordLoginButton; ///标题的容器 @@ -47,7 +45,6 @@ } #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.backButton]; [self.view addSubview:self.passwordLoginButton]; [self.view addSubview:self.titleStackView]; [self.view addSubview:self.phoneView]; @@ -58,15 +55,9 @@ } - (void)initSubViewConstraints { - [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.size.mas_equalTo(CGSizeMake(15, 15)); - make.left.mas_equalTo(self.view).offset(15); - make.top.mas_equalTo(37+ kSafeAreaTopHeight); - }]; - [self.passwordLoginButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.view).offset(-15); - make.top.mas_equalTo(self.backButton.mas_bottom).offset(15); + make.top.mas_equalTo(self.view).offset(79 + kSafeAreaTopHeight); }]; [self.titleStackView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -88,10 +79,6 @@ - (void)initEevents { @weakify(self); - ///点击了返回的按钮 - [[self.backButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { - - }]; ///点击了密码登录 [[self.passwordLoginButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) { @@ -112,15 +99,6 @@ } #pragma mark - Getters And Setters -- (UIButton *)backButton { - if (!_backButton) { - _backButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_backButton setImage:[UIImage imageNamed:@"icon_unattention"] forState:UIControlStateNormal]; - [_backButton setImage:[UIImage imageNamed:@"icon_small_attention"] forState:UIControlStateSelected]; - } - return _backButton; -} - - (UIButton *)passwordLoginButton { if (!_passwordLoginButton) { _passwordLoginButton = [UIButton buttonWithType:UIButtonTypeCustom]; diff --git a/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m index 9f74c061..6e64f482 100644 --- a/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m +++ b/xplan-ios/Main/Login/View/LoginVerifCodeViewController.m @@ -12,13 +12,13 @@ ///Tool #import "XCHUDTool.h" ///Presenter -#import "LoginPresenter.h" +#import "LoginVerifCodePresent.h" ///Protocole -#import "LoginProtocol.h" +#import "LoginVerifCodeProtocol.h" ///View #import "LoginVerifCodeView.h" -@interface LoginVerifCodeViewController () +@interface LoginVerifCodeViewController () ///标题的容器 @property (nonatomic,strong) UIStackView *titleStackView; ///标题 @@ -37,13 +37,8 @@ @implementation LoginVerifCodeViewController -- (void)dealloc -{ - NSLog(@"aaaaa"); -} - -- (LoginPresenter *)createPresenter { - return [[LoginPresenter alloc] init]; +- (LoginVerifCodePresent *)createPresenter { + return [[LoginVerifCodePresent alloc] init]; } - (void)viewDidLoad { @@ -112,6 +107,10 @@ self.cutdownLabel.hidden = NO; } +- (void)loginSuccess { + [XCHUDTool showSuccessWithMessage:@"登录成功"]; +} + #pragma mark - Getters And Setters - (UIStackView *)titleStackView { if (!_titleStackView) {