Files
yinmeng-ios-store/yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneLoginVC.m

735 lines
28 KiB
Mathematica
Raw Normal View History

2023-12-07 10:50:21 +08:00
//
// DDV2PhoneLoginVC.m
// DingDangApp
//
// Created by apple on 2023/7/4.
//
#import "DDV2PhoneLoginVC.h"
#import "AppDelegate.h"
2023-12-12 18:36:32 -08:00
/// View
#import "DDLoginTextView.h"
2023-12-07 10:50:21 +08:00
#import "DDWebViewController.h"
2023-12-12 18:36:32 -08:00
/// Tool
#import "AppDelegate+CYLTabBar.h"
#import "HttpRequestHelper.h"
#import "DDDESEncrypt.h"
//#import "DDLoginAccountModel.h"
/// Model
#import "AccountInfoStorage.h"
#import "AccountModel.h"
/// Third
#import <SVGAPlayer.h>
#import <SVGA.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
#import <GeYanSdk/GeYanSdk.h>
typedef enum : NSUInteger {
DD_Login_Input_Phone,
DD_Login_Input_Password,
DD_Login_Input_Code,
} DDLoignType;
2023-12-07 10:50:21 +08:00
@interface DDV2PhoneLoginVC ()
2023-12-12 18:36:32 -08:00
@property (nonatomic, strong) SVGAPlayer *logoSVGAPlayer;
2023-12-07 10:50:21 +08:00
/****/
2023-12-12 18:36:32 -08:00
//@property (nonatomic, strong) UILabel *titleLabel;
2023-12-07 10:50:21 +08:00
/****/
@property (nonatomic, strong) DDLoginTextView *phoneView;
2023-12-12 18:36:32 -08:00
/** **/
@property (nonatomic, strong) UIButton *codeButton;
2023-12-07 10:50:21 +08:00
/****/
@property (nonatomic, strong) DDLoginTextView *codeView;
/****/
@property (nonatomic, strong) DDLoginTextView *passWordView;
/****/
@property (nonatomic, strong) DDLoginTextView *inviteView;
/****/
@property (nonatomic, strong) YYLabel *noLoginlabel;
/**1 2**/
@property (nonatomic, assign) NSInteger isLoginType;
@property(nonatomic,strong) UIButton *loginBtn;
@property(nonatomic, assign) BOOL isChecked;
@property(nonatomic, assign) CFAbsoluteTime startTime;
@property (nonatomic, strong) UIButton *loginTypeBtn;
@end
@implementation DDV2PhoneLoginVC
2023-12-12 18:36:32 -08:00
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:KNoti_InviteCodeUpdateKey object:nil];
}
#pragma mark - Life Cycle
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[IQKeyboardManager sharedManager].enable = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[IQKeyboardManager sharedManager].enable = NO;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.isLoginType = 1;
// [self defaultNavTitle:@"" hideLine:YES];
[self dd_addNavImage:@[@"myinfo_6"] isLeft:YES target:self action:@selector(backButtonAction) tags:nil];
self.view.backgroundColor = [UIColor whiteColor];
[self initSubView];
//
// [self initCLShanYanWithLogin];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inviteCodeUpdate:) name:KNoti_InviteCodeUpdateKey object:nil];
}
#pragma mark - inviteView
- (void)initSubView {
[self.view addSubview:self.logoSVGAPlayer];
[self.view addSubview:self.phoneView];
[self.logoSVGAPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self.view);
make.height.mas_equalTo(KScreenWidth * kScaleX);
}];
// [self.view addSubview:self.titleLabel];
// [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.equalTo(self.view).offset(25);
// make.top.equalTo(self.view).offset(DDNavigationBarHeight()+20);
// make.width.mas_equalTo(300);
// make.height.mas_equalTo(28);
// }];
//
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.top.mas_equalTo(self.logoSVGAPlayer.mas_bottom).mas_offset(20);
make.height.mas_equalTo(40);
}];
//
// [self.view addSubview:self.codeView];
// [self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.equalTo(self.view);
// make.top.mas_equalTo(self.phoneView.mas_bottom).mas_offset(22);
// make.height.mas_equalTo(40);
// }];
//
// [self.view addSubview:self.passWordView];
// self.passWordView.hidden = YES;
// [self.passWordView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.equalTo(self.view);
// make.top.mas_equalTo(self.phoneView.mas_bottom).mas_offset(22);
// make.height.mas_equalTo(40);
// }];
//
// [self.view addSubview:self.inviteView];
// [self.inviteView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.equalTo(self.view);
// make.top.mas_equalTo(self.codeView.mas_bottom).mas_offset(22);
// make.height.mas_equalTo(40);
// }];
// [self.view addSubview:self.loginTypeBtn];
// [self.loginTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.mas_equalTo(self.phoneView.mas_bottom).offset(123);
// make.left.equalTo(self.view).offset(25);
// make.width.mas_equalTo(100);
// make.height.mas_equalTo(52);
// }];
// [self.view addSubview:self.noLoginlabel];
// CGFloat width = [ToolsObject sizeWithText:@"如无法登录,请点击这里" andFont:DDFont(12) maxSize:CGSizeMake(230, 52) andlineSpacing:1].width;
// [self.noLoginlabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.right.equalTo(self.view).offset(-25);
// make.height.mas_equalTo(52);
// make.centerY.equalTo(self.loginTypeBtn);
// make.width.mas_equalTo(width+10);
// }];
// [self.view addSubview:self.loginBtn];
// [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.centerX.equalTo(self.view);
// make.width.mas_equalTo(250);
// make.height.mas_equalTo(50);
// make.top.mas_equalTo(self.loginTypeBtn.mas_bottom).mas_offset(30);
// }];
// NSString * invite_code = [ToolsObject getInfoObject:@"invite_code"];
// self.inviteView.textField.text = invite_code?:@"";
}
#pragma mark - Action
- (void)backButtonAction {
[self.navigationController popViewControllerAnimated:NO];
}
- (void)getCodeNumberAction {
}
2023-12-07 10:50:21 +08:00
#pragma mark ------ ------
- (void)initCLShanYanWithLogin {
//
GyAuthViewModel *authViewModel = [self fullScreenModel];
[self login:authViewModel];
}
//
- (GyAuthViewModel *)fullScreenModel {
GyAuthViewModel *authViewModel = [self defaultModel];;
authViewModel.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
return authViewModel;
}
- (void)login:(GyAuthViewModel *)viewModel {
// oneTapLogin
WeakSelf(ws)
if ([GeYanSdk isPreGettedTokenValidate]) {
[GeYanSdk oneTapLogin:self withViewModel:viewModel andCallback:^(NSDictionary *dic) {
[ws loginFinish:dic];
}];
return;
}
[GeYanSdk preGetToken:^(NSDictionary *preDic) {
NSLog(@"preGetToken: %@ %@", preDic, preDic[@"msg"]);
if (![GeYanSdk isPreGettedTokenValidate]) {
return;
}
[GeYanSdk oneTapLogin:self withViewModel:viewModel andCallback:^(NSDictionary * dic) {
[ws loginFinish:dic];
}];
}];
}
- (void)loginFinish:(NSDictionary *)result {
NSLog(@"oneTapLogin: %@", result);
[GeYanSdk stopLoading];
[self queryPhoneNumber:result];
[GeYanSdk closeAuthVC:YES completion:^{
NSLog(@"关闭授权页面");
}];
}
///
- (void)queryPhoneNumber:(NSDictionary*)result {
if (![result[@"code"] isEqualToNumber:@30000]) {
return;
}
NSString *token = result[@"token"];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSDictionary *params = @{
@"gyuid": appDelegate.gyUid ?: @"",
@"token": token ?: @"",
};
[self loginWithShanYanWithDict:params.mutableCopy];
}
/** UI **/
- (GyAuthViewModel *)defaultModel {
GyAuthViewModel *authViewModel = GyAuthViewModel.new;
authViewModel.statusBarStyle = UIStatusBarStyleDefault;
//
authViewModel.naviHidden = YES;
//
authViewModel.backgroundImage = [UIImage imageNamed:@"login_bg_icon_1"];
//Logo/
authViewModel.appLogo = [UIImage imageNamed:@"login_bg_icon_2"];
//logo y x
OLRect logoRect = {KAdaptedWidth(130), 0, 0, 0, 0, 0, {102, 150}};
authViewModel.logoRect = logoRect;
//Phone Number Preview/
authViewModel.phoneNumFont = [UIFont boldSystemFontOfSize:20];
authViewModel.phoneNumColor = UIColor.whiteColor;
OLRect phoneNumRect = {KAdaptedWidth(359), 0, 0, 0, 0, 0, {kWidth, 20}};
authViewModel.phoneNumRect = phoneNumRect;
//Slogan/
authViewModel.sloganTextColor = DDHEXColor(0xDCDADA);
authViewModel.sloganTextFont = [UIFont systemFontOfSize:14];
// y x
OLRect sloganRect = {KAdaptedWidth(395), 0, 0, 0, 0, 0, {0, 0}};
authViewModel.sloganRect = sloganRect;
//Authorization Button/
authViewModel.authButtonImages = @[[UIImage imageNamed:@"login_bg_icon_7"],[UIImage imageNamed:@"login_bg_icon_7"],[UIImage imageNamed:@"login_bg_icon_7"]];
authViewModel.authButtonTitle = [[NSAttributedString alloc] initWithString:@""];
OLRect authButtonRect = {KAdaptedWidth(442), 0, 0, 0, 0, 0, {278, 50}};
authViewModel.authButtonRect = authButtonRect;
//
authViewModel.switchButtonHidden = YES;
// -------------- UI -------------------
[authViewModel setCustomUIHandler:^(UIView *customAreaView) {
UIButton *otherLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
otherLoginBtn.frame = CGRectMake(customAreaView.bounds.size.width/2 - 278/2, KAdaptedHeight(518), 278, 50);
[otherLoginBtn setTitle:@"其他号码登录" forState:UIControlStateNormal];
[otherLoginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[otherLoginBtn setBackgroundColor:DDHEXColor(0x6F2EBB)];
[[otherLoginBtn titleLabel] setFont:[UIFont boldSystemFontOfSize:15]];
[otherLoginBtn addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside];
otherLoginBtn.layer.masksToBounds = YES;
otherLoginBtn.layer.cornerRadius = 50/2;
[customAreaView addSubview:otherLoginBtn];
}];
// CheckBox & Privacy Terms/
authViewModel.defaultCheckBoxState = YES;
authViewModel.checkBoxSize = CGSizeMake(20, 20);
authViewModel.checkedImage = [UIImage imageNamed:@"RoomGift_10"];
authViewModel.uncheckedImage = [UIImage imageNamed:@"RoomGift_9"];
//Custom Area/
//Orientation
authViewModel.supportedInterfaceOrientations = UIInterfaceOrientationMaskPortrait;
//present
authViewModel.modalPresentationStyle = UIModalPresentationFullScreen;
//
authViewModel.pullAuthVCStyle = OLPullAuthVCStyleModal;
//
authViewModel.userInterfaceStyle = @(0);
self.isChecked = YES;
authViewModel.closePopupImage = [UIImage imageNamed:@"guanbi_icon"];
//--------------------------
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 0;
paragraphStyle.alignment = NSTextAlignmentLeft;
paragraphStyle.paragraphSpacing = 0.0;
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.firstLineHeadIndent = 0.0;
authViewModel.privacyTermsAttributes = @{
NSForegroundColorAttributeName: DDHEXColor(0x5981FF),
NSParagraphStyleAttributeName: paragraphStyle,
NSFontAttributeName: [UIFont systemFontOfSize:11]
};
authViewModel.termTextColor = DDHEXColor(0x999999);
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
NSString * userAgreementUrl = [NSString stringWithFormat:@"%@#/publicpage?position=1010",KWebURL];
NSString * privacyPolicyUrl = [NSString stringWithFormat:@"%@#/publicpage?position=1009",KWebURL];
// html
NSURLRequest *userAgreementUrlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:userAgreementUrl?:@""]];
NSURLRequest *privacyPolicyUrlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:privacyPolicyUrl?:@""]];
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
GyAuthPrivacyItem *item1 = [[GyAuthPrivacyItem alloc] initWithTitle:@"《啵柚语音用户协议》"
urlRequest:userAgreementUrlRequest
index:1
block:nil];
GyAuthPrivacyItem *item2 = [[GyAuthPrivacyItem alloc] initWithTitle:@"《啵柚语音隐私政策》"
urlRequest:privacyPolicyUrlRequest
index:2
block:nil];
authViewModel.additionalPrivacyTerms = @[item1, item2];
//----------------------------------
authViewModel.tapAuthBackgroundBlock = ^() {
NSLog(@"点击弹窗授权页面背景 回调");
};
WeakSelf(ws)
authViewModel.clickAuthButtonBlock = ^BOOL{
if (!ws.isChecked) {
[ToolsObject addPopVieToText:@"请先阅读并同意《啵柚语音用户协议》和《啵柚语音隐私政策》"];
return NO;
}
self->_startTime = NSDate.new.timeIntervalSince1970;
NSLog(@"点击登录按钮 回调");
return YES;
};
authViewModel.clickCheckboxBlock = ^(BOOL isChecked) {
NSLog(@"点击checkbox 回调 %@", @(isChecked));
ws.isChecked = isChecked;
};
authViewModel.viewLifeCycleBlock = ^(NSString *viewLifeCycle, BOOL animated) {
NSLog(@"页面生命周期 回调: %@, %@", viewLifeCycle, @(animated));
};
authViewModel.loadingViewBlock = ^(UIView *containerView) {
NSLog(@"授权页面,加载进度条");
};
authViewModel.stopLoadingViewBlock = ^(UIView *containerView) {
NSLog(@"授权页面,停止自定义加载进度条,调用[GeyanSDK stopLoading]之后的回调");
};
authViewModel.authVCTransitionBlock = ^(CGSize size, id <UIViewControllerTransitionCoordinator> coordinator, UIView *customAreaView) {
NSLog(@"页面生命周期 回调: 自定义VIEW");
};
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
return authViewModel;
}
- (void)clicked:(UIButton *)btn {
[GeYanSdk stopLoading];
[GeYanSdk closeAuthVC:YES completion:^{
NSLog(@"关闭授权页面");
}];
}
#pragma mark -
- (void)loginWithShanYanWithDict:(NSMutableDictionary *)dict {
WeakSelf(ws)
[dict setObject:[ToolsObject getDeviceIdentifier] forKey:@"phone_model"];
[dict setObject:[UIDevice currentDevice].systemVersion forKey:@"system_version"];
[NetworkRequest requestPOST:@"/quick/login" parameters:dict block:^(BaseResponse * _Nonnull response) {
if (response.isSuccess) {
if ([ToolsObject IsNullWithObject:response.data]) {
return;
}
AppUserModel * myModel = [AppUserModel new];
myModel.token = response.data[@"token"];
[ToolsObject saveUserModel:myModel];
2023-12-12 18:36:32 -08:00
// [ws getUserInfo:response.data[@"token"]];
2023-12-07 10:50:21 +08:00
}
}];
}
2023-12-12 18:36:32 -08:00
- (void)getUserInfo:(NSString *)uid token:(NSString *)token {
2023-12-07 10:50:21 +08:00
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
2023-12-12 18:36:32 -08:00
requestDict[@"uid"] = uid;
[HttpRequestHelper GET:@"/user/get" params:requestDict success:^(BaseModel * _Nonnull data) {
AppUserModel *model = [AppUserModel yy_modelWithJSON:data.data];
model.token = token;
[ToolsObject saveUserModel:model];
[ToolsObject addPopVieToText:@"登录成功"];
[self.navigationController popToRootViewControllerAnimated:NO];
AppDelegate *delegate =(AppDelegate *)[UIApplication sharedApplication].delegate;
[delegate configureForTabBarController];
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
2023-12-07 10:50:21 +08:00
}];
2023-12-12 18:36:32 -08:00
// [NetworkRequest requestPOST:@"/user/info" parameters:requestDict block:^(BaseResponse * _Nonnull response) {
// if (response.code == 200){
// if ([ToolsObject IsNullWithObject:response.data]) {
// return;
// }
// AppUserModel *model = [AppUserModel yy_modelWithJSON:response.data];
// AppUserModel * myModel = [ToolsObject getUserModel];
// myModel = model;
// myModel.token = token;
// [ToolsObject saveUserModel:myModel];
// [[DDSocketTool shareTool] starConnection];
// [DDSocketTool shareTool].socketConnectBlock = ^(BOOL isSuccess) {
// if (!isSuccess){
// [ToolsObject removeUserInfo];
// }
// AppDelegate *delegate =(AppDelegate *)[UIApplication sharedApplication].delegate;
// [delegate configureForTabBarController];
// };
// }
// }];
2023-12-07 10:50:21 +08:00
}
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
- (void)inviteCodeUpdate:(NSNotification *)noti {
2023-12-12 18:36:32 -08:00
if ([noti.object isKindOfClass:[NSDictionary class]]){
2023-12-07 10:50:21 +08:00
NSDictionary * dataDic = noti.object;
2023-12-12 18:36:32 -08:00
if ([ToolsObject IsNullWithObject:dataDic]) {
return;
}
self.install_params = dataDic;
2023-12-07 10:50:21 +08:00
}
}
- (void)loginTypeBtnClick:(UIButton *)btn {
self.loginTypeBtn.selected = !self.loginTypeBtn.selected;
self.passWordView.textField.text = @"";
self.codeView.textField.text = @"";
self.passWordView.hidden = !self.loginTypeBtn.isSelected;
self.codeView.hidden = self.loginTypeBtn.isSelected;
self.noLoginlabel.hidden = self.loginTypeBtn.isSelected;
self.inviteView.hidden = self.loginTypeBtn.isSelected;
if (self.loginTypeBtn.isSelected) {
[self.loginTypeBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.phoneView.mas_bottom).offset(63);
}];
}else{
[self.loginTypeBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.phoneView.mas_bottom).offset(123);
}];
}
if (self.passWordView.isHidden) {
self.isLoginType = 1;
}else{
self.isLoginType = 2;
}
}
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
- (void)setInstall_params:(NSDictionary *)install_params{
_install_params = install_params;
if (![ToolsObject IsNullWithObject:install_params]){
NSString * invite_code = install_params[@"invite_code"];
[ToolsObject setInfoObject:invite_code?:@"" forKey:@"invite_code"];
self.inviteView.textField.text = invite_code?:@"";
}
}
2023-12-12 18:36:32 -08:00
- (NSString *)getPhoneEncryptDes{
return [DDDESEncrypt DD_EncryptUseDES:self.phoneView.textField.text key:@"1ea53d260ecf11e7b56e00163e046a26"];
}
- (NSString *)getPasswordEncryptDes {
return [DDDESEncrypt DD_EncryptUseDES:self.passWordView.textField.text key:@"1ea53d260ecf11e7b56e00163e046a26"];
}
//
- (void)requestCode{
if ([ToolsObject IsNullWithObject:self.phoneView.textField.text]) {
[ToolsObject addPopVieToText:@"手机号不能为空"];
return;
}
if (self.phoneView.textField.text.length != 11) {
[ToolsObject addPopVieToText:@"请输入正确的手机号"];
return;
}
self.codeView.getCodeBtn.enabled = NO;
WeakSelf(ws)
// NSString *desPhone = [DDDESEncrypt DD_EncryptUseDES:self.phoneView.textField.text key:@"1ea53d260ecf11e7b56e00163e046a26"];
NSMutableDictionary *parameter = @{@"mobile":[self getPhoneEncryptDes], @"type":@(1)}.mutableCopy;
[HttpRequestHelper POST:@"sms/getCode" params:parameter success:^(BaseModel * _Nonnull data) {
[ToolsObject addPopVieToText:data.message];
[ws.codeView.getCodeBtn startCountDownWithSecond:60];
[ws.codeView.getCodeBtn countDownChanging:^NSString *(JKCountDownButton *countDownButton,NSUInteger second) {
NSString *title = [NSString stringWithFormat:@" %zds后可重发 ",second];
return title;
}];
[ws.codeView.getCodeBtn countDownFinished:^NSString *(JKCountDownButton *countDownButton, NSUInteger second) {
ws.codeView.getCodeBtn.enabled = YES;
return @" 重新获取 ";
}];
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
[ToolsObject addPopVieToText:message];
ws.codeView.getCodeBtn.enabled = YES;
}];
// [NetworkRequest requestPOST:@"sms/getCode" parameters:parameter block:^(BaseResponse * _Nonnull response) {
// if (response.isSuccess) {
// [ToolsObject addPopVieToText:response.msg];
// [ws.codeView.getCodeBtn startCountDownWithSecond:60];
// [ws.codeView.getCodeBtn countDownChanging:^NSString *(JKCountDownButton *countDownButton,NSUInteger second) {
// NSString *title = [NSString stringWithFormat:@" %zds后可重发 ",second];
// return title;
// }];
// [ws.codeView.getCodeBtn countDownFinished:^NSString *(JKCountDownButton *countDownButton, NSUInteger second) {
// ws.codeView.getCodeBtn.enabled = YES;
// return @" 重新获取 ";
// }];
//
// } else {
// [ToolsObject addPopVieToText:response.msg];
// ws.codeView.getCodeBtn.enabled = YES;
// }
// }];
}
- (void)loginBtnClick {
[self loginRequest];
2023-12-07 10:50:21 +08:00
}
2023-12-12 18:36:32 -08:00
- (void)loginRequest
2023-12-07 10:50:21 +08:00
{
2023-12-12 18:36:32 -08:00
[self.view endEditing:YES];
if ([ToolsObject IsNullWithObject:self.phoneView.textField.text]) {
[ToolsObject addPopVieToText:@"手机号不能为空"];
return;
}
if (self.phoneView.textField.text.length != 11) {
[ToolsObject addPopVieToText:@"请输入正确的手机号"];
return;
}
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
NSString *loginUrl = @"oauth/token";
if (self.isLoginType == 1) {
// loginUrl = @"oauth/token";
if ([ToolsObject IsNullWithObject:self.codeView.textField.text]) {
[ToolsObject addPopVieToText:@"请输入验证码"];
return;
}
if (self.codeView.textField.text.length != 5) {
[ToolsObject addPopVieToText:@"请输入6位验证码"];
return;
}
[dic setObject:self.codeView.textField.text forKey:@"code"];
[dic setObject:self.inviteView.textField.text?:@"" forKey:@"invite_code"];
}else if (self.isLoginType == 2){
// loginUrl = @"/pwd/login";
if ([ToolsObject IsNullWithObject:self.passWordView.textField.text]) {
[ToolsObject addPopVieToText:@"请输入密码"];
return;
}
if (self.passWordView.textField.text.length < 6) {
[ToolsObject addPopVieToText:@"密码需要同时包含6-12位字母和数字"];
return;
}
[dic setObject:[self getPasswordEncryptDes] forKey:@"password"];
}
[dic setObject:[self getPhoneEncryptDes] forKey:@"phone"];
[dic setObject:@"uyzjdhds" forKey:@"client_secret"];
[dic setObject:@"1" forKey:@"version"];
[dic setObject:@"erban-client" forKey:@"client_id"];
[dic setObject:@"password" forKey:@"grant_type"];
WeakSelf(ws)
[HttpRequestHelper POST:loginUrl params:dic success:^(BaseModel * _Nonnull data) {
AccountModel *accountModel = [AccountModel DD_ModelWithDict:data.data];
if (accountModel && accountModel.access_token.length > 0) {
[[AccountInfoStorage instance] saveAccountInfo:accountModel];
}
AppUserModel *model = [AppUserModel new];
model.token = accountModel.access_token;
[ToolsObject saveUserModel:model];
[ws getUserInfo:accountModel.uid token:accountModel.access_token];
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
[ToolsObject addPopVieToText:message];
}];
// [NetworkRequest requestPOST:loginUrl parameters:dic block:^(BaseResponse * _Nonnull response) {
// if (response.isSuccess) {
// if ([ToolsObject IsNullWithObject:response.data]) {
// return;
// }
// AppUserModel * myModel = [AppUserModel new];
// myModel.token = response.data[@"token"];
// [ToolsObject saveUserModel:myModel];
// [ws getUserInfo:response.data[@"token"]];
// } else {
// [ToolsObject addPopVieToText:response.msg];
// }
// }];
}
#pragma mark - Get
- (SVGAPlayer *)logoSVGAPlayer {
if (!_logoSVGAPlayer) {
_logoSVGAPlayer = [[SVGAPlayer alloc] init];
_logoSVGAPlayer.loops = 1;
_logoSVGAPlayer.clearsAfterStop = NO;
}
return _logoSVGAPlayer;
}
- (UIButton *)codeButton {
if (!_codeButton) {
_codeButton = [[UIButton alloc] init];
[_codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
[_codeButton addTarget:self action:@selector(getCodeNumberAction) forControlEvents:UIControlEventTouchUpInside];
}
return _codeButton;
}
- (DDLoginTextView *)phoneView {
2023-12-07 10:50:21 +08:00
if (!_phoneView) {
_phoneView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldPhone];
}
return _phoneView;
}
2023-12-12 18:36:32 -08:00
- (DDLoginTextView *)passWordView {
2023-12-07 10:50:21 +08:00
if (!_passWordView) {
_passWordView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldPassWord];
}
return _passWordView;
}
2023-12-12 18:36:32 -08:00
-(DDLoginTextView *)inviteView {
2023-12-07 10:50:21 +08:00
if (!_inviteView) {
_inviteView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldInvideCode];
}
return _inviteView;
}
2023-12-12 18:36:32 -08:00
- (DDLoginTextView *)codeView {
2023-12-07 10:50:21 +08:00
if (!_codeView) {
_codeView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldGetCode];
WeakSelf(ws)
_codeView.getCodeBlock = ^{
2023-12-12 18:36:32 -08:00
[ws requestCode];
2023-12-07 10:50:21 +08:00
};
}
return _codeView;
}
- (UIButton *)loginTypeBtn {
if (!_loginTypeBtn) {
_loginTypeBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
[_loginTypeBtn setTitle:@"密码登录" forState:(UIControlStateNormal)];
[_loginTypeBtn setTitle:@"验证码登录" forState:(UIControlStateSelected)];
[_loginTypeBtn setTitleColor:DDHEXColor(0x333333) forState:(UIControlStateNormal)];
[_loginTypeBtn setTitleColor:DDHEXColor(0x333333) forState:(UIControlStateSelected)];
_loginTypeBtn.titleLabel.font = DDFont(12);
[_loginTypeBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
[_loginTypeBtn addTarget:self action:@selector(loginTypeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
} return _loginTypeBtn;
}
2023-12-12 18:36:32 -08:00
- (YYLabel *)noLoginlabel {
2023-12-07 10:50:21 +08:00
if (!_noLoginlabel) {
_noLoginlabel = [[YYLabel alloc]init];
_noLoginlabel.textColor = DDHEXColor(0x333333);
_noLoginlabel.font = DDFont(11);
_noLoginlabel.textAlignment = NSTextAlignmentCenter;
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"如无法登录,请点击这里"];
text.yy_alignment = NSTextAlignmentRight;
[text yy_setTextHighlightRange:[text.string rangeOfString:@"请点击这里"] color:DDHEXColor(0x0F8EFD) backgroundColor:[UIColor whiteColor] userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
DDWebViewController * webVC = [DDWebViewController webControlerWithUrlStr:[NSString stringWithFormat:@"%@#/helpAndfeedback",KWebURL] isShowNavBar:NO navTitle:@""];
webVC.view.backgroundColor = UIColor.whiteColor;
[[ToolsObject getCurrentViewController].navigationController pushViewController:webVC animated:NO];
} longPressAction:nil];
_noLoginlabel.attributedText = text;
}
return _noLoginlabel;
}
2023-12-12 18:36:32 -08:00
- (UIButton *)loginBtn {
2023-12-07 10:50:21 +08:00
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
[_loginBtn setTitle:@"登录" forState:(UIControlStateNormal)];
[_loginBtn setBackgroundImage:[UIImage imageNamed:@"v2_com_btn"] forState:UIControlStateNormal];
[_loginBtn setBackgroundImage:[UIImage imageNamed:@"v2_com_btn3"] forState:UIControlStateDisabled];
[_loginBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateDisabled)];
2023-12-12 18:36:32 -08:00
2023-12-07 10:50:21 +08:00
[_loginBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
_loginBtn.titleLabel.font = DDFont(16);
[_loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
@end