CNLiveVitaeCertificateAddPhotoCell.swift
7.92 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
//
// CNLiveVitaeCertificateAddPhotoCell.swift
// metaCode
//
// Created by zx on 2024/7/26.
//
import Foundation
import HXPHPicker
typealias SelectUploadImageBlock = (_ uploadImage: UIImage,_ key: String,_ url: String) -> Void
class CNLiveVitaeCertificateAddPhotoCell: UITableViewCell, PhotoPickerControllerDelegate{
var selectImageBlock:SelectUploadImageBlock?
lazy var whiteBgView :UIView = {
let whiteBgView = UIView()
whiteBgView.backgroundColor = .white
whiteBgView.layer.cornerRadius = 12
whiteBgView.clipsToBounds = true
return whiteBgView
}()
lazy var uploadTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "请上传个人证书图片"
titleLabel.font = BoldFont_15
return titleLabel
}()
lazy var uploadRealBgView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = HexColor("#F7F8FA")
return bottomNavView
}()
lazy var uploadRealTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .left
titleLabel.numberOfLines = 2
titleLabel.text = "·请上传真实信息,否则可能会影响你的信用\n·图片只自己查询和做认证,对外不展示图片"
titleLabel.font = Font_11
return titleLabel
}()
lazy var uploadPhotoBgImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_cerPhotoBg")
iconImgView.isUserInteractionEnabled = true
iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(uploadPhotoBgImgViewAction)))
return iconImgView
}()
lazy var uploadPhotoImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_cerPhoto")
return iconImgView
}()
lazy var uploadPhotoTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .left
titleLabel.text = "上传图片"
titleLabel.font = BoldFont_16
return titleLabel
}()
lazy var chakanTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#666666")
titleLabel.textAlignment = .right
titleLabel.text = "点击查看"
titleLabel.font = Font_14
return titleLabel
}()
lazy var realTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#1961FE")
titleLabel.textAlignment = .left
titleLabel.text = "正确示意"
titleLabel.font = Font_14
titleLabel.isUserInteractionEnabled = true
titleLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(uploadShiYiAction)))
return titleLabel
}()
lazy var realBgView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = .clear
bottomNavView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(uploadShiYiAction)))
return bottomNavView
}()
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.whiteBgView)
self.whiteBgView.snp.makeConstraints { make in
make.top.equalTo(15)
make.height.equalTo(351)
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
}
self.whiteBgView.addSubview(self.uploadTitleLabel)
self.uploadTitleLabel.snp.makeConstraints { make in
make.top.equalTo(20)
make.left.equalTo(15)
}
self.whiteBgView.addSubview(self.uploadRealBgView)
self.uploadRealBgView.snp.makeConstraints { make in
make.top.equalTo(self.uploadTitleLabel.snp.bottom).offset(10)
make.left.equalTo(15)
make.height.equalTo(50)
make.right.equalToSuperview().offset(-15)
}
self.uploadRealBgView.addSubview(self.uploadRealTitleLabel)
self.uploadRealTitleLabel.snp.makeConstraints { make in
make.left.equalTo(10)
make.centerY.equalToSuperview()
}
self.whiteBgView.addSubview(self.uploadPhotoBgImgView)
self.uploadPhotoBgImgView.snp.makeConstraints { make in
make.top.equalTo(self.uploadRealBgView.snp.bottom).offset(15)
make.left.equalTo(15)
make.height.equalTo(180)
make.right.equalToSuperview().offset(-15)
}
self.uploadPhotoBgImgView.addSubview(self.uploadPhotoImgView)
self.uploadPhotoImgView.snp.makeConstraints { make in
make.top.equalTo(50)
make.width.height.equalTo(50)
make.centerX.equalToSuperview()
}
self.uploadPhotoBgImgView.addSubview(self.uploadPhotoTitleLabel)
self.uploadPhotoTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.uploadPhotoImgView.snp.bottom).offset(10)
make.centerX.equalToSuperview()
}
self.whiteBgView.addSubview(self.chakanTitleLabel)
self.chakanTitleLabel.snp.makeConstraints { make in
make.right.equalTo(self.uploadPhotoBgImgView.snp.centerX).offset(-5)
make.top.equalTo(self.uploadPhotoBgImgView.snp.bottom).offset(15)
}
self.whiteBgView.addSubview(self.realTitleLabel)
self.realTitleLabel.snp.makeConstraints { make in
make.left.equalTo(self.uploadPhotoBgImgView.snp.centerX).offset(5)
make.top.equalTo(self.uploadPhotoBgImgView.snp.bottom).offset(15)
}
self.whiteBgView.addSubview(self.realBgView)
self.realBgView.snp.makeConstraints { make in
make.left.equalTo(self.uploadPhotoBgImgView.snp.centerX)
make.top.equalTo(self.uploadPhotoBgImgView.snp.bottom).offset(5)
make.width.equalTo(100)
make.bottom.equalToSuperview()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func uploadPhotoBgImgViewAction(){
//上传图片
let config = PhotoTools.getWXPickerConfig()
config.selectMode = .single
config.selectOptions = .photo
config.maximumSelectedPhotoCount = 3
let pickerController = PhotoPickerController(picker: config)
pickerController.pickerDelegate = self
pickerController.isOriginal = false
currentViewController()!.present(pickerController, animated: true, completion: nil)
}
@objc func uploadShiYiAction(){
//跳转上传示意图页面
navigationViewController().pushViewController(CNLiveVitaeCerAddPhotoController(), animated: true)
}
}
extension CNLiveVitaeCertificateAddPhotoCell {
func pickerController(_ pickerController: PhotoPickerController,
didFinishSelection result: PickerResult) {
result.getImage { [weak self] (image, photoAsset, index) in
if let image = image {
let uploadKey = UploadManager.uploadViateImage(imageData: image.jpegData(compressionQuality: 1.0)! as NSData, progressBlock: {key, progress in
print("获取进度==>\(progress)")
}, successBlock: { [weak self] key,url in
self?.selectImageBlock?(image,key,url)
})
}else {
print("failed")
}
} completionHandler: { (images) in
}
}
}