CNLiveHomeTwoHengTuCell.swift
11.5 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//
// CNLiveHomeTwoHengTuCell.swift
// metaCode
//
// Created by zx on 2025/3/14.
// 一行2横图,title subTitle
import Foundation
class CNLiveHomeTwoHengTuCell: UITableViewCell {
//我的收藏
var _collectionModel : [CNLiveCollectionListModel]?
var collectionModel : [CNLiveCollectionListModel]? {
get{
_collectionModel
}
set{
_collectionModel = newValue!
for obj in contentView.subviews{
obj.removeFromSuperview()
}
self.setupNewCollectionUI(model: _collectionModel!)
}
}
//播放记录
var _followModel : [CNLiveHomeFollowModel]?
var followModel : [CNLiveHomeFollowModel]? {
get{
_followModel
}
set{
_followModel = newValue!
for obj in contentView.subviews{
obj.removeFromSuperview()
}
self.setupNewFollowUI(model: _followModel!)
}
}
//slideModel
var _slideModel : [CNLiveAlbumModel]?
var slideModel : [CNLiveAlbumModel]? {
get{
_slideModel
}
set{
_slideModel = newValue!
for obj in contentView.subviews{
obj.removeFromSuperview()
}
setupNewUI(model: _slideModel!)
}
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
contentView.backgroundColor = .clear
self.backgroundColor = .clear
contentView.clipsToBounds = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewCollectionUI(model:[CNLiveCollectionListModel]){
//创建cell 1-2个横版图
for (idx,mdl) in model.enumerated(){
let leftPadding:CGFloat = 15.0
let imgW:CGFloat = (KSreenWidth-45.0)/2.0
let imgH:CGFloat = imgW*93.0/165.0
let x:CGFloat = leftPadding+(imgW+15.0)*CGFloat(idx)
let y:CGFloat = 10.0
let imageView = UIImageView(frame: CGRectMake(x, y, imgW, imgH))
imageView.kf.setImage(with: URL(string:mdl.poster))
imageView.tag = idx
imageView.addCorner(conrners:[.topLeft,.topRight], radius: 9)
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
contentView.addSubview(imageView)
let payIconView = UIImageView()
payIconView.image = UIImage(named: "home_player_pay")
payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15)
imageView.addSubview(payIconView)
payIconView.isHidden = true
let grayBgView = UIView(frame: CGRect(x: imageView.left, y: imageView.bottom, width: imageView.width, height: grayH))
grayBgView.backgroundColor = HexColor("#FAFAFA")
grayBgView.addCorner(conrners:[.bottomLeft,.bottomRight], radius: 9)
grayBgView.clipsToBounds = true
contentView.addSubview(grayBgView)
let titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+10, width: imageView.width, height: 20))
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#333333")
titleLbl.text = mdl.title
contentView.addSubview(titleLbl)
let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y: titleLbl.bottom+3, width: titleLbl.width, height: 34))
subTitleLbl.font = Font_12
subTitleLbl.textColor = HexColor("#999999")
subTitleLbl.numberOfLines = 2
subTitleLbl.text = mdl.subTitle
contentView.addSubview(subTitleLbl)
}
}
func setupNewFollowUI(model:[CNLiveHomeFollowModel]){
//创建cell 1-2个横版图
for (idx,mdl) in model.enumerated(){
let leftPadding:CGFloat = 15.0
let imgW:CGFloat = (KSreenWidth-45.0)/2.0
let imgH:CGFloat = imgW*93.0/165.0
let x:CGFloat = leftPadding+(imgW+15.0)*CGFloat(idx)
let y:CGFloat = 10.0
let imageView = UIImageView(frame: CGRectMake(x, y, imgW, imgH))
imageView.kf.setImage(with: URL(string:mdl.poster))
imageView.tag = idx
imageView.addCorner(conrners:[.topLeft,.topRight], radius: 9)
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
contentView.addSubview(imageView)
let payIconView = UIImageView()
payIconView.image = UIImage(named: "home_player_pay")
payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15)
imageView.addSubview(payIconView)
let isPaid = CNLivePlayerTool.isShowPaidIcon(product: mdl.product)
if isPaid{
payIconView.isHidden = false
}else{
payIconView.isHidden = true
}
// if mdl.product?.productType == "2" || mdl.product?.productType == "5"{//付费
// payIconView.isHidden = false
// }else{
// if mdl.product?.check == true {
// //免费或者付过费了
// payIconView.isHidden = true
// } else {
// if mdl.product?.productType == "4" {
// //这里表示可以进行试听
// payIconView.isHidden = true
// } else {
// payIconView.isHidden = true
// }
// }
// }
let grayBgView = UIView(frame: CGRect(x: imageView.left, y: imageView.bottom, width: imageView.width, height: grayH))
grayBgView.backgroundColor = HexColor("#FAFAFA")
grayBgView.addCorner(conrners:[.bottomLeft,.bottomRight], radius: 9)
grayBgView.clipsToBounds = true
contentView.addSubview(grayBgView)
let titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+10, width: imageView.width, height: 20))
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#333333")
titleLbl.text = mdl.title
contentView.addSubview(titleLbl)
let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y: titleLbl.bottom+3, width: titleLbl.width, height: 34))
subTitleLbl.font = Font_12
subTitleLbl.textColor = HexColor("#999999")
subTitleLbl.numberOfLines = 2
subTitleLbl.text = mdl.description
contentView.addSubview(subTitleLbl)
}
}
func setupNewUI(model:[CNLiveAlbumModel]){
//创建cell 1-2个横版图
for (idx,mdl) in model.enumerated(){
let leftPadding:CGFloat = 15.0
let imgW:CGFloat = (KSreenWidth-45.0)/2.0
let imgH:CGFloat = imgW*93.0/165.0
let x:CGFloat = leftPadding+(imgW+15.0)*CGFloat(idx)
let y:CGFloat = 10.0
let imageView = UIImageView(frame: CGRectMake(x, y, imgW, imgH))
imageView.kf.setImage(with: URL(string:mdl.poster))
imageView.tag = idx
imageView.addCorner(conrners:[.topLeft,.topRight], radius: 9)
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
contentView.addSubview(imageView)
let payIconView = UIImageView()
payIconView.image = UIImage(named: "home_player_pay")
payIconView.frame = CGRect(x: 0, y: 0, width: 26, height: 15)
imageView.addSubview(payIconView)
let isPaid = CNLivePlayerTool.isShowPaidIcon(product: mdl.product)
if isPaid{
payIconView.isHidden = false
}else{
payIconView.isHidden = true
}
// if mdl.product?.productType == "2" || mdl.product?.productType == "5"{//付费
// payIconView.isHidden = false
// }else{
// if mdl.product?.check == true {
// //免费或者付过费了
// payIconView.isHidden = true
// } else {
// if mdl.product?.productType == "4" {
// //这里表示可以进行试听
// payIconView.isHidden = true
// } else {
// payIconView.isHidden = true
// }
// }
// }
let grayBgView = UIView(frame: CGRect(x: imageView.left, y: imageView.bottom, width: imageView.width, height: grayH))
grayBgView.backgroundColor = HexColor("#FAFAFA")
grayBgView.addCorner(conrners:[.bottomLeft,.bottomRight], radius: 9)
grayBgView.clipsToBounds = true
contentView.addSubview(grayBgView)
let titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+10, width: imageView.width, height: 20))
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#333333")
titleLbl.text = mdl.title
contentView.addSubview(titleLbl)
let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y: titleLbl.bottom+3, width: titleLbl.width, height: 34))
subTitleLbl.font = Font_12
subTitleLbl.textColor = HexColor("#999999")
subTitleLbl.numberOfLines = 2
subTitleLbl.text = mdl.subTitle
contentView.addSubview(subTitleLbl)
}
}
@objc func imgTapAction(ges: UITapGestureRecognizer){
let imageView = ges.view as! UIImageView
let i = imageView.tag
if let contentMdl = self.slideModel?[i]{
CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(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, slideModel: nil)
}else if let contentMdl = self.followModel?[i] as? CNLiveHomeFollowModel{
CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: contentMdl.modelId , contentId: contentMdl.contentId , pid: contentMdl.activeId , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.shareUrl , title: contentMdl.title , s_to: "" ,trailerId: "" , controller: nil, slideModel: nil)
}else if let contentMdl = self.collectionModel?[i] as? CNLiveCollectionListModel{//我的收藏
if contentMdl.model == kCNDownSlideContentsModelModelAlbum_video{
//专辑
CNLiveDownSlideTool.pushVodController(albumId: contentMdl.albumId, navigationVC: navigationViewController())
}else{
//点播
CNLiveDownSlideTool.pushVodController(contentId: contentMdl.contentId, navigationVC: navigationViewController(), isAblumVideo: false)
}
}
}
}