Commit 692aed9edcd8815e9ca989bc87e04ef84cf9e9aa

Authored by “张旭”
1 parent 821d2c98

网页内容图片预览

metaCode/Classes/Main/HomePage/Controller/WebController/CNWebViewController.swift
@@ -11,6 +11,7 @@ import WebViewJavascriptBridge @@ -11,6 +11,7 @@ import WebViewJavascriptBridge
11 import CNLiveShareToolKit 11 import CNLiveShareToolKit
12 import CommonCrypto 12 import CommonCrypto
13 import CNLiveBusinessTools 13 import CNLiveBusinessTools
  14 +import SKPhotoBrowser
14 15
15 16
16 let WjjH5 = "wjjh5.cnlive.com" 17 let WjjH5 = "wjjh5.cnlive.com"
@@ -91,8 +92,9 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ @@ -91,8 +92,9 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
91 self.bridge = WKWebViewJavascriptBridge(for: self.webView) 92 self.bridge = WKWebViewJavascriptBridge(for: self.webView)
92 self.bridge?.setWebViewDelegate(self) 93 self.bridge?.setWebViewDelegate(self)
93 } 94 }
94 - //h5拉起原生分享 js call oc 95 +
95 func configBridgeRegister() -> Void { 96 func configBridgeRegister() -> Void {
  97 + //h5拉起原生分享 js call oc
96 self.bridge?.registerHandler("wjjylzgVideoShare", handler: { data, responseCallback in 98 self.bridge?.registerHandler("wjjylzgVideoShare", handler: { data, responseCallback in
97 // print("js call oc\(data)") 99 // print("js call oc\(data)")
98 let dic = data as! Dictionary<String, String> 100 let dic = data as! Dictionary<String, String>
@@ -105,6 +107,34 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{ @@ -105,6 +107,34 @@ class CNWebViewController:CNLiveBaseViewController ,WKNavigationDelegate{
105 } 107 }
106 108
107 }) 109 })
  110 +
  111 + // 网页内容图片预览
  112 + self.bridge?.registerHandler("wjjPreviewImage", handler: { data, responseCallback in
  113 + // print("js call oc\(data)")
  114 + var images = [SKPhoto]()
  115 + let dic = data as! Dictionary<String, Any>
  116 + let index = (dic["index"] as! NSString).integerValue
  117 + let imageArray = dic["imgArr"] as! NSArray
  118 + var imgArray = NSMutableArray()
  119 + for dict in imageArray {
  120 + var imgUrl = ""
  121 + if let dictemp = dict as? String{
  122 + imgArray.add(dictemp)
  123 + imgUrl = dictemp
  124 + }else if let dictemp = dict as? Dictionary<String, Any>{
  125 + imgArray.add(dictemp["src"] ?? "")
  126 + imgUrl = dictemp["src"] as! String
  127 + }
  128 + let photo = SKPhoto.photoWithImageURL(imgUrl)
  129 + photo.shouldCachePhotoURLImage = false
  130 + photo.photoURL = imgUrl
  131 + images.append(photo)
  132 + }
  133 + let browser = SKPhotoBrowser(photos: images)
  134 + browser.initializePageIndex(index)
  135 + currentViewController()?.present(browser, animated: true)
  136 +
  137 + })
108 } 138 }
109 139
110 //点击...分享获取h5参数oc call js 140 //点击...分享获取h5参数oc call js