CNLiveDownSlideTool.swift
7.75 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
//
// 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,trailerId:String,controller:UIViewController?){//contentMdl:CNLiveDownSlideContentsModel
if (model == kCNDownSlideContentsModelModel1) {
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
if controller != nil{
controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else{
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}
}else if (model == kCNDownSlideContentsModelModel2){
let queryItem = URLQueryItem(name: "contentId", value: contentId)
let queryItem1 = URLQueryItem(name: "activityId", value: pid)
let queryItem2 = URLQueryItem(name: "pid", value: pid)
let queryItem3 = URLQueryItem(name: "trailerId", value: trailerId)
let urlComponents = NSURLComponents(string: shareUrl)!
urlComponents.queryItems = [queryItem, queryItem1, queryItem2, queryItem3]
let regURL = urlComponents.url
let webVC = CNWebViewController()
webVC.url = regURL
if controller != nil{
controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else{
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}
}else if (model == kCNDownSlideContentsModelModel3) || (model == kCNDownSlideContentsModelModel4){
let webVC = CNWebViewController()
// webVC.url = URL(string: "http://wjjh5.cnlive.com/cnBlockMore.html?channelName=yjzg&pageId=&isShowTitle=true&blockType=28&contentType=13&title=%E5%9B%AD%E9%95%BF%E8%AF%BE%E7%A8%8B&pageName=&moreUrl=https%3A%2F%2Fcmsapi.cnlive.com%2FcontentApi%2FgetBlockContents%3FblockId%3D12165")//"https://managemall.cnlive.com/html/mall/1/#/pages/main/goodsList/goodsList?scene=app")
webVC.url = URL(string: thirdUrl)
if controller != nil{
controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else{
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
if controller != nil{
controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else{
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
if controller != nil{
controller!.navigationController?.pushViewController(webVC, animated: pushAnimated)
}else{
navigationViewController().visibleViewController?.navigationController?.pushViewController(webVC, animated: pushAnimated)
}
}else if (model == kCNDownSlideContentsModelModelAlbum_ugc){
showLoading(message: "")
self.pushShortVideoController(contentId: contentId, navigationVC: navigationViewController().visibleViewController?.navigationController)
}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 pushShortVideoController(contentId:String,navigationVC:UINavigationController?){
//请求getAlbumMsg获取上次播放集数
//获取专辑详情(简介等)
CNLiveHomePageViewModel.getAlbumMsg(aid: contentId) { result, status in
hiddenLoading()
if status == .success{
let model = result as! CNLiveAlbumMsgModel
//短剧-跳转短剧播放页
let toIndex = model.episodeLast-1 <= 0 ? 0 : model.episodeLast-1
navigationVC?.pushViewController( CNLiveShortVideoViewController(aid: contentId, currentIndex: toIndex), animated: pushAnimated)
}else{
//短剧-跳转短剧播放页
navigationVC?.pushViewController(CNLiveShortVideoViewController(aid: contentId), animated: pushAnimated)
}
}
}
class func pushShortVideoController(aid:String,page: NSInteger, currentIndex: NSInteger, dataArray: [CNLiveAlbumListModel],navigationVC:UINavigationController?){
//请求getAlbumMsg获取上次播放集数
//获取专辑详情(简介等)
CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
hiddenLoading()
if status == .success{
let model = result as! CNLiveAlbumMsgModel
//短剧-跳转短剧播放页
let toIndex = model.episodeLast-1 <= 0 ? 0 : model.episodeLast-1
navigationVC?.pushViewController( CNLiveShortVideoViewController(aid: aid, page: page, currentIndex: currentIndex, dataArray: dataArray), animated: pushAnimated)
}else{
//短剧-跳转短剧播放页
navigationVC?.pushViewController(CNLiveShortVideoViewController(aid: aid), animated: pushAnimated)
}
}
}
}