CNLiveDownSlideTool.swift
11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//
// CNLiveDownSlideTool.swift
// metaCode
//
// Created by zx on 2023/10/25.
// 跳转
import Foundation
import CNLiveShareToolKit
class CNLiveDownSlideTool:NSObject{
class func pushWebVCWithContentsMdl(model:String,contentId:String,pid:String,shareUrl:String,thirdUrl:String,title:String,s_to:String){//contentMdl:CNLiveDownSlideContentsModel
if (model == kCNDownSlideContentsModelModel1) || (model == kCNDownSlideContentsModelModel2){
let queryItem = URLQueryItem(name: "contentId", value: contentId)
let queryItem1 = URLQueryItem(name: "videoId", value: pid)
let urlComponents = NSURLComponents(string: shareUrl)!
urlComponents.queryItems = [queryItem, queryItem1]
let regURL = urlComponents.url
let webVC = CNWebViewController()
webVC.url = regURL
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if (model == kCNDownSlideContentsModelModel3) || (model == kCNDownSlideContentsModelModel4){
let webVC = CNWebViewController()
webVC.url = URL(string: thirdUrl)
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if (model == kCNDownSlideContentsModelModelAlbum){
let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
let queryItem = URLQueryItem(name: "aid", value: contentId)
let queryItem1 = URLQueryItem(name: "title", value: title)
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if (model == kCNDownSlideContentsModelModelAlbum_video){
let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
let queryItem = URLQueryItem(name: "aid", value: contentId)
let queryItem1 = URLQueryItem(name: "title", value: title)
let queryItem2 = URLQueryItem(name: "channelName", value: "yjzg")
let queryItem3 = URLQueryItem(name: "isShowTitle", value: "true")
let queryItem4 = URLQueryItem(name: "isWjjReport", value: "true")
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1,queryItem2,queryItem3,queryItem4]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if (model == kCNDownSlideContentsModelModelAlbum_ugc){
//短剧-跳转短剧播放页
navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentId), animated: pushAnimated)
}else if model == kCNDownSlideContentsModelModelServing{
//跳转微信小程序
if let data = s_to.data(using: .utf8) {
do {
let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
let miniAppId = jsonResult!["id"] as! String
let miniPath = jsonResult!["path"] as! String
CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
} catch {
print("JSON 解析错误")
}
} else {
print("无法将字符串转换为数据")
}
}else{
return
}
}
class func pushWebVCWithCNLiveAlbumMdl(albumModel:CNLiveAlbumModel,controller:UIViewController){
if (albumModel.model == kCNDownSlideContentsModelModel1) || (albumModel.model == kCNDownSlideContentsModelModel2){
let queryItem = URLQueryItem(name: "contentId", value: albumModel.contentId)
let queryItem1 = URLQueryItem(name: "videoId", value: albumModel.pid)
let urlComponents = NSURLComponents(string: (albumModel.shareUrl))!
urlComponents.queryItems = [queryItem, queryItem1]
let regURL = urlComponents.url
let webVC = CNWebViewController()
webVC.url = regURL
controller.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if (albumModel.model == kCNDownSlideContentsModelModel3) || (albumModel.model == kCNDownSlideContentsModelModel4){
let webVC = CNWebViewController()
webVC.url = URL(string: (albumModel.thirdUrl))
controller.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else if albumModel.model == kCNDownSlideContentsModelModelAlbum{
let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
let queryItem = URLQueryItem(name: "aid", value: albumModel.contentId)
let queryItem1 = URLQueryItem(name: "title", value: albumModel.title)
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
controller.navigationController?.pushViewController(webVC, animated: true)
}else if (albumModel.model == kCNDownSlideContentsModelModelAlbum_video){
let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
let queryItem = URLQueryItem(name: "aid", value: albumModel.contentId)
let queryItem1 = URLQueryItem(name: "title", value: albumModel.title)
let queryItem2 = URLQueryItem(name: "channelName", value: "yjzg")
let queryItem3 = URLQueryItem(name: "isShowTitle", value: "true")
let queryItem4 = URLQueryItem(name: "isWjjReport", value: "true")
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1,queryItem2,queryItem3,queryItem4]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
controller.navigationController?.pushViewController(webVC, animated: true)
}else if (albumModel.model == kCNDownSlideContentsModelModelAlbum_ugc){
//短剧-跳转短剧播放页
navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: albumModel.contentId), animated: pushAnimated)
}else if albumModel.model == kCNDownSlideContentsModelModelServing{
//跳转微信小程序
if let data = (albumModel.s_to ?? "").data(using: .utf8) {
do {
let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
let miniAppId = jsonResult!["id"] as! String
let miniPath = jsonResult!["path"] as! String
CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
} catch {
print("JSON 解析错误")
}
} else {
print("无法将字符串转换为数据")
}
}else{
return
}
}
class func detailPushWebVCWithContentsMdl(contentMdl:CNLiveDownSlideContentsModel,viewController:UIViewController){
if (contentMdl.model == kCNDownSlideContentsModelModel1) || (contentMdl.model == kCNDownSlideContentsModelModel2){
let queryItem = URLQueryItem(name: "contentId", value: contentMdl.contentId)
let queryItem1 = URLQueryItem(name: "videoId", value: contentMdl.pid)
let urlComponents = NSURLComponents(string: (contentMdl.shareUrl))!
urlComponents.queryItems = [queryItem, queryItem1]
let regURL = urlComponents.url
let webVC = CNWebViewController()
webVC.url = regURL
viewController.navigationController?.pushViewController(webVC, animated: true)
}else if (contentMdl.model == kCNDownSlideContentsModelModel3) || (contentMdl.model == kCNDownSlideContentsModelModel4){
let webVC = CNWebViewController()
webVC.url = URL(string: (contentMdl.thirdUrl))
viewController.navigationController?.pushViewController(webVC, animated: true)
}else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum){
let urlString = "http://wjjh5.cnlive.com/cnYmAlbumVideoList.html"
let queryItem = URLQueryItem(name: "aid", value: contentMdl.contentId)
let queryItem1 = URLQueryItem(name: "title", value: contentMdl.title)
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
viewController.navigationController?.pushViewController(webVC, animated: true)
}else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_video){
let urlString = "http://wjjh5.cnlive.com/cnYjzgAlbumVideo.html"
let queryItem = URLQueryItem(name: "aid", value: contentMdl.contentId)
let queryItem1 = URLQueryItem(name: "title", value: contentMdl.title)
let queryItem2 = URLQueryItem(name: "channelName", value: "yjzg")
let queryItem3 = URLQueryItem(name: "isShowTitle", value: "true")
let queryItem4 = URLQueryItem(name: "isWjjReport", value: "true")
let urlComponents = NSURLComponents(string: urlString)
urlComponents!.queryItems = [queryItem, queryItem1,queryItem2,queryItem3,queryItem4]
let regURL = urlComponents?.url
let webVC = CNWebViewController()
webVC.url = regURL
viewController.navigationController?.pushViewController(webVC, animated: true)
}else if (contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc){
//短剧-跳转短剧播放页
navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(aid: contentMdl.contentId), animated: pushAnimated)
}else if contentMdl.model == kCNDownSlideContentsModelModelServing{
//跳转微信小程序
if let data = (contentMdl.s_to ?? "").data(using: .utf8) {
do {
let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
let miniAppId = jsonResult!["id"] as! String
let miniPath = jsonResult!["path"] as! String
CNLiveShareImageManager.pushWeChatMiniProgrem(withMiniAppId: miniAppId, path: miniPath, extMsg: "", extDic: [:])
} catch {
print("JSON 解析错误")
}
} else {
print("无法将字符串转换为数据")
}
}else{
return
}
}
}