完善用户信息的页面的 补全
This commit is contained in:
16
xplan-ios/Main/Login/Presenter/LoginBindPhonePresent.h
Normal file
16
xplan-ios/Main/Login/Presenter/LoginBindPhonePresent.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// LoginBindPhonePresent.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/9/15.
|
||||
//
|
||||
|
||||
#import "BaseMvpPresenter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface LoginBindPhonePresent : BaseMvpPresenter
|
||||
- (void)logout;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
22
xplan-ios/Main/Login/Presenter/LoginBindPhonePresent.m
Normal file
22
xplan-ios/Main/Login/Presenter/LoginBindPhonePresent.m
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// LoginBindPhonePresent.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/9/15.
|
||||
//
|
||||
|
||||
#import "LoginBindPhonePresent.h"
|
||||
#import "BaseMvpProtocol.h"
|
||||
|
||||
@implementation LoginBindPhonePresent
|
||||
|
||||
- (id<BaseMvpProtocol>)getView {
|
||||
return ((id<BaseMvpProtocol>) [super getView]);
|
||||
}
|
||||
|
||||
|
||||
- (void)logout {
|
||||
[[self getView] tokenInvalid];
|
||||
}
|
||||
|
||||
@end
|
@@ -6,8 +6,6 @@
|
||||
//
|
||||
|
||||
#import "LoginForgetPasswordPresent.h"
|
||||
///第三方
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
///Tool
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "DESEncrypt.h"
|
||||
@@ -31,8 +29,6 @@
|
||||
- (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) {
|
||||
|
||||
}] mobile:phone type:[NSString stringWithFormat:@"%d", type]];
|
||||
@@ -52,20 +48,4 @@
|
||||
} showLoading:YES] phone:phone newPwd:desPassword smsCode:smsCode];
|
||||
}
|
||||
|
||||
/// 开启一个倒计时
|
||||
/// @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
|
||||
|
@@ -8,9 +8,12 @@
|
||||
#import "BaseMvpPresenter.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class ThirdUserInfo;
|
||||
@interface LoginFullInfoPresenter : BaseMvpPresenter
|
||||
|
||||
/// 获取保存的第三方的数据模型
|
||||
+ (ThirdUserInfo * __nullable)getThirdUserInfo;
|
||||
|
||||
/// 随机获取昵称
|
||||
- (void)randomRequestNick;
|
||||
|
||||
@@ -25,10 +28,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)complectionInfoWithAvatar:(NSString *)avatar
|
||||
gender:(NSString *)gender
|
||||
nick:(NSString *)nick
|
||||
inviteCode:(NSString *)inviteCode
|
||||
roomUid:(NSString *)roomUid
|
||||
shareUid:(NSString *)shareUid
|
||||
shareChannel:(NSString *)shareChannel;
|
||||
inviteCode:(NSString * __nullable)inviteCode
|
||||
roomUid:(NSString * __nullable)roomUid
|
||||
shareUid:(NSString * __nullable)shareUid
|
||||
shareChannel:(NSString * __nullable)shareChannel;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -11,6 +11,8 @@
|
||||
#import "LoginFullInfoProtocol.h"
|
||||
///Tool
|
||||
#import "AccountInfoStorage.h"
|
||||
///Model
|
||||
#import "ThirdUserInfo.h"
|
||||
|
||||
@implementation LoginFullInfoPresenter
|
||||
|
||||
@@ -19,6 +21,14 @@
|
||||
}
|
||||
|
||||
|
||||
/// 获取保存的第三方的数据模型
|
||||
+ (ThirdUserInfo * __nullable)getThirdUserInfo {
|
||||
if ([AccountInfoStorage instance].thirdUserInfo) {
|
||||
return [AccountInfoStorage instance].thirdUserInfo;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// 随机获取昵称
|
||||
- (void)randomRequestNick {
|
||||
[Api randomNickWithComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
@@ -40,10 +50,10 @@
|
||||
- (void)complectionInfoWithAvatar:(NSString *)avatar
|
||||
gender:(NSString *)gender
|
||||
nick:(NSString *)nick
|
||||
inviteCode:(NSString *)inviteCode
|
||||
roomUid:(NSString *)roomUid
|
||||
shareUid:(NSString *)shareUid
|
||||
shareChannel:(NSString *)shareChannel {
|
||||
inviteCode:(NSString * __nullable)inviteCode
|
||||
roomUid:(NSString * __nullable)roomUid
|
||||
shareUid:(NSString * __nullable)shareUid
|
||||
shareChannel:(NSString * __nullable)shareChannel {
|
||||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||||
NSString * ticket = [[AccountInfoStorage instance] getTicket];
|
||||
if (inviteCode.length <= 0) {
|
||||
|
@@ -81,6 +81,8 @@
|
||||
if (unionid == nil) {
|
||||
unionid = @"";
|
||||
}
|
||||
///保存一下第三方的值
|
||||
[AccountInfoStorage instance].thirdUserInfo = userInfo;
|
||||
|
||||
[Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
[[self getBaseVC] hideHUD];
|
||||
|
@@ -24,9 +24,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// @param phone 手机号
|
||||
/// @param code 验证码
|
||||
- (void)bindWithPhone:(NSString *)phone code:(NSString *)code;
|
||||
/// 开启一个倒计时
|
||||
/// @param total 倒计时的时间
|
||||
- (void)openCutDownWithTotal:(int)total;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -31,8 +31,6 @@
|
||||
- (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) {
|
||||
|
||||
}] mobile:phone type:[NSString stringWithFormat:@"%d", type]];
|
||||
@@ -66,23 +64,4 @@
|
||||
} showLoading:YES] phone:phone code:code uid:uid ticket:ticket];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// 开启一个倒计时
|
||||
/// @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
|
||||
|
@@ -12,10 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol LoginForgetPasswordProtocol <NSObject>
|
||||
///请求手机号的验证码成功
|
||||
- (void)phoneSmsCodeSuccess;
|
||||
///倒计时进行中
|
||||
- (void)countDownWithCurrent:(int)current;
|
||||
///倒计时结束
|
||||
- (void)countDownFinish;
|
||||
///重置密码成功
|
||||
- (void)resetPasswrodSuccess;
|
||||
@end
|
||||
|
@@ -12,10 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol LoginVerifCodeProtocol <NSObject>
|
||||
///请求手机号的验证码成功
|
||||
- (void)phoneSmsCodeSuccess;
|
||||
///倒计时进行中
|
||||
- (void)countDownWithCurrent:(int)current;
|
||||
///倒计时结束
|
||||
- (void)countDownFinish;
|
||||
///登录成功
|
||||
- (void)loginSuccess;
|
||||
///绑定手机号成功
|
||||
|
@@ -13,8 +13,9 @@
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "NSString+Regex.h"
|
||||
#import "UIButton+EnlargeTouchArea.h"
|
||||
///Tool
|
||||
#import "BaseMvpPresenter.h"
|
||||
#import "LoginBindPhonePresent.h"
|
||||
///VC
|
||||
#import "LoginVerifCodeViewController.h"
|
||||
|
||||
@@ -38,8 +39,8 @@
|
||||
return YES;
|
||||
}
|
||||
#pragma mark - life cycle
|
||||
- (BaseMvpPresenter *)createPresenter {
|
||||
return [[BaseMvpPresenter alloc] init];
|
||||
- (LoginBindPhonePresent *)createPresenter {
|
||||
return [[LoginBindPhonePresent alloc] init];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
@@ -63,7 +64,7 @@
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.view).offset(150);
|
||||
@@ -146,8 +147,10 @@
|
||||
[[self.backButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
@strongify(self)
|
||||
///退出登录状态
|
||||
#warning to do 需要处理不绑定手机的时候 相当于直接退出登录
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
[self dismissViewControllerAnimated:NO completion:^{
|
||||
// [self.presenter logout];
|
||||
#warning to do 退出登录
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -211,6 +214,7 @@
|
||||
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_backButton setImage:[UIImage imageNamed:@"common_nav_back"] forState:UIControlStateNormal];
|
||||
[_backButton setImage:[UIImage imageNamed:@"common_nav_back"] forState:UIControlStateSelected];
|
||||
[_backButton setEnlargeEdgeWithTop:15 right:15 bottom:15 left:15];
|
||||
}
|
||||
return _backButton;
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "CountDownHelper.h"
|
||||
#import "UIImage+Utils.h"
|
||||
///Presenter
|
||||
#import "LoginForgetPasswordPresent.h"
|
||||
@@ -19,7 +20,7 @@
|
||||
#import "LoginForgetEditView.h"
|
||||
|
||||
|
||||
@interface LoginForgetPasswordViewController ()<LoginForgetPasswordProtocol>
|
||||
@interface LoginForgetPasswordViewController ()<LoginForgetPasswordProtocol, CountDownHelperDelegate>
|
||||
///容器
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///手机号
|
||||
@@ -50,9 +51,15 @@
|
||||
[self.view endEditing:NO];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
[[CountDownHelper shareHelper] stopCountDown];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.title = @"忘记密码";
|
||||
[CountDownHelper shareHelper].delegate = self;
|
||||
[self.view addSubview:self.stackView];
|
||||
[self.view addSubview:self.finishButton];
|
||||
|
||||
@@ -113,23 +120,25 @@
|
||||
- (void)phoneSmsCodeSuccess {
|
||||
self.codeView.authCodeButton.enabled= NO;
|
||||
[self showSuccessToast:@"验证码发送成功"];
|
||||
}
|
||||
///倒计时进行中
|
||||
- (void)countDownWithCurrent:(int)current {
|
||||
[self.codeView.authCodeButton setTitle:[NSString stringWithFormat:@"%ds后重试", current] forState:UIControlStateDisabled];
|
||||
}
|
||||
///倒计时结束
|
||||
- (void)countDownFinish {
|
||||
self.codeView.authCodeButton.enabled= YES;
|
||||
[self.codeView.authCodeButton setTitle:@"重新发送" forState:UIControlStateNormal];
|
||||
[[CountDownHelper shareHelper] openCountdownWithTime:60];
|
||||
}
|
||||
///重置密码成功
|
||||
- (void)resetPasswrodSuccess {
|
||||
[self showSuccessToast:@"重置密码成功"];
|
||||
[[CountDownHelper shareHelper] stopCountDown];
|
||||
[self showSuccessToast:@"重置密码成功"];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - CountDownHelperDelegate
|
||||
///倒计时进行中
|
||||
- (void)onCountdownOpen:(int)time {
|
||||
[self.codeView.authCodeButton setTitle:[NSString stringWithFormat:@"%ds后重试", time] forState:UIControlStateDisabled];
|
||||
}
|
||||
///倒计时结束
|
||||
- (void)onCountdownFinish {
|
||||
self.codeView.authCodeButton.enabled= YES;
|
||||
[self.codeView.authCodeButton setTitle:@"重新发送" forState:UIControlStateNormal];
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIButton *)finishButton{
|
||||
if (!_finishButton) {
|
||||
|
@@ -14,6 +14,8 @@
|
||||
#import "ThemeColor.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "UIButton+EnlargeTouchArea.h"
|
||||
///Model
|
||||
#import "ThirdUserInfo.h"
|
||||
///P
|
||||
#import "LoginFullInfoPresenter.h"
|
||||
#import "LoginFullInfoProtocol.h"
|
||||
@@ -41,6 +43,10 @@
|
||||
@property (nonatomic,strong) UIButton *femaleButton;
|
||||
///下一步
|
||||
@property (nonatomic,strong) UIButton *nextButton;
|
||||
///第三方的用户信息
|
||||
@property (nonatomic,strong) ThirdUserInfo *thirdInfo;
|
||||
///目前选择的性别
|
||||
@property (nonatomic,copy) NSString *sexString;
|
||||
@end
|
||||
|
||||
@implementation LoginFullInfoViewController
|
||||
@@ -56,6 +62,10 @@
|
||||
[self initEvents];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.view addSubview:self.titleLabel];
|
||||
@@ -70,6 +80,12 @@
|
||||
|
||||
[self.sexStackView addArrangedSubview:self.maleButton];
|
||||
[self.sexStackView addArrangedSubview:self.femaleButton];
|
||||
|
||||
if ([self.presenter getThirdUserInfo]) {
|
||||
self.textField.text = [self.presenter getThirdUserInfo].userName;
|
||||
} else {
|
||||
[self.presenter randomRequestNick];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
@@ -93,7 +109,7 @@
|
||||
make.left.right.mas_equalTo(self.backView).inset(25);
|
||||
make.top.bottom.mas_equalTo(self.backView);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
[self.sexStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.backView);
|
||||
@@ -113,12 +129,15 @@
|
||||
@strongify(self);
|
||||
self.femaleButton.selected = NO;
|
||||
x.selected = YES;
|
||||
self.sexString = @"1";
|
||||
|
||||
}];
|
||||
|
||||
[[self.femaleButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
@strongify(self);
|
||||
x.selected = YES;
|
||||
self.maleButton.selected = NO;
|
||||
self.sexString = @"2";
|
||||
}];
|
||||
|
||||
|
||||
@@ -135,9 +154,45 @@
|
||||
}];
|
||||
|
||||
[[self.nextButton rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
#warning to do 补全资料待完善
|
||||
@strongify(self);
|
||||
[self updateUserInfo];
|
||||
}];
|
||||
|
||||
[[self.textField.rac_textSignal map:^id _Nullable(NSString * _Nullable value) {
|
||||
if (value.length > 15) {
|
||||
value = [value substringToIndex:15];
|
||||
}
|
||||
return value;
|
||||
}] subscribeNext:^(id _Nullable x) {
|
||||
@strongify(self);
|
||||
self.textField.text = x;
|
||||
[self updateNextButton];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
///更新用户信息
|
||||
- (void)updateUserInfo {
|
||||
[self.presenter complectionInfoWithAvatar:[self getAvatarUrl] gender:self.maleButton.selected ? @"1":@"2" nick:self.textField.text inviteCode:nil roomUid:nil shareUid:nil shareChannel:nil];
|
||||
}
|
||||
|
||||
///获取头像 可能是从第三方获取的头像
|
||||
- (NSString *)getAvatarUrl {
|
||||
NSString * avatar;
|
||||
if ([self.presenter getThirdUserInfo] && [self.presenter getThirdUserInfo].avatarUrl.length > 0) {
|
||||
avatar = [self.presenter getThirdUserInfo].avatarUrl;
|
||||
} else {
|
||||
avatar = @"https://image.lecheng163.com/yinyou_default_avatar.png";
|
||||
}
|
||||
return avatar;
|
||||
}
|
||||
|
||||
- (void)updateNextButton {
|
||||
if (self.textField.text.length > 0 && self.sexString.length > 0) {
|
||||
self.nextButton.enabled = YES;
|
||||
} else {
|
||||
self.nextButton.enabled = NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - LoginFullInfoProtocol
|
||||
@@ -146,10 +201,20 @@
|
||||
}
|
||||
|
||||
- (void)complementInfoSuccess {
|
||||
|
||||
UIViewController *vc = self.presentingViewController;
|
||||
while (vc.presentingViewController) {
|
||||
vc = vc.presentingViewController;
|
||||
}
|
||||
[vc dismissViewControllerAnimated:YES completion:^{
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setSexString:(NSString *)sexString {
|
||||
_sexString = sexString;
|
||||
[self updateNextButton];
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
@@ -198,6 +263,7 @@
|
||||
_nameLabel.text = @"昵称";
|
||||
_nameLabel.font = [UIFont systemFontOfSize:15];
|
||||
_nameLabel.textColor = [ThemeColor secondTextColor];
|
||||
[_nameLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[_nameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||
|
||||
}
|
||||
@@ -210,7 +276,6 @@
|
||||
_textField.textColor = [ThemeColor mainTextColor];
|
||||
_textField.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15.f];
|
||||
_textField.borderStyle = UITextBorderStyleNone;
|
||||
_textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
_textField.tintColor = [ThemeColor appMainColor];
|
||||
_textField.textAlignment = NSTextAlignmentRight;
|
||||
_textField.backgroundColor = [UIColor clearColor];
|
||||
@@ -223,7 +288,9 @@
|
||||
_refreshButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateNormal];
|
||||
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateSelected];
|
||||
[_refreshButton setEnlargeEdgeWithTop:0 right:0 bottom:0 left:25];
|
||||
[_refreshButton setEnlargeEdgeWithTop:0 right:0 bottom:0 left:10];
|
||||
[_refreshButton setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[_refreshButton setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||||
}
|
||||
return _refreshButton;
|
||||
}
|
||||
|
@@ -127,10 +127,18 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)disMissVC {
|
||||
UIViewController *vc = self.presentingViewController;
|
||||
while (vc.presentingViewController) {
|
||||
vc = vc.presentingViewController;
|
||||
}
|
||||
[vc dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
}
|
||||
#pragma mark - LoginPasswordProtocol
|
||||
- (void)phoneAndPasswordLoginSuccess {
|
||||
[self showSuccessToast:@"登录成功"];
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
[self disMissVC];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "CountDownHelper.h"
|
||||
///Presenter
|
||||
#import "LoginVerifCodePresent.h"
|
||||
///Protocole
|
||||
@@ -18,7 +19,7 @@
|
||||
///View
|
||||
#import "LoginVerifCodeView.h"
|
||||
|
||||
@interface LoginVerifCodeViewController ()<LoginVerifCodeProtocol>
|
||||
@interface LoginVerifCodeViewController ()<LoginVerifCodeProtocol, CountDownHelperDelegate>
|
||||
///标题的容器
|
||||
@property (nonatomic,strong) UIStackView *titleStackView;
|
||||
///标题
|
||||
@@ -36,7 +37,6 @@
|
||||
@end
|
||||
|
||||
@implementation LoginVerifCodeViewController
|
||||
|
||||
- (LoginVerifCodePresent *)createPresenter {
|
||||
return [[LoginVerifCodePresent alloc] init];
|
||||
}
|
||||
@@ -53,8 +53,14 @@
|
||||
[self.view endEditing:NO];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
[[CountDownHelper shareHelper] stopCountDown];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[CountDownHelper shareHelper].delegate = self;
|
||||
[self.view addSubview:self.titleStackView];
|
||||
[self.view addSubview:self.codeView];
|
||||
[self.view addSubview:self.retryStackView];
|
||||
@@ -114,35 +120,46 @@
|
||||
return attribute;
|
||||
}
|
||||
|
||||
- (void)disMissVC {
|
||||
[[CountDownHelper shareHelper] stopCountDown];
|
||||
UIViewController *vc = self.presentingViewController;
|
||||
while (vc.presentingViewController) {
|
||||
vc = vc.presentingViewController;
|
||||
}
|
||||
[vc dismissViewControllerAnimated:YES completion:nil];
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
}
|
||||
|
||||
#pragma mark - LoginVerifCodeProtocol
|
||||
- (void)loginSuccess {
|
||||
[self showSuccessToast:@"登录成功"];
|
||||
[self disMissVC];
|
||||
}
|
||||
|
||||
///绑定手机号成功
|
||||
- (void)bindPhoneSuccess {
|
||||
[self disMissVC];
|
||||
}
|
||||
#pragma mark - LoginProtocol
|
||||
- (void)phoneSmsCodeSuccess {
|
||||
self.codeSendLabel.hidden = NO;
|
||||
self.codeSendLabel.text = [NSString stringWithFormat:@"验证码已发送至:%@", self.phone];
|
||||
[[CountDownHelper shareHelper] openCountdownWithTime:60];
|
||||
}
|
||||
|
||||
- (void)countDownFinish {
|
||||
#pragma mark - CountDownHelperDelegate
|
||||
- (void)onCountdownFinish {
|
||||
self.retryCodeButton.hidden = NO;
|
||||
self.cutdownLabel.hidden = YES;
|
||||
self.codeSendLabel.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)countDownWithCurrent:(int)current {
|
||||
self.cutdownLabel.attributedText = [self createRetrySendCodeWithTime:current];
|
||||
- (void)onCountdownOpen:(int)time {
|
||||
self.cutdownLabel.attributedText = [self createRetrySendCodeWithTime:time];
|
||||
self.retryCodeButton.hidden = YES;
|
||||
self.cutdownLabel.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)loginSuccess {
|
||||
[self showSuccessToast:@"登录成功"];
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
///绑定手机号成功
|
||||
- (void)bindPhoneSuccess {
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIStackView *)titleStackView {
|
||||
if (!_titleStackView) {
|
||||
|
@@ -66,7 +66,6 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
@end
|
||||
|
||||
@implementation LoginViewController
|
||||
|
||||
- (LoginPresenter *)createPresenter {
|
||||
return [[LoginPresenter alloc] init];
|
||||
}
|
||||
@@ -77,14 +76,8 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
[self setEvents];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self hideNavigationBar];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[self showNavigationBar];
|
||||
- (BOOL)isHiddenNavBar {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)initView {
|
||||
@@ -109,7 +102,6 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void)setUpConstraints {
|
||||
[self.appIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(110 + kSafeAreaTopHeight);
|
||||
@@ -196,6 +188,7 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
[self.appleButton addGestureRecognizer:appleTap];
|
||||
|
||||
[[self.agreeButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
@strongify(self)
|
||||
self.agreeButton.selected = !self.agreeButton.selected;
|
||||
if (self.agreeButton.isSelected) {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
@@ -209,7 +202,7 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
|
||||
// 一键登录
|
||||
[[self.loginButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
||||
@strongify(self)
|
||||
@strongify(self)
|
||||
if (self.agreeButton.isSelected) {
|
||||
[self phoneQuickLogin];
|
||||
} else {
|
||||
@@ -367,7 +360,7 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
}
|
||||
#pragma mark - LoginProtocol
|
||||
- (void)loginSuccess {
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
[self showSuccessToast:@"登录成功"];
|
||||
}
|
||||
|
||||
@@ -440,9 +433,9 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
attString.yy_color = [ThemeColor mainTextColor];
|
||||
NSString *userString = @"《用户服务协议》";
|
||||
NSMutableAttributedString *userAttString = [[NSMutableAttributedString alloc] initWithString:userString attributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]}];
|
||||
@weakify(self)
|
||||
// @weakify(self)
|
||||
[userAttString yy_setTextHighlightRange:NSMakeRange(0, userAttString.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
@strongify(self);
|
||||
// @strongify(self);
|
||||
// 跳转用户协议
|
||||
// [self goToWebview:HtmlUrlKey(kUserProtocalURL)];
|
||||
} longPressAction:nil];
|
||||
@@ -452,7 +445,7 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||||
NSString *protocolString = @"《隐私政策》";
|
||||
NSMutableAttributedString *privateString = [[NSMutableAttributedString alloc] initWithString:protocolString attributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]}];
|
||||
[privateString yy_setTextHighlightRange:NSMakeRange(0, privateString.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
@strongify(self);
|
||||
// @strongify(self);
|
||||
// 跳转隐私政策
|
||||
// [self goToWebview:HtmlUrlKey(kPrivacyURL)];
|
||||
} longPressAction:nil];
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "XCHUDTool.h"
|
||||
///VC
|
||||
#import "TabbarViewController.h"
|
||||
#import "BaseViewController.h"
|
||||
@@ -41,7 +42,7 @@
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
[self.presenter autoLogin];
|
||||
[self.presenter autoLogin];
|
||||
}
|
||||
|
||||
- (MainPresenter *)presenter {
|
||||
@@ -65,8 +66,6 @@
|
||||
[self bindPhone];
|
||||
return;
|
||||
}
|
||||
userInfo.nick = nil;
|
||||
userInfo.avatar = nil;
|
||||
if (userInfo.nick == nil || userInfo.avatar == nil) {
|
||||
[self completeUserInfo];
|
||||
return;
|
||||
@@ -76,7 +75,9 @@
|
||||
|
||||
- (void)tokenInvalid {
|
||||
LoginViewController *lvc = [[LoginViewController alloc] init];
|
||||
[self.navigationController pushViewController:lvc animated:YES];
|
||||
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
|
||||
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)completeUserInfo {
|
||||
@@ -131,4 +132,21 @@
|
||||
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[ThemeColor tabbarNormalColor]} forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
#pragma mark - 如果不实现的话 如果在main里面请求接口的时候 需要的话 就会导致方法找不到的错误
|
||||
- (void)showSuccessToast:(NSString *)msg {
|
||||
[XCHUDTool showSuccessWithMessage:msg];
|
||||
}
|
||||
|
||||
- (void)showErrorToast:(NSString *)msg {
|
||||
[XCHUDTool showErrorWithMessage:msg];
|
||||
}
|
||||
|
||||
- (void)showLoading {
|
||||
[XCHUDTool showGIFLoading];
|
||||
}
|
||||
|
||||
- (void)hideHUD {
|
||||
[XCHUDTool hideHUD];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user