CNLiveIdentityResTableCell.swift
4.64 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
//
// CNLiveIdentityResTableCell.swift
// metaCode
//
// Created by zx on 2024/6/24.
// 身份大库tableViewCell
import Foundation
import Kingfisher
import SnapKit
typealias IdentityResSelectBlock = (_ currentCell: CNLiveIdentityResTableCell ,_ identitiesId:String) -> Void
class CNLiveIdentityResTableCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
lazy var twoTitleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(15, 15, KSreenWidth-30-40, 24))
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.font = BoldFont_17
return titleLabel
}()
//3级身份列表
lazy var threeArr: [MineAuthenticationsChildIdentitiesModel] = {
var threeArr = [MineAuthenticationsChildIdentitiesModel]()
return threeArr
}()
let kCNLiveIdentityResThreeCollectCellID = "kCNLiveIdentityResThreeCollectCellID"
lazy var threeCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSizeMake(100, 93)
layout.minimumLineSpacing = 10
layout.scrollDirection = .horizontal
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = .white
collectionView.register(CNLiveIdentityResThreeCollectCell.self, forCellWithReuseIdentifier: kCNLiveIdentityResThreeCollectCellID)
return collectionView
}()
//childModel
var _childModel : MineAuthenticationsChildModel?
var childModel : MineAuthenticationsChildModel? {
get{
_childModel
}
set{
_childModel = newValue!
setupNewUI(model: _childModel!)
}
}
var _tblCellIsSelect:Bool = false
var tblCellIsSelect:Bool{
get{
_tblCellIsSelect
}
set{
_tblCellIsSelect = newValue
}
}
var currentSeleIndex = -1
var selectBlock:IdentityResSelectBlock?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.backgroundColor = .clear
self.contentView.backgroundColor = .clear
self.selectionStyle = .none
self.contentView.addSubview(self.twoTitleLabel)
self.contentView.addSubview(self.threeCollectionView)
self.threeCollectionView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(15)
make.right.equalToSuperview().offset(-15)
make.top.equalTo(self.twoTitleLabel.snp.bottom).offset(10)
make.height.equalTo(112)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupNewUI(model:MineAuthenticationsChildModel){
self.twoTitleLabel.text = model.name
self.threeArr = model.identities
self.threeCollectionView.reloadData()
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
self.childModel?.identities.count ?? 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveIdentityResThreeCollectCellID, for: indexPath) as! CNLiveIdentityResThreeCollectCell
if indexPath.row == self.currentSeleIndex{
if self.tblCellIsSelect == true{
cell.cellIsSelected = true
}else{
cell.cellIsSelected = false
}
}else{
cell.cellIsSelected = false
}
cell.identitiesModel = self.threeArr[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.currentSeleIndex = indexPath.row
let identitiesModel = self.threeArr[indexPath.row]
if identitiesModel.userAuth == 0{
//正在审核
showMessage(message: "您已认证过该身份,不能重复认证")
return
}else if identitiesModel.userAuth == 1{
//审核成功
showMessage(message: "您已认证过该身份,不能重复认证")
return
}else if identitiesModel.userAuth == -1{
//审核失败
}else{
}
self.selectBlock?(self,identitiesModel.id)
self.threeCollectionView.reloadData()
}
}