Commit e82e1e30b86f5e140ead95fc7b6214eec98aa603

Authored by “张旭”
1 parent 715aa40e

适配h5播放直播的参数 , 跳转工具优化方法

metaCode/Classes/Main/HomePage/Controller/DownSlideController/CNUpSlideDetailViewController.swift
... ... @@ -69,7 +69,7 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
69 69 let frame = self.view.bounds
70 70 let view = CNUpSlideDetailScrollView(frame: frame)
71 71 view.callBack = {(contentMdl:CNLiveDownSlideContentsModel)->Void in
72   - CNLiveDownSlideTool.detailPushWebVCWithContentsMdl(contentMdl: contentMdl, viewController: self)
  72 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model, contentId: contentMdl.contentId, pid: contentMdl.pid, shareUrl: contentMdl.shareUrl, thirdUrl: contentMdl.thirdUrl, title: contentMdl.title, s_to: contentMdl.s_to, trailerId: contentMdl.trailerId, controller: self)
73 73 }
74 74 view.delegate = self
75 75 return view
... ... @@ -289,7 +289,7 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
289 289 }
290 290 cell.albumModel = albumModel
291 291 cell.enterBlock = { albumModel in
292   - CNLiveDownSlideTool.pushWebVCWithCNLiveAlbumMdl(albumModel: albumModel,controller: self)
  292 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumModel.model, contentId: albumModel.contentId, pid: albumModel.pid, shareUrl: albumModel.shareUrl, thirdUrl: albumModel.thirdUrl, title: albumModel.title, s_to: albumModel.s_to, trailerId: albumModel.trailerId, controller: self)
293 293 }
294 294 return cell
295 295 }
... ... @@ -328,11 +328,10 @@ class CNUpSlideDetailViewController: CNLiveBaseViewController,UITableViewDataSou
328 328  
329 329 }else if self.slideModel?.type == SlideModelTypeOneCourse75{
330 330 //大图课程,跳转h5
331   -// CNLiveDownSlideTool.pushWebVCWithCNLiveAlbumMdl(albumModel: albumModel,controller: self)
332 331 }
333 332 }
334 333 }else{
335   - CNLiveDownSlideTool.pushWebVCWithCNLiveAlbumMdl(albumModel: albumModel,controller: self)
  334 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumModel.model, contentId: albumModel.contentId, pid: albumModel.pid, shareUrl: albumModel.shareUrl, thirdUrl: albumModel.thirdUrl, title: albumModel.title, s_to: albumModel.s_to, trailerId: albumModel.trailerId, controller: self)
336 335 }
337 336 }
338 337  
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNDownSlideSingleCourseCell.swift
... ... @@ -320,11 +320,10 @@ class CNDownSlideSingleCourseCell: UITableViewCell {
320 320 let tag = sender.tag
321 321 if self.myCurriculum?.list.count ?? 0 > 0{
322 322 let albumMdl = self.myCurriculum?.list[tag]
323   - CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumMdl?.model ?? "", contentId: albumMdl?.contentId ?? "", pid: albumMdl?.pid ?? "", shareUrl: albumMdl?.shareUrl ?? "", thirdUrl: albumMdl?.thirdUrl ?? "", title: albumMdl?.title ?? "", s_to: albumMdl?.s_to ?? "")
324   -
  323 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumMdl?.model ?? "", contentId: albumMdl?.contentId ?? "", pid: albumMdl?.pid ?? "", shareUrl: albumMdl?.shareUrl ?? "", thirdUrl: albumMdl?.thirdUrl ?? "", title: albumMdl?.title ?? "", s_to: albumMdl?.s_to ?? "",trailerId: albumMdl?.trailerId ?? "", controller: nil)
