Commit 0cf673d3 authored by David黄金龙's avatar David黄金龙

对接 H5

parent 6aedec8d
......@@ -9,17 +9,19 @@
import UIKit
import WebKit
import Photos
import dsBridge
class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
var operationFlag:Bool = false
typealias Block = (YHWebModel) -> ()
var block: Block?
var viewModel: YHHomeWebViewModel!
var webview = WKWebView()
var webview = DWKWebView()
var progBar = UIProgressView()
var bottomView: YHHomeWebBottomView!
var url = ""
......@@ -100,9 +102,21 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
//获取状态栏高度
let statusHeight = k_Height_statusBar()
// 创建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
let api = YHJsApi()
// api.delegate = self
webview.addJavascriptObject(api, namespace: nil)
// 创建网址
let url = NSURL(string: url)
// 创建请求
......
......@@ -13,29 +13,44 @@ typealias JSCallback = (String, Bool)->Void
typealias JSDicCallback = ([String : Any],Bool)->Void
class YHJsApi: NSObject {
weak var delegate : YHH5WebViewVC? = nil
weak var delegate : YHBaseViewController? = nil
}
extension YHJsApi {
//展示pics
@objc func showPicsSyn(_ dicPics:[String : Any]) {
//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导航栏隐藏、显示
@objc func setAppNavigation(_ tag : Any) {
let tmp : Bool = tag as? Bool ?? false
DispatchQueue.main.async {
self.delegate?.setAppNavigation(tmp)
if let delegate = self.delegate as? YHH5WebViewVC {
delegate.setAppNavigation(tmp)
}
}
}
//保存图片到本地
@objc func saveLocalPictureSyn(_ picUrl: String) {
DispatchQueue.main.async {
self.delegate?.saveLocalPictureSyn(picUrl)
if let delegate = self.delegate as? YHH5WebViewVC {
delegate.saveLocalPictureSyn(picUrl)
}
}
}
}
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