CNLiveVitaeAddCertificateController.swift
6.96 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
//
// CNLiveVitaeAddCertificateController.swift
// metaCode
//
// Created by zx on 2024/7/26.
// 数字简历-添加证书页面
import Foundation
import SnapKit
class CNLiveVitaeAddCertificateController:CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate{
var isAddCerPhoto = true//true为增加证书图片 false为增加证书信息
var seleImage:UIImage?
var seleImageUrl:String = ""
lazy var dataArray :NSMutableArray = {
let dataArray = NSMutableArray()
return dataArray
}()
let kCNLiveVitaeCertificateAddPhotoCellIdentifier = "kCNLiveVitaeCertificateAddPhotoCellIdentifier"
let kCNLiveVitaeCertificateAddInfoCellIdentifier = "kCNLiveVitaeCertificateAddInfoCellIdentifier"
lazy var tableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.tableFooterView = UIView.init()
tableView.register(CNLiveVitaeCertificateAddPhotoCell.self, forCellReuseIdentifier: kCNLiveVitaeCertificateAddPhotoCellIdentifier)
tableView.register(CNLiveVitaeCertificateAddInfoCell.self, forCellReuseIdentifier: kCNLiveVitaeCertificateAddInfoCellIdentifier)
tableView.backgroundColor = .clear
return tableView
}()
lazy var bottomZhiNanWhiteView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = .white
return bottomNavView
}()
lazy var addCertificateBtn: UIButton = {
let nextBtn = UIButton(type: .custom)
nextBtn.setTitle("确认提交", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.backgroundColor = HexColor("#1961FE")
nextBtn.layer.cornerRadius = 20
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(addCertificateBtnAction), for: .touchUpInside)
return nextBtn
}()
lazy var chengNuoTitleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#B4B4B4")
titleLabel.textAlignment = .center
titleLabel.numberOfLines = 2
titleLabel.text = "我承诺以上所填写资料均完全真实,如被证实有虚假成分,本人愿意承担一切责任"
titleLabel.font = Font_12
return titleLabel
}()
override func viewDidLoad() {
super.viewDidLoad()
titleName = "个人证书"
navigationBarHidden = false
self.initUI()
}
deinit {}
func initUI(){
self.view.backgroundColor = HexColor("#F9F9F9")
self.view.addSubview(self.tableView)
self.tableView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.right.equalToSuperview()
make.height.equalToSuperview().offset(-KNavigationHeight-60-63)
}
self.view.addSubview(self.chengNuoTitleLabel)
self.chengNuoTitleLabel.snp.makeConstraints { make in
make.top.equalTo(self.tableView.snp.bottom).offset(15)
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.bottom.equalToSuperview().offset(-75)
}
self.view.addSubview(self.bottomZhiNanWhiteView)
self.bottomZhiNanWhiteView.snp.makeConstraints { make in
make.height.equalTo(60)
make.bottom.left.right.equalToSuperview()
}
self.bottomZhiNanWhiteView.isHidden = true
self.bottomZhiNanWhiteView.addSubview(self.addCertificateBtn)
self.addCertificateBtn.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.top.equalTo(10)
make.height.equalTo(40)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if self.isAddCerPhoto == true{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVitaeCertificateAddPhotoCellIdentifier) as? CNLiveVitaeCertificateAddPhotoCell
else {
let cell = CNLiveVitaeCertificateAddPhotoCell()
return cell
}
cell.selectImageBlock = { image,key,url in
self.isAddCerPhoto = false
self.tableView.reloadData()
self.seleImage = image
self.seleImageUrl = url
self.bottomZhiNanWhiteView.isHidden = false
}
return cell
}else{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVitaeCertificateAddInfoCellIdentifier) as? CNLiveVitaeCertificateAddInfoCell
else {
let cell = CNLiveVitaeCertificateAddInfoCell()
return cell
}
cell.uploadImage = self.seleImage
cell.tfReturnBlock = {
self.view.endEditing(true)
}
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if isAddCerPhoto == true{
return 351
}else{
return 620
}
}
//确认提交证书
@objc func addCertificateBtnAction(){
let cell = self.tableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! CNLiveVitaeCertificateAddInfoCell
//判断非空
if self.seleImage == nil{
showMessage(message: "请上传图片")
return
}
if cell.cerNameTF.text?.count == 0{
showMessage(message: "请填写证书名称")
return
}
if cell.cerNumberTF.text?.count == 0{
showMessage(message: "请填写资格证编号")
return
}
if cell.cerJiGouTF.text?.count == 0{
showMessage(message: "请填写发证机构")
return
}
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
//提交证书
CNLiveVitaeViewModel.saveCertificate(img: self.seleImageUrl, lv: cell.cerLevelTF.text ?? "", number: cell.cerNumberTF.text ?? "", organization: cell.cerJiGouTF.text ?? "", time: cell.cerTimeTF.text ?? "", title: cell.cerNameTF.text ?? "", uploadTime: "", validity: cell.cerYouXiaoTF.text ?? "", vsid: vsid){result, respStatue in
if respStatue == .success{
self.navigationController?.viewControllers.forEach({ item in
if (item.isKind(of: CNLiveVitaeVocationalCertificateController.self)) {
self.navigationController?.popToViewController(item, animated: true)
}
})
}
}
}
}