Commit 62919885 authored by David黄金龙's avatar David黄金龙

1、几处代码优化

2、添加几处 H5的方法支持
parent a071ee4a
......@@ -323,6 +323,7 @@ extension YHServiceOrderListView : UITableViewDelegate,UITableViewDataSource {
vc.url = url
vc.isFullScreenFlag = false
vc.isNeedRefreshDataFlag = true
vc.isSupportWebviewInterBackFlag = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
......
......@@ -17,6 +17,17 @@ import Photos
class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
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)
webview.scrollView.contentInsetAdjustmentBehavior = .never
webview.navigationDelegate = self
......@@ -107,7 +118,7 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var isSupportWebviewInterBackFlag : Bool = false
//默认的返回按钮图片
private var myDefaultBackImage : UIImage = UIImage(named: "activity_nav_back") ?? UIImage()
private var myDefaultBackImage : UIImage = UIImage(named: "back_icon") ?? UIImage()
override func backItemClick(_ sender: Any) {
if isSupportWebviewInterBackFlag {
......@@ -352,11 +363,20 @@ extension YHH5WebViewVC {
// MARK: - h5实现的接口
extension YHH5WebViewVC {
func setNavigationBackColor(_ tag : String) {
if tag.contains("0") {
myDefaultBackImage = UIImage(named: "activity_nav_back") ?? UIImage()
func supportInnerBackSyn(_ tag : String) {
if tag.contains("1") {
isSupportWebviewInterBackFlag = true
} else {
isSupportWebviewInterBackFlag = false
}
}
func setNavigationBackColor(_ tag : String) {
if tag.contains("1") {
myDefaultBackImage = UIImage(named: "back_icon") ?? UIImage()
} else {
myDefaultBackImage = UIImage(named: "activity_nav_back") ?? UIImage()
}
gk_backImage = myDefaultBackImage
}
......
......@@ -17,10 +17,21 @@ class YHJsApi: NSObject {
}
extension YHJsApi {
//12、webView内支持内部一级一级返回
@objc func supportInnerBackSyn(_ tag : Any) {
DispatchQueue.main.async {
if let tag = tag as? String, tag.count == 1 {
if let delegate = self.delegate as? YHH5WebViewVC {
delegate.supportInnerBackSyn(tag)
}
}
}
}
//11、设置导航栏返回按钮颜色
@objc func setNavigationBackColor(_ color : Any) {
DispatchQueue.main.async {
if let color = color as? String, color.count > 0 {
if let color = color as? String, color.count == 1 {
if let delegate = self.delegate as? YHH5WebViewVC {
delegate.setNavigationBackColor(color)
......
......@@ -546,6 +546,7 @@ extension YHMessageDetailListVC: UITableViewDelegate, UITableViewDataSource {
vc.url = url
vc.isFullScreenFlag = false
vc.isNeedRefreshDataFlag = true
vc.isSupportWebviewInterBackFlag = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
} else if msg.redirectPage == YHRedirectPage.renewalPlan.rawValue { // 我的续签方案 H5
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment