Files
peko-ios/YuMi/Modules/YMLogin/View/NewLogin/XPLoginViewController.m
2024-05-23 11:25:18 +08:00

887 lines
35 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMLoginViewController.m
// YUMI
//
// Created by XY on 2023/2/13.
//
#import "XPLoginViewController.h"
#import <Masonry.h>
#import "DJDKMIMOMColor.h"
#import "UIImage+Utils.h"
#import "YUMIMacroUitls.h"
#import <ReactiveObjC.h>
#import "YUMIHtmlUrl.h"
#import "UIButton+EnlargeTouchArea.h"
#import <AuthenticationServices/ASAuthorizationAppleIDButton.h>
#import "YUMIConstant.h"
#import "GCDHelper.h"
#import "TTPopup.h"
#import "StatisticsServiceHelper.h"
#import "XNDJTDDLoadingTool.h"
#import "XPWebViewController.h"
#import "XPLoginPhoneViewController.h"
#import "UserPrivacyView.h"
#import "AESUtils.h"
#import "LoginPresenter.h"
#import "LoginProtocol.h"
#import "PILoginManager.h"
#import "XPLoginInputView.h"
#import "XPLoginAraeViewController.h"
#import "XPForgetPwdViewController.h"
#import "PISwitchingEnvironmentVC.h"
UIKIT_EXTERN NSString * const kYouMiNumberCountKey;
NSString * const HadAgreePrivacy = @"HadAgreePrivacy";
@interface XPLoginViewController ()<LoginProtocol,XPLoginInputViewDelegate,XPLoginAraeViewControllerDelegate>
///背景
@property(nonatomic,strong) UIImageView *bgImageView;
///logo
@property(nonatomic,strong) UIImageView *logoView;
/// 同意按钮
@property (nonatomic, strong) UIButton *agreeBtn;
/// 协议隐私政策
@property (nonatomic, strong) YYLabel *protocolLabel;
/// 勾选隐私政策提示泡泡
@property (nonatomic, strong) UIImageView *authBubbleView;
/// 泡泡提示内容
@property (nonatomic, strong) UILabel *authBubbleLabel;
@property (nonatomic, strong) UIStackView *stackView;
///手机
@property (nonatomic, strong) UIButton *fbButtonView;
///wx
@property (nonatomic, strong) UIButton *googleButtonView;
///qq
@property (nonatomic, strong) UIButton *lineButtonView;
@property (nonatomic, strong) UIButton *appleButton;
///谷歌登录配置
@property (nonatomic,strong) GIDConfiguration *configuration;
///上次登錄背景
@property(nonatomic,strong) UIImageView *nextView;
///上次登錄
@property(nonatomic,strong) UILabel *nextLabel;
///选择类型背景
@property(nonatomic,strong) UIImageView *chooseTypeView;
///选择手机登录
@property(nonatomic,strong) UIButton *chooseAccountBtn;
///选择密码登录
@property(nonatomic,strong) UIButton *chooseSMSBtn;
/// 手机号输入框
@property (nonatomic, strong) XPLoginInputView *phoneInputView;
/// 验证码输入框
@property (nonatomic, strong) XPLoginInputView *codeInputView;
///// 账号登录手机号输入框
@property (nonatomic, strong) XPLoginInputView *accountView;
/// 账号登录密码输入框
@property (nonatomic, strong) XPLoginInputView *accountPwdView;
/// 忘记密码
@property (nonatomic, strong) UIButton *forgetBtn;
/// 登录按钮
@property (nonatomic, strong) UIButton *loginBtn;
///区号
@property (nonatomic,copy) NSString *pi_phoneAreaCode;
///类型,0密码1.手机
@property(nonatomic,assign) int selectType;
@end
@implementation XPLoginViewController
- (LoginPresenter *)createPresenter {
return [[LoginPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self createUI];
[self racBind];
#ifdef DEBUG
[self setSwitchingEnvironmentVC];
#else
#endif
self.selectType = 0;
NSString *code = [NSString getCountryCode];
self.pi_phoneAreaCode = [code stringByReplacingOccurrencesOfString:@"+" withString:@""];
[[NSNotificationCenter defaultCenter]postNotificationName:@"kInLoginVC" object:nil];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
- (void)racBind {
@weakify(self);
RAC(self.loginBtn, enabled) = [[RACSignal combineLatest:@[self.phoneInputView.inputTextField.rac_textSignal, self.codeInputView.inputTextField.rac_textSignal,self.accountView.inputTextField.rac_textSignal,self.accountPwdView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString* smsCode,NSString *account,NSString *accountPwd){
@strongify(self);
if(self.selectType == 0){
return @(account.length > 0 && accountPwd.length >= 6);
}
return @((phone.length > 0) && smsCode.length > 0);
}] takeUntil:self.rac_willDeallocSignal];
}
- (void)createUI {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"hadAgree" forKey:HadAgreePrivacy];
[defaults synchronize];
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.bgImageView];
[self.view addSubview:self.logoView];
[self.view addSubview:self.chooseAccountBtn];
[self.view addSubview:self.chooseSMSBtn];
[self.view addSubview:self.chooseTypeView];
[self.view addSubview:self.accountView];
[self.view addSubview:self.accountPwdView];
[self.view addSubview:self.phoneInputView];
[self.view addSubview:self.codeInputView];
[self.view addSubview:self.forgetBtn];
[self.view addSubview:self.loginBtn];
[self.view addSubview:self.stackView];
[self.view addSubview:self.protocolLabel];
[self.view addSubview:self.agreeBtn];
[self.view addSubview:self.authBubbleView];
[self.authBubbleView addSubview:self.authBubbleLabel];
if (@available(iOS 13.0, *)) {
#ifdef DEBUG
[self.stackView addArrangedSubview:self.appleButton];
#else
if(isEnterprise == YES){
[self.stackView addArrangedSubview:self.appleButton];
}
#endif
}
[self.stackView addArrangedSubview:self.googleButtonView];
[self.stackView addArrangedSubview:self.fbButtonView];
[self.stackView addArrangedSubview:self.lineButtonView];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(91));
}];
[self.logoView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_offset(kGetScaleWidth(162));
make.height.mas_equalTo(kGetScaleWidth(32));
make.centerX.equalTo(self.view);
make.top.equalTo(self.bgImageView.mas_bottom).mas_offset(kGetScaleWidth(10));
}];
CGFloat width = KScreenWidth/2;
[self.chooseAccountBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(22));
make.width.mas_equalTo(width);
make.top.equalTo(self.logoView.mas_bottom).mas_offset(kGetScaleWidth(31));
}];
[self.chooseSMSBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(kGetScaleWidth(22));
make.width.mas_equalTo(width);
make.top.equalTo(self.logoView.mas_bottom).mas_offset(kGetScaleWidth(31));
make.trailing.mas_equalTo(0);
}];
[self.chooseTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.logoView.mas_bottom).mas_offset(kGetScaleWidth(48));
make.width.height.mas_equalTo(kGetScaleWidth(24));
make.leading.mas_equalTo(KScreenWidth/4 - kGetScaleWidth(12));
}];
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.chooseTypeView.mas_bottom).offset(kGetScaleWidth(13));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.accountPwdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.phoneInputView.mas_bottom).offset(kGetScaleWidth(20));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.phoneInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.accountView);
}];
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.accountPwdView);
}];
[self.forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.codeInputView.mas_bottom).mas_offset(kGetScaleWidth(8));
make.trailing.mas_equalTo(-kGetScaleWidth(52));
make.height.mas_equalTo(kGetScaleWidth(17));
}];
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(303));
make.centerX.equalTo(self.view);
make.top.equalTo(self.forgetBtn.mas_bottom).mas_offset(kGetScaleWidth(23));
make.height.mas_equalTo(kGetScaleWidth(48));
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.loginBtn.mas_bottom).offset(kGetScaleWidth(27));
make.centerX.mas_equalTo(self.view);
}];
CGFloat left = isMSRTL() ? -11 : 11;
CGFloat protocolWidth = 204;
if (isMSRTL()){
protocolWidth = 250;
}else if (isMSEN()){
protocolWidth = 270;
}
[self.protocolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view).offset(left);
make.height.mas_greaterThanOrEqualTo(22);
make.width.mas_equalTo(protocolWidth);
make.bottom.mas_equalTo(-kGetScaleWidth(35));
}];
[self.agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.protocolLabel.mas_leading).offset(0);
make.top.mas_equalTo(self.protocolLabel.mas_top);
make.width.height.mas_equalTo(22);
}];
[self.authBubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.agreeBtn).mas_offset((-16));
make.top.mas_equalTo(self.agreeBtn.mas_bottom);
make.width.mas_equalTo(235);
make.height.mas_equalTo(29);
}];
[self.authBubbleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(8);
make.trailing.mas_equalTo(-8);
make.bottom.mas_equalTo(self.authBubbleView).mas_offset(isMSZH() ? -6:0);
}];
if (@available(iOS 13.0, *)) {
#ifdef DEBUG
[self.appleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(295));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
#else
if(isEnterprise == YES){
[self.appleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(295));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
}
#endif
}
[self.googleButtonView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(295));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
[self.fbButtonView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(295));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
self.fbButtonView.hidden = YES;
self.lineButtonView.hidden = YES;
[self.lineButtonView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(295));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
id type = [[NSUserDefaults standardUserDefaults]valueForKey:@"kLoginSuccessType"];
if(type != nil){
UIButton *typeButton ;
if([type intValue] == ThirdLoginType_Apple){
typeButton = self.appleButton;
}else if([type intValue] == ThirdLoginType_Gmail){
typeButton = self.googleButtonView;
}
// else if([type intValue] == ThirdLoginType_FB){
// typeButton = self.fbButtonView;
// }else if([type intValue] == ThirdLoginType_Line){
// typeButton = self.lineButtonView;
// }
// if(typeButton == nil){
// return;
// }
// [self.view addSubview:self.nextView];
// [self.nextView addSubview:self.nextLabel];
// [self.nextView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.trailing.mas_equalTo(-kGetScaleWidth(28));
// make.width.mas_equalTo(kGetScaleWidth(70));
// make.height.mas_equalTo(kGetScaleWidth(24));
// make.centerY.equalTo(typeButton.mas_top);
// }];
// [self.nextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.edges.equalTo(self.nextView);
// }];
}
}
-(void)setSwitchingEnvironmentVC{
UIButton *but = [UIButton new];
[but setTitle:@"切换环境" forState:UIControlStateNormal];
[but setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[self.view addSubview:but];
[but addTarget:self action:@selector(switchingEnvironmentVCAction) forControlEvents:UIControlEventTouchUpInside];
[but mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-kGetScaleWidth(30));
make.top.mas_equalTo(kStatusBarHeight+20);
}];
}
-(void)switchingEnvironmentVCAction{
#ifdef DEBUG
PISwitchingEnvironmentVC *vc = [PISwitchingEnvironmentVC new];
[self.navigationController pushViewController:vc animated:YES];
#else
#endif
}
- (void)setConfigPrivacyAlertView {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *isShow = [defaults objectForKey:kYouMiNumberCountKey];
// 隐私协议弹出
if (!isShow && isShow.length <= 0) {
UserPrivacyView * alertView = [[UserPrivacyView alloc] init];
alertView.controller = self;
TTPopupService * config = [[TTPopupService alloc] init];
config.shouldDismissOnBackgroundTouch = NO;
config.contentView = alertView;
[TTPopup popupWithConfig:config];
};
}
- (void)loginDidClick:(UIButton *)sender {
if (self.agreeBtn.selected) {
ThirdLoginType type = sender.tag - 1000;
if(type == ThirdLoginType_Gmail){
[self.presenter thirdLoginByGoogleWithPresentingViewController:self configuration:self.configuration];
return;
}else if(type == ThirdLoginType_FB){
[self.presenter thirdLoginByFBWithPresentingViewController:self];
return;
}else if(type == ThirdLoginType_Line){
[self.presenter thirdLoginByLine:self];
return;
}
[self.presenter thirdLoginWithType:type];
} else {
[UIView animateWithDuration:0.5 animations:^{
self.authBubbleView.alpha = 1.0;
}];
}
}
/// 点击同意
- (void)agreeBtnClicked {
self.agreeBtn.selected = !self.agreeBtn.selected;
if (self.agreeBtn.isSelected) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"hadAgree" forKey:HadAgreePrivacy];
[defaults synchronize];
[UIView animateWithDuration:0.5 animations:^{
self.authBubbleView.alpha = 0.0;
}];
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * hadAgree = [defaults stringForKey:HadAgreePrivacy];
if (hadAgree.length > 0) {
[defaults removeObjectForKey:HadAgreePrivacy];
}
}
}
/// 点击手机号登录
- (void)phoneLoginBtnClicked {
if (self.agreeBtn.isSelected) {
XPLoginPhoneViewController *phoneVC = [[XPLoginPhoneViewController alloc] init];
[self.navigationController pushViewController:phoneVC animated:YES];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventLoginPhoneClick];
} else {
[UIView animateWithDuration:0.5 animations:^{
self.authBubbleView.alpha = 1.0;
}];
}
}
/// 点击一键登录
- (void)quickLoginBtnClicked {
if (self.agreeBtn.isSelected) {
XPLoginPhoneViewController *phoneVC = [[XPLoginPhoneViewController alloc] init];
[self.navigationController pushViewController:phoneVC animated:YES];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventLoginPhoneClick];
} else {
[UIView animateWithDuration:0.5 animations:^{
self.authBubbleView.alpha = 1.0;
}];
}
}
/// 登录
- (void)loginBtnClicked {
if (!self.agreeBtn.selected) {
[UIView animateWithDuration:0.5 animations:^{
self.authBubbleView.alpha = 1.0;
}];
return;
}
[XNDJTDDLoadingTool showOnlyView:self.view];
if(self.selectType == 0){
NSString *phone = self.accountView.inputTextField.text;
NSString *password = self.accountPwdView.inputTextField.text;
[self.presenter loginWithPhone:phone password:password];
return;
}
NSString *phone = self.phoneInputView.inputTextField.text;
NSString *smsCode = self.codeInputView.inputTextField.text;
NSString * phoneStr = [NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode, phone];
[self.presenter loginWithPhone:phoneStr code:smsCode phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)forgetBtnClicked {
XPForgetPwdViewController *forgetVC = [[XPForgetPwdViewController alloc] init];
[self.navigationController pushViewController:forgetVC animated:YES];
}
#pragma mark - LoginProtocol
- (void)loginThirdPartSuccess {
[self.codeInputView cancelTimer];
[PILoginManager loginWithVC:self isLoginPhone:NO];
[self showSuccessToast:YMLocalizedString(@"XPLoginViewController4")];
}
-(void)chooseAccountAction{
self.selectType = 0;
}
-(void)chooseSMSAction{
self.selectType = 1;
}
-(void)setSelectType:(int)selectType{
_selectType = selectType;
_chooseAccountBtn.selected = _selectType == 0;
_chooseSMSBtn.selected = _selectType != 0;
_forgetBtn.hidden = _selectType != 0;
_accountView.hidden = _selectType != 0;
_accountPwdView.hidden = _selectType != 0;
_phoneInputView.hidden = _selectType == 0;
_codeInputView.hidden = _selectType == 0;
[self.chooseTypeView.superview layoutIfNeeded];
CGFloat lead = _selectType == 0 ? KScreenWidth/4 - kGetScaleWidth(12) : KScreenWidth/4 * 3 - kGetScaleWidth(12);
[UIView animateWithDuration:0.1 animations:^{
[self.chooseTypeView mas_updateConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(lead);
}];
[self.chooseTypeView.superview layoutIfNeeded];
}];
}
#pragma mark - XPLoginInputViewDelegate
- (void)smsCodeAction {
NSString *phone = self.phoneInputView.inputTextField.text;
if (phone.length == 0 ) {
[self showErrorToast:YMLocalizedString(@"XPLoginPhoneViewController0")];
return;
}
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,phone] type:GetSmsType_Regist phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)areaListAction {
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
#pragma mark - XPLoginAraeViewControllerDelegate
- (void)chooseAreaCodeSuccess:(NSString *)code {
if (code.length > 0) {
self.pi_phoneAreaCode = code;
[self.phoneInputView.areaCodeBtn setTitle:[NSString stringWithFormat:@"+%@", code] forState:UIControlStateNormal];
}
}
#pragma mark - LoginVerifCodeProtocol
- (void)loginWithPhoenSuccess{
[XNDJTDDLoadingTool hideOnlyView:self.view];
[[NSUserDefaults standardUserDefaults]setValue:@(ThirdLoginType_Phone) forKey:@"kLoginSuccessType"];
[[NSUserDefaults standardUserDefaults]synchronize];
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController1")];
[PILoginManager loginWithVC:self isLoginPhone:YES];
}
- (void)loginSuccess {
[self.codeInputView cancelTimer];
[XNDJTDDLoadingTool hideOnlyView:self.view];
[[NSUserDefaults standardUserDefaults]removeObjectForKey:@"kLoginSuccessType"];
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController1")];
[PILoginManager loginWithVC:self isLoginPhone:NO];
}
- (void)loginFailWithMsg:(NSString *)msg{
[self showErrorToast:msg];
[XNDJTDDLoadingTool hideOnlyView:self.view];
}
- (void)phoneSmsCodeSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.codeInputView fireTimer];
}
#pragma mark - 懒加载
- (UIButton *)agreeBtn {
if(!_agreeBtn) {
_agreeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_agreeBtn setImage:[UIImage imageNamed:@"login_agree"] forState:UIControlStateSelected];
[_agreeBtn setImage:[UIImage imageNamed:@"login_disagree"] forState:UIControlStateNormal];
[_agreeBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_agreeBtn addTarget:self action:@selector(agreeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *hadAgree = [defaults objectForKey:HadAgreePrivacy];
if (hadAgree.length > 0) {
_agreeBtn.selected = YES;
}
}
return _agreeBtn;
}
- (YYLabel *)protocolLabel {
if (!_protocolLabel) {
_protocolLabel = [[YYLabel alloc] init];
_protocolLabel.font = kFontRegular(12);
_protocolLabel.numberOfLines = 0;
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginViewController6")];
attString.yy_color = UIColorFromRGB(0xB3B3C3);
NSRange userRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController7")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} range:userRange];
@weakify(self);
[attString yy_setTextHighlightRange:userRange color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@strongify(self);
// 跳转用户协议
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = URLWithType(kUserProtocalURL);
[self.navigationController pushViewController:webVC animated:YES];
} longPressAction:nil];
NSRange andRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController8")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xB3B3C3)} range:andRange];
NSRange protocolRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController9")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)} range:protocolRange];
[attString yy_setTextHighlightRange:protocolRange color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@strongify(self);
// 跳转隐私政策
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.url = URLWithType(kPrivacyURL);
[self.navigationController pushViewController:webVC animated:YES];
} longPressAction:nil];
_protocolLabel.attributedText = attString;
}
return _protocolLabel;
}
- (UIImageView *)authBubbleView {
if (!_authBubbleView) {
_authBubbleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_auth_bubble"]];
_authBubbleView.contentMode = UIViewContentModeScaleAspectFit;
_authBubbleView.alpha = 0;
}
return _authBubbleView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = kGetScaleWidth(16);
}
return _stackView;
}
- (UILabel *)authBubbleLabel {
if (!_authBubbleLabel) {
_authBubbleLabel = [[UILabel alloc] init];
_authBubbleLabel.text = YMLocalizedString(@"XPLoginViewController11");
_authBubbleLabel.font = [UIFont systemFontOfSize:9];
_authBubbleLabel.textColor = UIColor.whiteColor;
_authBubbleLabel.numberOfLines = 2;
}
return _authBubbleLabel;
}
- (UIButton *)fbButtonView {
if (!_fbButtonView) {
_fbButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
[_fbButtonView setImage: [UIImage imageNamed:@"login_facebook"] forState:UIControlStateNormal];
[_fbButtonView setTitle:YMLocalizedString(@"XPLoginViewController14") forState:UIControlStateNormal];
_fbButtonView.titleLabel.font = kFontMedium(16);
[_fbButtonView setTitleColor:UIColorFromRGB(0x6D6B89) forState:UIControlStateNormal];
[_fbButtonView setImageEdgeInsets:UIEdgeInsetsMake(0, kGetScaleWidth(28), 0, kGetScaleWidth(200))];
_fbButtonView.backgroundColor = UIColorFromRGB(0xF3F5FA);
_fbButtonView.layer.cornerRadius = kGetScaleWidth(46)/2;
_fbButtonView.layer.masksToBounds = YES;
_fbButtonView.tag = 1000 + ThirdLoginType_FB;
[_fbButtonView addTarget:self action:@selector(loginDidClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _fbButtonView;
}
- (UIButton *)googleButtonView {
if (!_googleButtonView) {
_googleButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
[_googleButtonView setImage: [UIImage imageNamed:@"login_gmail"] forState:UIControlStateNormal];
[_googleButtonView setTitle:YMLocalizedString(@"XPLoginViewController13") forState:UIControlStateNormal];
_googleButtonView.titleLabel.font = kFontMedium(16);
[_googleButtonView setTitleColor:UIColorFromRGB(0x6D6B89) forState:UIControlStateNormal];
[_googleButtonView setImageEdgeInsets:UIEdgeInsetsMake(0, kGetScaleWidth(28), 0, kGetScaleWidth(200))];
_googleButtonView.backgroundColor = UIColorFromRGB(0xF3F5FA);
_googleButtonView.layer.cornerRadius = kGetScaleWidth(46)/2;
_googleButtonView.layer.masksToBounds = YES;
_googleButtonView.tag = 1000 + ThirdLoginType_Gmail;
[_googleButtonView addTarget:self action:@selector(loginDidClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _googleButtonView;
}
- (UIButton *)lineButtonView {
if (!_lineButtonView) {
_lineButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
[_lineButtonView setImage: [UIImage imageNamed:@"login_line"] forState:UIControlStateNormal];
[_lineButtonView setTitle:YMLocalizedString(@"XPLoginViewController15") forState:UIControlStateNormal];
_lineButtonView.titleLabel.font = kFontMedium(16);
[_lineButtonView setTitleColor:UIColorFromRGB(0x6D6B89) forState:UIControlStateNormal];
[_lineButtonView setImageEdgeInsets:UIEdgeInsetsMake(0, kGetScaleWidth(28), 0, kGetScaleWidth(200))];
_lineButtonView.backgroundColor = UIColorFromRGB(0xF3F5FA);
_lineButtonView.layer.cornerRadius = kGetScaleWidth(46)/2;
_lineButtonView.layer.masksToBounds = YES;
_lineButtonView.tag = 1000 + ThirdLoginType_Line;
[_lineButtonView addTarget:self action:@selector(loginDidClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _lineButtonView;
}
- (UIButton *)appleButton {
if (!_appleButton) {
_appleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_appleButton setImage: [UIImage imageNamed:@"login_apple"] forState:UIControlStateNormal];
[_appleButton setTitle:YMLocalizedString(@"XPLoginViewController12") forState:UIControlStateNormal];
_appleButton.titleLabel.font = kFontMedium(16);
[_appleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_appleButton setImageEdgeInsets:UIEdgeInsetsMake(0, kGetScaleWidth(28), 0, kGetScaleWidth(200))];
_appleButton.backgroundColor = UIColorFromRGB(0x141414);
_appleButton.layer.cornerRadius = kGetScaleWidth(46)/2;
_appleButton.layer.masksToBounds = YES;
_appleButton.tag = 1000 + ThirdLoginType_Apple;
[_appleButton addTarget:self action:@selector(loginDidClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _appleButton;
}
- (GIDConfiguration *)configuration{
if (!_configuration){
NSString * number = [AESUtils aesDecrypt:@"ScLBu7ctIiyGCKPro3Jj6XMdsdCCpNT9L4wyjHEF+bguqubkXNSayFBGMKmoDwe1hjfAc958XSaBdMyEaFXLO38Bwq3xURYVNpgEM4b14zg="];
_configuration = [[GIDConfiguration alloc] initWithClientID:number];
}
return _configuration;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [[UIImageView alloc]init];
_bgImageView.image = kImage(@"pi_app_logo_new_bg");
_bgImageView.contentMode = 2;
}
return _bgImageView;
}
- (UIImageView *)logoView{
if(!_logoView){
_logoView = [UIImageView new];
_logoView.image = kImage(@"pi_login_new_logo");
}
return _logoView;
}
- (UIImageView *)nextView{
if(!_nextView){
_nextView = [UIImageView new];
_nextView.image = kImage(@"login_next_login");
}
return _nextView;
}
- (UILabel *)nextLabel{
if(!_nextLabel){
_nextLabel = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginViewController17") font:kFontMedium(12) textColor:[UIColor whiteColor]];
_nextLabel.textAlignment = NSTextAlignmentCenter;
}
return _nextLabel;
}
- (XPLoginInputView *)phoneInputView {
if (!_phoneInputView) {
_phoneInputView = [[XPLoginInputView alloc] init];
_phoneInputView.areaStackView.hidden = NO;
_phoneInputView.delegate = self;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPhoneViewController5")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_phoneInputView.inputTextField.attributedPlaceholder = placeholder;
_phoneInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
_phoneInputView.hidden = YES;
}
return _phoneInputView;
}
- (XPLoginInputView *)codeInputView {
if (!_codeInputView) {
_codeInputView = [[XPLoginInputView alloc] init];
_codeInputView.smsCodeBtn.hidden = NO;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPhoneViewController6")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_codeInputView.inputTextField.attributedPlaceholder = placeholder;
_codeInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
_codeInputView.delegate = self;
_codeInputView.hidden = YES;
}
return _codeInputView;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xD1F9FF),UIColorFromRGB(0xDEE4FF),UIColorFromRGB(0xEEDCFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
[_loginBtn setImage:nextImage forState:UIControlStateNormal];
[_loginBtn setImage:disableImage forState:UIControlStateDisabled];
_loginBtn.layer.cornerRadius = kGetScaleWidth(48)/2;
_loginBtn.layer.masksToBounds = YES;
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginPhoneViewController8") font:kFontMedium(16) textColor:[UIColor whiteColor]];
titleView.textAlignment = NSTextAlignmentCenter;
[_loginBtn addSubview:titleView];
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.loginBtn);
}];
[_loginBtn addTarget:self action:@selector(loginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
- (UIImageView *)chooseTypeView{
if(!_chooseTypeView){
_chooseTypeView = [UIImageView new];
_chooseTypeView.userInteractionEnabled = YES;
[_chooseTypeView setImage:kImage(@"ms_login_choose_phone_icon")];
}
return _chooseTypeView;
}
- (UIButton *)chooseAccountBtn{
if(!_chooseAccountBtn){
_chooseAccountBtn = [UIButton new];
[_chooseAccountBtn setTitle:YMLocalizedString(@"XPLoginPhoneViewController9" ) forState:UIControlStateNormal];
[_chooseAccountBtn setTitleColor:UIColorFromRGB(0x84868A) forState:UIControlStateNormal];
[_chooseAccountBtn setTitleColor:UIColorFromRGB(0x000000) forState:UIControlStateSelected];
_chooseAccountBtn.titleLabel.font = kFontMedium(16);
[_chooseAccountBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
_chooseAccountBtn.selected = YES;
[_chooseAccountBtn addTarget:self action:@selector(chooseAccountAction) forControlEvents:UIControlEventTouchUpInside];
}
return _chooseAccountBtn;
}
- (UIButton *)chooseSMSBtn{
if(!_chooseSMSBtn){
_chooseSMSBtn = [UIButton new];
[_chooseSMSBtn setTitle:YMLocalizedString(@"XPLoginPhoneViewController10") forState:UIControlStateNormal];
[_chooseSMSBtn setTitleColor:UIColorFromRGB(0x84868A) forState:UIControlStateNormal];
[_chooseSMSBtn setTitleColor:UIColorFromRGB(0x000000) forState:UIControlStateSelected];
_chooseSMSBtn.titleLabel.font = kFontMedium(16);
[_chooseSMSBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_chooseSMSBtn addTarget:self action:@selector(chooseSMSAction) forControlEvents:UIControlEventTouchUpInside];
}
return _chooseSMSBtn;
}
- (XPLoginInputView *)accountView {
if (!_accountView) {
_accountView = [[XPLoginInputView alloc] init];
_accountView.areaStackView.hidden = YES;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController6")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB4B7BD) range:NSMakeRange(0, placeholder.length)];
_accountView.inputTextField.attributedPlaceholder = placeholder;
_accountView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
return _accountView;
}
- (XPLoginInputView *)accountPwdView {
if (!_accountPwdView) {
_accountPwdView = [[XPLoginInputView alloc] init];
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController3")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB4B7BD) range:NSMakeRange(0, placeholder.length)];
_accountPwdView.inputTextField.attributedPlaceholder = placeholder;
_accountPwdView.inputTextField.keyboardType = UIKeyboardTypeAlphabet;
_accountPwdView.inputTextField.secureTextEntry = YES;
}
return _accountPwdView;
}
- (UIButton *)forgetBtn {
if (!_forgetBtn) {
_forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_forgetBtn setTitle:YMLocalizedString(@"XPRoomRedPacketPwdView1") forState:UIControlStateNormal];
[_forgetBtn setTitleColor:UIColorFromRGB(0xB4B7BD) forState:UIControlStateNormal];
_forgetBtn.titleLabel.font = kFontRegular(12);
[_forgetBtn addTarget:self action:@selector(forgetBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _forgetBtn;
}
@end