618 lines
25 KiB
Objective-C
618 lines
25 KiB
Objective-C
//
|
||
// LoginViewController.m
|
||
// mew-ios
|
||
//
|
||
// Created by 触海 on 2023/11/6.
|
||
//
|
||
|
||
#import "MewLoginViewController.h"
|
||
#import "MewLoginNumberViewController.h"
|
||
#import "MewButton.h"
|
||
#import "MewWebViewController.h"
|
||
//apple
|
||
#import <AuthenticationServices/ASAuthorizationAppleIDButton.h>
|
||
#import <AuthenticationServices/AuthenticationServices.h>
|
||
#import <NTESQuickPass/NTESQuickPass.h>
|
||
///Third
|
||
#import <YYText.h>
|
||
#import <Masonry/Masonry.h>
|
||
///Tool
|
||
#import "MewMacro.h"
|
||
#import "MEWThemeColor.h"
|
||
#import "MewHUDTool.h"
|
||
#import "UIImage+MewUtils.h"
|
||
#import "MewConstant.h"
|
||
#import "MEWGCDHelper.h"
|
||
#import "Base.h"
|
||
#import "AccountInfoStorage.h"
|
||
#import "Api+Login.h"
|
||
#import "MewHtmlUrl.h"
|
||
///Present
|
||
#import "MewLoginPresenter.h"
|
||
#import "MewLoginProtocol.h"
|
||
#import "MewThirdUserInfo.h"
|
||
|
||
|
||
|
||
UIKIT_EXTERN NSString * const kYinyouPrivateKey;
|
||
NSString * const kPhoneQuickPrivacyKey = @"PhoneQuickPrivacyKey";
|
||
NSString * const kHadAgreePrivacy = @"HadAgreePrivacy";
|
||
|
||
typedef NS_ENUM(NSUInteger, XYLoginType) {
|
||
XYLoginTypeUnknow = 0, //未知
|
||
XYLoginTypeTelecom = 1, //电信
|
||
XYLoginTypeChinaMobile = 2, //移动
|
||
XYLoginTypeUnicom = 3 //联通
|
||
};
|
||
|
||
|
||
@interface MewLoginViewController ()<ASAuthorizationControllerDelegate,ASAuthorizationControllerPresentationContextProviding>
|
||
@property (nonatomic, strong) UIView *contentView;
|
||
/** 登录按钮*/
|
||
@property (nonatomic, strong) UIButton *loginButton;
|
||
|
||
//@property (nonatomic, strong) UIStackView *stackView;
|
||
/// 苹果
|
||
@property (nonatomic, strong) MewButton *appleButtonView;
|
||
|
||
/** 同意勾选按钮*/
|
||
@property (nonatomic, strong) UIButton *agreeButton;
|
||
/** 同意即可登录 */
|
||
@property (nonatomic, strong) YYLabel *agreeLabel;
|
||
/** 勾选隐私政策提示泡泡 */
|
||
@property (nonatomic, strong) UIImageView *authBubbleView;
|
||
/** 泡泡提示内容 */
|
||
@property (nonatomic, strong) UILabel *authBubbleLabel;
|
||
|
||
@property (nonatomic, strong) UIImageView *bgImageView;
|
||
@property (nonatomic, strong) UIImageView *helloBgImageView;
|
||
@property (nonatomic, strong) UILabel *helloTitleLabel;
|
||
@property (nonatomic, strong) UILabel *helloDetailLabel;
|
||
@property (nonatomic, strong) UIView *leftLineView;
|
||
@property (nonatomic, strong) UIView *rightLineView;
|
||
@property (nonatomic, strong) UILabel *otherLoginTitleLabel;
|
||
@end
|
||
|
||
@implementation MewLoginViewController
|
||
|
||
|
||
- (MewLoginPresenter *)createPresenter {
|
||
return [[MewLoginPresenter alloc] init];
|
||
}
|
||
|
||
#pragma mark - Life Cycle
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
[self mew_initView];
|
||
[self mew_setUpConstraints];
|
||
|
||
}
|
||
|
||
- (void)viewWillAppear:(BOOL)animated {
|
||
[super viewWillAppear:animated];
|
||
|
||
}
|
||
|
||
- (BOOL)mew_isHiddenNavBar {
|
||
return YES;
|
||
}
|
||
|
||
#pragma mark - Init View
|
||
- (void)mew_initView {
|
||
[self.view addSubview:self.bgImageView];
|
||
[self.view addSubview:self.helloBgImageView];
|
||
[self.view addSubview:self.helloTitleLabel];
|
||
[self.view addSubview:self.helloDetailLabel];
|
||
// [self.view addSubview:self.logoImageView];
|
||
[self.view addSubview:self.contentView];
|
||
[self.contentView addSubview:self.loginButton];
|
||
// [self.contentView addSubview:self.stackView];
|
||
[self.view addSubview:self.agreeButton];
|
||
[self.view addSubview:self.agreeLabel];
|
||
[self.view addSubview:self.authBubbleView];
|
||
[self.authBubbleView addSubview:self.authBubbleLabel];
|
||
[self.view addSubview:self.leftLineView];
|
||
[self.view addSubview:self.rightLineView];
|
||
[self.view addSubview:self.otherLoginTitleLabel];
|
||
[self.view addSubview:self.appleButtonView];
|
||
|
||
|
||
}
|
||
|
||
- (void)mew_setUpConstraints {
|
||
CGFloat kscale = 363.0 / 375.0;
|
||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.equalTo(self.view);
|
||
}];
|
||
[self.helloBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(kStatusBarHeight + 92);
|
||
make.left.mas_equalTo(40);
|
||
make.width.height.mas_equalTo(58);
|
||
}];
|
||
[self.helloTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.helloBgImageView.mas_right).offset(10);
|
||
make.bottom.equalTo(self.helloBgImageView);
|
||
}];
|
||
[self.helloDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(self.helloBgImageView.mas_bottom).offset(20);
|
||
make.left.equalTo(self.helloBgImageView);
|
||
}];
|
||
|
||
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(40);
|
||
make.right.mas_equalTo(-40);
|
||
make.top.equalTo(self.helloDetailLabel.mas_bottom).offset(115);
|
||
make.height.mas_equalTo(52);
|
||
}];
|
||
|
||
|
||
|
||
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.view).offset(329);
|
||
make.left.right.bottom.mas_equalTo(0);
|
||
}];
|
||
|
||
|
||
|
||
// [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
// make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 60);
|
||
// make.centerX.mas_equalTo(self.view);
|
||
// make.height.mas_equalTo(75);
|
||
// }];
|
||
|
||
[self.appleButtonView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 60);
|
||
make.centerX.mas_equalTo(self.view);
|
||
make.height.mas_equalTo(75);
|
||
}];
|
||
|
||
[self.agreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.appleButtonView.mas_bottom).offset(20);
|
||
make.height.mas_equalTo(40);
|
||
make.width.mas_equalTo(220);
|
||
make.centerX.mas_equalTo(self.view).mas_offset(15 - 6);
|
||
}];
|
||
|
||
[self.agreeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.mas_equalTo(self.agreeLabel.mas_left).mas_offset(6);
|
||
make.centerY.mas_equalTo(self.agreeLabel.mas_centerY);
|
||
make.width.height.mas_equalTo(30);
|
||
}];
|
||
|
||
[self.authBubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(self.agreeButton).mas_offset((-16));
|
||
make.top.mas_equalTo(self.agreeButton.mas_bottom);
|
||
make.width.mas_equalTo(235);
|
||
make.height.mas_equalTo(29);
|
||
}];
|
||
|
||
[self.authBubbleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.mas_equalTo(8);
|
||
make.bottom.mas_equalTo(self.authBubbleView).mas_offset(-6);
|
||
}];
|
||
|
||
[self.otherLoginTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.bottom.equalTo(self.appleButtonView.mas_top).offset(-32);
|
||
make.centerX.equalTo(self.view);
|
||
}];
|
||
[self.leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.right.equalTo(self.otherLoginTitleLabel.mas_left).offset(-15);
|
||
make.centerY.equalTo(self.otherLoginTitleLabel);
|
||
make.left.equalTo(self.view).offset(31);
|
||
make.height.mas_equalTo(0.5);
|
||
}];
|
||
[self.rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.otherLoginTitleLabel.mas_right).offset(15);
|
||
make.centerY.equalTo(self.otherLoginTitleLabel);
|
||
make.right.equalTo(self.view).offset(-31);
|
||
make.height.mas_equalTo(0.5);
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)mew_setViewHidden {
|
||
|
||
if (@available(iOS 13.0, *)) {
|
||
self.leftLineView.hidden = NO;
|
||
self.rightLineView.hidden = NO;
|
||
self.otherLoginTitleLabel.hidden = NO;
|
||
self.appleButtonView.hidden = NO;
|
||
} else {
|
||
self.leftLineView.hidden = YES;
|
||
self.rightLineView.hidden = YES;
|
||
self.otherLoginTitleLabel.hidden = YES;
|
||
self.appleButtonView.hidden = YES;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
#pragma mark - MewLoginProtocol
|
||
- (void)mew_loginSuccess {
|
||
[self dismissViewControllerAnimated:YES completion:nil];
|
||
[self mew_showSuccessToast:@"登录成功"];
|
||
}
|
||
|
||
|
||
#pragma mark - Event Response
|
||
- (void)mew_loginButtonAction:(UIButton *)sender {
|
||
if (!self.agreeButton.isSelected) {
|
||
[MewHUDTool showErrorWithMessage:@"请勾选协议"];
|
||
return;
|
||
}
|
||
|
||
MewLoginNumberViewController *controller = [[MewLoginNumberViewController alloc] init];
|
||
[self.navigationController pushViewController:controller animated:NO];
|
||
}
|
||
/// 同意隐私政策
|
||
- (void)mew_agreeButtonAction:(UIButton *)sender {
|
||
self.agreeButton.selected = !self.agreeButton.selected;
|
||
if (self.agreeButton.isSelected) {
|
||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||
[defaults setObject:@"hadAgree" forKey:kHadAgreePrivacy];
|
||
[defaults synchronize];
|
||
[UIView animateWithDuration:0.5 animations:^{
|
||
self.authBubbleView.alpha = 0.0;
|
||
}];
|
||
} else {
|
||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||
NSString * hadAgree = [defaults stringForKey:kHadAgreePrivacy];
|
||
if (hadAgree.length > 0) {
|
||
[defaults removeObjectForKey:kHadAgreePrivacy];
|
||
}
|
||
}
|
||
}
|
||
|
||
/// 苹果登录
|
||
- (void)mew_loginWithApple {
|
||
if (!self.agreeButton.isSelected) {
|
||
[MewHUDTool showErrorWithMessage:@"请勾选协议"];
|
||
return;
|
||
}
|
||
|
||
|
||
if (@available(iOS 13.0, *)) {
|
||
// 基于用户的Apple ID授权用户,生成用户授权请求的一种机制
|
||
ASAuthorizationAppleIDProvider * appleIDProvider = [[ASAuthorizationAppleIDProvider alloc] init];
|
||
// 创建新的AppleID 授权请求
|
||
ASAuthorizationAppleIDRequest * authAppleIDRequest = [appleIDProvider createRequest];
|
||
// 在用户授权期间请求的联系信息
|
||
// authAppleIDRequest.requestedScopes = @[ASAuthorizationScopeFullName, ASAuthorizationScopeEmail];
|
||
//如果 KeyChain 里面也有登录信息的话,可以直接使用里面保存的用户名和密码进行登录。
|
||
// ASAuthorizationPasswordRequest * passwordRequest = [[[ASAuthorizationPasswordProvider alloc] init] createRequest];
|
||
|
||
NSMutableArray <ASAuthorizationRequest *> * array = [NSMutableArray arrayWithCapacity:2];
|
||
if (authAppleIDRequest) {
|
||
[array addObject:authAppleIDRequest];
|
||
}
|
||
// if (passwordRequest) {
|
||
// [array addObject:passwordRequest];
|
||
// }
|
||
NSArray <ASAuthorizationRequest *> * requests = [array copy];
|
||
// 由ASAuthorizationAppleIDProvider创建的授权请求 管理授权请求的控制器
|
||
ASAuthorizationController * authorization = [[ASAuthorizationController alloc] initWithAuthorizationRequests:requests];
|
||
// 设置授权控制器通知授权请求的成功与失败的代理
|
||
authorization.delegate = self;
|
||
// 设置提供 展示上下文的代理,在这个上下文中 系统可以展示授权界面给用户
|
||
authorization.presentationContextProvider = self;
|
||
// 在控制器初始化期间启动授权流
|
||
[authorization performRequests];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
/// 手机 || 密码登录 || Apple
|
||
//- (void)didClickRecognizer:(UITapGestureRecognizer *)tap {
|
||
// if (!self.agreeButton.isSelected) {
|
||
// [MewHUDTool showErrorWithMessage:@"请勾选协议"];
|
||
// return;
|
||
// }
|
||
//
|
||
// MewLoginNumberViewController *controller = [[MewLoginNumberViewController alloc] init];
|
||
// [self.navigationController pushViewController:controller animated:NO];
|
||
//}
|
||
|
||
#pragma mark - ASAuthorizationControllerDelegate
|
||
// 授权成功
|
||
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
|
||
|
||
if ([authorization.credential isKindOfClass:[ASAuthorizationAppleIDCredential class]]) {
|
||
MewThirdUserInfo *userInfo = [[MewThirdUserInfo alloc] init];
|
||
|
||
ASAuthorizationAppleIDCredential * credential = (ASAuthorizationAppleIDCredential *)authorization.credential;
|
||
|
||
// 苹果用户唯一标识符,该值在同一个开发者账号下的所有 App 下是一样的,开发者可以用该唯一标识符与自己后台系统的账号体系绑定起来。
|
||
NSString * userID = credential.user;
|
||
//把用户的唯一标识 传给后台 判断该用户是否绑定手机号,如果绑定了直接登录,如果没绑定跳绑定手机号页面
|
||
// // 苹果用户信息 如果授权过,可能无法再次获取该信息
|
||
NSPersonNameComponents * fullName = credential.fullName;
|
||
NSString * email = credential.email;
|
||
//
|
||
// // 服务器验证需要使用的参数
|
||
NSString * authorizationCode = [[NSString alloc] initWithData:credential.authorizationCode encoding:NSUTF8StringEncoding];
|
||
NSString * identityToken = [[NSString alloc] initWithData:credential.identityToken encoding:NSUTF8StringEncoding];
|
||
//
|
||
NSString *tokenStr = [@"ios" stringByAppendingString:userID];
|
||
// // 用于判断当前登录的苹果账号是否是一个真实用户,取值有:unsupported、unknown、likelyReal
|
||
ASUserDetectionStatus realUserStatus = credential.realUserStatus;
|
||
|
||
if (fullName.familyName.length > 0 && fullName.givenName.length > 0) {
|
||
userInfo.userName = [NSString stringWithFormat:@"%@%@",fullName.familyName, fullName.givenName];
|
||
}
|
||
|
||
[AccountInfoStorage instance].MewThirdUserInfo = userInfo;
|
||
[MewHUDTool mew_showLoadingWithMessage:@"正在登录中"];
|
||
[self.presenter mew_thirdLoginWithApple:identityToken unionId:userID];
|
||
|
||
// [Api loginWithThirdPart:^(BaseModel * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
|
||
//
|
||
//
|
||
// } openid:identityToken unionid:userID access_token:identityToken type:@"5"];
|
||
|
||
// NSLog(@"userID: %@", userID);
|
||
// NSLog(@"fullName: %@", fullName);
|
||
// NSLog(@"email: %@", email);
|
||
// NSLog(@"authorizationCode: %@", authorizationCode);
|
||
// NSLog(@"identityToken: %@", identityToken);
|
||
// NSLog(@"realUserStatus: %@", @(realUserStatus));
|
||
}else if ([authorization.credential isKindOfClass:[ASPasswordCredential class]]) {
|
||
// 这个获取的是iCloud记录的账号密码,需要输入框支持iOS 12 记录账号密码的新特性,如果不支持,可以忽略
|
||
// 用户登录使用现有的密码凭证
|
||
ASPasswordCredential * passwordCredential = (ASPasswordCredential *)authorization.credential;
|
||
// 密码凭证对象的用户标识 用户的唯一标识
|
||
NSString * user = passwordCredential.user;
|
||
|
||
//把用户的唯一标识 传给后台 判断该用户是否绑定手机号,如果绑定了直接登录,如果没绑定跳绑定手机号页面
|
||
|
||
// // 密码凭证对象的密码
|
||
// NSString * password = passwordCredential.password;
|
||
// NSLog(@"userID: %@", user);
|
||
// NSLog(@"password: %@", password);
|
||
|
||
} else {
|
||
|
||
}
|
||
}
|
||
// 授权失败
|
||
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)) {
|
||
NSString *errorMsg = nil;
|
||
switch (error.code) {
|
||
case ASAuthorizationErrorCanceled:
|
||
errorMsg = @"用户取消了授权请求";
|
||
break;
|
||
case ASAuthorizationErrorFailed:
|
||
errorMsg = @"授权请求失败";
|
||
break;
|
||
case ASAuthorizationErrorInvalidResponse:
|
||
errorMsg = @"授权请求响应无效";
|
||
break;
|
||
case ASAuthorizationErrorNotHandled:
|
||
errorMsg = @"未能处理授权请求";
|
||
break;
|
||
case ASAuthorizationErrorUnknown:
|
||
errorMsg = @"授权请求失败未知原因";
|
||
break;
|
||
}
|
||
NSLog(@"%@", errorMsg);
|
||
}
|
||
|
||
#pragma mark- ASAuthorizationControllerPresentationContextProviding
|
||
- (ASPresentationAnchor)presentationAnchorForAuthorizationController:(ASAuthorizationController *)controller API_AVAILABLE(ios(13.0)){
|
||
return self.view.window;
|
||
}
|
||
|
||
|
||
#pragma mark - Getters And Setters
|
||
- (UIButton *)loginButton{ //手机号码一键登录
|
||
if (!_loginButton) {
|
||
_loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
_loginButton.layer.masksToBounds = YES;
|
||
_loginButton.layer.cornerRadius = 45/2.f;
|
||
[_loginButton setTitle:@"账号登录" forState:UIControlStateNormal];
|
||
[_loginButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
||
_loginButton.titleLabel.font = kFontMedium(16);
|
||
_loginButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
||
UIImage *bgImage = [UIImage mew_gradientColorImageFromColors:@[[MEWThemeColor mewColorWithHexString:@"#FF60FD"],
|
||
[MEWThemeColor mewColorWithHexString:@"##8974FF"],
|
||
[MEWThemeColor mewColorWithHexString:@"#69EBFF"]] gradientType:MewGradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth - 80, 52)];
|
||
_loginButton.backgroundColor = [UIColor colorWithPatternImage:bgImage];
|
||
// [_loginButton setTitleColor:ThemeColor.mewMainTextColor forState:UIControlStateNormal];
|
||
// UIImage *image = [UIImage mew_gradientColorImageFromColors:@[[MEWThemeColor mewConfirmButtonGradientStartColor],[MEWThemeColor mewConfirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth - 52 * 2, 45)];
|
||
// [_loginButton setBackgroundImage:image forState:UIControlStateNormal];
|
||
[_loginButton addTarget:self action:@selector(mew_loginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _loginButton;
|
||
}
|
||
|
||
- (UIButton *)agreeButton {
|
||
if (!_agreeButton) {
|
||
_agreeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
[_agreeButton setImage:[UIImage imageNamed:@"mew_login_agree_normal"] forState:UIControlStateNormal];
|
||
[_agreeButton setImage:[UIImage imageNamed:@"mew_login_agree_sel"] forState:UIControlStateSelected];
|
||
[_agreeButton addTarget:self action:@selector(mew_agreeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||
// _agreeButton.backgroundColor = UIColor.blueColor;
|
||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||
NSString *hadAgree = [defaults objectForKey:kHadAgreePrivacy];
|
||
if (hadAgree.length > 0) {
|
||
_agreeButton.selected = YES;
|
||
}
|
||
}
|
||
return _agreeButton;
|
||
}
|
||
|
||
- (YYLabel *)agreeLabel {
|
||
if (!_agreeLabel) {
|
||
_agreeLabel = [[YYLabel alloc] init];
|
||
_agreeLabel.font = [UIFont systemFontOfSize:12];
|
||
_agreeLabel.numberOfLines = 0;
|
||
_agreeLabel.attributedText = [self privacyAttributedStr];
|
||
_agreeLabel.textAlignment = NSTextAlignmentCenter;
|
||
[_agreeLabel sizeToFit];
|
||
}
|
||
return _agreeLabel;
|
||
}
|
||
|
||
- (NSMutableAttributedString *)privacyAttributedStr{
|
||
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"同意"];
|
||
attString.yy_color = UIColorMewRGBAlpha(0xFFFFFF, 0.8);
|
||
NSString *userString = @"《用户服务协议》";
|
||
NSMutableAttributedString *userAttString = [[NSMutableAttributedString alloc] initWithString:userString attributes:@{NSForegroundColorAttributeName:UIColor.whiteColor}];
|
||
__weak typeof(self) weakSelf = 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) {
|
||
__strong typeof(self) strongSelf = weakSelf;
|
||
// 跳转用户协议
|
||
MewWebViewController * webVC = [[MewWebViewController alloc] init];
|
||
webVC.url = URLWithType(kUserProtocalURL);
|
||
[strongSelf.navigationController pushViewController:webVC animated:YES];
|
||
} longPressAction:nil];
|
||
|
||
NSMutableAttributedString *andString = [[NSMutableAttributedString alloc] initWithString:@"和"];
|
||
andString.yy_color = UIColorMewRGBAlpha(0xFFFFFF, 0.8);
|
||
NSString *protocolString = @"《隐私政策》";
|
||
NSMutableAttributedString *privateString = [[NSMutableAttributedString alloc] initWithString:protocolString attributes:@{NSForegroundColorAttributeName:UIColor.whiteColor}];
|
||
[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);
|
||
__strong typeof(self) strongSelf = weakSelf;
|
||
// 跳转隐私政策
|
||
MewWebViewController * webVC = [[MewWebViewController alloc] init];
|
||
webVC.url = URLWithType(kPrivacyURL);
|
||
[self.navigationController pushViewController:webVC animated:YES];
|
||
} longPressAction:nil];
|
||
[attString appendAttributedString:userAttString];
|
||
[attString appendAttributedString:andString];
|
||
[attString appendAttributedString:privateString];
|
||
return attString;
|
||
}
|
||
|
||
- (UIImageView *)authBubbleView {
|
||
if (!_authBubbleView) {
|
||
_authBubbleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_auth_bubble"]];
|
||
_authBubbleView.contentMode = UIViewContentModeScaleAspectFit;
|
||
_authBubbleView.alpha = 0;
|
||
}
|
||
return _authBubbleView;
|
||
}
|
||
|
||
- (UILabel *)authBubbleLabel {
|
||
if (!_authBubbleLabel) {
|
||
_authBubbleLabel = [[UILabel alloc] init];
|
||
_authBubbleLabel.text = @"同意隐私政策和用户协议后,才可以注册登录哦~";
|
||
_authBubbleLabel.font = [UIFont systemFontOfSize:10];
|
||
_authBubbleLabel.textColor = UIColor.whiteColor;
|
||
}
|
||
return _authBubbleLabel;
|
||
}
|
||
|
||
- (UIView *)contentView {
|
||
if (!_contentView) {
|
||
_contentView = [[UIView alloc] init];
|
||
}
|
||
return _contentView;
|
||
}
|
||
|
||
//- (UIStackView *)stackView {
|
||
// if (!_stackView) {
|
||
// _stackView = [[UIStackView alloc] init];
|
||
// _stackView.distribution = UIStackViewDistributionEqualSpacing;
|
||
// _stackView.spacing = 32;
|
||
// _stackView.axis = UILayoutConstraintAxisHorizontal;
|
||
// _stackView.alignment = UIStackViewAlignmentFill;
|
||
// }
|
||
// return _stackView;
|
||
//}
|
||
|
||
- (MewButton *)appleButtonView { //手机号登录
|
||
if (!_appleButtonView) {
|
||
_appleButtonView = [[MewButton alloc] initWithImagePosition:MewButtonImagePositionTop];
|
||
[_appleButtonView setImage: [UIImage imageNamed:@"mew_login_apple"] forState:UIControlStateNormal];
|
||
[_appleButtonView setTitle:@"苹果登录" forState:UIControlStateNormal];
|
||
[_appleButtonView setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
||
_appleButtonView.titleLabel.font = kFontRegular(12);
|
||
_appleButtonView.imageTitleSpace = 5.0;
|
||
[_appleButtonView addTarget:self action:@selector(mew_loginWithApple) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _appleButtonView;
|
||
}
|
||
|
||
//#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
||
//- (ASAuthorizationAppleIDButton *)appleButton API_AVAILABLE(ios(13.0)){ //苹果登录
|
||
// if (!_appleButton) {
|
||
// if (@available(iOS 13.0, *)) {
|
||
// _appleButton = [[ASAuthorizationAppleIDButton alloc] initWithAuthorizationButtonType:ASAuthorizationAppleIDButtonTypeSignIn authorizationButtonStyle:ASAuthorizationAppleIDButtonStyleWhite];
|
||
// } else {
|
||
// // Fallback on earlier versions
|
||
// }
|
||
// _appleButton.cornerRadius = 25;
|
||
// _appleButton.tag = 1000 + ThirdLoginType_Apple;
|
||
//// _appleButton.hidden = NO;
|
||
// }
|
||
// return _appleButton;
|
||
//}
|
||
//#endif
|
||
|
||
- (UIImageView *)bgImageView {
|
||
if (!_bgImageView) {
|
||
_bgImageView = [[UIImageView alloc] init];
|
||
_bgImageView.image = [UIImage imageNamed:@"mew_home_bg"];
|
||
}
|
||
return _bgImageView;
|
||
}
|
||
|
||
- (UIImageView *)helloBgImageView {
|
||
if (!_helloBgImageView) {
|
||
_helloBgImageView = [[UIImageView alloc] init];
|
||
_helloBgImageView.image = [UIImage imageNamed:@"mew_login_logo"];
|
||
}
|
||
return _helloBgImageView;
|
||
}
|
||
|
||
- (UILabel *)helloTitleLabel {
|
||
if (!_helloTitleLabel){
|
||
_helloTitleLabel = [[UILabel alloc]init];
|
||
_helloTitleLabel.text = @"Hi!";
|
||
_helloTitleLabel.textColor = UIColor.whiteColor;
|
||
_helloTitleLabel.font = kFontMedium(68);
|
||
}
|
||
return _helloTitleLabel;
|
||
}
|
||
|
||
- (UILabel *)helloDetailLabel {
|
||
if (!_helloDetailLabel) {
|
||
_helloDetailLabel = [[UILabel alloc]init];
|
||
_helloDetailLabel.text = @"欢迎来到Mew";
|
||
_helloDetailLabel.textColor = UIColor.whiteColor;
|
||
_helloDetailLabel.font = kFontMedium(40);
|
||
}
|
||
return _helloDetailLabel;
|
||
}
|
||
|
||
- (UIView *)leftLineView {
|
||
if (!_leftLineView) {
|
||
_leftLineView = [[UIView alloc] init];
|
||
_leftLineView.backgroundColor = UIColor.whiteColor;
|
||
}
|
||
return _leftLineView;
|
||
}
|
||
|
||
- (UIView *)rightLineView {
|
||
|
||
if (!_rightLineView) {
|
||
_rightLineView = [[UIView alloc] init];
|
||
_rightLineView.backgroundColor = UIColor.whiteColor;
|
||
}
|
||
return _rightLineView;
|
||
}
|
||
- (UILabel *)otherLoginTitleLabel {
|
||
if (!_otherLoginTitleLabel) {
|
||
_otherLoginTitleLabel = [[UILabel alloc ]init];
|
||
_otherLoginTitleLabel.text = @"其他登录方式";
|
||
_otherLoginTitleLabel.textColor = UIColor.whiteColor;
|
||
_otherLoginTitleLabel.font = kFontRegular(13);
|
||
}
|
||
return _otherLoginTitleLabel;
|
||
}
|
||
@end
|