CNLiveSelectHangYeController.swift
13.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
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
//
// CNLiveSelectHangYeController.swift
// metaCode
//
// Created by zx on 2024/7/23.
// 我的职业页面
import Foundation
import SnapKit
typealias SelectAddWorkZhiYeBlock = (_ zhiyeStr:String) -> Void
class CNLiveSelectHangYeController:CNLiveBaseViewController, UITableViewDataSource, UITableViewDelegate{
var isAddWorkJiLu = false//是否是添加工作记录
var selectAddWorkZhiYeBlock:SelectAddWorkZhiYeBlock?
var currSeleFirIndex = 0
var currSeleSecIndex = -1
lazy var firstDataArray :Array<MineAuthenticationsChildModel> = {
let dataArray = Array<MineAuthenticationsChildModel>()
return dataArray
}()
lazy var secDataArray :Array<MineAuthenticationsChildModel> = {
let dataArray = Array<MineAuthenticationsChildModel>()
return dataArray
}()
let kCNLiveHangYeFirCellIdentifier = "kCNLiveHangYeFirCellIdentifier"
let kCNLiveHangYeSecCellIdentifier = "kCNLiveHangYeSecCellIdentifier"
lazy var firstTableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.register(CNLiveHangYeFirCell.self, forCellReuseIdentifier: kCNLiveHangYeFirCellIdentifier)
tableView.backgroundColor = HexColor("#F6F7FB")
return tableView
}()
lazy var secTableView : UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
tableView.tableFooterView = UIView.init()
tableView.register(CNLiveHangYeSecCell.self, forCellReuseIdentifier: kCNLiveHangYeSecCellIdentifier)
tableView.backgroundColor = .white
return tableView
}()
lazy var bottomZhiNanWhiteView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = .white
return bottomNavView
}()
lazy var jiuYeZhiNanBtn: 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(tijiaoBtnAction), for: .touchUpInside)
return nextBtn
}()
override func viewDidLoad() {
super.viewDidLoad()
titleName = "我的职业"
navigationBarHidden = false
self.view.addSubview(self.firstTableView)
self.firstTableView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.equalToSuperview()
make.height.equalToSuperview().offset(-KNavigationHeight-60)
make.width.equalTo(adapt_length(length: 107))
}
self.view.addSubview(self.secTableView)
self.secTableView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.right.equalToSuperview()
make.height.equalToSuperview().offset(-KNavigationHeight-60)
make.left.equalTo(self.firstTableView.snp.right)
}
self.view.addSubview(self.bottomZhiNanWhiteView)
self.bottomZhiNanWhiteView.snp.makeConstraints { make in
make.top.equalTo(self.firstTableView.snp.bottom)
make.bottom.left.right.equalToSuperview()
}
self.bottomZhiNanWhiteView.addSubview(self.jiuYeZhiNanBtn)
self.jiuYeZhiNanBtn.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.top.equalTo(10)
make.height.equalTo(40)
}
let vsid = UserInfoManager.shared.userInfo.currentUser?.vsid ?? ""
let sid = UserInfoManager.shared.userInfo.uid
self.getHangYeData(vsid: vsid, sid: sid)
}
deinit {
}
@objc func tijiaoBtnAction(){
if self.isAddWorkJiLu{
let firModel = self.firstDataArray[self.currSeleFirIndex]
let secModel = self.secDataArray[self.currSeleSecIndex]
let hangYeStr = firModel.name+"·"+secModel.name
self.selectAddWorkZhiYeBlock?(hangYeStr)
self.navigationController?.viewControllers.forEach({ item in
if (item.isKind(of: CNLiveVitaeAddWorkController.self)) {
self.navigationController?.popToViewController(item, animated: true)
}
})
}else{
let isRealChengNuo = self.getRealChengNuo()
if isRealChengNuo == false{
//弹出承诺弹窗
self.show17Alert()
}else{
//确认后返回到数字资产页面 接口变更行业 变更为对应行业
self.popZiChanController()
}
}
}
// MARK: - 获取行业数据
func getHangYeData(vsid:String,sid:String){
CNLiveMineViewModel.requestsIndustryInfo(channelId: "", type: "2", sid: sid, vsid: vsid) { result, respStatue in
if respStatue == .success{
if let res = result as? [MineAuthenticationsChildModel]{
//添加每个MineAuthenticationsBaseModel到self.dataArray对应的 频道列表model里
if res.count > 0{
self.firstDataArray = res
self.secDataArray = res[0].child
self.firstTableView.reloadData()
self.secTableView.reloadData()
self.currSeleFirIndex = 0
self.currSeleSecIndex = -1
}else{
//没有行业列表 ,提示暂无内容
}
}
}else{
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == self.firstTableView{
return self.firstDataArray.count
}else{
return self.secDataArray.count
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if tableView == self.firstTableView{
//fir
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveHangYeFirCellIdentifier) as? CNLiveHangYeFirCell
else {
let cell = CNLiveHangYeFirCell()
return cell
}
let authModel = self.firstDataArray[indexPath.row]
cell.authModel = authModel
if self.currSeleFirIndex == indexPath.row{
cell.isSelect = true
}else{
cell.isSelect = false
}
return cell
}else{
//sec
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveHangYeSecCellIdentifier) as? CNLiveHangYeSecCell
else {
let cell = CNLiveHangYeSecCell()
return cell
}
let authModel = self.secDataArray[indexPath.row]
cell.authModel = authModel
if self.currSeleSecIndex == indexPath.row{
cell.isSelect = true
}else{
cell.isSelect = false
}
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView == self.firstTableView{
self.currSeleFirIndex = indexPath.row
self.currSeleSecIndex = -1
self.secDataArray = self.firstDataArray[indexPath.row].child
self.firstTableView.reloadData()
self.secTableView.reloadData()
}else{
self.currSeleSecIndex = indexPath.row
self.secTableView.reloadData()
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
50
}
func popZiChanController(){
if let userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
let jianli_city = userDic["jianli_city"] as? String
let jianli_vitaeId = userDic["jianli_vitaeId"] as? String
let vsid = userDic["vsid"] as? String
let jianli_profession = userDic["jianli_profession"] as? String ?? ""
let jianli_professionId = userDic["jianli_professionId"] as? String
let jianli_icon = userDic["jianli_icon"] as? String ?? ""
let jianli_phone = userDic["jianli_phone"] as? String ?? ""
let jianli_selfIntroduction = userDic["jianli_selfIntroduction"] as? String
let jianli_workTime = userDic["jianli_workTime"] as? String
let jianli_showAge = userDic["jianli_showAge"] as? Bool ?? false
let jianli_showAddress = userDic["jianli_showAddress"] as? Bool ?? false
let jianli_showAwards = userDic["jianli_showAwards"] as? Bool ?? false
let jianli_showPhone = userDic["jianli_showPhone"] as? Bool ?? false
let jianli_updateTime = userDic["jianli_updateTime"] as? String ?? ""
let firModel = self.firstDataArray[self.currSeleFirIndex]
let secModel = self.secDataArray[self.currSeleSecIndex]
let hangYeStr = firModel.name+"·"+secModel.name
CNLiveVitaeViewModel.saveVitae(city: jianli_city ?? "", icon: jianli_icon, isSave: false, id: jianli_vitaeId ?? "", phone: jianli_phone, profession: hangYeStr, professionId: String(format: "%d", secModel.industryId), selfIntroduction: jianli_selfIntroduction ?? "", showAddress: jianli_showAddress, showAge: jianli_showAge, showAwards: jianli_showAwards, showPhone:jianli_showPhone, updateTime: jianli_updateTime, vsid: vsid ?? "", workTime: jianli_workTime ?? ""){ result, respStatue in
if respStatue == .success{
self.navigationController?.viewControllers.forEach({ item in
if (item.isKind(of: CNLiveDigitalResumeController.self)) {
self.navigationController?.popToViewController(item, animated: true)
}
})
}
}
}else{
let tempDic = NSMutableDictionary()
UserDefaults.standard.setValue(tempDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
}
}
// MARK: - Alert弹窗
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.saveRealChengNuo()
self.hiden17Alert()
self.popZiChanController()
}
func saveRealChengNuo(){
if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
userDic.updateValue(true, forKey: "hangYeChengNuo")
UserDefaults.standard.setValue(userDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
}else{
let tempDic = NSMutableDictionary()
UserDefaults.standard.setValue(tempDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
}
}
func getRealChengNuo()->Bool{
if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
if let isChengNuo = userDic["hangYeChengNuo"] as? Bool{
if isChengNuo == true{
return true
}else{
return false
}
}else{
return false
}
}else{
let tempDic = NSMutableDictionary()
UserDefaults.standard.setValue(tempDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
return false
}
}
@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-120)
make.height.equalTo((KSreenWidth-120)*330/390)
}
self.alertBgImgView.image = UIImage(named: "mine_chengnuo")
}
func hiden17Alert(){
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.removeFromSuperview()
}
})
}
}