CNLiveAlbumCell.swift
5.65 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
//
// CNLiveAlbumCell.swift
// metaCode
//
// Created by zx on 2024/1/8.
//
import Foundation
import QMUIKit
class CNLiveAlbumCell:UITableViewCell{
var albumModelArr:Array<CNLiveAlbumListModel>?
var _albumMsgModel : CNLiveAlbumMsgModel?
var albumMsgModel : CNLiveAlbumMsgModel? {
get{
_albumMsgModel
}
set{
_albumMsgModel = newValue!
self.setupNewUIMsgModel(model: _albumMsgModel!)
}
}
//AlbumModel
var _albumModel : CNLiveAlbumModel?
var albumModel : CNLiveAlbumModel? {
get{
_albumModel
}
set{
_albumModel = newValue!
self.setupNewUI(model: _albumModel!)
}
}
//MARK: - 懒加载
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 15, y: 15, width: 45, height: 45))
iconImgView.layer.cornerRadius = 5
iconImgView.clipsToBounds = true
return iconImgView
}()
///标题
lazy var titleLabl: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, 15, KSreenWidth-(self.iconImgView.right+15)-80, 21))
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.font = Font_15
titleLabel.text = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
return titleLabel
}()
///副标题
lazy var subTitleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.right+15, self.titleLabl.bottom+5, 60, 17))
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.font = Font_12
titleLabel.text = "共68集"
return titleLabel
}()
lazy var playBtn: QMUIButton = {
let playBtn = QMUIButton.init(type: .custom)
playBtn.frame = CGRect(x: KSreenWidth-80, y: 0, width: 65, height: 26)
playBtn.centerY = self.iconImgView.centerY
playBtn.layer.cornerRadius = 13
playBtn.clipsToBounds = true
playBtn.setTitle("播放", for: .normal)
playBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
playBtn.backgroundColor = HexColor("#609AFF")
playBtn.titleLabel?.font = Font_13
playBtn.addTarget(self, action: #selector(playBtnAction), for: .touchUpInside)
return playBtn
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.contentView.addSubview(self.iconImgView)
self.contentView.addSubview(self.titleLabl)
self.contentView.addSubview(self.subTitleLabel)
self.contentView.addSubview(self.playBtn)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:CNLiveAlbumModel){
self.titleLabl.text = model.title
self.subTitleLabel.text = model.subTitle
self.iconImgView.kf.setImage(with: URL(string: model.poster))
self.titleLabl.width = KSreenWidth-(self.iconImgView.right+15)-80
self.playBtn.left = KSreenWidth-80
}
func setupNewUIMsgModel(model:CNLiveAlbumMsgModel){
self.titleLabl.text = model.albumName
self.subTitleLabel.text = model.subTitle
self.iconImgView.kf.setImage(with: URL(string: model.albumImg))
self.titleLabl.width = KSreenWidth-(self.iconImgView.right+15)-80-30
self.playBtn.left = KSreenWidth-80-30
}
@objc func playBtnAction(){
showLoading(message: "")
self.getAlbumList()
}
//获取专辑详情(简介等)
// func getAlbumMsg(){
// var aid = ""
// if self.albumModel != nil{
// aid = self.albumModel!.contentId
// }else if self.albumMsgModel != nil{
// aid = self.albumMsgModel!.albumId
// }else{
// aid = ""
// }
// CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
// hiddenLoading()
// if status == .success{
// let model = result as! CNLiveAlbumMsgModel
// for listModel in self.albumModelArr! {
// listModel.albumMsgModel = model
// }
// print("暂时跳转主页")
// navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(albumModelArr: self.albumModelArr!), animated: true)
// }else{
//
// }
// }
// }
//获取专辑视频列表详情(播放地址 ,点赞数等信息)
func getAlbumList(){
showLoading(message: "")
var aid = ""
if self.albumModel != nil{
aid = self.albumModel!.contentId
}else if self.albumMsgModel != nil{
aid = self.albumMsgModel!.albumId
}else{
aid = ""
}
navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(aid: aid), animated: true)
return
//
// CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in
// hiddenLoading()
// if status == .success{
// let arr = result as! Array<CNLiveAlbumListModel>
// self.albumModelArr = Array(arr)
// self.getAlbumMsg()
// }else{
//
// }
// }
}
}