Files
yinmeng-ios-store/yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneLoginVC.m
2023-12-13 17:47:43 -08:00

735 lines
28 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.

//
// DDV2PhoneLoginVC.m
// DingDangApp
//
// Created by apple on 2023/7/4.
//
#import "DDV2PhoneLoginVC.h"
#import "AppDelegate.h"
/// View
#import "DDLoginTextView.h"
#import "DDWebViewController.h"
/// 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;
@interface DDV2PhoneLoginVC ()
@property (nonatomic, strong) SVGAPlayer *logoSVGAPlayer;
/**标题**/
//@property (nonatomic, strong) UILabel *titleLabel;
/**账号**/
@property (nonatomic, strong) DDLoginTextView *phoneView;
/** 获取验证码 **/
@property (nonatomic, strong) UIButton *codeButton;
/**验证码**/
@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
- (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 {
}
#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);
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?:@""]];
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");
};
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];
// [ws getUserInfo:response.data[@"token"]];
}
}];
}
- (void)getUserInfo:(NSString *)uid token:(NSString *)token {
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
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) {
}];
// [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];
// };
// }
// }];
}
- (void)inviteCodeUpdate:(NSNotification *)noti {
if ([noti.object isKindOfClass:[NSDictionary class]]){
NSDictionary * dataDic = noti.object;
if ([ToolsObject IsNullWithObject:dataDic]) {
return;
}
self.install_params = dataDic;
}
}
- (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;
}
}
- (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?:@"";
}
}
- (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];
}
- (void)loginRequest
{
[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 {
if (!_phoneView) {
_phoneView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldPhone];
}
return _phoneView;
}
- (DDLoginTextView *)passWordView {
if (!_passWordView) {
_passWordView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldPassWord];
}
return _passWordView;
}
-(DDLoginTextView *)inviteView {
if (!_inviteView) {
_inviteView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldInvideCode];
}
return _inviteView;
}
- (DDLoginTextView *)codeView {
if (!_codeView) {
_codeView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldGetCode];
WeakSelf(ws)
_codeView.getCodeBlock = ^{
[ws requestCode];
};
}
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;
}
- (YYLabel *)noLoginlabel {
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;
}
- (UIButton *)loginBtn {
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)];
[_loginBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
_loginBtn.titleLabel.font = DDFont(16);
[_loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
@end