CNLiveIdentityRepositoryController.swift
14.8 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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
//
// CNLiveIdentityRepositoryController.swift
// metaCode
//
// Created by zx on 2024/6/24.
// 身份大库 页面
import Foundation
import SnapKit
class CNLiveIdentityRepositoryController:CNLiveBaseViewController,UITableViewDataSource,UITableViewDelegate{
var currentSeleIndex = -1
var currentSeleCollectionIndex = -1
var channelId:String = "0"
var currCollectMdl:MineAuthenticationsChildIdentitiesModel?
//2级行业数组
lazy var dataArray :NSMutableArray = {
let dataArray = NSMutableArray()
return dataArray
}()
//所有数据 ,1级行业数组
var totalFirstChildsArr = Array<MineAuthenticationsChildModel>()
let kCNLiveIdentityRespositoryCellIdentifier = "kCNLiveIdentityRespositoryCellIdentifier"
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(CNLiveIdentityResTableCell.self, forCellReuseIdentifier: kCNLiveIdentityRespositoryCellIdentifier)
tableView.backgroundColor = .clear
return tableView
}()
lazy var zhinanBtn: UIButton = {
let nextBtn = UIButton(type: .custom)
nextBtn.setTitle("就业指南", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.backgroundColor = HexColor("#1961FE")
nextBtn.layer.cornerRadius = 39.0/2
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(zhinanBtnAction), for: .touchUpInside)
return nextBtn
}()
lazy var bottomTotalView :UIView = {
let bottomNavView = UIView(frame: CGRect(x: 0, y: KSreenHeight-189, width: KSreenWidth, height: 189))
bottomNavView.backgroundColor = .white
bottomNavView.layer.cornerRadius = 16
bottomNavView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
// shadowCode
bottomNavView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
bottomNavView.layer.shadowOffset = CGSize(width: 0, height: 0)
bottomNavView.layer.shadowOpacity = 1
bottomNavView.layer.shadowRadius = 10
bottomNavView.addSubview(self.iconImgView)
self.iconImgView.addSubview(self.rightIconImgView)
bottomNavView.addSubview(self.seleTitleLabel)
bottomNavView.addSubview(self.tishiTitleLabel)
bottomNavView.addSubview(self.buXuanZeBtn)
bottomNavView.addSubview(self.xuanZeBtn)
return bottomNavView
}()
lazy var iconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: 20, y: 20, width: 50, height: 50))
iconImgView.contentMode = .scaleAspectFill
iconImgView.clipsToBounds = true
return iconImgView
}()
lazy var rightIconImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: self.iconImgView.width-15, y: self.iconImgView.height-15, width: 15, height: 15))
iconImgView.image = UIImage(named: "auth_selected")
return iconImgView
}()
lazy var seleTitleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(0, self.iconImgView.bottom+1, 90, 17))
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .center
titleLabel.font = BoldFont_12
return titleLabel
}()
lazy var tishiTitleLabel: UILabel = {
let titleLabel = UILabel.init(frame: CGRectMake(0, 107, 300, 21))
titleLabel.centerX = KSreenWidth / 2
titleLabel.textColor = HexColor("#999999")
titleLabel.textAlignment = .center
titleLabel.text = "身份选择后不可修改"
titleLabel.font = BoldFont_12
return titleLabel
}()
lazy var buXuanZeBtn: UIButton = {
let closeBtn = UIButton(type: .custom)
closeBtn.frame = CGRect(x: 15, y: 135, width: (KSreenWidth-30)/2, height: 39)
closeBtn.layer.cornerRadius = 21
closeBtn.layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]
closeBtn.layer.borderColor = HexColor("#1961FE")?.cgColor
closeBtn.layer.borderWidth = 0.45
closeBtn.backgroundColor = .white
closeBtn.setTitle("暂不选择", for: .normal)
closeBtn.setTitleColor(HexColor("#1961FE"), for: .normal)
closeBtn.titleLabel?.font = Font_17
closeBtn.addTarget(self, action: #selector(buXuanZeBtnAction), for: .touchUpInside)
return closeBtn
}()
lazy var xuanZeBtn: UIButton = {
let closeBtn = UIButton(type: .custom)
closeBtn.frame = CGRect(x: 15+(KSreenWidth-30)/2, y: 135, width: (KSreenWidth-30)/2, height: 39)
closeBtn.layer.cornerRadius = 21
closeBtn.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMaxXMaxYCorner]
// closeBtn.layer.borderColor = HexColor("#1961FE")?.cgColor
// closeBtn.layer.borderWidth = 0.45
closeBtn.backgroundColor = HexColor("#1961FE")
closeBtn.setTitle("选好了", for: .normal)
closeBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
closeBtn.titleLabel?.font = Font_17
closeBtn.addTarget(self, action: #selector(xuanZeBtnAction), for: .touchUpInside)
return closeBtn
}()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
navigationBarHidden = false
titleName = "教育培训"
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
let sid = UserInfoManager.shared.userInfo.uid
self.getAuthenticationsApi(vsid: vsid, sid: sid)
self.initUI()
let deleteNavBtn = UIButton(type: .custom)
deleteNavBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: 80, height: KNavigationHeight-KStatusBarHeight)
deleteNavBtn.backgroundColor = .clear
deleteNavBtn.setTitle("切换行业", for: .normal)
deleteNavBtn.setTitleColor(HexColor("#1961FE"), for: .normal)
deleteNavBtn.titleLabel?.font = Font_13
// deleteNavBtn.setImage(UIImage(named: "auth_shuaxin"), for: .normal)
// deleteNavBtn.setupButtonImageAndTitlePossitionWith(padding: 5, style: .right)
deleteNavBtn.addTarget(self, action: #selector(changeNavBtnClick), for: .touchUpInside)
self.rightNavBtns = [deleteNavBtn]
}
func initUI(){
self.view.addSubview(self.tableView)
self.tableView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(-59)
}
self.view.addSubview(self.zhinanBtn)
self.zhinanBtn.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-10)
make.height.equalTo(39)
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
}
self.view.addSubview(self.bottomTotalView)
self.bottomTotalView.isHidden = true
}
deinit {
}
func numberOfSections(in tableView: UITableView) -> Int {
1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.dataArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveIdentityRespositoryCellIdentifier) as? CNLiveIdentityResTableCell
else {
let cell = CNLiveIdentityResTableCell()
return cell
}
if self.currentSeleIndex == indexPath.row{
cell.tblCellIsSelect = true
}else{
cell.tblCellIsSelect = false
}
cell.currentSeleIndex = self.currentSeleCollectionIndex
let model = self.dataArray[indexPath.row] as! MineAuthenticationsChildModel
cell.childModel = model
cell.selectBlock = {[weak self] currCell,identitiesId in
if let idxPath = self?.tableView.indexPath(for: currCell){
self!.currentSeleIndex = idxPath.row
self!.currentSeleCollectionIndex = currCell.currentSeleIndex
self!.channelId = identitiesId
self!.tableView.reloadData()
let idMdl = currCell.threeArr[currCell.currentSeleIndex]
self!.currCollectMdl = idMdl
self!.iconImgView.kf.setImage(with: URL(string: idMdl.icon),placeholder: UIImage(named: "auth_shenfen"))
self!.seleTitleLabel.text = idMdl.name
self!.bottomTotalView.isHidden = false
self!.tishiTitleLabel.text = idMdl.name+"身份选择后不可修改"
}
}
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 161
}
@objc func changeNavBtnClick(){
var infoArr = Array<String>()
self.totalFirstChildsArr.forEach { childModel in
let childMdl = childModel
infoArr.append(childMdl.name)
}
MineStandListAlertView.showStandListView(infos: infoArr as NSArray,name: "行业切换", show_type: .string, isAddPerson: false) {text in
let seleText = text as? String
let tempArr = self.totalFirstChildsArr
tempArr.forEach({ userMdl in
if userMdl.name == seleText{
//找到1级行业
self.dataArray = NSMutableArray(array: userMdl.child)
self.tableView.reloadData()
self.titleName = userMdl.name
}
})
}
}
@objc func zhinanBtnAction(){
//弹窗
self.show17Alert()
}
let delegate = UIApplication.shared.delegate as! AppDelegate
/// 未认证-inputType17时弹窗背景图
lazy var alertBgImgView:UIImageView = {
let alertBgImgView:UIImageView = UIImageView()
alertBgImgView.tag = 20001
alertBgImgView.isUserInteractionEnabled = true
let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgImgViewClickAction))
alertBgImgView.addGestureRecognizer(ges)
return alertBgImgView
}()
lazy var alertBgView:UIView = {
let alertBgView:UIView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight))
alertBgView.backgroundColor = HexColor("#000000")
alertBgView.alpha = 0.6
alertBgView.isUserInteractionEnabled = true
alertBgView.tag = 20000
let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgViewClickAction))
alertBgView.addGestureRecognizer(ges)
return alertBgView
}()
// MARK: - 点击弹窗,按类型跳转
@objc func alertBgImgViewClickAction() {
self.hiden17Alert()
}
@objc func alertBgViewClickAction() {
//点击蒙版隐藏view
self.hiden17Alert()
}
//弹出弹窗
func show17Alert(){
delegate.window?.addSubview(self.alertBgView)
delegate.window?.addSubview(self.alertBgImgView)
alertBgImgView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KSreenWidth-80)
make.height.equalTo((KSreenWidth-80)*170.5/295)
}
self.alertBgImgView.image = UIImage(named: "auth_alert_unOpen")
}
func hiden17Alert(){
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.removeFromSuperview()
}
})
}
// MARK: - 暂不选择 按钮
@objc func buXuanZeBtnAction(){
self.bottomTotalView.isHidden = true
self.currentSeleIndex = -1
self.currentSeleCollectionIndex = -1
self.tableView.reloadData()
}
// MARK: - 选好了 按钮
@objc func xuanZeBtnAction(){
if self.currCollectMdl?.userAuth == 0{//正在审核
showMessage(message: "您已认证过该身份,不能重复认证")
return
}else if self.currCollectMdl?.userAuth == 1{//审核成功
//进入身份认证页面
self.bottomTotalView.isHidden = true
}else if self.currCollectMdl?.userAuth == -1{//审核失败
// showMessage(message: "审核失败")
self.bottomTotalView.isHidden = true
}else{
self.bottomTotalView.isHidden = true
}
if UserInfoManager.shared.userInfo.userMsgUsers?.verifyUsers.count ?? 0 > 0{
//实名认证过->身份管理页面
let listModel = StandListModel()
listModel.id = Int(self.currCollectMdl?.id ?? "0")!
listModel.name = ""
let vc = CNLiveDigitalRealManageController()
vc.listModel = listModel
self.navigationController?.pushViewController(vc, animated: true)
}else{
//未实名认证->实名认证
let vc = CNLiveRealNameAuthController()
vc.channelId = self.channelId
self.navigationController?.pushViewController(vc, animated: true)
}
}
//行业认证列表
func getAuthenticationsApi(vsid:String,sid:String)
{
showLoading(message: "")
CNLiveMineViewModel.requestsIndustryInfo(channelId: "", sid: sid, vsid: vsid) { result, respStatue in
if respStatue == .success{
if let res = result as? [MineAuthenticationsChildModel]{
//添加每个MineAuthenticationsBaseModel到self.dataArray对应的 频道列表model里
if res.count > 0{
//所有二级行业
var totalTwoChildsArr = Array<MineAuthenticationsChildModel>()
let twoChildModels = res.first
twoChildModels?.child.forEach { twoChildModel in
totalTwoChildsArr.append(twoChildModel)
}
self.totalFirstChildsArr = Array(res) as! [MineAuthenticationsChildModel]
self.dataArray = NSMutableArray(array: totalTwoChildsArr)
self.tableView.reloadData()
self.titleName = twoChildModels?.name ?? ""
}else{
//没有行业列表 ,提示暂无内容
// self.show17Alert()
}
}
}else{
}
}
}
}