CNLiveVodPlayShopCollectionCell.swift
4.7 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
//
// CNLiveVodPlayShopCollectionCell.swift
// metaCode
//
// Created by zx on 2025/3/5.
// 点播-电商商品 列表cell
import Foundation
import Kingfisher
class CNLiveVodPlayShopCollectionCell: UICollectionViewCell {
//contentsModel
var _vodPlayShopModel : CNLiveVodPlayShopModel?
var vodPlayShopModel : CNLiveVodPlayShopModel? {
get{
_vodPlayShopModel
}
set{
_vodPlayShopModel = newValue!
setupNewUI(model: _vodPlayShopModel!)
}
}
//默认商品列表
var _albumModel : CNLiveAlbumModel?
var albumModel : CNLiveAlbumModel? {
get{
_albumModel
}
set{
_albumModel = newValue!
self.setupNewUI(goodsModel: _albumModel!)
}
}
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 9, y: 9, width: 72, height: 72))
iconImgView.contentMode = .scaleAspectFill
iconImgView.clipsToBounds = true
iconImgView.layer.cornerRadius = 9
return iconImgView
}()
lazy var titleBgView :UIView = {
let iconImgView = UIView(frame: CGRect(x: 0, y: 0, width: 235, height: 90))
iconImgView.clipsToBounds = true
iconImgView.layer.cornerRadius = 9
iconImgView.backgroundColor = HexColor("#FAFAFA")
return iconImgView
}()
lazy var titleLabel: UILabel = {
let titleLbl = UILabel()
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#333333")
titleLbl.numberOfLines = 2
return titleLbl
}()
lazy var subTitleLabel: UILabel = {
let titleLbl = UILabel()
titleLbl.font = BoldFont_14
titleLbl.textColor = HexColor("#E24F63")
titleLbl.numberOfLines = 1
return titleLbl
}()
//购买
lazy var payBtn: UIButton = {
let expandBtn = UIButton.init(type: .custom)
expandBtn.backgroundColor = HexColor("#478BFF")
expandBtn.clipsToBounds = true
expandBtn.layer.cornerRadius = 9
expandBtn.frame = CGRect(x: 0, y: 0, width: 64, height: 21)
expandBtn.setTitle("购买", for: .normal)
expandBtn.setTitle("购买", for: .highlighted)
expandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
expandBtn.setImage(UIImage(named: "home_player_shoppingCart"), for: .normal)
expandBtn.setImage(UIImage(named: "home_player_shoppingCart"), for: .selected)
expandBtn.titleLabel?.font = Font_12
expandBtn.setupButtonImageAndTitlePossitionWith(padding: 6, style: .left)
expandBtn.isUserInteractionEnabled = false
// expandBtn.addTarget(self, action: #selector(payBtnAction), for: .touchUpInside)
return expandBtn
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.contentView.addSubview(self.titleBgView)
self.titleBgView.addSubview(self.iconImgView)
self.titleBgView.addSubview(self.titleLabel)
self.titleBgView.addSubview(self.subTitleLabel)
self.titleBgView.addSubview(self.payBtn)
titleBgView.snp.makeConstraints { make in
make.left.top.width.height.equalToSuperview()
}
iconImgView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(9)
make.top.equalToSuperview().offset(9)
make.width.equalTo(72)
make.height.equalTo(72)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(self.iconImgView.snp.right).offset(10)
make.top.equalToSuperview().offset(6)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(40)
}
subTitleLabel.snp.makeConstraints { make in
make.left.equalTo(self.titleLabel.snp.left)
make.bottom.equalTo(self.iconImgView.snp.bottom)
}
payBtn.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.bottom.equalTo(self.iconImgView.snp.bottom)
make.width.equalTo(64)
make.height.equalTo(21)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:CNLiveVodPlayShopModel){
self.iconImgView.kf.setImage(with: URL(string: model.img))
self.titleLabel.text = model.title
self.subTitleLabel.text = model.price
}
func setupNewUI(goodsModel:CNLiveAlbumModel){
self.iconImgView.kf.setImage(with: URL(string: goodsModel.poster))
self.titleLabel.text = goodsModel.title
self.subTitleLabel.text = goodsModel.numberModel?.price
}
//购买
@objc func payBtnAction(){
}
}