CNIDCardView.swift
4.15 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
//
// CNIDCardView.swift
// metaCode
//
// Created by zx on 2023/9/16.
// 身份认证卡片
import Foundation
class CNIDCardView: UIView{
//IDmodel
var _idModel : StandListModel?
var idModel : StandListModel? {
get{
_idModel
}
set{
_idModel = newValue
self.iDCardBGView.kf.setImage(with: URL(string: _idModel!.cardImg), placeholder: UIImage(named: "homePage_idCardBG"))
self.loadIDDetailData()
}
}
override init(frame: CGRect) {
super.init(frame: frame)
self.initUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initUI()
{
self.addSubview(self.contentView)
self.contentView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalToSuperview()
make.height.equalToSuperview()
}
self.addSubview(self.iDCardBGView)
self.iDCardBGView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalToSuperview()
make.height.equalToSuperview()
}
}
func loadIDDetailData(){
// showLoading(message: "")
self.subviews.forEach { view in
if view.tag >= 10000{
view.removeFromSuperview()
}
}
CNLiveMineViewModel.requestsStandInfo(identityId: "\(_idModel!.id)", type: .havedate, authType: .person) { [self] result, respStatue in
hiddenLoading()
if respStatue == .success {
let cardArray = result as! NSMutableArray
let count = cardArray.count
if cardArray.count > 0{
for i in (0..<cardArray.count){
let idCardModel = cardArray[i] as! MineStandInfoModel
let siBianGap:CGFloat = 17
let labelsGap:CGFloat = 10
let keyLabel = UILabel.init()
keyLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
keyLabel.textAlignment = .left
keyLabel.font = Font(15)
keyLabel.backgroundColor = .clear
keyLabel.text = idCardModel.name ?? ""
keyLabel.frame = CGRect(x: siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: 70, height: 21)
keyLabel.adjustsFontSizeToFitWidth = true
keyLabel.tag = 10000+i
self.addSubview(keyLabel)
let valueLabel = UILabel.init()
valueLabel.textColor = HexColor(_idModel?.backgroundColor ?? "")
valueLabel.textAlignment = .left
valueLabel.font = Font(15)
valueLabel.backgroundColor = .clear
valueLabel.text = idCardModel.userInfo ?? ""
valueLabel.frame = CGRect(x: keyLabel.right+labelsGap+siBianGap, y: siBianGap+CGFloat(i)*21+CGFloat(i)*labelsGap, width: self.width-keyLabel.right-labelsGap-siBianGap-5, height: 21)
valueLabel.adjustsFontSizeToFitWidth = true
valueLabel.tag = 20000+i
self.addSubview(valueLabel)
}
}else{
//没数据
}
}
}
}
// MARK: - 懒加载
///视图总容器
lazy var contentView : UIView = {
let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0 ))
contentView.backgroundColor = UIColor.clear
return contentView
}()
/// 身份卡片-背景图
lazy var iDCardBGView:UIImageView = {
let iDCardBGView:UIImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
iDCardBGView.backgroundColor = UIColor.clear
return iDCardBGView
}()
}