CNLiveMineAuthFormViewController.swift
14.3 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
//
// CNLiveMineAuthFormViewController.swift
// metaCode
//
// Created by open on 2024/1/23.
//
import Foundation
import UIKit
import EmptyDataSet_Swift
class CNLiveMineAuthFormViewController: CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource,EmptyDataSetSource, EmptyDataSetDelegate {
let kMIneBodyAuthFormViewCellIdentifier = "kMIneBodyAuthFormViewCellIdentifier"
lazy var tableView: UITableView = {
let tableView = UITableView.init(frame: .zero, style: .grouped)
tableView.delegate = self
tableView.dataSource = self
tableView.emptyDataSetSource = self
tableView.emptyDataSetDelegate = self
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsVerticalScrollIndicator = false
tableView.showsHorizontalScrollIndicator = false
tableView.register(MineAuthFormTableViewCell.self, forCellReuseIdentifier: kMIneBodyAuthFormViewCellIdentifier)
return tableView
}()
lazy var dataArray: NSMutableArray = {
let array = NSMutableArray.init()
if _listModel.userAuth {
}else{
let dict03 = ["back":"mine_form_auth_btn_persion","icon":"mine_form_auth_btn_persion_icon","name":"个人认证","desc":"适合个人创作者、行业专家、自媒体领域"]
let dict01 = ["back":"mine_form_auth_btn_formal_larg","icon":"mine_form_auth_btn_enterprise_icon","name":"企业认证","desc":"适合企业、个体工商户"]
let dict02 = ["back":"mine_form_auth_btn_formal_larg","icon":"mine_form_auth_btn_agency_icon","name":"机构认证","desc":"适合国家机构、社会组织、高校等"]
let temp_array = NSMutableArray()
temp_array.add(dict01)
temp_array.add(dict02)
temp_array.add(dict03)
array.add(temp_array as! [Dictionary<String,String>])
}
return array
}()
var _listModel: StandListModel!
init(listModel:StandListModel) {
super.init(nibName:nil, bundle:nil)
_listModel = listModel
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
navigationBarHidden = false
titleName = "元码官方认证"
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(get_system_tabbar_height() - get_system_tabbar_ui_height())
}
}
func numberOfSections(in tableView: UITableView) -> Int {
return dataArray.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: kMIneBodyAuthFormViewCellIdentifier) as? MineAuthFormTableViewCell else {
return MineAuthFormTableViewCell()
}
cell.clickBlock = {[weak self] view in
guard let self = self else { return }
showLoading(message: "")
let titleLabel = view.viewWithTag(1000) as! UILabel
if titleLabel.text == "个人认证" {
CNLiveMineViewModel.requestsStandInfo(identityId: "\(_listModel.id)", type: .nodate, authType: .person) {[self] result, respStatue in
if respStatue == .success {
let model = (result as! [MineStandInfoModel]).first
if model?.inputType == 17 || model == nil {
showMessage(message: "此权限对您暂未开放,请先到首页学习成长")
return
}
self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: self._listModel, authType: .person), animated: true)
}
}
}
if titleLabel.text == "企业认证" {
CNLiveMineViewModel.requestsStandInfo(identityId: "\(_listModel.id)", type: .nodate, authType: .enterprise) {[self] result, respStatue in
if respStatue == .success {
let model = (result as! [MineStandInfoModel]).first
if model?.inputType == 17 || model == nil {
showMessage(message: "此权限对您暂未开放,请先到首页学习成长")
return
}
self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: self._listModel, authType: .enterprise), animated: true)
}
}
}
if titleLabel.text == "机构认证" {
CNLiveMineViewModel.requestsStandInfo(identityId: "\(_listModel.id)", type: .nodate, authType: .agency) {[self] result, respStatue in
if respStatue == .success {
let model = (result as! [MineStandInfoModel]).first
if model?.inputType == 17 || model == nil {
showMessage(message: "此权限对您暂未开放,请先到首页学习成长")
return
}
self.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: self._listModel, authType: .agency), animated: true)
}
}
}
}
let obj = dataArray[indexPath.section]
if obj is Dictionary<String, String> {
let dict = obj as! Dictionary<String, String>
cell.mainView.image = UIImage(named: dict["back"]! as String)
cell.headerImageView.image = UIImage(named: dict["icon"]! as String)
cell.titleLabel.text = dict["name"]! as String
cell.descLabel.text = dict["desc"]! as String
cell.whiteView01.isHidden = true
}
if obj is [Dictionary<String,String>] {
cell.whiteView01.isHidden = false
let dict01 = (obj as! Array<Dictionary<String, String>>).first
cell.mainView.image = UIImage(named: dict01!["back"]! as String)
cell.headerImageView.image = UIImage(named: dict01!["icon"]! as String)
cell.titleLabel.text = dict01!["name"]! as String
cell.descLabel.text = dict01!["desc"]! as String
let dict02 = (obj as! Array<Dictionary<String, String>>).last
cell.headerImageView01.image = UIImage(named: dict02!["icon"]! as String)
cell.titleLabel01.text = dict02!["name"]! as String
cell.descLabel01.text = dict02!["desc"]! as String
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let obj = dataArray[indexPath.section]
if obj is Dictionary<String, String> {
return adapt_length(length: 190)
}
if obj is [Dictionary<String,String>] {
return adapt_length(length: 280)
}
return adapt_length(length: 0.01)
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return adapt_length(length: 10)
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return adapt_length(length: 10)
}
}
extension CNLiveMineAuthFormViewController {
func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
return UIImage(named: "mine_list_source_unusual_empty")
}
func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
return NSAttributedString(string: "您已添加此身份,请直接使用", attributes: [.font: Font_17,.foregroundColor: HexColor("#666666")!])
}
}
typealias clickWithClickBlock = (_ view: UIView) -> Void
class MineAuthFormTableViewCell: UITableViewCell {
lazy var mainView: UIImageView = {
let view = UIImageView.init()
view.backgroundColor = .white
view.contentMode = .scaleAspectFill
view.layer.cornerRadius = adapt_length(length: 10)
view.layer.masksToBounds = true
return view
}()
lazy var whiteView: UIView = {
let view = UIView.init()
view.backgroundColor = .white
view.layer.masksToBounds = true
view.layer.cornerRadius = adapt_length(length: 10)
view.isUserInteractionEnabled = true
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickWithWhiteAction)))
return view
}()
lazy var headerImageView: UIImageView = {
let headerImageView = UIImageView.init()
headerImageView.backgroundColor = .white
headerImageView.contentMode = .scaleAspectFill
headerImageView.layer.masksToBounds = true
return headerImageView
}()
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.tag = 1000
titleLabel.textColor = HexColor("#333333")
titleLabel.font = semibold_adapt_font(pointSize: 16)
return titleLabel
}()
lazy var descLabel: UILabel = {
let descLabel = UILabel.init()
descLabel.textColor = HexColor("#999999")
descLabel.font = regular_adapt_font(pointSize: 14)
return descLabel
}()
lazy var whiteView01: UIView = {
let view = UIView.init()
view.backgroundColor = .white
view.isHidden = true
view.layer.masksToBounds = true
view.layer.cornerRadius = adapt_length(length: 10)
view.isUserInteractionEnabled = true
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickWithWhite01Action)))
return view
}()
lazy var headerImageView01: UIImageView = {
let headerImageView = UIImageView.init()
headerImageView.backgroundColor = .white
headerImageView.contentMode = .scaleAspectFill
headerImageView.layer.masksToBounds = true
return headerImageView
}()
lazy var titleLabel01: UILabel = {
let titleLabel = UILabel.init()
titleLabel.tag = 1000
titleLabel.textColor = HexColor("#333333")
titleLabel.font = semibold_adapt_font(pointSize: 16)
return titleLabel
}()
lazy var descLabel01: UILabel = {
let descLabel = UILabel.init()
descLabel.textColor = HexColor("#999999")
descLabel.font = regular_adapt_font(pointSize: 12)
return descLabel
}()
var clickBlock: clickWithClickBlock!
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .clear
backgroundColor = .clear
selectionStyle = .none
contentView.addSubview(mainView)
mainView.snp.makeConstraints { make in
make.center.equalToSuperview()
make.top.left.equalToSuperview().offset(10)
make.bottom.right.equalToSuperview().offset(-10)
}
contentView.addSubview(whiteView)
whiteView.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-adapt_length(length: 20))
make.left.equalToSuperview().offset(adapt_length(length: 30))
make.right.equalToSuperview().offset(-adapt_length(length: 30))
make.height.equalTo(adapt_length(length: 80))
}
whiteView.addSubview(headerImageView)
headerImageView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(adapt_length(length: 5))
make.size.equalTo(adapt_length(length: 70))
}
whiteView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(headerImageView.snp.top).offset(adapt_length(length: 10))
make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10))
make.right.equalToSuperview().offset(-adapt_length(length: 10))
}
whiteView.addSubview(descLabel)
descLabel.snp.makeConstraints { make in
make.bottom.equalTo(headerImageView.snp.bottom).offset(-adapt_length(length: 10))
make.left.equalTo(headerImageView.snp.right).offset(adapt_length(length: 10))
make.right.equalToSuperview().offset(-adapt_length(length: 10))
}
contentView.addSubview(whiteView01)
whiteView01.snp.makeConstraints { make in
make.bottom.equalTo(whiteView.snp.top).offset(-adapt_length(length: 10))
make.left.equalToSuperview().offset(adapt_length(length: 30))
make.right.equalToSuperview().offset(-adapt_length(length: 30))
make.height.equalTo(adapt_length(length: 80))
}
whiteView01.addSubview(headerImageView01)
headerImageView01.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(adapt_length(length: 5))
make.size.equalTo(adapt_length(length: 70))
}
whiteView01.addSubview(titleLabel01)
titleLabel01.snp.makeConstraints { make in
make.top.equalTo(headerImageView01.snp.top).offset(adapt_length(length: 10))
make.left.equalTo(headerImageView01.snp.right).offset(adapt_length(length: 10))
make.right.equalToSuperview().offset(-adapt_length(length: 10))
}
whiteView01.addSubview(descLabel01)
descLabel01.snp.makeConstraints { make in
make.bottom.equalTo(headerImageView01.snp.bottom).offset(-adapt_length(length: 10))
make.left.equalTo(headerImageView01.snp.right).offset(adapt_length(length: 10))
make.right.equalToSuperview().offset(-adapt_length(length: 10))
}
}
@objc func clickWithWhiteAction() {
self.clickBlock(whiteView)
}
@objc func clickWithWhite01Action() {
self.clickBlock(whiteView01)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}