修改登录注册UI和登录注册逻辑
This commit is contained in:
@@ -762,6 +762,10 @@
|
||||
8C2C3F3A2B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F392B28E22E002C3C34 /* YYAnimatedImageView+ShowImage.m */; };
|
||||
8C2C3F492B29335E002C3C34 /* DDLoginAccountModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F482B29335E002C3C34 /* DDLoginAccountModel.m */; };
|
||||
8C2C3F4B2B294528002C3C34 /* login_logo.svga in Resources */ = {isa = PBXBuildFile; fileRef = 8C2C3F4A2B294528002C3C34 /* login_logo.svga */; };
|
||||
8C2C3F4E2B2A38C4002C3C34 /* DDV2PasswordLoginVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F4D2B2A38C4002C3C34 /* DDV2PasswordLoginVC.m */; };
|
||||
8C2C3F542B2A41F5002C3C34 /* DDV2PhoneCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F532B2A41F5002C3C34 /* DDV2PhoneCodeVC.m */; };
|
||||
8C2C3F572B2A4350002C3C34 /* DDLoginSVGAView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F562B2A4350002C3C34 /* DDLoginSVGAView.m */; };
|
||||
8C2C3F5A2B2A70F9002C3C34 /* DDLoginRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F592B2A70F9002C3C34 /* DDLoginRequest.m */; };
|
||||
8CE493992B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */; };
|
||||
8CE4939C2B23F45C00CA14D5 /* NSArray+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939B2B23F45C00CA14D5 /* NSArray+DDSafe.m */; };
|
||||
8CE493A02B23F5FA00CA14D5 /* DDUploadFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939F2B23F5FA00CA14D5 /* DDUploadFile.m */; };
|
||||
@@ -2180,6 +2184,15 @@
|
||||
8C2C3F472B29335E002C3C34 /* DDLoginAccountModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDLoginAccountModel.h; sourceTree = "<group>"; };
|
||||
8C2C3F482B29335E002C3C34 /* DDLoginAccountModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDLoginAccountModel.m; sourceTree = "<group>"; };
|
||||
8C2C3F4A2B294528002C3C34 /* login_logo.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = login_logo.svga; sourceTree = "<group>"; };
|
||||
8C2C3F4C2B2A38C4002C3C34 /* DDV2PasswordLoginVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDV2PasswordLoginVC.h; sourceTree = "<group>"; };
|
||||
8C2C3F4D2B2A38C4002C3C34 /* DDV2PasswordLoginVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDV2PasswordLoginVC.m; sourceTree = "<group>"; };
|
||||
8C2C3F522B2A41F5002C3C34 /* DDV2PhoneCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDV2PhoneCodeVC.h; sourceTree = "<group>"; };
|
||||
8C2C3F532B2A41F5002C3C34 /* DDV2PhoneCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDV2PhoneCodeVC.m; sourceTree = "<group>"; };
|
||||
8C2C3F552B2A4350002C3C34 /* DDLoginSVGAView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDLoginSVGAView.h; sourceTree = "<group>"; };
|
||||
8C2C3F562B2A4350002C3C34 /* DDLoginSVGAView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDLoginSVGAView.m; sourceTree = "<group>"; };
|
||||
8C2C3F582B2A70F9002C3C34 /* DDLoginRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDLoginRequest.h; sourceTree = "<group>"; };
|
||||
8C2C3F592B2A70F9002C3C34 /* DDLoginRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDLoginRequest.m; sourceTree = "<group>"; };
|
||||
8C2C3F5E2B2A886A002C3C34 /* DDV2RequestUrl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDV2RequestUrl.h; sourceTree = "<group>"; };
|
||||
8CAB97312B2259EA00ED8639 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
8CE493972B23F44800CA14D5 /* NSMutableDictionary+DDSafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+DDSafe.h"; sourceTree = "<group>"; };
|
||||
8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+DDSafe.m"; sourceTree = "<group>"; };
|
||||
@@ -2287,6 +2300,12 @@
|
||||
1802B3C62A540A620036DCEF /* DDV2LoginVC.m */,
|
||||
1802B3CC2A5419530036DCEF /* DDV2PhoneLoginVC.h */,
|
||||
1802B3CD2A5419530036DCEF /* DDV2PhoneLoginVC.m */,
|
||||
8C2C3F4C2B2A38C4002C3C34 /* DDV2PasswordLoginVC.h */,
|
||||
8C2C3F4D2B2A38C4002C3C34 /* DDV2PasswordLoginVC.m */,
|
||||
8C2C3F522B2A41F5002C3C34 /* DDV2PhoneCodeVC.h */,
|
||||
8C2C3F532B2A41F5002C3C34 /* DDV2PhoneCodeVC.m */,
|
||||
8C2C3F582B2A70F9002C3C34 /* DDLoginRequest.h */,
|
||||
8C2C3F592B2A70F9002C3C34 /* DDLoginRequest.m */,
|
||||
);
|
||||
path = Login;
|
||||
sourceTree = "<group>";
|
||||
@@ -2298,6 +2317,8 @@
|
||||
1802B3CA2A540F870036DCEF /* DDProtocolView.m */,
|
||||
1802B3D92A541B6B0036DCEF /* DDLoginTextView.h */,
|
||||
1802B3DA2A541B6B0036DCEF /* DDLoginTextView.m */,
|
||||
8C2C3F552B2A4350002C3C34 /* DDLoginSVGAView.h */,
|
||||
8C2C3F562B2A4350002C3C34 /* DDLoginSVGAView.m */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@@ -4642,6 +4663,7 @@
|
||||
1802B3C42A540A1C0036DCEF /* Login */,
|
||||
188CA9512A4FC51200DAFC86 /* Home */,
|
||||
18AFFEB22A4BCACA008F6478 /* Mine */,
|
||||
8C2C3F5E2B2A886A002C3C34 /* DDV2RequestUrl.h */,
|
||||
);
|
||||
path = V2Versions;
|
||||
sourceTree = "<group>";
|
||||
@@ -6442,6 +6464,7 @@
|
||||
188EC1162A47CF3200060F03 /* HXPhotoTools.m in Sources */,
|
||||
188EC10A2A47CF3200060F03 /* UIImageView+HXExtension.m in Sources */,
|
||||
18B5E59A2A4D23410089CEB1 /* DDShoppingHeaderCell.m in Sources */,
|
||||
8C2C3F5A2B2A70F9002C3C34 /* DDLoginRequest.m in Sources */,
|
||||
188CA95F2A4FCAF600DAFC86 /* YVBannerModel.m in Sources */,
|
||||
18B5E5A52A4D2F3E0089CEB1 /* XXNumberButton.m in Sources */,
|
||||
1812EC872A54FD6100FF2AC0 /* DDRoomLuckyGiftAlertView.m in Sources */,
|
||||
@@ -6485,11 +6508,13 @@
|
||||
1894B4212A4D8B3A0071063B /* DDCustomAlertView.m in Sources */,
|
||||
188EC11A2A47CF3200060F03 /* HXAlbumListViewController.m in Sources */,
|
||||
1838643B2A28A17B005BF235 /* ZLForceTouchPreviewController.m in Sources */,
|
||||
8C2C3F4E2B2A38C4002C3C34 /* DDV2PasswordLoginVC.m in Sources */,
|
||||
188EC13C2A47CF3300060F03 /* HXMECancelBlock.m in Sources */,
|
||||
18660CF92A2193750032D0C9 /* JXTAlertController.m in Sources */,
|
||||
189391D92A67E6E000674134 /* HCKeepBGRunManager.m in Sources */,
|
||||
188E48F82A663313002CED30 /* DDMarqueeLabel.m in Sources */,
|
||||
18660D4F2A2193C50032D0C9 /* UIImage+Custom.m in Sources */,
|
||||
8C2C3F572B2A4350002C3C34 /* DDLoginSVGAView.m in Sources */,
|
||||
8CE493A42B23F7EF00CA14D5 /* DDWeakTimer.m in Sources */,
|
||||
18BC965C2A22174900D83036 /* DDLoginViewController.m in Sources */,
|
||||
188EBF972A47CF0C00060F03 /* DDFaceViewPageControl.m in Sources */,
|
||||
@@ -6721,6 +6746,7 @@
|
||||
188EBFA82A47CF1300060F03 /* DDFMDBMessageTool.m in Sources */,
|
||||
18A7E6972A4E7E4E0078E659 /* DDDecorateAlertView.m in Sources */,
|
||||
188AF5C22A276449004DD4CF /* RoomPublicScreenGiftCell.m in Sources */,
|
||||
8C2C3F542B2A41F5002C3C34 /* DDV2PhoneCodeVC.m in Sources */,
|
||||
188EC1322A47CF3300060F03 /* HXPhotoSubViewCell.m in Sources */,
|
||||
188EC1342A47CF3300060F03 /* HXCustomPreviewView.m in Sources */,
|
||||
18660D702A21942F0032D0C9 /* BaseTableViewCell.m in Sources */,
|
||||
@@ -7079,10 +7105,8 @@
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/DingDangApp/BsaseClass/Third/SdkLib",
|
||||
);
|
||||
|
||||
MARKETING_VERSION = 1.4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = cn.dingdang.voice;
|
||||
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
@@ -7139,10 +7163,8 @@
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/DingDangApp/BsaseClass/Third/SdkLib",
|
||||
);
|
||||
|
||||
MARKETING_VERSION = 1.4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = cn.dingdang.voice;
|
||||
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
|
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 配置主窗口
|
||||
- (void)configureForTabBarController;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -11,81 +11,113 @@
|
||||
#import "HomeViewController.h"
|
||||
#import "DDLoginViewController.h"
|
||||
#import "DDV2LoginVC.h"
|
||||
#import "DDSocketTool.h"
|
||||
#import "DDYoungModeFullView.h"
|
||||
#import "DDYoungModeViewController.h"
|
||||
#import "RoomViewController.h"
|
||||
/// Tool
|
||||
#import "DDSocketTool.h"
|
||||
#import "AccountModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "HttpRequestHelper.h"
|
||||
#import "DDLoginRequest.h"
|
||||
|
||||
@interface AppDelegate (CYLTabBar)
|
||||
|
||||
|
||||
@end
|
||||
@implementation AppDelegate (CYLTabBar)
|
||||
- (void)configureForTabBarController {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = Kblack_color;
|
||||
[self.window makeKeyAndVisible];
|
||||
self.tabBarController = [[WLCoustomTabBarController alloc] initTabBar];
|
||||
self.window.rootViewController = self.tabBarController;
|
||||
AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo];
|
||||
if (accountModel == nil || accountModel.uid == nil || accountModel.access_token == nil) {
|
||||
[self gotoWithLoginController];
|
||||
return;
|
||||
AppUserModel * userModel = [ToolsObject getUserModel];
|
||||
if (userModel){
|
||||
if (![ToolsObject IsNullWithObject:userModel.token]){
|
||||
}
|
||||
|
||||
|
||||
if ([[AccountInfoStorage instance] getTicket].length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self loadRequestLoginTicket];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Request
|
||||
- (void)loadRequestLoginTicket {
|
||||
[ToolsObject ShowSVProgressHUD:@"正在加载页面中,请稍等"];
|
||||
AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo];
|
||||
NSDictionary *param = @{
|
||||
@"access_token" : accountModel.access_token,
|
||||
@"issue_type" : @"multi"
|
||||
};
|
||||
[HttpRequestHelper POST:@"/oauth/ticket" params:param success:^(BaseModel * _Nonnull data) {
|
||||
[ToolsObject DismissSVProgressHUD];
|
||||
NSArray *tickets = [data.data valueForKey:@"tickets"];
|
||||
NSString *ticket = [tickets[0] valueForKey:@"ticket"];
|
||||
[[AccountInfoStorage instance] saveTicket:ticket];
|
||||
[self getUserInfo];
|
||||
[[DDSocketTool shareTool] starConnection];
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = Kblack_color;
|
||||
[self.window makeKeyAndVisible];
|
||||
self.tabBarController = [[WLCoustomTabBarController alloc] initTabBar];
|
||||
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
||||
[ToolsObject addPopVieToText:[NSString stringWithFormat:@"加载页面%@失败,请重新登录",message]];
|
||||
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||
[[AccountInfoStorage instance] saveTicket:nil];
|
||||
[self gotoWithLoginController];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)getUserInfo {
|
||||
[DDLoginRequest DD_LoadRequestUserInfo:[[AccountInfoStorage instance] getUid] completed:^(UserInfoModel * _Nonnull userInfo) {
|
||||
if (userInfo == nil) {
|
||||
// 去填资料
|
||||
return;
|
||||
}
|
||||
|
||||
[self initWindow];
|
||||
// 判断是否开启了青少年模式
|
||||
if ([kUserDefaults objectForKey:KYoungPasswordKey]) {
|
||||
if (self.inRoom) {
|
||||
[RoomViewController destoryVC];
|
||||
}
|
||||
|
||||
[self gotoWithYoungerController];
|
||||
} else {
|
||||
[self gotoWithTabbarController];
|
||||
|
||||
if (self.alertViewIsShow) return;
|
||||
self.alertViewIsShow = [ToolsObject allowShowFirstOpenAlert];
|
||||
if ([ToolsObject allowShowFirstOpenAlert]) {
|
||||
DDYoungModeFullView *youngPopView = [DDYoungModeFullView showYoungPopView];
|
||||
[youngPopView show];
|
||||
}
|
||||
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initWindow {
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
self.window.backgroundColor = Kblack_color;
|
||||
[self.window makeKeyAndVisible];
|
||||
}
|
||||
|
||||
- (void)gotoWithYoungerController {
|
||||
DDYoungModeViewController *youngModeVC = [DDYoungModeViewController new];
|
||||
youngModeVC.openYoungMode = YES;
|
||||
UINavigationController *youngModeNC = [[UINavigationController alloc] initWithRootViewController:youngModeVC];
|
||||
self.window.rootViewController = youngModeNC;
|
||||
self.tabBarController = nil;
|
||||
}else{
|
||||
}
|
||||
|
||||
- (void)gotoWithTabbarController {
|
||||
self.tabBarController = [[WLCoustomTabBarController alloc] initTabBar];
|
||||
self.window.rootViewController = self.tabBarController;
|
||||
if (self.alertViewIsShow) {
|
||||
return;
|
||||
}
|
||||
if ([ToolsObject allowShowFirstOpenAlert]) {
|
||||
DDYoungModeFullView *youngPopView = [DDYoungModeFullView showYoungPopView];
|
||||
[youngPopView show];
|
||||
self.alertViewIsShow = YES;
|
||||
}else{
|
||||
self.alertViewIsShow = NO;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
|
||||
/// 去登录页面
|
||||
- (void)gotoWithLoginController {
|
||||
DDV2LoginVC *loginVC = [DDV2LoginVC new];
|
||||
UINavigationController *loginNC = [[UINavigationController alloc] initWithRootViewController:loginVC];
|
||||
self.window.rootViewController = loginNC;
|
||||
}
|
||||
}else{
|
||||
DDV2LoginVC *loginVC = [DDV2LoginVC new];
|
||||
UINavigationController *loginNC = [[UINavigationController alloc] initWithRootViewController:loginVC];
|
||||
self.window.rootViewController = loginNC;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)getUserInfo
|
||||
{
|
||||
NSMutableDictionary *requestDict = [NSMutableDictionary dictionary];
|
||||
[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];
|
||||
NSString * token = myModel.token;
|
||||
myModel = model;
|
||||
myModel.token = token;
|
||||
[ToolsObject saveUserModel:myModel];
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
@end
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#import "RoomConfigModel.h"
|
||||
#import "SDImageCache.h"
|
||||
#import "RoomEditPassWordView.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
static NSString *SAVELOGIN = @"LOGINMODEL";
|
||||
static NSString *SAVECITYINFO = @"CITYINFO";
|
||||
static NSString *SAVELOGINVIDEO = @"LOGINVIDEO";
|
||||
@@ -834,15 +835,17 @@ static NSString *SAVEROOMCONFIG = @"ROOMCONFIG";
|
||||
UIWindow * window = [[AppDelegate getAppdelegate] window];
|
||||
if ([[AppDelegate getAppdelegate] inRoom]) {
|
||||
if ([RoomSmallView shareView].isHidden) {
|
||||
[[RoomViewController shareVC].navigationController dismissViewControllerAnimated:YES completion:^{
|
||||
}];
|
||||
[[RoomViewController shareVC].navigationController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
[[RoomSmallView shareView] dismiss];
|
||||
[RoomViewController destoryVC];
|
||||
}
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
|
||||
[[DDSocketTool shareTool] closeConnection];
|
||||
[ToolsObject removeUserInfo];
|
||||
[[AccountInfoStorage instance] saveTicket:nil];
|
||||
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||
[kUserDefaults removeObjectForKey:KYoungPasswordKey];
|
||||
|
||||
DDV2LoginVC *loginViewController = [[DDV2LoginVC alloc] init];
|
||||
|
@@ -53,6 +53,7 @@
|
||||
alertView.alertViewClickBlock = ^(NSInteger index, NSString * _Nonnull title) {
|
||||
if ([title isEqualToString:@"退出"]) {
|
||||
[ToolsObject loginOutJump];
|
||||
|
||||
}
|
||||
};
|
||||
[alertView showAlertView];
|
||||
|
12
yinmeng-ios/DingDangApp/V2Versions/DDV2RequestUrl.h
Normal file
12
yinmeng-ios/DingDangApp/V2Versions/DDV2RequestUrl.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// DDV2RequestUrl.h
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#ifndef DDV2RequestUrl_h
|
||||
#define DDV2RequestUrl_h
|
||||
|
||||
|
||||
#endif /* DDV2RequestUrl_h */
|
36
yinmeng-ios/DingDangApp/V2Versions/Login/DDLoginRequest.h
Normal file
36
yinmeng-ios/DingDangApp/V2Versions/Login/DDLoginRequest.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// DDLoginRequest.h
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class UserInfoModel;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
typedef void(^completed)(void);
|
||||
typedef void(^completedUserInfo)(UserInfoModel *userInfo);
|
||||
|
||||
|
||||
@interface DDLoginRequest : NSObject
|
||||
|
||||
/// 获取验证码
|
||||
+ (void)DD_LoadRequestPhoneCode:(NSString *)phone success:(completed)success;
|
||||
|
||||
/// 手机登录
|
||||
+ (void)DD_LoadRequestLoginPhone:(NSString *)phone code:(NSString *)code success:(completed)success;
|
||||
|
||||
/// 密码登录
|
||||
+ (void)DD_LoadRequestLoginPassword:(NSString *)password account:(NSString *)account success:(completed)success;
|
||||
|
||||
/// 根据用户的id获取用户的信息
|
||||
/// - Parameter userId: 用户uid
|
||||
+ (void)DD_LoadRequestUserInfo:(NSString *)userId completed:(completedUserInfo)completed;
|
||||
|
||||
/// 获取登录的字符串
|
||||
+ (NSString *)DD_GetLoginUrlTitle;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
102
yinmeng-ios/DingDangApp/V2Versions/Login/DDLoginRequest.m
Normal file
102
yinmeng-ios/DingDangApp/V2Versions/Login/DDLoginRequest.m
Normal file
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// DDLoginRequest.m
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDLoginRequest.h"
|
||||
/// Tool
|
||||
#import "DDSystemTool.h"
|
||||
#import "HttpRequestHelper.h"
|
||||
#import "NSObject+DDExtension.h"
|
||||
/// Model
|
||||
#import "AccountModel.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "UserInfoModel.h"
|
||||
|
||||
@implementation DDLoginRequest
|
||||
|
||||
/// 获取验证码
|
||||
+ (void)DD_LoadRequestPhoneCode:(NSString *)phone success:(completed)success{
|
||||
// type: 1-注册账号
|
||||
NSMutableDictionary *param = [NSMutableDictionary dictionary];
|
||||
param[@"mobile"] = [DDSystemTool DD_GetPhoneEncryptDes:phone];
|
||||
param[@"type"] = @(1);
|
||||
[HttpRequestHelper POST:@"sms/getCode" params:param success:^(BaseModel * _Nonnull data) {
|
||||
[ToolsObject addPopVieToText:data.message];
|
||||
success();
|
||||
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
||||
[ToolsObject addPopVieToText:message];
|
||||
}];
|
||||
}
|
||||
|
||||
// 手机号登录
|
||||
+ (void)DD_LoadRequestLoginPhone:(NSString *)phone code:(NSString *)code success:(completed)success {
|
||||
NSMutableDictionary *param = [self DD_LoadCommonRequestParamAccount:phone];
|
||||
param[@"code"] = code;
|
||||
param[@"invite_code"] = @"";
|
||||
[self DD_LoadRequestLogin:param completed:success];
|
||||
}
|
||||
|
||||
// 密码登录
|
||||
+ (void)DD_LoadRequestLoginPassword:(NSString *)password account:(NSString *)account success:(completed)success {
|
||||
NSMutableDictionary *param = [self DD_LoadCommonRequestParamAccount:account];
|
||||
param[@"password"] = [DDSystemTool DD_GetPasswordEncryptDes:password];
|
||||
[self DD_LoadRequestLogin:param completed:success];
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
+ (void)DD_LoadRequestUserInfo:(NSString *)userId completed:(completedUserInfo)completed {
|
||||
NSMutableDictionary *param = [NSMutableDictionary dictionary];
|
||||
param[@"uid"] = userId;
|
||||
[HttpRequestHelper GET:@"/user/get" params:param success:^(BaseModel * _Nonnull data) {
|
||||
UserInfoModel *userInfo = [UserInfoModel DD_ModelWithDict:data.data];
|
||||
completed(userInfo);
|
||||
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
||||
[ToolsObject addPopVieToText:message];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private Method
|
||||
+ (NSString *)DD_GetLoginUrlTitle {
|
||||
return @"oauth/token";
|
||||
}
|
||||
|
||||
/// 获取登录公共参数
|
||||
+ (NSMutableDictionary *)DD_LoadCommonRequestParamAccount:(NSString *)account {
|
||||
NSMutableDictionary *param = [NSMutableDictionary dictionary];
|
||||
[param setObject:@"uyzjdhds" forKey:@"client_secret"];
|
||||
[param setObject:@"1" forKey:@"version"];
|
||||
[param setObject:@"erban-client" forKey:@"client_id"];
|
||||
[param setObject:@"password" forKey:@"grant_type"];
|
||||
[param setObject:[DDSystemTool DD_GetPhoneEncryptDes:account] forKey:@"phone"];
|
||||
return param;
|
||||
}
|
||||
|
||||
/// 发起请求
|
||||
+ (void)DD_LoadRequestLogin:(NSDictionary *)params completed:(completed)completed{
|
||||
[HttpRequestHelper POST:[self DD_GetLoginUrlTitle] params:params success:^(BaseModel * _Nonnull data) {
|
||||
AccountModel *accountModel = [AccountModel DD_ModelWithDict:data.data];
|
||||
if (accountModel && accountModel.access_token.length > 0) {
|
||||
[[AccountInfoStorage instance] saveAccountInfo:accountModel];
|
||||
[self DD_LoadRequestUserInfo:accountModel.uid completed:^(UserInfoModel * _Nonnull userInfo) {
|
||||
if (userInfo != nil) {
|
||||
[ToolsObject addPopVieToText:@"登录成功"];
|
||||
completed();
|
||||
} else {
|
||||
[ToolsObject addPopVieToText:@"获取用户失败,请重新登录"];
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
[ToolsObject addPopVieToText:@"获取用户失败,请重新登录"];
|
||||
}
|
||||
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
||||
[ToolsObject addPopVieToText:message];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
@@ -39,6 +39,7 @@
|
||||
- (BOOL)ishiddenNavigationView {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = UIColor.whiteColor;
|
||||
@@ -53,6 +54,11 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
// self.navigationController.navigationBar.hidden = YES;
|
||||
}
|
||||
|
||||
#pragma mark - Init
|
||||
- (void)initSubView {
|
||||
[self.view addSubview:self.logoSVGAPlayer];
|
||||
|
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DDV2PasswordLoginVC.h
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDBaseVC.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DDV2PasswordLoginVC : DDBaseVC
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
181
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PasswordLoginVC.m
Normal file
181
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PasswordLoginVC.m
Normal file
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// DDV2PasswordLoginVC.m
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDV2PasswordLoginVC.h"
|
||||
#import "AppDelegate+CYLTabBar.h"
|
||||
/// View
|
||||
#import "DDLoginTextView.h"
|
||||
#import "DDLoginSVGAView.h"
|
||||
/// Tool
|
||||
#import "UIImage+Custom.h"
|
||||
#import "DDSystemTool.h"
|
||||
#import "DDLoginRequest.h"
|
||||
/// Third
|
||||
#import <IQKeyboardManager/IQKeyboardManager.h>
|
||||
|
||||
|
||||
@interface DDV2PasswordLoginVC ()
|
||||
|
||||
@property (nonatomic, strong) UIButton *codeButton;
|
||||
@property (nonatomic, strong) DDLoginSVGAView *loginSvgaView;
|
||||
/**账号**/
|
||||
@property (nonatomic, strong) DDLoginTextView *accountView;
|
||||
/**密码**/
|
||||
@property (nonatomic, strong) DDLoginTextView *passWordView;
|
||||
/**登录**/
|
||||
@property (nonatomic, strong) UIButton *loginButton;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation DDV2PasswordLoginVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = UIColor.whiteColor;
|
||||
[self setUI];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = YES;
|
||||
}
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = NO;
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)setUI {
|
||||
[self.view addSubview:self.loginSvgaView];
|
||||
[self.view addSubview:self.codeButton];
|
||||
[self.view addSubview:self.accountView];
|
||||
[self.view addSubview:self.passWordView];
|
||||
[self.view addSubview:self.loginButton];
|
||||
|
||||
[self.codeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(kStatusBarHeight + 20);
|
||||
make.right.mas_equalTo(-20);
|
||||
}];
|
||||
|
||||
[self.loginSvgaView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(KScreenWidth * kScaleX);
|
||||
}];
|
||||
|
||||
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.loginSvgaView.mas_bottom);
|
||||
make.left.right.equalTo(self.view).inset(50);
|
||||
make.height.mas_equalTo(51);
|
||||
}];
|
||||
|
||||
[self.passWordView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self.view);
|
||||
make.width.height.mas_equalTo(self.accountView);
|
||||
make.top.equalTo(self.accountView.mas_bottom).offset(20);
|
||||
}];
|
||||
|
||||
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.passWordView.mas_bottom).offset(20);
|
||||
make.left.height.right.equalTo(self.passWordView);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
- (void)backButtonAction {
|
||||
[self.navigationController popViewControllerAnimated:NO];
|
||||
}
|
||||
|
||||
- (void)loginBtnClickAction {
|
||||
if (self.accountView.textField.text.length == 0 || [self.accountView.textField.text isEqualToString:@""]) {
|
||||
[ToolsObject addPopVieToText:@"请输入账号"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.passWordView.textField.text.length == 0 || [self.passWordView.textField.text isEqualToString:@""]) {
|
||||
[ToolsObject addPopVieToText:@"请输入密码"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.passWordView.textField.text.length < 6) {
|
||||
[ToolsObject addPopVieToText:@"密码需要同时包含6-12位字母和数字"];
|
||||
return;
|
||||
}
|
||||
|
||||
[self loadRequestLoginPassword];
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Request
|
||||
- (void)loadRequestLoginPassword {
|
||||
[ToolsObject ShowSVProgressHUD:@"正在登录中,请稍等"];
|
||||
[DDLoginRequest DD_LoadRequestLoginPassword:self.passWordView.textField.text account:self.accountView.textField.text success:^{
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
|
||||
AppDelegate *delegate =(AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
[delegate configureForTabBarController];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Get
|
||||
- (UIButton *)codeButton {
|
||||
if (!_codeButton) {
|
||||
_codeButton = [[UIButton alloc] init];
|
||||
[_codeButton setTitle:@"验证码登录" forState:UIControlStateNormal];
|
||||
_codeButton.titleLabel.font = DDFont(16);
|
||||
[_codeButton setTitleColor:DDHEXColor(0x333333) forState:(UIControlStateNormal)];
|
||||
[_codeButton addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _codeButton;
|
||||
}
|
||||
|
||||
|
||||
- (DDLoginSVGAView *)loginSvgaView {
|
||||
if (!_loginSvgaView) {
|
||||
_loginSvgaView = [[DDLoginSVGAView alloc] init];
|
||||
WeakSelf(weakSelf);
|
||||
_loginSvgaView.backButtonCloseEvent = ^{
|
||||
[weakSelf backButtonAction];
|
||||
};
|
||||
}
|
||||
return _loginSvgaView;
|
||||
}
|
||||
|
||||
|
||||
- (DDLoginTextView *)accountView {
|
||||
if (!_accountView) {
|
||||
_accountView = [[DDLoginTextView alloc] initWithFrame:CGRectZero withType:DDTextFieldPasswordAccount];
|
||||
}
|
||||
return _accountView;
|
||||
}
|
||||
|
||||
- (DDLoginTextView *)passWordView {
|
||||
if (!_passWordView) {
|
||||
_passWordView = [[DDLoginTextView alloc] initWithFrame:CGRectZero withType:DDTextFieldPassWord];
|
||||
_passWordView.customLeftText = @"";
|
||||
}
|
||||
return _passWordView;
|
||||
}
|
||||
|
||||
- (UIButton *)loginButton {
|
||||
if (!_loginButton) {
|
||||
_loginButton = [[UIButton alloc] init];
|
||||
[_loginButton setTitle:@"登录" forState:(UIControlStateNormal)];
|
||||
_loginButton.layer.cornerRadius = 51.0/2;
|
||||
_loginButton.layer.masksToBounds = YES;
|
||||
[_loginButton setTitleColor:[DDAppColor dd_noClickBtnTitleColor] forState:UIControlStateDisabled];
|
||||
[_loginButton setTitleColor:[DDAppColor dd_sureBtnTitleColor] forState:UIControlStateNormal];
|
||||
_loginButton.titleLabel.font = DDFont(16);
|
||||
UIImage *bgImage = [UIImage imageWithColor:[DDAppColor dd_sureBtnGradientBeginColor]];
|
||||
[_loginButton setBackgroundImage:bgImage forState:UIControlStateNormal];
|
||||
[_loginButton addTarget:self action:@selector(loginBtnClickAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _loginButton;
|
||||
}
|
||||
|
||||
@end
|
16
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneCodeVC.h
Normal file
16
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneCodeVC.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DDV2PhoneCodeVC.h
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDBaseVC.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DDV2PhoneCodeVC : DDBaseVC
|
||||
@property (nonatomic, copy) NSString *phoneTitle;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
142
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneCodeVC.m
Normal file
142
yinmeng-ios/DingDangApp/V2Versions/Login/DDV2PhoneCodeVC.m
Normal file
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// DDV2PhoneCodeVC.m
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDV2PhoneCodeVC.h"
|
||||
#import "AppDelegate+CYLTabBar.h"
|
||||
/// View
|
||||
#import "DDLoginTextView.h"
|
||||
#import "DDLoginSVGAView.h"
|
||||
/// Tool
|
||||
#import "DDAppColor.h"
|
||||
#import "UIImage+Custom.h"
|
||||
#import "DDSystemTool.h"
|
||||
#import "DDLoginRequest.h"
|
||||
/// Third
|
||||
#import <IQKeyboardManager/IQKeyboardManager.h>
|
||||
|
||||
@interface DDV2PhoneCodeVC ()
|
||||
@property (nonatomic, strong) DDLoginSVGAView *logoSVGAPlayer;
|
||||
/**验证码**/
|
||||
@property (nonatomic, strong) DDLoginTextView *codeView;
|
||||
/** 登录 */
|
||||
@property(nonatomic,strong) UIButton *loginButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation DDV2PhoneCodeVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
self.view.backgroundColor = UIColor.whiteColor;
|
||||
[self setUI];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = YES;
|
||||
}
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[IQKeyboardManager sharedManager].enable = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
- (void)backButtonAction {
|
||||
[self.navigationController popViewControllerAnimated:NO];
|
||||
}
|
||||
|
||||
- (void)loginBtnClickAction {
|
||||
if (self.codeView.textField.text.length == 0 || [self.codeView.textField.text isEqualToString:@""]) {
|
||||
[ToolsObject addPopVieToText:@"验证码不能为空"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.codeView.textField.text.length != 5) {
|
||||
[ToolsObject addPopVieToText:@"请输入5位的验证码"];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self loadRequestLogin];
|
||||
}
|
||||
|
||||
#pragma mark - Request
|
||||
- (void)loadRequestLogin {
|
||||
[ToolsObject ShowSVProgressHUD:@"正在登录中,请稍等"];
|
||||
[DDLoginRequest DD_LoadRequestLoginPhone:self.phoneTitle code:self.codeView.textField.text success:^{
|
||||
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
AppDelegate *delegate =(AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
[delegate configureForTabBarController];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)setUI {
|
||||
[self.view addSubview:self.logoSVGAPlayer];
|
||||
[self.view addSubview:self.codeView];
|
||||
[self.view addSubview:self.loginButton];
|
||||
|
||||
[self.logoSVGAPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(KScreenWidth * kScaleX);
|
||||
}];
|
||||
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.logoSVGAPlayer.mas_bottom).offset(20);
|
||||
make.left.right.equalTo(self.view).inset(50);
|
||||
make.height.mas_equalTo(51);
|
||||
}];
|
||||
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.codeView.mas_bottom).offset(20);
|
||||
make.height.left.right.equalTo(self.codeView);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Get
|
||||
- (DDLoginSVGAView *)logoSVGAPlayer {
|
||||
if (!_logoSVGAPlayer) {
|
||||
_logoSVGAPlayer = [[DDLoginSVGAView alloc] init];
|
||||
WeakSelf(weakSelf);
|
||||
_logoSVGAPlayer.backButtonCloseEvent = ^{
|
||||
[weakSelf backButtonAction];
|
||||
};
|
||||
}
|
||||
return _logoSVGAPlayer;
|
||||
}
|
||||
|
||||
- (DDLoginTextView *)codeView {
|
||||
if (!_codeView) {
|
||||
_codeView = [[DDLoginTextView alloc] initWithFrame:CGRectZero withType:DDTextFieldGetCode];
|
||||
[_codeView.getCodeBtn startCountDownWithSecond:60];
|
||||
[_codeView.getCodeBtn countDownChanging:^NSString *(JKCountDownButton *countDownButton, NSUInteger second) {
|
||||
return [NSString stringWithFormat:@"%zds",second];
|
||||
}];
|
||||
[_codeView.getCodeBtn countDownFinished:^NSString *(JKCountDownButton *countDownButton, NSUInteger second) {
|
||||
return @" 重新获取 ";
|
||||
}];
|
||||
}
|
||||
return _codeView;
|
||||
}
|
||||
|
||||
- (UIButton *)loginButton {
|
||||
if (!_loginButton) {
|
||||
_loginButton = [[UIButton alloc] init];
|
||||
[_loginButton setTitle:@"登录" forState:UIControlStateNormal];
|
||||
_loginButton.layer.cornerRadius = 51.0/2;
|
||||
_loginButton.layer.masksToBounds = YES;
|
||||
[_loginButton setTitleColor:[DDAppColor dd_noClickBtnTitleColor] forState:UIControlStateDisabled];
|
||||
[_loginButton setTitleColor:[DDAppColor dd_sureBtnTitleColor] forState:UIControlStateNormal];
|
||||
_loginButton.titleLabel.font = DDFont(16);
|
||||
UIImage *bgImage = [UIImage imageWithColor:[DDAppColor dd_sureBtnGradientBeginColor]];
|
||||
[_loginButton setBackgroundImage:bgImage forState:UIControlStateNormal];
|
||||
[_loginButton addTarget:self action:@selector(loginBtnClickAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _loginButton;
|
||||
}
|
||||
|
||||
@end
|
@@ -10,66 +10,42 @@
|
||||
/// View
|
||||
#import "DDLoginTextView.h"
|
||||
#import "DDWebViewController.h"
|
||||
#import "DDV2PasswordLoginVC.h"
|
||||
#import "DDV2PhoneCodeVC.h"
|
||||
#import "DDLoginSVGAView.h"
|
||||
/// Tool
|
||||
#import "AppDelegate+CYLTabBar.h"
|
||||
#import "HttpRequestHelper.h"
|
||||
#import "DDDESEncrypt.h"
|
||||
//#import "DDLoginAccountModel.h"
|
||||
#import "DDSystemTool.h"
|
||||
#import "DDAppColor.h"
|
||||
#import "UIImage+Custom.h"
|
||||
#import "DDLoginRequest.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) DDLoginSVGAView *logoSVGAPlayer;
|
||||
/**账号**/
|
||||
@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];
|
||||
self.navigationController.navigationBar.hidden = YES;
|
||||
[IQKeyboardManager sharedManager].enable = YES;
|
||||
}
|
||||
|
||||
@@ -81,422 +57,59 @@ typedef enum : NSUInteger {
|
||||
- (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.view addSubview:self.codeButton];
|
||||
[self.view addSubview:self.loginTypeBtn];
|
||||
|
||||
[self.loginTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(kStatusBarHeight + 20);
|
||||
make.right.mas_equalTo(-20);
|
||||
}];
|
||||
|
||||
[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);
|
||||
make.left.right.equalTo(self.view).inset(50);
|
||||
make.height.mas_equalTo(51);
|
||||
}];
|
||||
[self.codeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self.view);
|
||||
make.width.height.mas_equalTo(self.phoneView);
|
||||
make.top.equalTo(self.phoneView.mas_bottom).offset(20);
|
||||
}];
|
||||
//
|
||||
// [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 {
|
||||
|
||||
// 获取成功跳转到下一步
|
||||
[self requestCode];
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
DDV2PasswordLoginVC *passwordVC = [[DDV2PasswordLoginVC alloc] init];
|
||||
[self.navigationController pushViewController:passwordVC animated:NO];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (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"];
|
||||
}
|
||||
|
||||
#pragma mark - Request
|
||||
//获取手机验证码
|
||||
- (void)requestCode{
|
||||
|
||||
if ([ToolsObject IsNullWithObject:self.phoneView.textField.text]) {
|
||||
[ToolsObject addPopVieToText:@"手机号不能为空"];
|
||||
return;
|
||||
@@ -505,139 +118,23 @@ typedef enum : NSUInteger {
|
||||
[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;
|
||||
[DDLoginRequest DD_LoadRequestPhoneCode:self.phoneView.textField.text success:^{
|
||||
DDV2PhoneCodeVC *codeController = [[DDV2PhoneCodeVC alloc] init];
|
||||
codeController.phoneTitle = self.phoneView.textField.text;
|
||||
[self.navigationController pushViewController:codeController animated:NO];
|
||||
}];
|
||||
[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 {
|
||||
- (DDLoginSVGAView *)logoSVGAPlayer {
|
||||
if (!_logoSVGAPlayer) {
|
||||
_logoSVGAPlayer = [[SVGAPlayer alloc] init];
|
||||
_logoSVGAPlayer.loops = 1;
|
||||
_logoSVGAPlayer.clearsAfterStop = NO;
|
||||
_logoSVGAPlayer = [[DDLoginSVGAView alloc] init];
|
||||
WeakSelf(weakSelf);
|
||||
_logoSVGAPlayer.backButtonCloseEvent = ^{
|
||||
[weakSelf backButtonAction];
|
||||
};
|
||||
}
|
||||
return _logoSVGAPlayer;
|
||||
}
|
||||
@@ -646,89 +143,35 @@ typedef enum : NSUInteger {
|
||||
if (!_codeButton) {
|
||||
_codeButton = [[UIButton alloc] init];
|
||||
[_codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
|
||||
_codeButton.titleLabel.font = DDFont(16);
|
||||
[_codeButton setTitleColor:[DDAppColor dd_noClickBtnTitleColor] forState:UIControlStateDisabled];
|
||||
[_codeButton setTitleColor:[DDAppColor dd_sureBtnTitleColor] forState:UIControlStateNormal];
|
||||
_codeButton.layer.cornerRadius = 51.0/2;
|
||||
_codeButton.layer.masksToBounds = YES;
|
||||
UIImage *bgImage = [UIImage imageWithColor:[DDAppColor dd_sureBtnGradientBeginColor]];
|
||||
[_codeButton setBackgroundImage:bgImage forState:UIControlStateNormal];
|
||||
[_codeButton addTarget:self action:@selector(getCodeNumberAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _codeButton;
|
||||
}
|
||||
|
||||
|
||||
- (DDLoginTextView *)phoneView {
|
||||
if (!_phoneView) {
|
||||
_phoneView = [[DDLoginTextView alloc]initWithFrame:CGRectZero withType:DDTextFieldPhone];
|
||||
_phoneView.customLeftText = @"+86";
|
||||
}
|
||||
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.titleLabel.font = DDFont(16);
|
||||
_loginTypeBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[_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
|
||||
|
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// DDLoginSVGAView.h
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void(^completed)(void);
|
||||
@interface DDLoginSVGAView : UIView
|
||||
@property (nonatomic, strong, readonly) UIButton *backButton;
|
||||
// svga
|
||||
@property (nonatomic, copy) NSString *svgaString;
|
||||
|
||||
@property (nonatomic, copy) completed backButtonCloseEvent;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// DDLoginSVGAView.m
|
||||
// DingDangApp
|
||||
//
|
||||
// Created by 触海 on 2023/12/13.
|
||||
//
|
||||
|
||||
#import "DDLoginSVGAView.h"
|
||||
/// Third
|
||||
#import <SVGAPlayer.h>
|
||||
#import <SVGA.h>
|
||||
|
||||
@interface DDLoginSVGAView()
|
||||
|
||||
@property (nonatomic, strong) SVGAPlayer *logoSVGAPlayer;
|
||||
/**返回按钮**/
|
||||
@property (nonatomic, strong) UIButton *backButton;
|
||||
|
||||
@property (nonatomic, strong) SVGAParser *parser;
|
||||
@end
|
||||
|
||||
@implementation DDLoginSVGAView
|
||||
|
||||
#pragma mark - Init
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self setUI];
|
||||
self.svgaString = @"login_logo";
|
||||
// [self setLogoLoginAnimation];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Action
|
||||
- (void)backButtonAction {
|
||||
if (self.backButtonCloseEvent) {
|
||||
self.backButtonCloseEvent();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)setUI {
|
||||
[self addSubview:self.logoSVGAPlayer];
|
||||
[self addSubview:self.backButton];
|
||||
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(24);
|
||||
make.left.mas_equalTo(20);
|
||||
make.top.mas_equalTo(kStatusBarHeight + 20);
|
||||
}];
|
||||
|
||||
[self.logoSVGAPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Set
|
||||
- (void)setSvgaString:(NSString *)svgaString {
|
||||
_svgaString = svgaString;
|
||||
NSString *svga = _svgaString.length == 0 || [svgaString isEqualToString:@""] ? @"login_logo" : _svgaString;
|
||||
WeakSelf(weakSelf);
|
||||
SVGAParser *parser = [[SVGAParser alloc] init];
|
||||
[parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
if (videoItem != nil) {
|
||||
weakSelf.logoSVGAPlayer.videoItem = videoItem;
|
||||
[weakSelf.logoSVGAPlayer startAnimation];
|
||||
}
|
||||
} failureBlock:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Get
|
||||
- (UIButton *)backButton {
|
||||
if (!_backButton) {
|
||||
_backButton = [[UIButton alloc] init];
|
||||
[_backButton setImage:[UIImage imageNamed:@"myinfo_6"] forState:UIControlStateNormal];
|
||||
[_backButton addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _backButton;
|
||||
}
|
||||
|
||||
- (SVGAPlayer *)logoSVGAPlayer {
|
||||
if (!_logoSVGAPlayer) {
|
||||
_logoSVGAPlayer = [[SVGAPlayer alloc] init];
|
||||
_logoSVGAPlayer.loops = 1;
|
||||
_logoSVGAPlayer.clearsAfterStop = NO;
|
||||
}
|
||||
return _logoSVGAPlayer;
|
||||
}
|
||||
|
||||
@end
|
@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
typedef enum : NSUInteger {
|
||||
DDTextFieldNone,
|
||||
DDTextFieldPhone,
|
||||
DDTextFieldPasswordAccount,
|
||||
DDTextFieldGetCode,
|
||||
DDTextFieldPassWord,
|
||||
DDTextFieldInvideCode
|
||||
@@ -20,6 +21,7 @@ typedef enum : NSUInteger {
|
||||
|
||||
@interface DDLoginTextView : UIView
|
||||
@property (nonatomic, assign) DDTextFieldViewType type;
|
||||
@property (nonatomic, copy) NSString *customLeftText;
|
||||
@property (nonatomic, strong) UIImageView *iconImageView;
|
||||
@property (nonatomic, strong) UITextField *textField;
|
||||
@property (nonatomic, strong) JKCountDownButton *getCodeBtn;
|
||||
|
@@ -7,39 +7,60 @@
|
||||
|
||||
#import "DDLoginTextView.h"
|
||||
|
||||
@implementation DDLoginTextView
|
||||
@implementation DDLoginTextView {
|
||||
UILabel *_leftLabel;
|
||||
}
|
||||
|
||||
#pragma mark - Init
|
||||
- (instancetype)initWithFrame:(CGRect)frame withType:(DDTextFieldViewType)type
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = [DDAppColor dd_getColorWithHexText:@"#F8F8F8"];
|
||||
self.layer.cornerRadius = 51.0/2;
|
||||
self.layer.masksToBounds = YES;
|
||||
self.type = type;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setType:(DDTextFieldViewType)type
|
||||
{
|
||||
- (void)initLeftLabel {
|
||||
if (!_leftLabel){
|
||||
_leftLabel = [[UILabel alloc] init];
|
||||
_leftLabel.textColor = [DDAppColor dd_MajorTitleColor];
|
||||
_leftLabel.font = DDFont(18);
|
||||
[self addSubview:_leftLabel];
|
||||
[_leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.equalTo(self.iconImageView);
|
||||
make.centerY.equalTo(self);
|
||||
make.left.mas_equalTo(10);
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Set
|
||||
- (void)setType:(DDTextFieldViewType)type {
|
||||
_type = type;
|
||||
self.lineView.hidden = NO;
|
||||
// self.lineView.hidden = YES;
|
||||
switch (type) {
|
||||
case DDTextFieldPhone:
|
||||
{
|
||||
self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_3"];
|
||||
// self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_3"];
|
||||
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入手机号" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(20)}];
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入手机号" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(16)}];
|
||||
self.textField.jk_maxLength = 11;
|
||||
}
|
||||
break;
|
||||
case DDTextFieldGetCode:
|
||||
{
|
||||
self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_4"];
|
||||
case DDTextFieldGetCode: {
|
||||
// self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_4"];
|
||||
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(20)}];
|
||||
self.textField.jk_maxLength = 6;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(16)}];
|
||||
self.textField.jk_maxLength = 5;
|
||||
[self.textField mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.iconImageView.mas_right).offset(10);
|
||||
make.width.mas_equalTo(204);
|
||||
make.height.mas_equalTo(40);
|
||||
make.left.equalTo(self).offset(20);
|
||||
make.width.height.mas_equalTo(self);
|
||||
make.centerY.equalTo(self.iconImageView);
|
||||
}];
|
||||
[self.getCodeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -47,17 +68,27 @@
|
||||
make.centerY.equalTo(self.textField);
|
||||
make.height.mas_equalTo(24);
|
||||
make.width.mas_equalTo(80);
|
||||
make.right.equalTo(self).inset(25);
|
||||
make.right.equalTo(self).inset(5);
|
||||
}];
|
||||
}
|
||||
break;
|
||||
case DDTextFieldPasswordAccount: {
|
||||
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入账号/ID" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(16)}];
|
||||
[self.textField mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(20);
|
||||
make.width.height.mas_equalTo(self);
|
||||
make.centerY.equalTo(self.iconImageView);
|
||||
}];
|
||||
}
|
||||
break;
|
||||
case DDTextFieldPassWord:
|
||||
{
|
||||
self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_4"];
|
||||
// self.iconImageView.image = [UIImage imageNamed:@"login_bg_icon_4"];
|
||||
self.textField.secureTextEntry = YES;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入密码" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(20)}];
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入密码" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(16)}];
|
||||
[self.textField mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.iconImageView.mas_right).offset(10);
|
||||
make.left.equalTo(self).offset(20);
|
||||
make.width.mas_equalTo(244);
|
||||
make.height.mas_equalTo(40);
|
||||
make.centerY.equalTo(self.iconImageView);
|
||||
@@ -70,9 +101,9 @@
|
||||
}
|
||||
break;
|
||||
case DDTextFieldInvideCode:{
|
||||
self.iconImageView.image =[UIImage imageNamed:@"login_bg_icon_4"];
|
||||
// self.iconImageView.image =[UIImage imageNamed:@"login_bg_icon_4"];
|
||||
self.textField.keyboardType = UIKeyboardTypeASCIICapable;
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"邀请码(非必填)" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(20)}];
|
||||
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"邀请码(非必填)" attributes:@{NSForegroundColorAttributeName:DDHEXColor(0x999999), NSFontAttributeName : DDFont(16)}];
|
||||
@weakify(self);
|
||||
[[self.textField rac_textSignal] subscribeNext:^(NSString * _Nullable x) {
|
||||
@strongify(self);
|
||||
@@ -87,8 +118,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showPassWordBtnClick {
|
||||
|
||||
|
||||
- (void)setCustomLeftText:(NSString *)customLeftText {
|
||||
_customLeftText = customLeftText;
|
||||
|
||||
self.iconImageView.hidden = YES;
|
||||
if (_customLeftText.length == 0 || [_customLeftText isEqualToString:@""]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self initLeftLabel];
|
||||
_leftLabel.text = customLeftText;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Action
|
||||
- (void)showPassWordBtnClick {
|
||||
self.showPassWordBtn.selected = !self.showPassWordBtn.selected;
|
||||
if (self.showPassWordBtn.isSelected) {
|
||||
self.textField.secureTextEntry = NO;
|
||||
@@ -96,8 +142,17 @@
|
||||
}
|
||||
self.textField.secureTextEntry = YES;
|
||||
}
|
||||
-(UIButton *)showPassWordBtn
|
||||
{
|
||||
|
||||
|
||||
- (void)getCodeBtnClick {
|
||||
if (self.getCodeBlock) {
|
||||
self.getCodeBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Get
|
||||
- (UIButton *)showPassWordBtn {
|
||||
if (!_showPassWordBtn) {
|
||||
_showPassWordBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
|
||||
[_showPassWordBtn setImage:[UIImage imageNamed:@"login_bg_icon_5"] forState:(UIControlStateNormal)];
|
||||
@@ -113,23 +168,12 @@
|
||||
return _showPassWordBtn;
|
||||
}
|
||||
|
||||
- (void)getCodeBtnClick {
|
||||
|
||||
if (self.getCodeBlock) {
|
||||
self.getCodeBlock();
|
||||
}
|
||||
}
|
||||
|
||||
-(JKCountDownButton *)getCodeBtn
|
||||
{
|
||||
- (JKCountDownButton *)getCodeBtn {
|
||||
if (!_getCodeBtn) {
|
||||
_getCodeBtn = [JKCountDownButton buttonWithType:UIButtonTypeCustom];
|
||||
_getCodeBtn.titleLabel.font = DDFont(12);
|
||||
[_getCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
|
||||
[_getCodeBtn setBackgroundImage:[UIImage imageNamed:@"v2_com_btn2"] forState:(UIControlStateNormal)];
|
||||
[_getCodeBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
|
||||
[_getCodeBtn setBackgroundImage:[UIImage imageNamed:@"v2_com_btn3"] forState:UIControlStateDisabled];
|
||||
[_getCodeBtn setTitleColor:DDHEXColor(0xFFFFFF) forState:(UIControlStateDisabled)];
|
||||
[_getCodeBtn setTitle:@" " forState:UIControlStateNormal];
|
||||
[_getCodeBtn setTitleColor:[DDAppColor dd_MajorTitleColor] forState:UIControlStateNormal];
|
||||
[_getCodeBtn addTarget:self action:@selector(getCodeBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:_getCodeBtn];
|
||||
[_getCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -137,32 +181,32 @@
|
||||
make.centerY.equalTo(self.textField);
|
||||
make.height.mas_equalTo(24);
|
||||
make.width.mas_equalTo(80);
|
||||
make.right.equalTo(self).inset(25);
|
||||
make.right.equalTo(self).inset(5);
|
||||
}];
|
||||
}
|
||||
return _getCodeBtn;
|
||||
}
|
||||
-(UIImageView *)iconImageView
|
||||
{
|
||||
- (UIImageView *)iconImageView {
|
||||
if (!_iconImageView) {
|
||||
_iconImageView = [[UIImageView alloc]init];
|
||||
_iconImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_iconImageView.hidden = YES;
|
||||
[self addSubview:_iconImageView];
|
||||
[_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(25);
|
||||
make.top.mas_equalTo(self).mas_offset(9);
|
||||
// make.top.mas_equalTo(self).mas_offset(9);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.height.mas_equalTo(21);
|
||||
}];
|
||||
}
|
||||
return _iconImageView;
|
||||
}
|
||||
-(UITextField *)textField
|
||||
{
|
||||
|
||||
- (UITextField *)textField {
|
||||
if (!_textField) {
|
||||
_textField = [[UITextField alloc] init];
|
||||
_textField.font = DDFont(20);
|
||||
_textField.font = DDFont(16);
|
||||
_textField.textColor = DDHEXColor(0x333333);
|
||||
|
||||
[self addSubview:_textField];
|
||||
|
||||
[_textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -174,11 +218,11 @@
|
||||
}
|
||||
return _textField;
|
||||
}
|
||||
-(UIView *)lineView
|
||||
{
|
||||
- (UIView *)lineView {
|
||||
if (!_lineView) {
|
||||
_lineView = [[UIView alloc]init];
|
||||
_lineView.backgroundColor = DDHEXColor(0xEAEAEA);
|
||||
_lineView.hidden = YES;
|
||||
[self addSubview:_lineView];
|
||||
[_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.iconImageView.mas_bottom).offset(10);
|
||||
@@ -189,12 +233,5 @@
|
||||
}
|
||||
return _lineView;
|
||||
}
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
@@ -13,6 +13,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 获取设备的uuid
|
||||
+ (NSString *)DD_GetDeviceUUid;
|
||||
|
||||
/// 手机号码加密
|
||||
+ (NSString *)DD_GetPhoneEncryptDes:(NSString *)phone;
|
||||
|
||||
/// 密码加密
|
||||
+ (NSString *)DD_GetPasswordEncryptDes:(NSString *)password;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
#import "DDSystemTool.h"
|
||||
#import "DDDESEncrypt.h"
|
||||
|
||||
@implementation DDSystemTool
|
||||
|
||||
@@ -13,4 +14,13 @@
|
||||
+ (NSString *)DD_GetDeviceUUid {
|
||||
return [UIDevice currentDevice].identifierForVendor.UUIDString;
|
||||
}
|
||||
|
||||
+ (NSString *)DD_GetPhoneEncryptDes:(NSString *)phone {
|
||||
return [DDDESEncrypt DD_EncryptUseDES:phone key:@"1ea53d260ecf11e7b56e00163e046a26"];
|
||||
}
|
||||
|
||||
+ (NSString *)DD_GetPasswordEncryptDes:(NSString *)password {
|
||||
return [DDDESEncrypt DD_EncryptUseDES:password key:@"1ea53d260ecf11e7b56e00163e046a26"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class AccountModel, ThirdUserInfo;
|
||||
@class AccountModel, ThirdUserInfo, UserInfoModel;
|
||||
@interface AccountInfoStorage : NSObject
|
||||
@property (nonatomic, strong, readonly) AccountModel *accountModel;
|
||||
///如果是第三方登录的话 保存一下用户信息
|
||||
@@ -21,7 +21,9 @@
|
||||
- (id)mutableCopy NS_UNAVAILABLE;
|
||||
|
||||
- (AccountModel *)getCurrentAccountInfo;
|
||||
//- (UserInfoModel *)getCurrentUserInfo;
|
||||
- (void)saveAccountInfo:(AccountModel *)accountInfo;
|
||||
//- (void)saveUserInfo:(UserInfoModel *)userInfo;
|
||||
- (void)saveTicket:(NSString *)ticket;
|
||||
- (NSString *)getTicket;
|
||||
- (NSString *)getUid;
|
||||
|
@@ -43,8 +43,7 @@ static AccountInfoStorage *_instance = nil;
|
||||
return path;
|
||||
}
|
||||
|
||||
- (AccountModel *)getCurrentAccountInfo
|
||||
{
|
||||
- (AccountModel *)getCurrentAccountInfo {
|
||||
if (self.accountModel != nil) {
|
||||
return self.accountModel;
|
||||
}
|
||||
@@ -57,8 +56,7 @@ static AccountInfoStorage *_instance = nil;
|
||||
return self.accountModel;
|
||||
}
|
||||
|
||||
- (void)saveAccountInfo:(AccountModel *)accountInfo
|
||||
{
|
||||
- (void)saveAccountInfo:(AccountModel *)accountInfo {
|
||||
if (accountInfo == nil) {
|
||||
accountInfo = [[AccountModel alloc] init];
|
||||
}
|
||||
@@ -70,24 +68,21 @@ static AccountInfoStorage *_instance = nil;
|
||||
[data writeToFile:[self getFilePath] atomically:YES];
|
||||
}
|
||||
|
||||
- (void)saveTicket:(NSString *)t
|
||||
{
|
||||
- (void)saveTicket:(NSString *)t {
|
||||
self.ticket = t;
|
||||
}
|
||||
|
||||
- (NSString *)getTicket
|
||||
{
|
||||
- (NSString *)getTicket {
|
||||
|
||||
return @"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aWNrZXRfdHlwZSI6bnVsbCwidWlkIjoyODg0OTgsInRpY2tldF9pZCI6IjlkODFhNmYyLWE1YjUtNDAzYi1hMGJlLTlhZGRmOTQxZmQyYyIsImV4cCI6MzU5OSwiY2xpZW50X2lkIjoiZXJiYW4tY2xpZW50In0.agSo60aihw1TUttDM13pPMRTcTlxjSXcgAY7q98TuKo";
|
||||
// return @"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aWNrZXRfdHlwZSI6bnVsbCwidWlkIjoyODg0OTgsInRpY2tldF9pZCI6IjlkODFhNmYyLWE1YjUtNDAzYi1hMGJlLTlhZGRmOTQxZmQyYyIsImV4cCI6MzU5OSwiY2xpZW50X2lkIjoiZXJiYW4tY2xpZW50In0.agSo60aihw1TUttDM13pPMRTcTlxjSXcgAY7q98TuKo";
|
||||
if (self.ticket == nil) {
|
||||
return @"";
|
||||
}
|
||||
return self.ticket;
|
||||
}
|
||||
|
||||
- (NSString *)getUid
|
||||
{
|
||||
return @"288498";
|
||||
- (NSString *)getUid {
|
||||
// return @"288498";
|
||||
AccountModel *am = [self getCurrentAccountInfo];
|
||||
if (am == nil) {
|
||||
return @"";
|
||||
|
Reference in New Issue
Block a user