CNLiveDigitalResumePreViewMineJianJieController.swift
11.6 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
//
// CNLiveDigitalResumePreViewMineJianJieController.swift
// metaCode
//
// Created by zx on 2024/8/13.
// 数字简历-自我介绍页面
import Foundation
import SnapKit
import QMUIKit
class CNLiveDigitalResumePreViewMineJianJieController:CNLiveBaseViewController, QMUITextViewDelegate{
var introduce = ""
lazy var bgImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "mine_jianli_introduceBg")
return iconImgView
}()
lazy var yuanmaLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "自我介绍"
titleLabel.font = BoldFont_24
titleLabel.adjustsFontSizeToFitWidth=true
return titleLabel
}()
lazy var bottomDescLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#B4B4B4")
titleLabel.text = "请确保你本人的信息真实有效\n 上传虚假信息将对你的信用产生负面影响"
titleLabel.font = Font_13
titleLabel.textAlignment = .center
titleLabel.numberOfLines = 2
return titleLabel
}()
lazy var yuanmaDescLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "Introduce"
titleLabel.font = Font_16
return titleLabel
}()
lazy var addWorkBtn: 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(addWorkBtnAction), for: .touchUpInside)
return nextBtn
}()
lazy var textBgView :UIView = {
let bottomNavView = UIView()
bottomNavView.backgroundColor = .white
bottomNavView.layer.masksToBounds = true
bottomNavView.layer.cornerRadius = 12
return bottomNavView
}()
lazy var textView: QMUITextView = {
let textView = QMUITextView.init(frame: .zero)
textView.backgroundColor = HexColor("#FFFFFF")
textView.font = Font_15
textView.textColor = HexColor("#333333")
textView.placeholderColor = HexColor("#999999")
textView.placeholderMargins = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
textView.placeholder = "请输入自我介绍"
// textView.contentInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
textView.textAlignment = .left
textView.delegate = self
// textView.returnKeyType = .default
return textView
}()
lazy var huoJiangNumberLabel : UILabel = {
let numberLabel = UILabel.init()
numberLabel.text = "0/500"
numberLabel.textColor = .black
numberLabel.font = Font_15
numberLabel.textAlignment = .right
return numberLabel
}()
override func viewDidLoad() {
super.viewDidLoad()
navigationBarHidden = false
titleName = "自我介绍"
self.initUI()
if self.introduce.count > 0{
self.textView.text = self.introduce
self.huoJiangNumberLabel.text = "\(self.introduce.count)/500"
}
}
deinit {}
func initUI(){
self.view.backgroundColor = HexColor("#F9F9F9")
self.view.addSubview(self.bgImgView)
self.bgImgView.snp.makeConstraints { make in
make.top.equalTo(KNavigationHeight)
make.left.right.equalToSuperview()
make.height.equalTo(KSreenWidth*457/375)
}
self.bgImgView.addSubview(self.yuanmaLabel)
self.yuanmaLabel.snp.makeConstraints { make in
make.top.equalTo(59)
make.left.equalTo(30)
}
self.bgImgView.addSubview(self.yuanmaDescLabel)
self.yuanmaDescLabel.snp.makeConstraints { make in
make.top.equalTo(self.yuanmaLabel.snp.bottom).offset(5)
make.left.equalTo(30)
}
self.view.addSubview(self.bottomDescLabel)
self.bottomDescLabel.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.bottom.equalToSuperview().offset(-5)
make.height.equalTo(40)
}
self.view.addSubview(self.addWorkBtn)
self.addWorkBtn.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.bottom.equalTo(self.bottomDescLabel.snp.top).offset(-15)
make.height.equalTo(40)
}
self.view.addSubview(self.textBgView)
self.textBgView.snp.makeConstraints { make in
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.bottom.equalTo(self.addWorkBtn.snp.top).offset(-15)
make.top.equalTo(self.yuanmaDescLabel.snp.bottom).offset(42)
}
self.textBgView.addSubview(self.textView)
self.textView.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview().offset(-41)
make.top.equalTo(20)
}
self.textBgView.addSubview(self.huoJiangNumberLabel)
self.huoJiangNumberLabel.snp.makeConstraints { make in
make.width.equalTo(200)
make.bottom.equalToSuperview().offset(-21)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(21)
}
}
func textViewShouldEndEditing(_ textView: UITextView) -> Bool {
return self.textView.resignFirstResponder()
}
func textViewDidEndEditing(_ textView: UITextView) {
self.introduce = textView.text ?? ""
}
func textViewShouldReturn(_ textView: QMUITextView!) -> Bool {
self.introduce = textView.text ?? ""
return true
}
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return true
}
func textViewDidChange(_ textView: UITextView) {
let maxCount = 500
if textView.text.count > maxCount {
let selectRang = textView.markedTextRange
if let selectRang = selectRang {
let position = textView.position(from: (selectRang.start), offset: 0)
if position != nil {
return
}
}
let textContent = textView.text ?? ""
let textNum = textContent.count
if textNum > maxCount {
textView.text = string_prefix(index: maxCount, text: textContent)
}
}
self.huoJiangNumberLabel.text = "\(textView.text.count)/500"
}
private func string_prefix(index: Int, text: String) -> String {
if text.count <= index {
return text
} else {
let index = text.index(text.startIndex, offsetBy: index)
let str = text.prefix(upTo: index)
return String(str)
}
}
func saveJianJie(introduction:String){
if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
userDic.updateValue(introduction, forKey: "jianli_selfIntroduction")
UserDefaults.standard.setValue(userDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
self.updateViate(key: "jianli_selfIntroduction", value: introduction)
}else{
let tempDic = NSMutableDictionary()
UserDefaults.standard.setValue(tempDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
}
}
func updateViate(key:String,value:Any){
if let userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
var jianli_city = userDic["jianli_city"] as? String
if key == "jianli_city"{
jianli_city = (value as! String)
}
var jianli_vitaeId = userDic["jianli_vitaeId"] as? String
if key == "jianli_vitaeId"{
jianli_vitaeId = (value as! String)
}
var vsid = userDic["vsid"] as? String
if key == "vsid"{
vsid = (value as! String)
}
var jianli_profession = userDic["jianli_profession"] as? String ?? ""
if key == "jianli_profession"{
jianli_profession = value as! String
}
var jianli_professionId = userDic["jianli_professionId"] as? String
if key == "jianli_professionId"{
jianli_professionId = (value as! String)
}
var jianli_icon = userDic["jianli_icon"] as? String ?? ""
if key == "jianli_icon"{
jianli_icon = value as! String
}
var jianli_phone = userDic["jianli_phone"] as? String ?? ""
if key == "jianli_phone"{
jianli_phone = value as! String
}
var jianli_selfIntroduction = userDic["jianli_selfIntroduction"] as? String
if key == "jianli_selfIntroduction"{
jianli_selfIntroduction = (value as! String)
}
var jianli_workTime = userDic["jianli_workTime"] as? String
if key == "jianli_workTime"{
jianli_workTime = (value as! String)
}
var jianli_showAge = userDic["jianli_showAge"] as? Bool ?? false
if key == "jianli_showAge"{
jianli_showAge = value as! Bool
}
var jianli_showAddress = userDic["jianli_showAddress"] as? Bool ?? false
if key == "jianli_showAddress"{
jianli_showAddress = value as! Bool
}
var jianli_showAwards = userDic["jianli_showAwards"] as? Bool ?? false
if key == "jianli_showAwards"{
jianli_showAwards = value as! Bool
}
var jianli_showPhone = userDic["jianli_showPhone"] as? Bool ?? false
if key == "jianli_showPhone"{
jianli_showPhone = value as! Bool
}
var jianli_updateTime = userDic["jianli_updateTime"] as? String ?? ""
if key == "jianli_updateTime"{
jianli_updateTime = value as! String
}
CNLiveVitaeViewModel.saveVitae(city: jianli_city ?? "", icon: jianli_icon, isSave: false, id: jianli_vitaeId ?? "", phone: jianli_phone, profession: jianli_profession , professionId: jianli_professionId ?? "", 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?.popViewController(animated: true)
}
}
}else{
let tempDic = NSMutableDictionary()
UserDefaults.standard.setValue(tempDic, forKey: UserInfoManager.shared.userInfo.uid)
UserDefaults.standard.synchronize()
}
}
@objc func addWorkBtnAction(){
//提交
// if self.textView.text.count > 0{
self.saveJianJie(introduction:self.textView.text)
// }else{
// showMessage(message: "请输入自我介绍")
// }
}
}