325 324 }else if self.slideModel?.contents.count ?? 0 > 0{
326 325 let contentMdl = self.slideModel?.contents[tag]
327   - CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl?.model ?? "", contentId: contentMdl?.contentId ?? "", pid: contentMdl?.pid ?? "", shareUrl: contentMdl?.shareUrl ?? "", thirdUrl: contentMdl?.thirdUrl ?? "", title: contentMdl?.title ?? "", s_to: contentMdl?.s_to ?? "")
  326 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl?.model ?? "", contentId: contentMdl?.contentId ?? "", pid: contentMdl?.pid ?? "", shareUrl: contentMdl?.shareUrl ?? "", thirdUrl: contentMdl?.thirdUrl ?? "", title: contentMdl?.title ?? "", s_to: contentMdl?.s_to ?? "",trailerId: contentMdl?.trailerId ?? "", controller: nil)
328 327 }
329 328 }
330 329 }
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNLiveDownSlideRecommendCell.swift
... ... @@ -86,7 +86,7 @@ class CNLiveDownSlideRecommendCell: UITableViewCell {
86 86 let imageView = ges.view as! UIImageView
87 87 let i = imageView.tag
88 88 let contentMdl = (self.slideModel?.contents[i])!
89   - CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model ?? "", contentId: contentMdl.contentId ?? "", pid: contentMdl.pid ?? "", shareUrl: contentMdl.shareUrl ?? "", thirdUrl: contentMdl.thirdUrl ?? "", title: contentMdl.title ?? "", s_to: contentMdl.s_to ?? "")
  89 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model , contentId: contentMdl.contentId , pid: contentMdl.pid , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.thirdUrl , title: contentMdl.title , s_to: contentMdl.s_to ,trailerId: contentMdl.trailerId , controller: nil)
90 90 }
91 91  
92 92 }
... ...
metaCode/Classes/Main/HomePage/View/VerticalViews/DownSlide/CNLiveDownSlideTodayRecommendCell.swift
... ... @@ -66,6 +66,6 @@ class CNLiveDownSlideTodayRecommendCell: UITableViewCell {
66 66 let imageView = ges.view as! UIImageView
67 67 let i = imageView.tag
68 68 let contentMdl = self.slideModel?.contents[i]
69   - CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl?.model ?? "", contentId: contentMdl?.contentId ?? "", pid: contentMdl?.pid ?? "", shareUrl: contentMdl?.shareUrl ?? "", thirdUrl: contentMdl?.thirdUrl ?? "", title: contentMdl?.title ?? "", s_to: contentMdl?.s_to ?? "")
  69 + CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl?.model ?? "", contentId: contentMdl?.contentId ?? "", pid: contentMdl?.pid ?? "", shareUrl: contentMdl?.shareUrl ?? "", thirdUrl: contentMdl?.thirdUrl ?? "", title: contentMdl?.title ?? "", s_to: contentMdl?.s_to ?? "",trailerId: contentMdl?.trailerId ?? "", controller: nil)
70 70 }
71 71 }
... ...
metaCode/Classes/Main/HomePages/Model/CNLiveAlbumModel.swift
... ... @@ -6,7 +6,7 @@
6 6 // 全部专辑列表数据
7 7  
8 8 import Foundation
9   -
  9 +///contentApi/getBlockContent
