CNLiveVitaeVocationalCertificateController.swift
4.7 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
//
// CNLiveVitaeVocationalCertificateController.swift
// metaCode
//
// Created by zx on 2024/7/25.
// 职业证书页面
import Foundation
import SnapKit
class CNLiveVitaeVocationalCertificateController:CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate{
// var currSeleIndex = 0
var currSeleCerId = ""
lazy var dataArray :NSMutableArray = {
let dataArray = NSMutableArray()
return dataArray
}()
let kCNLiveVocationalCertificateFirCellIdentifier = "kCNLiveVocationalCertificateFirCellIdentifier"
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(CNLiveVocationalCertificateFirCell.self, forCellReuseIdentifier: kCNLiveVocationalCertificateFirCellIdentifier)
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 cerListArr :Array<CNLiveVitaeCertificatesModel> = {
let dataArray = Array<CNLiveVitaeCertificatesModel>()
return dataArray
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.getCetList()
}
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)
}
self.view.addSubview(self.bottomZhiNanWhiteView)
self.bottomZhiNanWhiteView.snp.makeConstraints { make in
make.top.equalTo(self.tableView.snp.bottom)
make.bottom.left.right.equalToSuperview()
}
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 {
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveVocationalCertificateFirCellIdentifier) as? CNLiveVocationalCertificateFirCell
else {
let cell = CNLiveVocationalCertificateFirCell()
return cell
}
for (idx,mdl) in self.cerListArr.enumerated(){
let cerModel = mdl
if cerModel.id == self.currSeleCerId{
cell.currSeleIndex = idx
break
}
}
cell.cerListArr = self.cerListArr
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return adapt_length(length: 277)+326
}
@objc func addCertificateBtnAction(){
self.navigationController?.pushViewController(CNLiveVitaeAddCertificateController(), animated: true)
}
func getCetList(){
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
CNLiveVitaeViewModel.getCerList(vsid: vsid, page: 1, pageSize: 100){ result, respStatue in
if respStatue == .success{
if let res = result as? [CNLiveVitaeCertificatesModel]{
self.cerListArr = res
self.tableView.reloadData()
}
}else{
showMessage(message: "数据异常")
}
}
}
}