Commit c9282a0a297256e960bb4c0c9a6d3dda01983bc2
1 parent
def2d4db
h5交互跳转微信小程序
getpage.getBlockContents支持跳转微信小程序
Showing
6 changed files
with
78 additions
and
12 deletions
metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideDetailViewController.swift
| @@ -300,18 +300,7 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou | @@ -300,18 +300,7 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou | ||
| 300 | } | 300 | } |
| 301 | } | 301 | } |
| 302 | }else{ | 302 | }else{ |
| 303 | - //视频跳转播放页;课程跳转h5 | ||
| 304 | - if albumModel.model == kCNDownSlideContentsModelModelAlbum_ugc{ | ||
| 305 | - //视频 | ||
| 306 | - //短剧-跳转短剧播放页 | ||
| 307 | - navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated) | ||
| 308 | - | ||
| 309 | - }else if albumModel.model == "1" || albumModel.model == "2" || albumModel.model == "3" || albumModel.model == "4"{ | ||
| 310 | - //课程 | ||
| 311 | - CNLiveDownSlideTool.pushWebVCWithCNLiveAlbumMdl(albumModel: albumModel,controller: self) | ||
| 312 | - }else{ | ||
| 313 | - | ||
| 314 | - } | 303 | + CNLiveDownSlideTool.pushWebVCWithCNLiveAlbumMdl(albumModel: albumModel,controller: self) |
| 315 | } | 304 | } |
| 316 | } | 305 | } |
| 317 | 306 |
metaCode/Classes/Main/HomePage/Controller/WebController/CNWebView.swift
| @@ -106,6 +106,20 @@ class CNWebView:UIView,WKNavigationDelegate{ | @@ -106,6 +106,20 @@ class CNWebView:UIView,WKNavigationDelegate{ | ||
| 106 | currentViewController()?.present(browser, animated: true) | 106 | currentViewController()?.present(browser, animated: true) |
| 107 | 107 | ||
| 108 | }) | 108 | }) |
| 109 | + | ||
| 110 | + //h5拉起原生 跳转微信小程序 | ||
| 111 | + self.bridge?.registerHandler("wjjH5TurntoServices", handler: { data, responseCallback in | ||
| 112 | +// print("js call oc\(data)") | ||
| 113 | + let dic = data as! Dictionary<String, Any> | ||
| 114 | + let type = dic["type"] as! String | ||
| 115 | + if type == "103"{ | ||
| 116 | + //跳转微信小程序 | ||
| 117 | + let toDic = dic["to"] as! Dictionary<String, Any> | ||
| 118 | + let miniAppId = toDic["id"] as! String | ||
| 119 | + let miniPath = toDic["path"] as! String | ||
| 120 | + CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:]) | ||
| 121 | + } | ||
| 122 | + }) | ||
| 109 | } | 123 | } |
| 110 | 124 | ||
| 111 | required init?(coder: NSCoder) { | 125 | required init?(coder: NSCoder) { |
metaCode/Classes/Main/HomePages/Model/CNLiveAlbumModel.swift
| @@ -42,6 +42,12 @@ class CNLiveAlbumModel:BaseModel{ | @@ -42,6 +42,12 @@ class CNLiveAlbumModel:BaseModel{ | ||
| 42 | var shareUrl = "" | 42 | var shareUrl = "" |
| 43 | var spIcon = "" | 43 | var spIcon = "" |
| 44 | var product:CNLiveAlbumProductModel? | 44 | var product:CNLiveAlbumProductModel? |
| 45 | + ///小程序地址和小程序id {"path":"page/login_hint/login_hint","id":"gh_234d4ed615a3"} | ||
| 46 | + var s_to: String? | ||
| 47 | + ///103时为微信小程序 | ||
| 48 | + var s_type: String? | ||
| 49 | + ///"weixin://dl/business/?t=NnvptiuER3k" | ||
| 50 | + var s_showType: String? | ||
| 45 | //还有部分属性没写 | 51 | //还有部分属性没写 |
| 46 | } | 52 | } |
| 47 | class CNLiveAlbumProductModel:BaseModel{ | 53 | class CNLiveAlbumProductModel:BaseModel{ |
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveAlbumCell.swift
| @@ -111,6 +111,9 @@ class CNLiveAlbumCell:UITableViewCell{ | @@ -111,6 +111,9 @@ class CNLiveAlbumCell:UITableViewCell{ | ||
| 111 | //短剧-跳转短剧播放页 | 111 | //短剧-跳转短剧播放页 |
| 112 | self.cellType = .playlet | 112 | self.cellType = .playlet |
| 113 | self.playBtn.setTitle("播放", for: .normal) | 113 | self.playBtn.setTitle("播放", for: .normal) |
| 114 | + }else if model.model == kCNDownSlideContentsModelModelServing{ | ||
| 115 | + self.cellType = .course | ||
| 116 | + self.playBtn.setTitle("进入", for: .normal) | ||
| 114 | } | 117 | } |
| 115 | self.titleLabl.text = model.title | 118 | self.titleLabl.text = model.title |
| 116 | self.subTitleLabel.text = model.subTitle | 119 | self.subTitleLabel.text = model.subTitle |
metaCode/Classes/Main/Model/CNLiveDownSlideModel.swift
| @@ -35,6 +35,8 @@ let kCNDownSlideContentsModelModel4: String = "4" | @@ -35,6 +35,8 @@ let kCNDownSlideContentsModelModel4: String = "4" | ||
| 35 | let kCNDownSlideContentsModelModelAlbum: String = "album" | 35 | let kCNDownSlideContentsModelModelAlbum: String = "album" |
| 36 | let kCNDownSlideContentsModelModelAlbum_video: String = "album_video" | 36 | let kCNDownSlideContentsModelModelAlbum_video: String = "album_video" |
| 37 | let kCNDownSlideContentsModelModelAlbum_ugc: String = "album_ugc" | 37 | let kCNDownSlideContentsModelModelAlbum_ugc: String = "album_ugc" |
| 38 | +let kCNDownSlideContentsModelModelServing: String = "serving"//微信小程序 | ||
| 39 | + | ||
| 38 | 40 | ||
| 39 | class CNLiveDownSlideContentsModel: BaseModel { | 41 | class CNLiveDownSlideContentsModel: BaseModel { |
| 40 | ///内容id | 42 | ///内容id |
| @@ -57,4 +59,10 @@ class CNLiveDownSlideContentsModel: BaseModel { | @@ -57,4 +59,10 @@ class CNLiveDownSlideContentsModel: BaseModel { | ||
| 57 | var shareUrl: String? | 59 | var shareUrl: String? |
| 58 | ///model为3,4时跳转url | 60 | ///model为3,4时跳转url |
| 59 | var thirdUrl: String? | 61 | var thirdUrl: String? |
| 62 | + ///小程序地址和小程序id {"path":"page/login_hint/login_hint","id":"gh_234d4ed615a3"} | ||
| 63 | + var s_to: String? | ||
| 64 | + ///103时为微信小程序 | ||
| 65 | + var s_type: String? | ||
| 66 | + ///"weixin://dl/business/?t=NnvptiuER3k" | ||
| 67 | + var s_showType: String? | ||
| 60 | } | 68 | } |
metaCode/Classes/Main/Util/CNLiveDownSlideTool.swift
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | // 跳转 | 6 | // 跳转 |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | +import CNLiveShareToolKit | ||
| 9 | 10 | ||
| 10 | class CNLiveDownSlideTool:NSObject{ | 11 | class CNLiveDownSlideTool:NSObject{ |
| 11 | class func pushWebVCWithContentsMdl(contentMdl:CNLiveDownSlideContentsModel){ | 12 | class func pushWebVCWithContentsMdl(contentMdl:CNLiveDownSlideContentsModel){ |
| @@ -39,6 +40,21 @@ class CNLiveDownSlideTool:NSObject{ | @@ -39,6 +40,21 @@ class CNLiveDownSlideTool:NSObject{ | ||
| 39 | 40 | ||
| 40 | //短剧-跳转短剧播放页 | 41 | //短剧-跳转短剧播放页 |
| 41 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId ?? ""), animated: pushAnimated) | 42 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId ?? ""), animated: pushAnimated) |
| 43 | + }else if contentMdl.model == kCNDownSlideContentsModelModelServing{ | ||
| 44 | + //跳转微信小程序 | ||
| 45 | + if let data = (contentMdl.s_to ?? "").data(using: .utf8) { | ||
| 46 | + do { | ||
| 47 | + let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] | ||
| 48 | + let miniAppId = jsonResult!["id"] as! String | ||
| 49 | + let miniPath = jsonResult!["path"] as! String | ||
| 50 | + CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:]) | ||
| 51 | + | ||
| 52 | + } catch { | ||
| 53 | + print("JSON 解析错误") | ||
| 54 | + } | ||
| 55 | + } else { | ||
| 56 | + print("无法将字符串转换为数据") | ||
| 57 | + } | ||
| 42 | }else{ | 58 | }else{ |
| 43 | return | 59 | return |
| 44 | } | 60 | } |
| @@ -74,6 +90,21 @@ class CNLiveDownSlideTool:NSObject{ | @@ -74,6 +90,21 @@ class CNLiveDownSlideTool:NSObject{ | ||
| 74 | //短剧-跳转短剧播放页 | 90 | //短剧-跳转短剧播放页 |
| 75 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated) | 91 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated) |
| 76 | 92 | ||
| 93 | + }else if albumModel.model == kCNDownSlideContentsModelModelServing{ | ||
| 94 | + //跳转微信小程序 | ||
| 95 | + if let data = (albumModel.s_to ?? "").data(using: .utf8) { | ||
| 96 | + do { | ||
| 97 | + let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] | ||
| 98 | + let miniAppId = jsonResult!["id"] as! String | ||
| 99 | + let miniPath = jsonResult!["path"] as! String | ||
| 100 | + CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:]) | ||
| 101 | + | ||
| 102 | + } catch { | ||
| 103 | + print("JSON 解析错误") | ||
| 104 | + } | ||
| 105 | + } else { | ||
| 106 | + print("无法将字符串转换为数据") | ||
| 107 | + } | ||
| 77 | }else{ | 108 | }else{ |
| 78 | return | 109 | return |
| 79 | } | 110 | } |
| @@ -110,6 +141,21 @@ class CNLiveDownSlideTool:NSObject{ | @@ -110,6 +141,21 @@ class CNLiveDownSlideTool:NSObject{ | ||
| 110 | }else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc){ | 141 | }else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc){ |
| 111 | //短剧-跳转短剧播放页 | 142 | //短剧-跳转短剧播放页 |
| 112 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId!), animated: pushAnimated) | 143 | navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId!), animated: pushAnimated) |
| 144 | + }else if contentMdl.model == kCNDownSlideContentsModelModelServing{ | ||
| 145 | + //跳转微信小程序 | ||
| 146 | + if let data = (contentMdl.s_to ?? "").data(using: .utf8) { | ||
| 147 | + do { | ||
| 148 | + let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] | ||
| 149 | + let miniAppId = jsonResult!["id"] as! String | ||
| 150 | + let miniPath = jsonResult!["path"] as! String | ||
| 151 | + CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:]) | ||
| 152 | + | ||
| 153 | + } catch { | ||
| 154 | + print("JSON 解析错误") | ||
| 155 | + } | ||
| 156 | + } else { | ||
| 157 | + print("无法将字符串转换为数据") | ||
| 158 | + } | ||
| 113 | }else{ | 159 | }else{ |
| 114 | return | 160 | return |
| 115 | } | 161 | } |