Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
iOSTeam
/
Majiabao
/
TealiveModule
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
06c25675
authored
Apr 19, 2024
by
pierce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs
parent
21a4c4bf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
59 deletions
LocalPodSpec/GDToolBox/GDToolBox/Classes/Base/WebView/GDWebView.swift
LocalPodSpec/GDToolBox/GDToolBox/Classes/Base/WebView/GDWebView.swift
View file @
06c25675
...
...
@@ -262,68 +262,62 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
public
func
userContentController
(
_
userContentController
:
WKUserContentController
,
didReceive
message
:
WKScriptMessage
)
{
//TODO:处理这里的逻辑: added By Pidan
//
if message.name == GDWebView.kJavaScriptInteractKey {
//
//
guard let body : String = message.body as? String else {return}
//
//
guard let jsonData = body.data(using: String.Encoding.utf8, allowLossyConversion: false) else {return}
//
let json = try! JSON(data: jsonData)
//
//
let dataDict = json["data"]
//
let webCid = json["cid"].intValue
//
switch webCid {
if
message
.
name
==
GDWebView
.
kJavaScriptInteractKey
{
guard
let
body
:
String
=
message
.
body
as?
String
else
{
return
}
guard
let
jsonData
=
body
.
data
(
using
:
String
.
Encoding
.
utf8
,
allowLossyConversion
:
false
)
else
{
return
}
let
json
=
try!
JSON
(
data
:
jsonData
)
let
dataDict
=
json
[
"data"
]
let
webCid
=
json
[
"cid"
]
.
intValue
switch
webCid
{
// case 1: // CID 为 1,打开榜单
// // TODO: 打开榜单
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
// }
// break
//
case 2: // CID 为2,打开网页
//
let shouldShare = dataDict["share"].boolValue
//
let halfScreen = dataDict["isShowHalf"].boolValue
//
let urlStr = dataDict["url"].stringValue
//
//
if halfScreen {
//
let heightRatio = CGFloat(dataDict["heightScale"].doubleValue / 100.0)
//
let widthRatio = CGFloat(dataDict["viewHeight"].doubleValue / 100.0)
//
//
var shouldCloseGift = true
//
if dataDict["closeGiftWindow"].isEmpty == false {
//
shouldCloseGift = dataDict["closeGiftWindow"].boolValue
//
}
//
case
2
:
// CID 为2,打开网页
let
shouldShare
=
dataDict
[
"share"
]
.
boolValue
let
halfScreen
=
dataDict
[
"isShowHalf"
]
.
boolValue
let
urlStr
=
dataDict
[
"url"
]
.
stringValue
if
halfScreen
{
let
heightRatio
=
CGFloat
(
dataDict
[
"heightScale"
]
.
doubleValue
/
100.0
)
let
widthRatio
=
CGFloat
(
dataDict
[
"viewHeight"
]
.
doubleValue
/
100.0
)
var
shouldCloseGift
=
true
if
dataDict
[
"closeGiftWindow"
]
.
isEmpty
==
false
{
shouldCloseGift
=
dataDict
[
"closeGiftWindow"
]
.
boolValue
}
//TODO:处理这里的逻辑: added By Pidan
// if let functionView = GDLiveHelper.shared.liveVC?.functionView as? GDLiveFunctionView {
//
// functionView.showHalfScreenView(for: urlStr, heightRatio: heightRatio, widthRadio: widthRatio, closeGiftPanel: shouldCloseGift)
// }
//
// } else {
// let webVC = GDWebViewController(url: urlStr)
// webVC.showShare = shouldShare
// webVC.hidesBottomBarWhenPushed = true
// if let vc = self.getPresentViewController?() {
// vc.navigationController?.pushViewController(webVC, animated: true)
// } else {
// self.viewController?.navigationController?.pushViewController(webVC, animated: true)
// }
//
// }
// case 4: // CID 为 4,打开客服
// let serviceVC = GDServiceController()
// serviceVC.hidesBottomBarWhenPushed = true
// if let vc = self.getPresentViewController?() {
// vc.navigationController?.pushViewController(serviceVC, animated: true)
// } else {
// self.viewController?.navigationController?.pushViewController(serviceVC, animated: true)
//
// }
//
// break
// case 5: // CID 为 5,跳转外链
// if let url: URL = URL(string: dataDict["url"].stringValue) {
// UIApplication.shared.openURL(url)
// }
// break
}
else
{
let
webVC
=
GDWebViewController
(
url
:
urlStr
)
webVC
.
showShare
=
shouldShare
webVC
.
hidesBottomBarWhenPushed
=
true
if
let
vc
=
self
.
getPresentViewController
?()
{
vc
.
navigationController
?
.
pushViewController
(
webVC
,
animated
:
true
)
}
else
{
self
.
viewController
?
.
navigationController
?
.
pushViewController
(
webVC
,
animated
:
true
)
}
}
case
4
:
// CID 为 4,打开客服
//TODO:处理这里的逻辑: added By Pidan
// GDRouter.ChatRoom?.showServiceCharRoom()
break
case
5
:
// CID 为 5,跳转外链
if
let
url
:
URL
=
URL
(
string
:
dataDict
[
"url"
]
.
stringValue
)
{
UIApplication
.
shared
.
openURL
(
url
)
}
break
// case 6: // CID 为 6,打开兑换钻石页面,废弃
// if DevConfig.devEnv {
// FTIndicator.showToastMessage("不支持功能")
...
...
@@ -974,13 +968,13 @@ public class GDWebView: WKWebView, WKNavigationDelegate, WKScriptMessageHandler
// } else {
// shareInviteView.show(on: self)
// }
//
default:
//
break
//
}
//
//
// 发布
//
actionPublisher.accept((cid: webCid, data: dataDict))
//
}
default
:
break
}
// 发布
actionPublisher
.
accept
((
cid
:
webCid
,
data
:
dataDict
))
}
}
// MARK: Public
...
...
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