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
5e5695e0
Commit
5e5695e0
authored
Oct 11, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h5 UI 代码 分支同步
parent
32d4cfda
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
50 deletions
+28
-50
YHH5WebViewVC.swift
.../Classes/Modules/InteractionH5(与H5交互)/YHH5WebViewVC.swift
+28
-50
No files found.
galaxy/galaxy/Classes/Modules/InteractionH5(与H5交互)/YHH5WebViewVC.swift
View file @
5e5695e0
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
//
//
import
UIKit
import
UIKit
import
WebKit
@preconcurrency
import
WebKit
import
dsBridge
import
dsBridge
import
Photos
import
Photos
...
@@ -17,17 +17,6 @@ import Photos
...
@@ -17,17 +17,6 @@ import Photos
class
YHH5WebViewVC
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
class
YHH5WebViewVC
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
lazy
var
webview
:
DWKWebView
=
{
lazy
var
webview
:
DWKWebView
=
{
// let userContentController = WKUserContentController()
// let config = WKWebViewConfiguration()
// config.userContentController = userContentController
//
// // 设置localStorage
// let appInfo = "{\"token\": \"a1cd4a59-974f-44ab-b264-46400f26c849\", \"userId\": \"89\"}"
// let jsString = "localStorage.setItem('userContent', '\(appInfo)');"
// let script = WKUserScript(source: jsString, injectionTime: .atDocumentStart, forMainFrameOnly: true)
// userContentController.addUserScript(script)
// let webview = DWKWebView(frame: .zero,configuration: config)
let
webview
=
DWKWebView
(
frame
:
.
zero
)
let
webview
=
DWKWebView
(
frame
:
.
zero
)
webview
.
scrollView
.
contentInsetAdjustmentBehavior
=
.
never
webview
.
scrollView
.
contentInsetAdjustmentBehavior
=
.
never
webview
.
navigationDelegate
=
self
webview
.
navigationDelegate
=
self
...
@@ -71,13 +60,11 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
...
@@ -71,13 +60,11 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
deinit
{
deinit
{
webview
.
removeObserver
(
self
,
forKeyPath
:
"estimatedProgress"
)
webview
.
removeObserver
(
self
,
forKeyPath
:
"estimatedProgress"
)
webview
.
removeObserver
(
self
,
forKeyPath
:
"title"
)
NotificationCenter
.
default
.
removeObserver
(
self
)
NotificationCenter
.
default
.
removeObserver
(
self
)
}
}
//分享到H5或者小程序
//分享到H5或者小程序
var
isShareToMiniProgramFlag
:
Bool
=
false
//是否分享到小程序 默认分享到h5
var
isShareToMiniProgramFlag
:
Bool
=
false
//是否分享到小程序 默认分享到h5
var
shareMiniPath
:
String
?
//分享到小程序时的 path
var
shareMiniPath
:
String
?
//分享到小程序时的 path
...
@@ -87,6 +74,9 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
...
@@ -87,6 +74,9 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var
shareH5Title
:
String
=
"20秒极速测分"
var
shareH5Title
:
String
=
"20秒极速测分"
var
shareH5Describe
:
String
=
"您的朋友邀请您进行香港优才测评,来试试吧"
var
shareH5Describe
:
String
=
"您的朋友邀请您进行香港优才测评,来试试吧"
//外部传进来的分享链接
var
shareUrlFromOutside
:
String
?
//二维码是否请求完成
//二维码是否请求完成
var
isQrInfoOk
:
Bool
=
false
var
isQrInfoOk
:
Bool
=
false
...
@@ -210,28 +200,6 @@ private extension YHH5WebViewVC {
...
@@ -210,28 +200,6 @@ private extension YHH5WebViewVC {
webview
.
load
(
request
as
URLRequest
)
webview
.
load
(
request
as
URLRequest
)
view
.
addSubview
(
webview
)
view
.
addSubview
(
webview
)
// if isWithBottomViewFlag {
// view.addSubview(shareView)
// shareView.snp.makeConstraints { make in
// make.bottom.left.right.equalToSuperview()
// make.height.equalTo(YHShareViewOnTablebarView.viewH)
// }
//
// if isFullScreenFlag {
// webview.snp.makeConstraints { make in
// make.top.left.right.equalToSuperview()
// make.bottom.equalTo(shareView.snp.top)
// }
// } else {
// webview.snp.makeConstraints { make in
// make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
// make.left.right.equalToSuperview()
// make.bottom.equalTo(shareView.snp.top)
// }
// }
// } else {
if
isFullScreenFlag
{
if
isFullScreenFlag
{
webview
.
snp
.
makeConstraints
{
make
in
webview
.
snp
.
makeConstraints
{
make
in
make
.
edges
.
equalToSuperview
()
make
.
edges
.
equalToSuperview
()
...
@@ -241,13 +209,12 @@ private extension YHH5WebViewVC {
...
@@ -241,13 +209,12 @@ private extension YHH5WebViewVC {
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
top
.
equalToSuperview
()
.
offset
(
k_Height_NavigationtBarAndStatuBar
)
make
.
left
.
right
.
bottom
.
equalToSuperview
()
make
.
left
.
right
.
bottom
.
equalToSuperview
()
}
}
}
}
// }
webview
.
addSubview
(
progBar
)
webview
.
addSubview
(
progBar
)
// 监听网页加载的进度
// 监听网页加载的进度
webview
.
addObserver
(
self
,
forKeyPath
:
"estimatedProgress"
,
options
:
.
new
,
context
:
nil
)
webview
.
addObserver
(
self
,
forKeyPath
:
"estimatedProgress"
,
options
:
.
new
,
context
:
nil
)
webview
.
addObserver
(
self
,
forKeyPath
:
"title"
,
options
:
.
new
,
context
:
nil
)
view
.
addSubview
(
noNetWorkTipsView
)
view
.
addSubview
(
noNetWorkTipsView
)
self
.
noNetWorkTipsView
.
snp
.
makeConstraints
{
make
in
self
.
noNetWorkTipsView
.
snp
.
makeConstraints
{
make
in
...
@@ -272,10 +239,20 @@ private extension YHH5WebViewVC {
...
@@ -272,10 +239,20 @@ private extension YHH5WebViewVC {
}
else
{
}
else
{
var
shareUrl
=
self
.
url
var
shareUrl
=
self
.
url
if
let
url
=
shareUrlFromOutside
{
shareUrl
=
url
}
//特殊场景处理
if
shareUrl
.
contains
(
"superAppBridge.html#/evaluation"
,
caseSensitive
:
false
)
{
if
shareUrl
.
contains
(
"superAppBridge.html#/evaluation"
,
caseSensitive
:
false
)
{
shareUrl
=
YHBaseUrlManager
.
shared
.
curH5URL
()
+
"superAppBridge.html#/evaluation?channel=APP-share&customer_id=
\(
YHLoginManager
.
shared
.
userModel
?
.
id
??
""
)
"
shareUrl
=
YHBaseUrlManager
.
shared
.
curH5URL
()
+
"superAppBridge.html#/evaluation?channel=APP-share&customer_id=
\(
YHLoginManager
.
shared
.
userModel
?
.
id
??
""
)
"
}
}
YHShareManager
.
shared
.
sendLinkContent
(
self
.
shareH5Title
,
self
.
shareH5Describe
,
UIImage
(
named
:
"AppIcon"
)
??
UIImage
(),
link
:
shareUrl
)
if
!
shareUrl
.
isEmpty
&&
!
self
.
shareH5Title
.
isEmpty
&&
!
self
.
shareH5Describe
.
isEmpty
{
YHShareManager
.
shared
.
sendLinkContent
(
self
.
shareH5Title
,
self
.
shareH5Describe
,
UIImage
(
named
:
"shareIcon"
)
??
UIImage
(),
link
:
shareUrl
)
}
}
}
}
}
...
@@ -314,7 +291,7 @@ extension YHH5WebViewVC {
...
@@ -314,7 +291,7 @@ extension YHH5WebViewVC {
self
.
progBar
.
alpha
=
1.0
self
.
progBar
.
alpha
=
1.0
progBar
.
setProgress
(
Float
(
webview
.
estimatedProgress
),
animated
:
true
)
progBar
.
setProgress
(
Float
(
webview
.
estimatedProgress
),
animated
:
true
)
//进度条的值最大为1.0
//进度条的值最大为1.0
if
(
self
.
webview
.
estimatedProgress
>=
1.0
)
{
if
self
.
webview
.
estimatedProgress
>=
1.0
{
if
isFullScreenFlag
{
if
isFullScreenFlag
{
gk_navBarAlpha
=
0.0
gk_navBarAlpha
=
0.0
}
}
...
@@ -325,6 +302,11 @@ extension YHH5WebViewVC {
...
@@ -325,6 +302,11 @@ extension YHH5WebViewVC {
self
.
progBar
.
progress
=
0
self
.
progBar
.
progress
=
0
})
})
}
}
}
else
if
keyPath
==
"title"
{
if
let
title
=
self
.
webview
.
title
,
title
.
isEmpty
==
false
{
self
.
navTitle
=
title
self
.
gk_navTitle
=
self
.
navTitle
}
}
}
}
}
...
@@ -332,15 +314,9 @@ extension YHH5WebViewVC {
...
@@ -332,15 +314,9 @@ extension YHH5WebViewVC {
}
}
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
if
isShowRightShareItemFlag
{
if
self
.
isShowRightShareItemFlag
{
addRightItems
()
self
.
addRightItems
()
}
}
if
let
title
=
webview
.
title
,
title
.
isEmpty
==
false
{
navTitle
=
title
gk_navTitle
=
navTitle
}
}
}
func
webView
(
_
webView
:
WKWebView
,
createWebViewWith
configuration
:
WKWebViewConfiguration
,
for
navigationAction
:
WKNavigationAction
,
windowFeatures
:
WKWindowFeatures
)
->
WKWebView
?
{
func
webView
(
_
webView
:
WKWebView
,
createWebViewWith
configuration
:
WKWebViewConfiguration
,
for
navigationAction
:
WKNavigationAction
,
windowFeatures
:
WKWindowFeatures
)
->
WKWebView
?
{
...
@@ -444,15 +420,17 @@ extension YHH5WebViewVC {
...
@@ -444,15 +420,17 @@ extension YHH5WebViewVC {
PHPhotoLibrary
.
requestAuthorization
{
status
in
PHPhotoLibrary
.
requestAuthorization
{
status
in
if
status
==
.
authorized
{
if
status
==
.
authorized
{
// 保存图片到相册
// 保存图片到相册
UIImageWriteToSavedPhotosAlbum
(
image
,
nil
,
nil
,
nil
)
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
UIImageWriteToSavedPhotosAlbum
(
image
,
nil
,
nil
,
nil
)
YHHUD
.
flash
(
message
:
"保存成功"
)
YHHUD
.
flash
(
message
:
"保存成功"
)
}
}
}
else
{
}
else
{
DispatchQueue
.
main
.
async
{
YHHUD
.
flash
(
message
:
"保存失败,请检查系统权限"
)
YHHUD
.
flash
(
message
:
"保存失败,请检查系统权限"
)
}
}
}
}
}
}
}
}
}
//MARK: - UIScrollViewDelegate
//MARK: - UIScrollViewDelegate
...
...
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