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
183939ae
Commit
183939ae
authored
Sep 20, 2024
by
Steven杜宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
// 签字
parent
f627d194
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
1 deletion
+97
-1
YHRealNameHelper.swift
...ResignDocumentManagement(续签文书管理)/M/YHRealNameHelper.swift
+97
-1
No files found.
galaxy/galaxy/Classes/Modules/IntelligentService(服务中心)/Resign(续签)/ResignDocumentManagement(续签文书管理)/M/YHRealNameHelper.swift
View file @
183939ae
...
...
@@ -8,6 +8,102 @@
import
UIKit
class
YHRealNameHelper
:
NSObject
{
enum
YHRealnameResult
:
Int
{
case
cancel
=
0
case
failed
=
1
case
success
=
2
}
enum
YHURLHandleResult
:
Int
{
case
null
=
0
case
cancel
=
1
case
allow
=
2
}
protocol
YHRealNameDelegate
:
AnyObject
{
func
realnameJumptoAlipay
()
func
realnameResult
(
_
result
:
YHRealnameResult
)
func
signResult
(
_
status
:
Bool
)
}
class
YHRealNameHelper
{
static
let
callbackScheme
=
"esign://demo"
static
let
realnameCallback
=
"esign://demo/realBack"
static
let
signCallback
=
"esign://demo/signBack"
static
let
jumpToAlipay
=
"alipays://platformapi/startapp?appId=20000067&url="
static
let
signResultWebCloseJSFunction
=
"jsbridge://signCallback"
static
let
realResultWebCloseJSFunction
=
"esign://demo/realBack"
@discardableResult
class
func
handleRealnameURL
(
_
url
:
URL
,
delegate
:
YHRealNameDelegate
?)
->
YHURLHandleResult
{
// 获取完整url并进行UTF-8转码
let
requestUrl
=
url
.
absoluteString
.
removingPercentEncoding
??
""
if
url
.
host
==
"zmcustprod.zmxy.com.cn"
{
// 跳转芝麻认证
delegate
?
.
realnameJumptoAlipay
()
let
requestEncodeUrl
=
YHURLEncodeHelper
.
urlEncodedString
(
requestUrl
)
??
""
if
#available(iOS 10.0, *)
{
UIApplication
.
shared
.
open
(
URL
(
string
:
"
\(
jumpToAlipay
)\(
requestEncodeUrl
)
"
)
!
,
options
:
[:],
completionHandler
:
nil
)
}
else
{
UIApplication
.
shared
.
open
(
URL
(
string
:
"
\(
jumpToAlipay
)\(
requestEncodeUrl
)
"
)
!
)
}
return
.
cancel
}
else
if
url
.
scheme
==
"alipays"
,
url
.
host
==
"platformapi"
{
// 跳转到支付宝
if
requestUrl
.
range
(
of
:
"?"
)
==
nil
{
delegate
?
.
realnameResult
(
.
cancel
)
}
else
{
UIApplication
.
shared
.
open
(
url
,
options
:
[:],
completionHandler
:
nil
)
}
}
else
if
requestUrl
.
hasPrefix
(
signResultWebCloseJSFunction
)
||
requestUrl
.
hasPrefix
(
signCallback
)
{
// H5 签署返回结果处理
let
params
=
extractParameters
(
from
:
requestUrl
)
if
params
.
isEmpty
{
delegate
?
.
realnameResult
(
.
cancel
)
}
else
{
var
status
=
(
params
[
"signResult"
]?
.
boolValue
()
??
false
)
if
!
status
,
let
tsignCode
=
params
[
"tsignCode"
]
{
status
=
(
tsignCode
.
intValue
()
==
0
)
}
delegate
?
.
signResult
(
status
)
}
return
.
cancel
}
else
if
requestUrl
.
hasPrefix
(
callbackScheme
)
||
requestUrl
.
hasPrefix
(
"js://tsignRealBack"
)
||
requestUrl
.
hasPrefix
(
"js://signCallBack"
)
{
// H5 实名返回结果处理
if
requestUrl
.
contains
(
realResultWebCloseJSFunction
)
{
let
params
=
extractParameters
(
from
:
requestUrl
)
let
status
=
params
[
"passed"
]?
.
boolValue
()
??
false
delegate
?
.
realnameResult
(
status
?
.
success
:
.
failed
)
}
return
.
cancel
}
return
.
allow
}
private
class
func
extractParameters
(
from
url
:
String
)
->
[
String
:
String
]
{
var
params
=
[
String
:
String
]()
if
let
range
=
url
.
range
(
of
:
"?"
)
{
let
strParam
=
String
(
url
[
range
.
upperBound
...
])
let
pairs
=
strParam
.
split
(
separator
:
"&"
)
for
pair
in
pairs
{
let
items
=
pair
.
split
(
separator
:
"="
)
if
items
.
count
==
2
{
params
[
String
(
items
[
0
])]
=
String
(
items
[
1
])
}
}
}
return
params
}
}
extension
String
{
func
boolValue
()
->
Bool
{
return
(
self
as
NSString
)
.
boolValue
}
func
intValue
()
->
Int
{
return
(
self
as
NSString
)
.
integerValue
}
}
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