CNLiveDigitalResumeController.swift
11.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
//
// CNLiveDigitalResumeController.swift
// metaCode
//
// Created by zx on 2024/7/11.
// 数字简历页面
import Foundation
///数字简历页面类型
enum CNLiveResumeType {
///默认状态
case normal
///我的简历
case mineResume
///预览简历
case previewResume
}
class CNLiveDigitalResumeController:CNLiveBaseViewController,UITableViewDataSource, UITableViewDelegate{
var resumeType:CNLiveResumeType = .normal
var certificatesCount:Int = 0//证书数量
//简历model
var vitaeModel:CNLiveVitaeModel?
lazy var moreNavBtn: UIButton = {
let moreNavBtn = UIButton(type: .custom)
moreNavBtn.frame = CGRect(x: 0, y: KStatusBarHeight, width: KNavigationHeight-KStatusBarHeight, height: KNavigationHeight-KStatusBarHeight)
moreNavBtn.backgroundColor = .clear
moreNavBtn.setImage(UIImage(named: "web_more"), for: .normal)
moreNavBtn.addTarget(self, action: #selector(moreNavBtnAction), for: .touchUpInside)
return moreNavBtn
}()
lazy var dataArray :NSMutableArray = {
let dataArray = NSMutableArray()
return dataArray
}()
let kCNLiveDigitalResumeCellIdentifier = "kCNLiveDigitalResumeCellIdentifier"
let kCNLiveDigitalResumeSecCellIdentifier = "kCNLiveDigitalResumeSecCellIdentifier"
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(CNLiveDigitalResumeCell.self, forCellReuseIdentifier: kCNLiveDigitalResumeCellIdentifier)
tableView.register(CNLiveDigitalResumeSecCell.self, forCellReuseIdentifier: kCNLiveDigitalResumeSecCellIdentifier)
tableView.backgroundColor = .clear
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("TT互联网行业培训就业指南", for: .normal)
nextBtn.setTitleColor(.white, for: .normal)
nextBtn.backgroundColor = HexColor("#1961FE")
nextBtn.layer.cornerRadius = 20
nextBtn.clipsToBounds = true
nextBtn.addTarget(self, action: #selector(jiuYeZhiNanBtnAction), for: .touchUpInside)
return nextBtn
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.getVitae()
self.getCetList()
}
override func viewDidLoad() {
super.viewDidLoad()
titleName = "数字简历"
navigationBarHidden = false
self.view.backgroundColor = HexColor("#F5F6FB")
self.rightNavBtns = [self.moreNavBtn]
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.jiuYeZhiNanBtn)
self.jiuYeZhiNanBtn.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.top.equalTo(10)
make.height.equalTo(40)
}
// self.getVitae()
}
deinit {
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveDigitalResumeCellIdentifier) as? CNLiveDigitalResumeCell
else {
let cell = CNLiveDigitalResumeCell()
return cell
}
cell.certificatesCount = self.certificatesCount
if self.vitaeModel?.vitae?.id ?? 0 > 0{
cell.vitaeModel = self.vitaeModel!
}
return cell
}else{
guard let cell = tableView.dequeueReusableCell(withIdentifier: kCNLiveDigitalResumeSecCellIdentifier) as? CNLiveDigitalResumeSecCell
else {
let cell = CNLiveDigitalResumeSecCell()
return cell
}
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0{
return 450+adapt_length(length: 86)
}else{
return adapt_length(length: 273+471+54.5)
}
}
@objc func moreNavBtnAction(){
print("moreNavBtnAction")
}
@objc func jiuYeZhiNanBtnAction(){
self.show17Alert()
}
// MARK: - 获取证书数量
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? [CNLiveVitaeCertificateModel]{
self.certificatesCount = res.count
self.tableView.reloadData()
}
}else{
showMessage(message: "数据异常")
}
}
}
// MARK: - 获取简历数据
func getVitae(){
CNLiveVitaeViewModel.getVitae(vsid: UserInfoManager.shared.userInfo.currentUser?.vsid ?? "", type: 1) { result, status in
if status == .success{
if let model = result as? CNLiveVitaeModel{
if model.vitae == nil{
//没有简历-保存简历
self.saveUpdateVitae(isSave: true)
}else{
//有简历-刷新页面
self.vitaeModel = model
self.tableView.reloadData()
self.saveViateModel()
}
}else{
}
}
}
}
func saveUpdateVitae(isSave:Bool){
CNLiveVitaeViewModel.saveVitae(city: "", icon: "", isSave: isSave, id: "0", phone: "", profession: "", professionId: "0", selfIntroduction: "", showAddress: true, showAge: true, showAwards: true, showPhone: true, updateTime: "", vsid: UserInfoManager.shared.userInfo.currentUser?.vsid ?? "", workTime: "") { result, status in
if status == .success{
}
}
/**
{
"city": "",
"icon": "",
"id": 0,
"phone": "",
"profession": "",
"professionId": 0,
"selfIntroduction": "",
"showAddress": true,
"showAge": true,
"showAwards": true,
"showPhone": true,
"updateTime": "",
"vsid": 9,
"workTime": ""
}
*/
}
func saveViateModel(){
if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
userDic.updateValue(String(format: "%d", self.vitaeModel!.vitae?.id ?? 0), forKey: "jianli_vitaeId")
userDic.updateValue(String(format: "%d", self.vitaeModel!.vitae?.vsid ?? 0), forKey: "vsid")
userDic.updateValue(self.vitaeModel!.vitae?.city ?? "", forKey: "jianli_city")
userDic.updateValue(self.vitaeModel!.vitae?.profession ?? "", forKey: "jianli_profession")
userDic.updateValue(self.vitaeModel!.vitae?.professionId ?? "", forKey: "jianli_professionId")
userDic.updateValue(self.vitaeModel!.vitae?.icon ?? "", forKey: "jianli_icon")
userDic.updateValue(self.vitaeModel!.vitae?.phone ?? "", forKey: "jianli_phone")
userDic.updateValue(self.vitaeModel!.vitae?.selfIntroduction ?? "", forKey: "jianli_selfIntroduction")
userDic.updateValue(self.vitaeModel!.vitae?.workTime ?? "", forKey: "jianli_workTime")
userDic.updateValue(self.vitaeModel!.vitae?.showAge ?? false, forKey: "jianli_showAge")
userDic.updateValue(self.vitaeModel!.vitae?.showAddress ?? false, forKey: "jianli_showAddress")
userDic.updateValue(self.vitaeModel!.vitae?.showAwards ?? false, forKey: "jianli_showAwards")
userDic.updateValue(self.vitaeModel!.vitae?.updateTime ?? "", forKey: "jianli_updateTime")
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()
}
}
// 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.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()
}
})
}
}