CNLiveHomeLanmuThreeImgCell.swift
4.51 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
//
// CNLiveHomeLanmuThreeImgCell.swift
// metaCode
//
// Created by zx on 2025/3/11.
// 一行3竖图,title subTitle
import Foundation
class CNLiveHomeLanmuThreeImgCell: UITableViewCell {
//slideModel
var _slideModel : [CNLiveAlbumModel]?
var slideModel : [CNLiveAlbumModel]? {
get{
_slideModel
}
set{
_slideModel = newValue!
setupNewUI(model: _slideModel!)
}
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
contentView.backgroundColor = .white
contentView.clipsToBounds = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:[CNLiveAlbumModel]){
//根据models.contents创建cell 1-3个竖版图
for (idx,mdl) in model.enumerated(){
let leftPadding:CGFloat = 15.0
let imgW:CGFloat = (KSreenWidth-60.0)/3.0
let imgH:CGFloat = imgW*140.0/105.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.verticalImg.count > 0 ? mdl.verticalImg : mdl.poster))
imageView.tag = idx
imageView.layer.cornerRadius = 9
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
contentView.addSubview(imageView)
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 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 titleLbl = UILabel(frame: CGRect(x: imageView.left, y: imageView.bottom+5, 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: 17))
subTitleLbl.font = Font_12
subTitleLbl.textColor = HexColor("#999999")
subTitleLbl.text = mdl.subTitle
contentView.addSubview(subTitleLbl)
}
}
@objc func detailBtnAction(){
}
@objc func imgTapAction(ges: UITapGestureRecognizer){
showLoading(message: "")
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)
}
}
}