CNLiveVocationalCertificateFirCell.swift
14.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
//
// CNLiveVocationalCertificateFirCell.swift
// metaCode
//
// Created by zx on 2024/7/25.
// 简历-职业证书顶部cell
import Foundation
import Kingfisher
import SnapKit
class CNLiveVocationalCertificateFirCell: UITableViewCell, UICollectionViewDataSource ,UICollectionViewDelegate{
var currSeleIndex = 0
var pageNum: NSInteger! = 1
//cerListArr
var _cerListArr : Array<CNLiveVitaeCertificatesModel>?
var cerListArr : Array<CNLiveVitaeCertificatesModel>? {
get{
_cerListArr
}
set{
_cerListArr = newValue!
setupNewUI(cerListArr :_cerListArr!)
}
}
lazy var bgImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_zhengshu-bg")
return iconImgView
}()
lazy var yuanmaLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "职业证书"
titleLabel.font = BoldFont_24
titleLabel.adjustsFontSizeToFitWidth=true
return titleLabel
}()
lazy var yuanmaDescLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "共 1 条"
titleLabel.font = Font_16
return titleLabel
}()
let kCNLiveVocationalCertificateFirCollectCellIdentifier = "kCNLiveVocationalCertificateFirCollectCellIdentifier"
let collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()//CNLiveVocationalCertifiteCollectionViewLayout()
layout.scrollDirection = .horizontal
layout.itemSize = CGSizeMake(76, 90)
layout.sectionInset = .init(top: 0, left: 15, bottom: 0, right: 15)
layout.minimumLineSpacing = 30
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.backgroundColor = .clear
collectionView.showsHorizontalScrollIndicator = false
return collectionView
}()
lazy var whiteBgView :UIView = {
let whiteBgView = UIView()
whiteBgView.backgroundColor = .white
whiteBgView.layer.cornerRadius = 12
whiteBgView.clipsToBounds = true
return whiteBgView
}()
lazy var cerDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "证书详情"
titleLabel.font = BoldFont_16
return titleLabel
}()
lazy var cerNameTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.text = "证书名称"
titleLabel.font = Font_12
return titleLabel
}()
lazy var cerNameDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "无"
titleLabel.font = BoldFont_14
return titleLabel
}()
lazy var cerLevelTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.text = "证书等级/分数"
titleLabel.font = Font_12
return titleLabel
}()
lazy var cerLevelDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "无"
titleLabel.font = BoldFont_14
return titleLabel
}()
lazy var authIconImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_yiyanzheng")
iconImgView.isHidden = true
return iconImgView
}()
lazy var cerNumberTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.text = "证书编号"
titleLabel.font = Font_12
return titleLabel
}()
lazy var cerNumberDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "无"
titleLabel.font = BoldFont_14
return titleLabel
}()
lazy var cerJiGouTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.text = "发证机构"
titleLabel.font = Font_12
return titleLabel
}()
lazy var cerJiGouDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "无"
titleLabel.font = BoldFont_14
return titleLabel
}()
lazy var cerStatusTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.text = "验证状态"
titleLabel.font = Font_12
return titleLabel
}()
lazy var cerStatusDetailTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "未验证"
titleLabel.font = BoldFont_14
return titleLabel
}()
lazy var authGuanfangIconImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_guanfnagAuth")
return iconImgView
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
self.contentView.addSubview(self.bgImgView)
self.bgImgView.snp.makeConstraints { make in
make.top.equalTo(0)
make.left.right.equalToSuperview()
make.height.equalTo(KSreenWidth*457/375)
}
self.contentView.addSubview(self.yuanmaLabel)
self.yuanmaLabel.snp.makeConstraints { make in
make.top.equalTo(adapt_length(length: 55))
make.left.equalTo(adapt_length(length: 30))
}
self.contentView.addSubview(self.yuanmaDescLabel)
self.yuanmaDescLabel.snp.makeConstraints { make in
make.top.equalTo(self.yuanmaLabel.snp.bottom).offset(adapt_length(length: 5))
make.left.equalTo(adapt_length(length: 30))
}
self.contentView.addSubview(self.collectionView)
self.collectionView.dataSource = self
self.collectionView.delegate = self
self.collectionView.register(CNLiveCertificateCollectionCell.self, forCellWithReuseIdentifier: kCNLiveVocationalCertificateFirCollectCellIdentifier)
self.collectionView.snp.makeConstraints { make in
make.top.equalTo(self.yuanmaDescLabel.snp.bottom).offset(adapt_length(length: 41))
make.height.equalTo(adapt_length(length: 114))
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
}
self.contentView.addSubview(self.whiteBgView)
self.whiteBgView.snp.makeConstraints { make in
make.top.equalTo(adapt_length(length: 277))
make.bottom.equalToSuperview()
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
}
self.whiteBgView.addSubview(self.cerDetailTitleLabel)
self.cerDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(15)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.cerNameTitleLabel)
self.cerNameTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerDetailTitleLabel.snp.bottom).offset(30)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.cerNameDetailTitleLabel)
self.cerNameDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerNameTitleLabel.snp.bottom).offset(3)
make.left.equalTo(15)
make.right.equalToSuperview().offset(-5)
}
self.whiteBgView.addSubview(self.cerLevelTitleLabel)
self.cerLevelTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerNameDetailTitleLabel.snp.bottom).offset(15)
make.left.equalTo(15)
make.width.equalTo(100)
make.height.equalTo(17)
}
self.whiteBgView.addSubview(self.cerLevelDetailTitleLabel)
self.cerLevelDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerLevelTitleLabel.snp.bottom).offset(3)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.authIconImgView)
self.authIconImgView.snp.makeConstraints { make in
make.top.equalTo(self.cerNameDetailTitleLabel.snp.bottom).offset(5)
make.right.equalToSuperview()
}
self.whiteBgView.addSubview(self.cerNumberTitleLabel)
self.cerNumberTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerLevelTitleLabel.snp.top)
make.right.equalToSuperview().offset(adapt_length(length: -117))
make.left.greaterThanOrEqualTo(self.cerLevelTitleLabel.snp.right).offset(5)
}
self.whiteBgView.addSubview(self.cerNumberDetailTitleLabel)
self.cerNumberDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerNumberTitleLabel.snp.bottom).offset(3)
make.left.equalTo(self.cerNumberTitleLabel.snp.left)
make.right.equalToSuperview().offset(-5)
}
self.whiteBgView.addSubview(self.cerJiGouTitleLabel)
self.cerJiGouTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerLevelDetailTitleLabel.snp.bottom).offset(15)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.cerJiGouDetailTitleLabel)
self.cerJiGouDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerJiGouTitleLabel.snp.bottom).offset(3)
make.left.equalTo(15)
make.right.equalToSuperview().offset(-5)
}
self.whiteBgView.addSubview(self.cerStatusTitleLabel)
self.cerStatusTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerJiGouDetailTitleLabel.snp.bottom).offset(15)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.cerStatusDetailTitleLabel)
self.cerStatusDetailTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.cerStatusTitleLabel.snp.bottom).offset(3)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.authGuanfangIconImgView)
self.authGuanfangIconImgView.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-20)
make.left.equalTo(15)
make.width.equalTo(83)
make.height.equalTo(16)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(cerListArr : Array<CNLiveVitaeCertificatesModel>){
self.yuanmaDescLabel.text = "共 \(cerListArr.count) 条"
self.collectionView.reloadData()
self.collectionView.scrollToItem(at: IndexPath(item: self.currSeleIndex, section: 0), at: .centeredHorizontally, animated: true)
}
func setupCerDetailNewUI(cerModel : CNLiveVitaeCertificatesModel){
self.cerNameDetailTitleLabel.text = (cerModel.title.count > 0) ? cerModel.title : "无"
self.cerLevelDetailTitleLabel.text = (cerModel.lv.count > 0) ? cerModel.lv : "无"
self.cerNumberDetailTitleLabel.text = (cerModel.number.count > 0) ? cerModel.number : "无"
self.cerJiGouDetailTitleLabel.text = (cerModel.organization.count > 0) ? cerModel.organization : "无"
var isAuthed = false
if cerModel.status == 0 || cerModel.status == -1{
isAuthed = false
}
if cerModel.status == 1{
isAuthed = true
}
self.cerStatusDetailTitleLabel.text = isAuthed ? "已验证" : "未验证"
self.authIconImgView.isHidden = isAuthed ? false : true
self.authGuanfangIconImgView.image = isAuthed ? UIImage(named: "mine_jianli_guanfnagAuth") : UIImage(named: "mine_jianli_zhenshi")
if isAuthed{
self.authGuanfangIconImgView.snp.remakeConstraints { make in
make.bottom.equalToSuperview().offset(-20)
make.left.equalTo(15)
make.width.equalTo(68)
make.height.equalTo(19)
}
}else{
self.authGuanfangIconImgView.snp.remakeConstraints { make in
make.bottom.equalToSuperview().offset(-20)
make.left.equalTo(15)
make.width.equalTo(83)
make.height.equalTo(16)
}
}
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.cerListArr?.count ?? 0 // 图片的数量
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVocationalCertificateFirCollectCellIdentifier, for: indexPath) as! CNLiveCertificateCollectionCell
if indexPath.row == self.currSeleIndex{
cell.cellIsSelected = true
if self.cerListArr?.count ?? 0 > 0{
let model = self.cerListArr![indexPath.row]
self.setupCerDetailNewUI(cerModel: model)
}
}else{
cell.cellIsSelected = false
}
if self.cerListArr?.count ?? 0 > 0{
let model = self.cerListArr?[indexPath.row]
cell.cerModel = model
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.currSeleIndex = indexPath.row
self.collectionView.reloadData()
if self.cerListArr?.count ?? 0 > 0{
let model = self.cerListArr![indexPath.row]
self.setupCerDetailNewUI(cerModel: model)
}
}
}