Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
e70fb8e5
Commit
e70fb8e5
authored
May 31, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 一键登录
parent
d14e52d9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
18 deletions
+86
-18
YHAppleLoginManager.swift
...sses/Modules/AppleLogin(苹果登录)/C/YHAppleLoginManager.swift
+48
-8
YHAppleLoginViewModel.swift
...es/Modules/AppleLogin(苹果登录)/V/YHAppleLoginViewModel.swift
+1
-1
YHOneKeyLoginManager.swift
...sses/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginManager.swift
+32
-3
YHOneKeyLoginViewModel.swift
...es/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginViewModel.swift
+5
-5
YHMyViewController.swift
...alaxy/Classes/Modules/Mine(我的)/C/YHMyViewController.swift
+0
-1
No files found.
galaxy/galaxy/Classes/Modules/AppleLogin(苹果登录)/C/YHAppleLoginManager.swift
View file @
e70fb8e5
...
@@ -12,7 +12,9 @@ import AuthenticationServices
...
@@ -12,7 +12,9 @@ import AuthenticationServices
class
YHAppleLoginManager
:
NSObject
{
class
YHAppleLoginManager
:
NSObject
{
static
let
shared
=
YHAppleLoginManager
()
static
let
shared
=
YHAppleLoginManager
()
let
viewModel
=
YHAppleLoginViewModel
()
func
appleLogin
()
{
func
appleLogin
()
{
let
appleIDProvider
=
ASAuthorizationAppleIDProvider
()
let
appleIDProvider
=
ASAuthorizationAppleIDProvider
()
...
@@ -29,27 +31,65 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
...
@@ -29,27 +31,65 @@ extension YHAppleLoginManager: ASAuthorizationControllerDelegate, ASAuthorizatio
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithAuthorization
authorization
:
ASAuthorization
)
{
func
authorizationController
(
controller
:
ASAuthorizationController
,
didCompleteWithAuthorization
authorization
:
ASAuthorization
)
{
var
userId
=
""
var
email
=
""
var
fullName
=
""
var
authorizationCodeStr
=
""
var
identityTokenStr
=
""
// 其中`authorization.credential`包含了Token,用户ID等授权所需信息,可上报到后台
// 其中`authorization.credential`包含了Token,用户ID等授权所需信息,可上报到后台
let
credential
=
authorization
.
credential
let
credential
=
authorization
.
credential
if
credential
is
ASPasswordCredential
{
if
credential
is
ASPasswordCredential
{
let
passwdCredential
=
credential
as!
ASPasswordCredential
let
passwdCredential
=
credential
as!
ASPasswordCredential
let
userIdentifier
=
passwdCredential
.
user
userId
=
passwdCredential
.
user
let
username
=
passwdCredential
.
user
let
username
=
passwdCredential
.
user
let
password
=
passwdCredential
.
password
let
password
=
passwdCredential
.
password
printLog
(
"username:
\(
username
)
, passwd:
\(
password
)
"
)
printLog
(
"username:
\(
username
)
, passwd:
\(
password
)
"
)
}
else
if
credential
is
ASAuthorizationAppleIDCredential
{
}
else
if
credential
is
ASAuthorizationAppleIDCredential
{
let
appleIdCredential
=
credential
as!
ASAuthorizationAppleIDCredential
let
appleIdCredential
=
credential
as!
ASAuthorizationAppleIDCredential
let
userIdentifier
=
appleIdCredential
.
user
userId
=
appleIdCredential
.
user
let
fullName
=
appleIdCredential
.
fullName
email
=
appleIdCredential
.
email
??
""
let
email
=
appleIdCredential
.
email
??
"email"
let
authorizationCode
=
appleIdCredential
.
authorizationCode
let
authorizationCode
=
appleIdCredential
.
authorizationCode
let
authorizationCodeStr
=
String
(
decoding
:
authorizationCode
!
,
as
:
UTF8
.
self
)
authorizationCodeStr
=
String
(
decoding
:
authorizationCode
!
,
as
:
UTF8
.
self
)
let
identityToken
=
appleIdCredential
.
identityToken
let
identityToken
=
appleIdCredential
.
identityToken
let
identityTokenStr
=
String
(
decoding
:
identityToken
!
,
as
:
UTF8
.
self
)
identityTokenStr
=
String
(
decoding
:
identityToken
!
,
as
:
UTF8
.
self
)
let
realUserStatus
=
appleIdCredential
.
realUserStatus
let
realUserStatus
=
appleIdCredential
.
realUserStatus
printLog
(
"authorizationCodeStr:
\(
authorizationCodeStr
)
"
)
}
printLog
(
"APPLE LOGIN userId:
\(
userId
)
"
)
printLog
(
"APPLE LOGIN identityToken:
\(
identityTokenStr
)
"
)
printLog
(
"APPLE LOGIN authorizationCode:
\(
authorizationCodeStr
)
"
)
let
parmas
:[
String
:
Any
]
=
[
"apple_id"
:
"string"
,
"user_id"
:
userId
,
"email"
:
"string"
,
"full_name"
:
"string"
,
"authorization_code"
:
authorizationCodeStr
,
"identity_token"
:
identityTokenStr
,
"mobile"
:
""
,
"sms_code"
:
""
]
self
.
viewModel
.
appleLogin
(
params
:
parmas
)
{
success
,
error
in
if
success
{
return
}
if
let
err
=
error
{
// 首次登录,没有传电话号码和验证码返回错误码:30001
if
err
.
errorCode
==
30001
{
return
}
var
msg
=
err
.
errorMsg
if
msg
.
isEmpty
{
msg
=
"登录失败"
}
YHHUD
.
flash
(
message
:
msg
)
}
}
}
}
}
...
...
galaxy/galaxy/Classes/Modules/AppleLogin(苹果登录)/V/YHAppleLoginViewModel.swift
View file @
e70fb8e5
...
@@ -10,7 +10,7 @@ import UIKit
...
@@ -10,7 +10,7 @@ import UIKit
class
YHAppleLoginViewModel
:
NSObject
{
class
YHAppleLoginViewModel
:
NSObject
{
func
appleLogin
(
params
:[
String
:
Any
],
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
func
appleLogin
(
params
:[
String
:
Any
],
_
callBackBlock
:
@escaping
(
_
success
:
Bool
,
_
error
:
YHErrorModel
?)
->
())
{
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
appleLogin
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
appleLogin
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{[
weak
self
]
json
,
code
in
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{[
weak
self
]
json
,
code
in
...
...
galaxy/galaxy/Classes/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginManager.swift
View file @
e70fb8e5
...
@@ -12,7 +12,7 @@ import AVFoundation
...
@@ -12,7 +12,7 @@ import AVFoundation
class
YHOneKeyLoginManager
{
class
YHOneKeyLoginManager
{
static
let
shared
=
YHOneKeyLoginManager
()
static
let
shared
=
YHOneKeyLoginManager
()
let
viewModel
=
YHOneKeyLoginViewModel
()
}
}
extension
YHOneKeyLoginManager
{
extension
YHOneKeyLoginManager
{
...
@@ -56,7 +56,7 @@ extension YHOneKeyLoginManager {
...
@@ -56,7 +56,7 @@ extension YHOneKeyLoginManager {
printLog
(
"设置secretKey结果:
\(
dict
)
"
)
printLog
(
"设置secretKey结果:
\(
dict
)
"
)
// 进行加速登录 方便点击登录时提速
// 进行加速登录 方便点击登录时提速
TXCommonHandler
.
sharedInstance
()
.
accelerateLoginPage
(
withTimeout
:
10
.0
)
{
TXCommonHandler
.
sharedInstance
()
.
accelerateLoginPage
(
withTimeout
:
5
.0
)
{
dic
in
dic
in
printLog
(
"加速登录结果:
\(
dic
)
"
)
printLog
(
"加速登录结果:
\(
dic
)
"
)
}
}
...
@@ -85,7 +85,7 @@ extension YHOneKeyLoginManager {
...
@@ -85,7 +85,7 @@ extension YHOneKeyLoginManager {
let
model
=
self
.
createLoginUIModel
()
let
model
=
self
.
createLoginUIModel
()
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
YHHUD
.
show
(
.
progress
(
message
:
"加载中..."
))
TXCommonHandler
.
sharedInstance
()
.
getLoginToken
(
withTimeout
:
3
.0
,
controller
:
UIViewController
.
current
!
,
model
:
model
)
{
TXCommonHandler
.
sharedInstance
()
.
getLoginToken
(
withTimeout
:
5
.0
,
controller
:
UIViewController
.
current
!
,
model
:
model
)
{
dict
in
dict
in
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
...
@@ -106,6 +106,35 @@ extension YHOneKeyLoginManager {
...
@@ -106,6 +106,35 @@ extension YHOneKeyLoginManager {
}
}
printLog
(
"oneKeyLogin token:
\(
token
)
"
)
printLog
(
"oneKeyLogin token:
\(
token
)
"
)
// 下面用Token去服务器换手机号,此处仅做参考
// 下面用Token去服务器换手机号,此处仅做参考
YHHUD
.
show
(
.
progress
(
message
:
"登录中..."
))
self
.
viewModel
.
oneKeyLogin
(
authToken
:
token
)
{
success
,
error
in
DispatchQueue
.
main
.
async
{
YHHUD
.
hide
()
}
if
success
{
return
}
if
let
err
=
error
{
// 首次登录,没有传电话号码和验证码返回错误码:30001
// if err.errorCode == 30001 {
//
// return
// }
var
msg
=
err
.
errorMsg
if
msg
.
isEmpty
{
msg
=
"登录失败"
}
YHHUD
.
flash
(
message
:
msg
)
}
}
/*
/*
[PNSVerifyTopRequest requestLoginWithToken:token complete:^(BOOL isSuccess, NSString * _Nonnull msg, NSDictionary * _Nonnull data) {
[PNSVerifyTopRequest requestLoginWithToken:token complete:^(BOOL isSuccess, NSString * _Nonnull msg, NSDictionary * _Nonnull data) {
...
...
galaxy/galaxy/Classes/Modules/AutoLogin(一键登录)/M/YHOneKeyLoginViewModel.swift
View file @
e70fb8e5
...
@@ -14,8 +14,8 @@ class YHOneKeyLoginViewModel {
...
@@ -14,8 +14,8 @@ class YHOneKeyLoginViewModel {
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
oneKeySecretKeyInfo
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
oneKeySecretKeyInfo
let
params
=
[
"iosInfo.bundleId"
:
"com.intelligence.galaxy"
]
let
params
=
[
"iosInfo.bundleId"
:
"com.intelligence.galaxy"
]
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
,
params
:
params
)
{
json
,
code
in
let
_
=
YHNetRequest
.
getRequest
(
url
:
strUrl
,
params
:
params
)
{
let
dic
=
json
.
data
json
,
code
in
printLog
(
"model 是 ==>
\(
json
)
"
)
printLog
(
"model 是 ==>
\(
json
)
"
)
if
json
.
code
==
200
{
if
json
.
code
==
200
{
if
let
dic
=
json
.
data
as?
[
String
:
Any
],
let
sdkKey
=
dic
[
"sdkKey"
]
as?
String
,
!
sdkKey
.
isEmpty
{
if
let
dic
=
json
.
data
as?
[
String
:
Any
],
let
sdkKey
=
dic
[
"sdkKey"
]
as?
String
,
!
sdkKey
.
isEmpty
{
...
@@ -38,9 +38,9 @@ class YHOneKeyLoginViewModel {
...
@@ -38,9 +38,9 @@ class YHOneKeyLoginViewModel {
let
params
:
[
String
:
Any
]
=
[
"auth_token"
:
authToken
]
let
params
:
[
String
:
Any
]
=
[
"auth_token"
:
authToken
]
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
oneKeyLogin
let
strUrl
=
YHBaseUrlManager
.
shared
.
curURL
()
+
YHAllApiName
.
Auth
.
oneKeyLogin
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
[
weak
self
]
json
,
code
in
let
_
=
YHNetRequest
.
postRequest
(
url
:
strUrl
,
params
:
params
)
{
//1. json字符串 转 对象
guard
let
self
=
self
else
{
return
}
json
,
code
in
printLog
(
json
)
printLog
(
json
)
let
dic
=
json
.
data
let
dic
=
json
.
data
guard
let
resultModel
=
YHUserModel
.
deserialize
(
dict
:
dic
as?
[
AnyHashable
:
Any
])
else
{
guard
let
resultModel
=
YHUserModel
.
deserialize
(
dict
:
dic
as?
[
AnyHashable
:
Any
])
else
{
...
...
galaxy/galaxy/Classes/Modules/Mine(我的)/C/YHMyViewController.swift
View file @
e70fb8e5
...
@@ -275,7 +275,6 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
...
@@ -275,7 +275,6 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
//#endif
//#endif
if
!
checkLogin
()
{
if
!
checkLogin
()
{
YHOneKeyLoginManager
.
shared
.
oneKeyLogin
()
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment