CNLiveDigitalAssetsController.swift
7.34 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
//
// CNLiveDigitalAssetsController.swift
// metaCode
//
// Created by zx on 2024/6/17.
// 我的数字资产页面
import Foundation
class CNLiveDigitalAssetsController:CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate{
var certificatesArr = [CNLiveVitaeCertificatesModel]()
lazy var nextBtn: UIButton = {
let nextBtn = UIButton(type: .custom)
nextBtn.setTitle("培训就业指南", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.titleLabel?.font = Font_17
nextBtn.backgroundColor = HexColor("#1961FE")
nextBtn.layer.cornerRadius = 22
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(nextBtnAction), for: .touchUpInside)
return nextBtn
}()
let kCNLiveDigitalFirstCellIdentifier = "kCNLiveDigitalFirstCellIdentifier"
let kCNLiveDigitalSecCellIdentifier = "kCNLiveDigitalSecCellIdentifier"
let kCNLiveDigitalThreeCellIdentifier = "kCNLiveDigitalThreeCellIdentifier"
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(CNLiveDigitalFirstCell.self, forCellReuseIdentifier: kCNLiveDigitalFirstCellIdentifier)
tableView.register(CNLiveDigitalSecCell.self, forCellReuseIdentifier: kCNLiveDigitalSecCellIdentifier)
tableView.register(CNLiveDigitalThreeCell.self, forCellReuseIdentifier: kCNLiveDigitalThreeCellIdentifier)
return tableView
}()
lazy var dataArray: NSMutableArray = {
var dataArray = NSMutableArray()
return dataArray
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.loadData()
}
override func viewDidLoad() {
super.viewDidLoad()
navigationBarHidden = false
titleName = "元码数字认证"
self.initUI()
// self.loadData()
}
func initUI(){
//背景图
let layerView = UIView()
layerView.frame = CGRect(x: 0, y: KNavigationHeight, width:KSreenWidth, height: adapt_length(length: 234))
// fillCode
let bgLayer1 = CAGradientLayer()
bgLayer1.colors = [UIColor(red: 0.16, green: 0.45, blue: 0.99, alpha: 1).cgColor, UIColor(red: 0.96, green: 0.96, blue: 0.98, alpha: 1).cgColor]
bgLayer1.locations = [0, 1]
bgLayer1.frame = layerView.bounds
bgLayer1.startPoint = CGPoint(x: 0.5, y: 0)
bgLayer1.endPoint = CGPoint(x: 1, y: 1)
layerView.layer.addSublayer(bgLayer1)
view.addSubview(layerView)
view.addSubview(self.tableView)
self.tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(KNavigationHeight)
make.bottom.equalToSuperview().offset(adapt_length(length: -59))
}
self.tableView.backgroundColor = .clear
self.view.addSubview(self.nextBtn)
self.nextBtn.snp.makeConstraints { make in
make.top.equalTo(self.tableView.snp.bottom).offset(adapt_length(length: 10))
make.height.equalTo(adapt_length(length: 44))
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
}
}
func loadData(){
CNLiveMineViewModel.requestsGETAuthInfoList(page: 1) { [weak self] result, respStatue in
if respStatue == .success {
let listBaseModel = result as! MineAuthListBaseModel
if self != nil{
var arr = Array<MineAuthListModel>()
listBaseModel.list.forEach { listMdl in
if listMdl.userStatus == 1{
arr.insert(listMdl, at: 0)
}else{
arr.append(listMdl)
}
}
self!.dataArray.removeAllObjects()
self!.dataArray.addObjects(from: arr)
self!.dataArray.add(MineAuthListModel())//加号
self!.tableView.reloadData()
}
self!.getCetList()
}else {
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveDigitalFirstCellIdentifier) as? CNLiveDigitalFirstCell
else {
let cell = CNLiveDigitalFirstCell()
return cell
}
cell.digitalFirstChangePersonBlock = {
self.loadData()
}
return cell
}else if indexPath.row == 1{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveDigitalSecCellIdentifier) as? CNLiveDigitalSecCell
else {
let cell = CNLiveDigitalSecCell()
cell.digitalListModels = self.dataArray as? [MineAuthListModel]
return cell
}
cell.digitalListModels = self.dataArray as? [MineAuthListModel]
return cell
}else{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveDigitalThreeCellIdentifier) as? CNLiveDigitalThreeCell
else {
let cell = CNLiveDigitalThreeCell()
return cell
}
cell.certificatesArr = self.certificatesArr
return cell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0{
return adapt_length(length: 121+20)
}else if indexPath.row == 1{
let cellH:CGFloat = adapt_length(length: 152+15)
if self.dataArray.count == 0{
return cellH
}else{
let hang:CGFloat = CGFloat((self.dataArray.count-1)/3+1)
return adapt_length(length: 53)+100*hang+15
}
}else{
if self.certificatesArr.count > 0{
let hang:CGFloat = CGFloat((self.certificatesArr.count-1)/3+1)
let imgW:CGFloat = CGFloat((KSreenWidth-80-30)/3.0)
let imgH:CGFloat = 101*imgW/85.0
return 15+125+(imgH+10)*hang-10+92
}else{
return 15+193+72+15
}
}
}
deinit {
}
@objc func nextBtnAction(){
showMessage(message: "此功能对您暂未开放")
}
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.certificatesArr = res
self.tableView.reloadData()
}
}else{
showMessage(message: "数据异常")
}
}
}
}