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
0cf673d3
Commit
0cf673d3
authored
Aug 06, 2024
by
David黄金龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接 H5
parent
6aedec8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
YHHomeWebViewController.swift
.../Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
+17
-3
YHJsApi.swift
...galaxy/Classes/Modules/InteractionH5(与H5交互)/YHJsApi.swift
+20
-5
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
View file @
0cf673d3
...
@@ -9,17 +9,19 @@
...
@@ -9,17 +9,19 @@
import
UIKit
import
UIKit
import
WebKit
import
WebKit
import
Photos
import
Photos
import
dsBridge
class
YHHomeWebViewController
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
class
YHHomeWebViewController
:
YHBaseViewController
,
WKUIDelegate
,
WKNavigationDelegate
{
var
operationFlag
:
Bool
=
false
var
operationFlag
:
Bool
=
false
typealias
Block
=
(
YHWebModel
)
->
()
typealias
Block
=
(
YHWebModel
)
->
()
var
block
:
Block
?
var
block
:
Block
?
var
viewModel
:
YHHomeWebViewModel
!
var
viewModel
:
YHHomeWebViewModel
!
var
webview
=
WKWebView
()
var
webview
=
D
WKWebView
()
var
progBar
=
UIProgressView
()
var
progBar
=
UIProgressView
()
var
bottomView
:
YHHomeWebBottomView
!
var
bottomView
:
YHHomeWebBottomView
!
var
url
=
""
var
url
=
""
...
@@ -100,9 +102,21 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
...
@@ -100,9 +102,21 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
//获取状态栏高度
//获取状态栏高度
let
statusHeight
=
k_Height_statusBar
()
let
statusHeight
=
k_Height_statusBar
()
// 创建wkwebview
// 创建wkwebview
webview
=
WKWebView
(
frame
:
CGRect
(
x
:
0
,
y
:
statusHeight
+
navHeight
!
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
-
statusHeight
-
navHeight
!
-
59
-
k_Height_safeAreaInsetsBottom
()))
webview
=
DWKWebView
(
frame
:
CGRect
(
x
:
0
,
y
:
statusHeight
+
navHeight
!
,
width
:
self
.
view
.
frame
.
width
,
height
:
self
.
view
.
frame
.
height
-
statusHeight
-
navHeight
!
-
59
-
k_Height_safeAreaInsetsBottom
()))
webview
.
navigationDelegate
=
self
webview
.
scrollView
.
contentInsetAdjustmentBehavior
=
.
never
webview
.
navigationDelegate
=
self
webview
.
navigationDelegate
=
self
let
api
=
YHJsApi
()
// api.delegate = self
webview
.
addJavascriptObject
(
api
,
namespace
:
nil
)
// 创建网址
// 创建网址
let
url
=
NSURL
(
string
:
url
)
let
url
=
NSURL
(
string
:
url
)
// 创建请求
// 创建请求
...
...
galaxy/galaxy/Classes/Modules/InteractionH5(与H5交互)/YHJsApi.swift
View file @
0cf673d3
...
@@ -13,29 +13,44 @@ typealias JSCallback = (String, Bool)->Void
...
@@ -13,29 +13,44 @@ typealias JSCallback = (String, Bool)->Void
typealias
JSDicCallback
=
([
String
:
Any
],
Bool
)
->
Void
typealias
JSDicCallback
=
([
String
:
Any
],
Bool
)
->
Void
class
YHJsApi
:
NSObject
{
class
YHJsApi
:
NSObject
{
weak
var
delegate
:
YH
H5WebViewVC
?
=
nil
weak
var
delegate
:
YH
BaseViewController
?
=
nil
}
}
extension
YHJsApi
{
extension
YHJsApi
{
//展示pics
//展示pics
@objc
func
showPicsSyn
(
_
dicPics
:[
String
:
Any
])
{
@objc
func
showPicsSyn
(
_
dicPics
:[
String
:
Any
])
{
//dsBridge.call("showPicsSyn",{pics:["123","456"], curIndex:1})
//dsBridge.call("showPicsSyn",{pics:["123","456"], curIndex:1})
if
dicPics
.
isEmpty
==
false
{
let
curIndex
:
Int
=
dicPics
[
"curIndex"
]
as?
Int
??
-
1
let
arrPics
:
[
String
]
=
dicPics
[
"pics"
]
as?
[
String
]
??
[]
if
curIndex
>
-
1
,
arrPics
.
count
>
0
{
DispatchQueue
.
main
.
async
{
// let arr = ["https://img1.baidu.com/it/u=2032777443,4245182967&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422","http://img0.baidu.com/it/u=594725074,698294204&fm=253&app=138&f=JPEG?w=800&h=1422"]
YHPictureReviewManager
.
shared
.
showNetWorkPicturs
(
curIndex
:
curIndex
,
arrPicturs
:
arrPics
)
}
}
}
}
}
//设置app导航栏隐藏、显示
//设置app导航栏隐藏、显示
@objc
func
setAppNavigation
(
_
tag
:
Any
)
{
@objc
func
setAppNavigation
(
_
tag
:
Any
)
{
let
tmp
:
Bool
=
tag
as?
Bool
??
false
let
tmp
:
Bool
=
tag
as?
Bool
??
false
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
self
.
delegate
?
.
setAppNavigation
(
tmp
)
if
let
delegate
=
self
.
delegate
as?
YHH5WebViewVC
{
delegate
.
setAppNavigation
(
tmp
)
}
}
}
}
}
//保存图片到本地
//保存图片到本地
@objc
func
saveLocalPictureSyn
(
_
picUrl
:
String
)
{
@objc
func
saveLocalPictureSyn
(
_
picUrl
:
String
)
{
DispatchQueue
.
main
.
async
{
DispatchQueue
.
main
.
async
{
self
.
delegate
?
.
saveLocalPictureSyn
(
picUrl
)
if
let
delegate
=
self
.
delegate
as?
YHH5WebViewVC
{
delegate
.
saveLocalPictureSyn
(
picUrl
)
}
}
}
}
}
}
}
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