10 10 class CNLiveAlbumBaseModel:BaseModel{
11 11 var endRow = 0
12 12 var firstPage = 0
... ... @@ -38,16 +38,18 @@ class CNLiveAlbumModel:BaseModel{
38 38 var tag = ""
39 39 var model = ""//1,2,3,4课程 album_ugc短剧 ,album_video专辑h5
40 40 var thirdUrl = ""
  41 + //model2 直播时用
  42 + var trailerId = ""
41 43 var publishTime = ""
42 44 var shareUrl = ""
43 45 var spIcon = ""
44 46 var product:CNLiveAlbumProductModel?
45 47 ///小程序地址和小程序id {"path":"page/login_hint/login_hint","id":"gh_234d4ed615a3"}
46   - var s_to: String?
  48 + var s_to = ""
47 49 ///103时为微信小程序
48   - var s_type: String?
  50 + var s_type = ""
49 51 ///"weixin://dl/business/?t=NnvptiuER3k"
50   - var s_showType: String?
  52 + var s_showType = ""
51 53 //还有部分属性没写
52 54 }
53 55 class CNLiveAlbumProductModel:BaseModel{
... ...
metaCode/Classes/Main/Model/CNLiveDownSlideModel.swift
... ... @@ -31,6 +31,8 @@ class CNLiveDownSlideModel: BaseModel {
31 31 var rowNum: Int = 0
32 32 ///具体内容 title subTitle poster thirdUrl或者shareUrl
33 33 var contents = [CNLiveDownSlideContentsModel]()
  34 +
  35 +
34 36 ///cell高度
35 37 var cellH: Float = 0
36 38  
... ... @@ -67,6 +69,8 @@ class CNLiveDownSlideContentsModel: BaseModel {
67 69 var model: String = ""
68 70 ///model为1,2时
69 71 var shareUrl: String = ""
  72 + ///model为2时 直播用
  73 + var trailerId: String = ""
70 74 ///model为3,4时跳转url
71 75 var thirdUrl: String = ""
72 76 ///小程序地址和小程序id {"path":"page/login_hint/login_hint","id":"gh_234d4ed615a3"}
... ... @@ -75,4 +79,6 @@ class CNLiveDownSlideContentsModel: BaseModel {
75 79 var s_type: String = ""
76 80 ///"weixin://dl/business/?t=NnvptiuER3k"
77 81 var s_showType: String = ""
  82 +
  83 +
78 84 }
... ...
metaCode/Classes/Main/Util/CNLiveDownSlideTool.swift
... ... @@ -9,9 +9,9 @@ import Foundation
9 9 import CNLiveShareToolKit
10 10  
11 11 class CNLiveDownSlideTool:NSObject{
12   - class func pushWebVCWithContentsMdl(model:String,contentId:String,pid:String,shareUrl:String,thirdUrl:String,title:String,s_to:String){//contentMdl:CNLiveDownSlideContentsModel
  12 + class func pushWebVCWithContentsMdl(model:String,contentId:String,pid:String,shareUrl:String,thirdUrl:String,title:String,s_to:String,trailerId:String,controller:UIViewController?){//contentMdl:CNLiveDownSlideContentsModel
13 13  
14   - if (model == kCNDownSlideContentsModelModel1) || (model == kCNDownSlideContentsModelModel2){
  14 + if (model == kCNDownSlideContentsModelModel1) {
15 15  
16 16 let queryItem = URLQueryItem(name: "contentId", value: contentId)
17 17 let queryItem1 = URLQueryItem(name: "videoId", value: pid)
... ... @@ -20,11 +20,35 @@ class CNLiveDownSlideTool:NSObject{
20 20 let regURL = urlComponents.url
21 21 let webVC = CNWebViewController()
22 22 webVC.url = regURL
23   - navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  23 + if controller != nil{
  24 + controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
  25 + }else{
  26 + navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  27 + }
  28 + }else if (model == kCNDownSlideContentsModelModel2){
  29 +
  30 + let queryItem = URLQueryItem(name: "contentId", value: contentId)
  31 + let queryItem1 = URLQueryItem(name: "activityId", value: pid)
  32 + let queryItem2 = URLQueryItem(name: "pid", value: pid)
  33 + let queryItem3 = URLQueryItem(name: "trailerId", value: trailerId)
  34 + let urlComponents = NSURLComponents(string: shareUrl)!
  35 + urlComponents.queryItems = [queryItem, queryItem1, queryItem2, queryItem3]
  36 + let regURL = urlComponents.url
  37 + let webVC = CNWebViewController()
  38 + webVC.url = regURL
  39 + if controller != nil{
  40 + controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
  41 + }else{
  42 + navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  43 + }
24 44 }else if (model == kCNDownSlideContentsModelModel3) || (model == kCNDownSlideContentsModelModel4){
25 45 let webVC = CNWebViewController()
26 46 webVC.url = URL(string: thirdUrl)
27   - navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  47 + if controller != nil{
  48 + controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
  49 + }else{
  50 + navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  51 + }
28 52 }else if (model == kCNDownSlideContentsModelModelAlbum){
29 53  
30 54 let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
... ... @@ -35,7 +59,11 @@ class CNLiveDownSlideTool:NSObject{
35 59 let regURL = urlComponents?.url
36 60 let webVC = CNWebViewController()
37 61 webVC.url = regURL
38   - navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  62 + if controller != nil{
  63 + controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
  64 + }else{
  65 + navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  66 + }
39 67 }else if (model == kCNDownSlideContentsModelModelAlbum_video){
40 68 let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
41 69 let queryItem = URLQueryItem(name: "aid", value: contentId)
... ... @@ -48,7 +76,11 @@ class CNLiveDownSlideTool:NSObject{
48 76 let regURL = urlComponents?.url
49 77 let webVC = CNWebViewController()
50 78 webVC.url = regURL
51   - navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  79 + if controller != nil{
  80 + controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
  81 + }else{
  82 + navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
  83 + }
52 84 }else if (model == kCNDownSlideContentsModelModelAlbum_ugc){
53 85  
54 86 //短剧-跳转短剧播放页
... ... @@ -72,131 +104,4 @@ class CNLiveDownSlideTool:NSObject{
72 104 return
73 105 }
74 106 }
75   - class func pushWebVCWithCNLiveAlbumMdl(albumModel:CNLiveAlbumModel,controller:UIViewController){
76   -
77   - if (albumModel.model == kCNDownSlideContentsModelModel1) || (albumModel.model == kCNDownSlideContentsModelModel2){
78   -
79   - let queryItem = URLQueryItem(name: "contentId", value: albumModel.contentId)
80   - let queryItem1 = URLQueryItem(name: "videoId", value: albumModel.pid)
81   - let urlComponents = NSURLComponents(string: (albumModel.shareUrl))!
82   - urlComponents.queryItems = [queryItem, queryItem1]
83   - let regURL = urlComponents.url
84   - let webVC = CNWebViewController()
85   - webVC.url = regURL
86   - controller.navigationController?.pushViewController(webVC, animated: pushAnimated)
87   - }else if (albumModel.model == kCNDownSlideContentsModelModel3) || (albumModel.model == kCNDownSlideContentsModelModel4){
88   - let webVC = CNWebViewController()
89   - webVC.url = URL(string: (albumModel.thirdUrl))
90   - controller.navigationController?.pushViewController(webVC, animated: pushAnimated)
91   - }else if albumModel.model == kCNDownSlideContentsModelModelAlbum{
92   -
93   - let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
94   - let queryItem = URLQueryItem(name: "aid", value: albumModel.contentId)
95   - let queryItem1 = URLQueryItem(name: "title", value: albumModel.title)
96   - let urlComponents = NSURLComponents(string: urlString)
97   - urlComponents!.queryItems = [queryItem, queryItem1]
98   - let regURL = urlComponents?.url
99   - let webVC = CNWebViewController()
100   - webVC.url = regURL
101   - controller.navigationController?.pushViewController(webVC, animated: true)
102   - }else if (albumModel.model == kCNDownSlideContentsModelModelAlbum_video){
103   - let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
104   - let queryItem = URLQueryItem(name: "aid", value: albumModel.contentId)
105   - let queryItem1 = URLQueryItem(name: "title", value: albumModel.title)
106   - let queryItem2 = URLQueryItem(name: "channelName", value: "yjzg")
107   - let queryItem3 = URLQueryItem(name: "isShowTitle", value: "true")
108   - let queryItem4 = URLQueryItem(name: "isWjjReport", value: "true")
109   - let urlComponents = NSURLComponents(string: urlString)
110   - urlComponents!.queryItems = [queryItem, queryItem1,queryItem2,queryItem3,queryItem4]
111   - let regURL = urlComponents?.url
112   - let webVC = CNWebViewController()
113   - webVC.url = regURL
114   - controller.navigationController?.pushViewController(webVC, animated: true)
115   - }else if (albumModel.model == kCNDownSlideContentsModelModelAlbum_ugc){
116   - //短剧-跳转短剧播放页
117   - navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated)
118   -
119   - }else if albumModel.model == kCNDownSlideContentsModelModelServing{
120   - //跳转微信小程序
121   - if let data = (albumModel.s_to ?? "").data(using: .utf8) {
122   - do {
123   - let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
124   - let miniAppId = jsonResult!["id"] as! String
125   - let miniPath = jsonResult!["path"] as! String
126   - CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
127   -
128   - } catch {
129   - print("JSON 解析错误")
130   - }
131   - } else {
132   - print("无法将字符串转换为数据")
133   - }
134   - }else{
135   - return
136   - }
137   - }
138   -
139   - class func detailPushWebVCWithContentsMdl(contentMdl:CNLiveDownSlideContentsModel,viewController:UIViewController){
140   -
141   - if (contentMdl.model == kCNDownSlideContentsModelModel1) || (contentMdl.model == kCNDownSlideContentsModelModel2){
142   -
143   - let queryItem = URLQueryItem(name: "contentId", value: contentMdl.contentId)
144   - let queryItem1 = URLQueryItem(name: "videoId", value: contentMdl.pid)
145   - let urlComponents = NSURLComponents(string: (contentMdl.shareUrl))!
146   - urlComponents.queryItems = [queryItem, queryItem1]
147   - let regURL = urlComponents.url
148   - let webVC = CNWebViewController()
149   - webVC.url = regURL
150   - viewController.navigationController?.pushViewController(webVC, animated: true)
151   -
152   - }else if (contentMdl.model == kCNDownSlideContentsModelModel3) || (contentMdl.model == kCNDownSlideContentsModelModel4){
153   - let webVC = CNWebViewController()
154   - webVC.url = URL(string: (contentMdl.thirdUrl))
155   - viewController.navigationController?.pushViewController(webVC, animated: true)
156   - }else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum){
157   -
158   - let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
159   - let queryItem = URLQueryItem(name: "aid", value: contentMdl.contentId)
160   - let queryItem1 = URLQueryItem(name: "title", value: contentMdl.title)
161   - let urlComponents = NSURLComponents(string: urlString)
162   - urlComponents!.queryItems = [queryItem, queryItem1]
163   - let regURL = urlComponents?.url
164   - let webVC = CNWebViewController()
165   - webVC.url = regURL
166   - viewController.navigationController?.pushViewController(webVC, animated: true)
167   - }else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_video){
168   - let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
169   - let queryItem = URLQueryItem(name: "aid", value: contentMdl.contentId)
170   - let queryItem1 = URLQueryItem(name: "title", value: contentMdl.title)
171   - let queryItem2 = URLQueryItem(name: "channelName", value: "yjzg")
172   - let queryItem3 = URLQueryItem(name: "isShowTitle", value: "true")
173   - let queryItem4 = URLQueryItem(name: "isWjjReport", value: "true")
174   - let urlComponents = NSURLComponents(string: urlString)
175   - urlComponents!.queryItems = [queryItem, queryItem1,queryItem2,queryItem3,queryItem4]
176   - let regURL = urlComponents?.url
177   - let webVC = CNWebViewController()
178   - webVC.url = regURL
179   - viewController.navigationController?.pushViewController(webVC, animated: true)
180   - }else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc){
181   - //短剧-跳转短剧播放页
182   - navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId), animated: pushAnimated)
183   - }else if contentMdl.model == kCNDownSlideContentsModelModelServing{
184   - //跳转微信小程序
185   - if let data = (contentMdl.s_to ?? "").data(using: .utf8) {
186   - do {
187   - let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
188   - let miniAppId = jsonResult!["id"] as! String
189   - let miniPath = jsonResult!["path"] as! String
190   - CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
191   -
192   - } catch {
193   - print("JSON 解析错误")
194   - }
195   - } else {
196   - print("无法将字符串转换为数据")
197   - }
198   - }else{
199   - return
200   - }
201   - }
202 107 }
... ...