2021-09-06 18:47:38 +08:00
|
|
|
|
//
|
|
|
|
|
// LoginViewController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by zu on 2021/8/31.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "LoginViewController.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Third
|
2021-09-06 18:47:38 +08:00
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
#import <ReactiveObjC.h>
|
|
|
|
|
#import <YYText.h>
|
|
|
|
|
#import <NTESQuickPass/NTESQuickPass.h>
|
2021-09-13 18:56:16 +08:00
|
|
|
|
#import <AuthenticationServices/ASAuthorizationAppleIDButton.h>
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
#import "GCDHelper.h"
|
|
|
|
|
#import "XCHUDTool.h"
|
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "XPConstant.h"
|
|
|
|
|
///Present
|
|
|
|
|
#import "LoginPresenter.h"
|
|
|
|
|
#import "LoginProtocol.h"
|
|
|
|
|
///VC
|
2021-09-08 21:29:47 +08:00
|
|
|
|
#import "LoginPhoneViewController.h"
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef NS_ENUM(NSUInteger, XYLoginType) {
|
|
|
|
|
XYLoginTypeUnknow = 0, //未知
|
|
|
|
|
XYLoginTypeTelecom = 1, //电信
|
|
|
|
|
XYLoginTypeChinaMobile = 2, //移动
|
|
|
|
|
XYLoginTypeUnicom = 3 //联通
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@interface LoginViewController () <LoginProtocol>
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView *appIcon;
|
|
|
|
|
/** 标题 */
|
|
|
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
|
|
/** 副标题 */
|
|
|
|
|
@property (nonatomic, strong) UILabel *subTitleLabel;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) UIView *contentView;
|
|
|
|
|
/** 登录按钮*/
|
|
|
|
|
@property (nonatomic, strong) UIButton *loginButton;
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
@property (nonatomic, strong) UIStackView *stackView;
|
2021-09-06 18:47:38 +08:00
|
|
|
|
///手机
|
2021-09-13 18:56:16 +08:00
|
|
|
|
@property (nonatomic, strong) UIButton *qqButtonView;
|
2021-09-06 18:47:38 +08:00
|
|
|
|
///wx
|
2021-09-13 18:56:16 +08:00
|
|
|
|
@property (nonatomic, strong) UIButton *wxButtonView;
|
2021-09-06 18:47:38 +08:00
|
|
|
|
///qq
|
2021-09-13 18:56:16 +08:00
|
|
|
|
@property (nonatomic, strong) UIButton *phoneButtonView;
|
|
|
|
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
|
|
|
|
@property (nonatomic, strong) ASAuthorizationAppleIDButton *appleButton;
|
|
|
|
|
#endif
|
2021-09-06 18:47:38 +08:00
|
|
|
|
/** 同意勾选按钮*/
|
|
|
|
|
@property (nonatomic, strong) UIButton *agreeButton;
|
|
|
|
|
/** 同意即可登录 */
|
|
|
|
|
@property (nonatomic, strong) YYLabel *agreeLabel;
|
|
|
|
|
/** 勾选隐私政策提示泡泡 */
|
|
|
|
|
@property (nonatomic, strong) UIImageView *authBubbleView;
|
|
|
|
|
/** 泡泡提示内容 */
|
|
|
|
|
@property (nonatomic, strong) UILabel *authBubbleLabel;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation LoginViewController
|
|
|
|
|
|
|
|
|
|
- (LoginPresenter *)createPresenter {
|
|
|
|
|
return [[LoginPresenter alloc] init];
|
|
|
|
|
}
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
[self initView];
|
|
|
|
|
[self setUpConstraints];
|
|
|
|
|
[self setEvents];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
[self hideNavigationBar];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
[self showNavigationBar];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initView {
|
|
|
|
|
[self.view addSubview:self.appIcon];
|
|
|
|
|
[self.view addSubview:self.titleLabel];
|
|
|
|
|
[self.view addSubview:self.subTitleLabel];
|
|
|
|
|
|
|
|
|
|
[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.stackView addArrangedSubview:self.qqButtonView];
|
|
|
|
|
[self.stackView addArrangedSubview:self.phoneButtonView];
|
|
|
|
|
[self.stackView addArrangedSubview:self.wxButtonView];
|
2021-09-13 18:56:16 +08:00
|
|
|
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
|
|
|
|
[self.stackView addArrangedSubview:self.appleButton];
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setUpConstraints {
|
|
|
|
|
[self.appIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(110 + kSafeAreaTopHeight);
|
|
|
|
|
make.left.mas_equalTo(52);
|
|
|
|
|
make.width.mas_equalTo(100);
|
|
|
|
|
make.height.mas_equalTo(100);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.appIcon.mas_top).offset(28.5);
|
|
|
|
|
make.left.mas_equalTo(self.appIcon.mas_right).offset(7.5);
|
|
|
|
|
make.height.mas_equalTo(20);
|
|
|
|
|
make.right.mas_equalTo(-20);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(13);
|
|
|
|
|
make.left.mas_equalTo(self.titleLabel.mas_left);
|
|
|
|
|
make.height.mas_equalTo(13);
|
|
|
|
|
make.right.mas_equalTo(-20);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.view).offset(iPhoneXSeries ? 300 : 228);
|
|
|
|
|
make.left.right.bottom.mas_equalTo(0);
|
|
|
|
|
}];
|
|
|
|
|
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self.view).inset(52);
|
|
|
|
|
make.top.mas_equalTo(70);
|
|
|
|
|
make.height.mas_equalTo(45);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 60);
|
|
|
|
|
make.centerX.mas_equalTo(self.view);
|
2021-09-13 18:56:16 +08:00
|
|
|
|
make.height.mas_equalTo(50);
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.agreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.loginButton.mas_bottom).offset(20);
|
|
|
|
|
make.height.mas_equalTo(40);
|
|
|
|
|
make.width.mas_equalTo(270);
|
|
|
|
|
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);
|
|
|
|
|
}];
|
2021-09-13 18:56:16 +08:00
|
|
|
|
|
|
|
|
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
|
|
|
|
|
[self.appleButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(50, 50));
|
|
|
|
|
}];
|
|
|
|
|
#endif
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setEvents {
|
|
|
|
|
// 手机登陆按钮点击
|
|
|
|
|
@weakify(self)
|
|
|
|
|
UITapGestureRecognizer *phoneTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickRecognizer:)];
|
|
|
|
|
[self.phoneButtonView addGestureRecognizer:phoneTap];
|
|
|
|
|
UITapGestureRecognizer * qqTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickRecognizer:)];
|
|
|
|
|
[self.qqButtonView addGestureRecognizer:qqTap];
|
|
|
|
|
UITapGestureRecognizer * wxTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickRecognizer:)];
|
|
|
|
|
[self.wxButtonView addGestureRecognizer:wxTap];
|
2021-09-13 18:56:16 +08:00
|
|
|
|
UITapGestureRecognizer * appleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickRecognizer:)];
|
|
|
|
|
[self.appleButton addGestureRecognizer:appleTap];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
|
|
|
|
[[self.agreeButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
|
|
|
|
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;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
// 一键登录
|
|
|
|
|
[[self.loginButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
|
|
|
|
@strongify(self)
|
|
|
|
|
if (self.agreeButton.isSelected) {
|
|
|
|
|
[self phoneQuickLogin];
|
|
|
|
|
} else {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.authBubbleView.alpha = 1.0;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)didClickRecognizer:(UITapGestureRecognizer *)tap {
|
|
|
|
|
UIView * view = tap.view;
|
|
|
|
|
if (self.agreeButton.isSelected) {
|
|
|
|
|
if ([view isEqual:self.phoneButtonView]) {
|
2021-09-08 21:29:47 +08:00
|
|
|
|
LoginPhoneViewController *inputPhoneVC = [[LoginPhoneViewController alloc] init];
|
2021-09-09 19:18:47 +08:00
|
|
|
|
[self.navigationController pushViewController:inputPhoneVC animated:YES];
|
2021-09-13 18:56:16 +08:00
|
|
|
|
} else{
|
|
|
|
|
ThirdLoginType type = view.tag - 1000;
|
|
|
|
|
[self.presenter thirdLoginWithType:type];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.authBubbleView.alpha = 1.0;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)phoneQuickLogin {
|
|
|
|
|
[XCHUDTool showLoading];
|
|
|
|
|
// 在使用一键登录之前,请先调用shouldQuickLogin方法,判断当前上网卡的网络环境和运营商是否可以一键登录
|
|
|
|
|
@weakify(self)
|
|
|
|
|
NTESQuickLoginManager *qlManager = [NTESQuickLoginManager sharedInstance];
|
|
|
|
|
BOOL shouldQL = [qlManager shouldQuickLogin];
|
|
|
|
|
if (!shouldQL) {
|
|
|
|
|
[self phoneQuickLoginFail];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 14:22:51 +08:00
|
|
|
|
[qlManager registerWithBusinessID:KeyWithType(KeyType_NTESQuickLoginBusinessId) timeout:3*1000 configURL:nil extData:nil completion:^(NSDictionary * _Nullable params, BOOL regSuccess) {
|
2021-09-06 18:47:38 +08:00
|
|
|
|
@strongify(self)
|
|
|
|
|
if (!regSuccess) {
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
[self phoneQuickLoginFail];
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSString *token = [params objectForKey:@"token"];
|
|
|
|
|
[qlManager getPhoneNumberCompletion:^(NSDictionary * _Nonnull resultDic) {
|
|
|
|
|
@strongify(self)
|
|
|
|
|
NSNumber *boolNum = [resultDic objectForKey:@"success"];
|
|
|
|
|
BOOL getPhoneNumberSuccess = [boolNum boolValue];
|
|
|
|
|
if (!getPhoneNumberSuccess) {
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
[self phoneQuickLoginFail];
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self configQuickLogin];
|
|
|
|
|
[qlManager CUCMCTAuthorizeLoginCompletion:^(NSDictionary * _Nonnull resultDic) {
|
|
|
|
|
@strongify(self)
|
|
|
|
|
NSNumber *boolNum = [resultDic objectForKey:@"success"];
|
|
|
|
|
BOOL authSuccess = [boolNum boolValue];
|
|
|
|
|
if (!authSuccess) {
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
NSString *resultCode = [resultDic objectForKey:@"resultCode"];
|
|
|
|
|
//取消一键登录
|
|
|
|
|
if ([resultCode isEqualToString:@"200020"] ||
|
|
|
|
|
[resultCode isEqualToString:@"10104"]) {
|
|
|
|
|
[XCHUDTool hideHUD];
|
|
|
|
|
} else {
|
|
|
|
|
[self phoneQuickLoginFail];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
@strongify(self)
|
|
|
|
|
// [TTStatisticsService trackEvent:@"one_click_login_succeed" eventDescribe:@"一键登录成功"];
|
|
|
|
|
// // 取号成功,获取acessToken
|
|
|
|
|
[XCHUDTool hideHUD];
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
|
[self.presenter phoneQuickLogin:resultDic[@"accessToken"] token:token];
|
|
|
|
|
});
|
|
|
|
|
}];
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)phoneQuickLoginFail {
|
|
|
|
|
[XCHUDTool showErrorWithMessage:@"一键登录失败,请检查手机网络状态。"];
|
2021-09-09 19:18:47 +08:00
|
|
|
|
LoginPhoneViewController *inputPhoneVC = [[LoginPhoneViewController alloc] init];
|
|
|
|
|
[self.navigationController pushViewController:inputPhoneVC animated:YES];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)configQuickLogin {
|
|
|
|
|
// 获取当前上网卡的运营商,0:未知 1:电信 2.移动 3.联通
|
|
|
|
|
NSInteger currentCarrier = [[NTESQuickLoginManager sharedInstance] getCarrier];
|
|
|
|
|
NTESQuickLoginModel *CMModel = [[NTESQuickLoginModel alloc] init];
|
|
|
|
|
CMModel.currentVC = self;
|
|
|
|
|
CMModel.presentDirectionType = NTESPresentDirectionPresent;
|
|
|
|
|
if (currentCarrier == XYLoginTypeUnicom) { // 联通
|
|
|
|
|
CMModel.logoImg = [UIImage imageNamed:@"login_unicom_mobile"];
|
|
|
|
|
}else if (currentCarrier == XYLoginTypeChinaMobile) { //移动
|
|
|
|
|
CMModel.logoImg = [UIImage imageNamed:@"login_china_mobile"];
|
|
|
|
|
}else { //电信
|
|
|
|
|
CMModel.logoImg = [UIImage imageNamed:@"login_ct_mobile"];
|
|
|
|
|
}
|
2021-09-13 14:22:51 +08:00
|
|
|
|
CMModel.backgroundColor = [ThemeColor appBackgroundColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
|
|
|
|
CMModel.logoWidth = 95;
|
|
|
|
|
CMModel.logoHeight = 95;
|
|
|
|
|
CMModel.logoOffsetTopY = 30;
|
|
|
|
|
CMModel.navText = @"一键登录";
|
|
|
|
|
CMModel.navTextColor = UIColor.whiteColor;
|
|
|
|
|
CMModel.navTextFont = [UIFont boldSystemFontOfSize:18];
|
|
|
|
|
|
|
|
|
|
CMModel.navReturnImg = [UIImage imageNamed:@"common_nav_back"];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
CMModel.navBgColor = [ThemeColor appBackgroundColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
|
|
|
|
CMModel.logBtnHeight = 45;
|
|
|
|
|
CMModel.logBtnRadius = 45.f / 2;
|
|
|
|
|
CMModel.logBtnOffsetTopY= 260;
|
|
|
|
|
CMModel.logBtnOriginLeft = 52;
|
|
|
|
|
CMModel.logBtnOriginRight = 52;
|
2021-09-13 14:22:51 +08:00
|
|
|
|
CMModel.logBtnUsableBGColor = [ThemeColor appMainColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
CMModel.logBtnText = @"本机号码一键登录";
|
|
|
|
|
CMModel.logBtnTextColor = UIColor.whiteColor;
|
|
|
|
|
CMModel.logBtnTextFont = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
|
|
|
|
|
|
|
|
|
|
CMModel.numberOffsetTopY = 170;
|
|
|
|
|
CMModel.numberColor = UIColor.whiteColor;
|
|
|
|
|
CMModel.numberFont = [UIFont boldSystemFontOfSize:20];
|
|
|
|
|
CMModel.brandColor = UIColor.whiteColor;
|
|
|
|
|
|
|
|
|
|
CMModel.uncheckedImg = [UIImage imageNamed:@"common_checkbox_uncheck"];
|
|
|
|
|
CMModel.checkedImg = [UIImage imageNamed:@"common_checkbox_checked"];
|
|
|
|
|
CMModel.checkboxWH = 20;
|
|
|
|
|
|
2021-09-13 14:22:51 +08:00
|
|
|
|
CMModel.privacyColor = [ThemeColor mainTextColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
CMModel.appPrivacyText = @"登录即代表同意《默认》,并授权音游获取本机号码。";
|
|
|
|
|
CMModel.privacyState = YES;
|
|
|
|
|
CMModel.privacyFont = [UIFont systemFontOfSize:12];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
CMModel.protocolColor = [ThemeColor appMainColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
|
|
|
|
CMModel.backActionBlock = ^{ //点击了返回按钮
|
|
|
|
|
[XCHUDTool hideHUD];
|
|
|
|
|
};
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
[[NTESQuickLoginManager sharedInstance] setupModel:CMModel];
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-09-13 18:56:16 +08:00
|
|
|
|
#pragma mark - LoginProtocol
|
|
|
|
|
- (void)phoneQuickLoginSuccess {
|
|
|
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)thirdLoginSuccess {
|
|
|
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
[XCHUDTool showSuccessWithMessage:@"登录成功"];
|
|
|
|
|
}
|
2021-09-06 18:47:38 +08:00
|
|
|
|
|
2021-09-13 18:56:16 +08:00
|
|
|
|
- (void)thirdLoginCancel {
|
|
|
|
|
[XCHUDTool showSuccessWithMessage:@"取消登录"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)thirdLoginFailth:(NSString *)message {
|
|
|
|
|
[XCHUDTool showErrorWithMessage:message];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
2021-09-06 18:47:38 +08:00
|
|
|
|
- (UIImageView *)appIcon {
|
|
|
|
|
if (!_appIcon) {
|
|
|
|
|
_appIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_appIcon"]];
|
|
|
|
|
}
|
|
|
|
|
return _appIcon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)titleLabel{
|
|
|
|
|
if (!_titleLabel) {
|
|
|
|
|
_titleLabel = [[UILabel alloc] init];
|
|
|
|
|
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
|
|
|
|
_titleLabel.text = AppName;
|
2021-09-13 14:22:51 +08:00
|
|
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
return _titleLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)subTitleLabel {
|
|
|
|
|
if (!_subTitleLabel) {
|
|
|
|
|
_subTitleLabel = [[UILabel alloc] init];
|
|
|
|
|
_subTitleLabel.font = [UIFont systemFontOfSize:13];
|
|
|
|
|
_subTitleLabel.text = @"来音游打游戏,争夺更多赏金!";
|
2021-09-13 14:22:51 +08:00
|
|
|
|
_subTitleLabel.textColor = [ThemeColor secondTextColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
_subTitleLabel.textAlignment = NSTextAlignmentLeft;
|
|
|
|
|
}
|
|
|
|
|
return _subTitleLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)loginButton{
|
|
|
|
|
if (!_loginButton) {
|
|
|
|
|
_loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
_loginButton.layer.masksToBounds = YES;
|
|
|
|
|
_loginButton.layer.cornerRadius = 45/2.f;
|
|
|
|
|
[_loginButton setTitle:@"本机号码一键登录" forState:UIControlStateNormal];
|
2021-09-09 19:18:47 +08:00
|
|
|
|
_loginButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
[_loginButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth - 52 * 2, 45)];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
[_loginButton setBackgroundImage:image forState:UIControlStateNormal];
|
|
|
|
|
}
|
|
|
|
|
return _loginButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)agreeButton {
|
|
|
|
|
if (!_agreeButton) {
|
|
|
|
|
_agreeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_agreeButton setImage:[UIImage imageNamed:@"common_checkbox_uncheck"] forState:UIControlStateNormal];
|
|
|
|
|
[_agreeButton setImage:[UIImage imageNamed:@"common_checkbox_checked"] forState:UIControlStateSelected];
|
|
|
|
|
}
|
|
|
|
|
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:@"登录即代表同意"];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
attString.yy_color = [ThemeColor mainTextColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
NSString *userString = @"《用户服务协议》";
|
2021-09-13 14:22:51 +08:00
|
|
|
|
NSMutableAttributedString *userAttString = [[NSMutableAttributedString alloc] initWithString:userString attributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]}];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
@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);
|
|
|
|
|
// 跳转用户协议
|
|
|
|
|
// [self goToWebview:HtmlUrlKey(kUserProtocalURL)];
|
|
|
|
|
} longPressAction:nil];
|
|
|
|
|
|
|
|
|
|
NSMutableAttributedString *andString = [[NSMutableAttributedString alloc] initWithString:@"和"];
|
2021-09-13 14:22:51 +08:00
|
|
|
|
andString.yy_color = [ThemeColor mainTextColor];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
NSString *protocolString = @"《隐私政策》";
|
2021-09-13 14:22:51 +08:00
|
|
|
|
NSMutableAttributedString *privateString = [[NSMutableAttributedString alloc] initWithString:protocolString attributes:@{NSForegroundColorAttributeName:[ThemeColor appMainColor]}];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
[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);
|
|
|
|
|
// 跳转隐私政策
|
|
|
|
|
// [self goToWebview:HtmlUrlKey(kPrivacyURL)];
|
|
|
|
|
} 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 = 43;
|
|
|
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
|
|
|
}
|
|
|
|
|
return _stackView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 18:56:16 +08:00
|
|
|
|
- (UIButton *)phoneButtonView {
|
2021-09-06 18:47:38 +08:00
|
|
|
|
if (!_phoneButtonView) {
|
2021-09-13 18:56:16 +08:00
|
|
|
|
_phoneButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_phoneButtonView setImage: [UIImage imageNamed:@"login_phone"] forState:UIControlStateNormal];
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
return _phoneButtonView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 18:56:16 +08:00
|
|
|
|
- (UIButton *)qqButtonView {
|
2021-09-06 18:47:38 +08:00
|
|
|
|
if (!_qqButtonView) {
|
2021-09-13 18:56:16 +08:00
|
|
|
|
_qqButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_qqButtonView setImage: [UIImage imageNamed:@"login_qq"] forState:UIControlStateNormal];
|
|
|
|
|
_qqButtonView.tag = 1000 + ThirdLoginType_QQ;
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
return _qqButtonView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 18:56:16 +08:00
|
|
|
|
- (UIButton *)wxButtonView {
|
2021-09-06 18:47:38 +08:00
|
|
|
|
if (!_wxButtonView) {
|
2021-09-13 18:56:16 +08:00
|
|
|
|
_wxButtonView = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_wxButtonView setImage: [UIImage imageNamed:@"login_wechat"] forState:UIControlStateNormal];
|
|
|
|
|
_wxButtonView.tag = 1000 + ThirdLoginType_WeChat;
|
2021-09-06 18:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
return _wxButtonView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-13 18:56:16 +08:00
|
|
|
|
#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:ASAuthorizationAppleIDButtonStyleBlack];
|
|
|
|
|
} else {
|
|
|
|
|
// Fallback on earlier versions
|
|
|
|
|
}
|
|
|
|
|
_appleButton.cornerRadius = 25;
|
|
|
|
|
_appleButton.tag = 1000 + ThirdLoginType_Apple;
|
|
|
|
|
}
|
|
|
|
|
return _appleButton;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-09-06 18:47:38 +08:00
|
|
|
|
@end
|