CNLiveDigitalResumeInfoController.swift 23.5 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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
//
//  CNLiveDigitalResumeInfoController.swift
//  metaCode
//
//  Created by zx on 2024/7/17.
//  数字简历信息页面

import Foundation
import SnapKit
import CoreLocation


class CNLiveDigitalResumeInfoController:CNLiveBaseViewController, UITextFieldDelegate,CLLocationManagerDelegate{
    let locationManager = CLLocationManager()

    lazy var topWhiteView :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = .white
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var yinsiTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#B4B4B4")
        titleLabel.text = "隐私设置(关闭后,对方将看不到该信息)"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()

    lazy var bottomWhiteView :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = .white
        bottomNavView.layer.cornerRadius = 9
        bottomNavView.clipsToBounds = true
        return bottomNavView
    }()
    lazy var weizhiTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "当前位置"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        return titleLabel
    }()
    lazy var weizhiRightTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "暂无定位信息"
        titleLabel.textAlignment = .right
        titleLabel.font = Font_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var weiZhiRightImgView :UIImageView = {
        let iconImgView = UIImageView()
        iconImgView.image = UIImage(named: "mine_header_message_gray_more")
        iconImgView.contentMode = .scaleAspectFit
        return iconImgView
    }()
    lazy var weiZhiTapView :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = .clear
        bottomNavView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(weiZhiTapAction)))
        return bottomNavView
    }()
    lazy var topLine1View :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var lianxiTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "联系电话"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var phoneTextFiled :UITextField = {
        let textFiled = UITextField()
        textFiled.textAlignment = .right
        textFiled.font = Font_15
        textFiled.attributedPlaceholder = NSAttributedString(string: "请输入", attributes: [.foregroundColor: HexColor("#B4B4B4")!])
        textFiled.textColor = HexColor("#333333")
        textFiled.delegate = self
        textFiled.returnKeyType = .done
        textFiled.clearButtonMode = .whileEditing
        return textFiled
    }()
    lazy var topLine2View :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var canjiaTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "参加工作时间"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var canjiaRightTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#B4B4B4")
        titleLabel.text = "请选择"
        titleLabel.textAlignment = .right
        titleLabel.font = Font_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var canjiaRightImgView :UIImageView = {
        let iconImgView = UIImageView()
        iconImgView.image = UIImage(named: "mine_header_message_gray_more")
        iconImgView.contentMode = .scaleAspectFit
        return iconImgView
    }()
    lazy var canjiaTapView :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = .clear
        bottomNavView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(canJiaTapAction)))
        return bottomNavView
    }()
    
    lazy var nianlingTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "展示我的年龄"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var nianLingSwitch: UISwitch = {
        let switchView = UISwitch.init()
        switchView.isOn = false
        switchView.onTintColor = .blue
        switchView.addTarget(self, action: #selector(nianLingSwitchAction), for: .valueChanged)
        return switchView
    }()
    lazy var phoneSwitch: UISwitch = {
        let switchView = UISwitch.init()
        switchView.isOn = false
        switchView.onTintColor = .blue
        switchView.addTarget(self, action: #selector(phoneSwitchAction), for: .valueChanged)
        return switchView
    }()
    lazy var weiZhiSwitch: UISwitch = {
        let switchView = UISwitch.init()
        switchView.isOn = false
        switchView.onTintColor = .blue
        switchView.addTarget(self, action: #selector(weiZhiSwitchAction), for: .valueChanged)
        return switchView
    }()
    lazy var huoJiangSwitch: UISwitch = {
        let switchView = UISwitch.init()
        switchView.isOn = false
        switchView.onTintColor = .blue
        switchView.addTarget(self, action: #selector(huoJiangSwitchAction), for: .valueChanged)
        return switchView
    }()

    lazy var bottomLine1View :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var phoneTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "展示我的手机号"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var bottomLine2View :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var zhanShiWeiZhiTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "展示我的位置"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    lazy var bottomLine3View :UIView = {
        let bottomNavView = UIView()
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var huoJiangTitleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.text = "展示我的获奖信息"
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_15
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        titleName = "数字简历信息"
        navigationBarHidden = false
        self.view.backgroundColor = HexColor("#F6F7FB")
        self.initUI()
        self.loadLocalData()
    }
    
    
    func initUI(){
        self.view.addSubview(self.topWhiteView)
        self.topWhiteView.snp.makeConstraints { make in
            make.top.equalTo(KNavigationHeight+15)
            make.left.equalTo(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(184)
        }
        self.topWhiteView.addSubview(self.weizhiTitleLabel)
        self.weizhiTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(15)
            make.width.equalTo(62)
            make.height.equalTo(21)
        }
        self.topWhiteView.addSubview(self.weizhiRightTitleLabel)
        self.weizhiRightTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.right.equalToSuperview().offset(-28)
            make.left.equalTo(self.weizhiTitleLabel.snp.right).offset(5)
        }
        self.topWhiteView.addSubview(self.weiZhiRightImgView)
        self.weiZhiRightImgView.snp.makeConstraints { make in
            make.width.height.equalTo(13)
            make.centerY.equalTo(self.weizhiRightTitleLabel.snp.centerY)
            make.left.equalTo(self.weizhiRightTitleLabel.snp.right)
        }
        self.topWhiteView.addSubview(self.topLine1View)
        self.topLine1View.snp.makeConstraints { make in
            make.top.equalTo(self.weizhiTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-15)
        }
        self.topWhiteView.addSubview(self.weiZhiTapView)
        self.weiZhiTapView.snp.makeConstraints { make in
            make.left.right.top.equalToSuperview()
            make.bottom.equalTo(self.topLine1View.snp.top)
        }
        self.topWhiteView.addSubview(self.lianxiTitleLabel)
        self.lianxiTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.topLine1View.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
        }
        self.topWhiteView.addSubview(self.phoneTextFiled)
        self.phoneTextFiled.snp.makeConstraints { make in
            make.centerY.equalTo(self.lianxiTitleLabel.snp.centerY)
            make.left.equalTo(self.lianxiTitleLabel.snp.right).offset(10)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(21)
        }
        self.topWhiteView.addSubview(self.topLine2View)
        self.topLine2View.snp.makeConstraints { make in
            make.top.equalTo(self.lianxiTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-15)
        }
        self.topWhiteView.addSubview(self.canjiaTitleLabel)
        self.canjiaTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.topLine2View.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
        }
        self.topWhiteView.addSubview(self.canjiaRightTitleLabel)
        self.canjiaRightTitleLabel.snp.makeConstraints { make in
            make.centerY.equalTo(self.canjiaTitleLabel.snp.centerY)
            make.right.equalToSuperview().offset(-28)
            make.left.equalTo(self.canjiaTitleLabel.snp.right).offset(5)
            make.height.equalTo(21)
        }
        self.topWhiteView.addSubview(self.canjiaRightImgView)
        self.canjiaRightImgView.snp.makeConstraints { make in
            make.width.height.equalTo(13)
            make.centerY.equalTo(self.canjiaRightTitleLabel.snp.centerY)
            make.left.equalTo(self.canjiaRightTitleLabel.snp.right)
        }
        self.topWhiteView.addSubview(self.canjiaTapView)
        self.canjiaTapView.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
            make.top.equalTo(self.topLine2View.snp.bottom)
        }
        
        self.view.addSubview(self.yinsiTitleLabel)
        self.yinsiTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.topWhiteView.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(self.topWhiteView.snp.left)
        }
        self.view.addSubview(self.bottomWhiteView)
        self.bottomWhiteView.snp.makeConstraints { make in
            make.top.equalTo(self.yinsiTitleLabel.snp.bottom).offset(adapt_length(length: 10))
            make.left.equalTo(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(246)
        }
        self.bottomWhiteView.addSubview(self.nianlingTitleLabel)
        self.nianlingTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.left.equalTo(15)
        }
        self.bottomWhiteView.addSubview(self.nianLingSwitch)
        self.nianLingSwitch.snp.makeConstraints { make in
            make.top.equalTo(20)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.bottomLine1View)
        self.bottomLine1View.snp.makeConstraints { make in
            make.top.equalTo(self.nianlingTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.phoneTitleLabel)
        self.phoneTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.bottomLine1View.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
        }
        self.bottomWhiteView.addSubview(self.phoneSwitch)
        self.phoneSwitch.snp.makeConstraints { make in
            make.top.equalTo(self.phoneTitleLabel.snp.top)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.bottomLine2View)
        self.bottomLine2View.snp.makeConstraints { make in
            make.top.equalTo(self.phoneTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.zhanShiWeiZhiTitleLabel)
        self.zhanShiWeiZhiTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.bottomLine2View.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
        }
        self.bottomWhiteView.addSubview(self.weiZhiSwitch)
        self.weiZhiSwitch.snp.makeConstraints { make in
            make.top.equalTo(self.zhanShiWeiZhiTitleLabel.snp.top)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.bottomLine3View)
        self.bottomLine3View.snp.makeConstraints { make in
            make.top.equalTo(self.zhanShiWeiZhiTitleLabel.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-15)
        }
        self.bottomWhiteView.addSubview(self.huoJiangTitleLabel)
        self.huoJiangTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(self.bottomLine3View.snp.bottom).offset(adapt_length(length: 20))
            make.left.equalTo(15)
        }
        self.bottomWhiteView.addSubview(self.huoJiangSwitch)
        self.huoJiangSwitch.snp.makeConstraints { make in
            make.top.equalTo(self.huoJiangTitleLabel.snp.top)
            make.right.equalToSuperview().offset(-15)
        }
    }
    
    func loadLocalData(){
        if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
            if let seleDay = userDic["selectDay"]{
                print(seleDay)
                //设置过工作日期
                self.canjiaRightTitleLabel.text = seleDay as? String
            }else{
                //没设置过工作日期
                self.canjiaRightTitleLabel.text = "请选择"
            }
            if let phone = userDic["phone"]{
                //设置过手机号
                self.phoneTextFiled.text = phone as? String
            }else{
                //没设置过手机号
                self.phoneTextFiled.text = ""
            }
            
            if let showAge = userDic["showAge"]{
                //设置展示年龄
                self.nianLingSwitch.isOn = showAge as! Bool
            }else{
                //没设置展示年龄
                self.nianLingSwitch.isOn = false
            }
            
            if let showPhone = userDic["showPhone"]{
                //设置展示手机号
                self.phoneSwitch.isOn = showPhone as! Bool
            }else{
                //没设置展示手机号
                self.phoneSwitch.isOn = false
            }
            
            if let showWeiZhi = userDic["showWeiZhi"]{
                //设置展示位置
                self.weiZhiSwitch.isOn = showWeiZhi as! Bool
            }else{
                //没设置展示位置
                self.weiZhiSwitch.isOn = false
            }
            
            if let showHuoJiang = userDic["showHuoJiang"]{
                //设置展示获奖
                self.huoJiangSwitch.isOn = showHuoJiang as! Bool
            }else{
                //没设置展示获奖
                self.huoJiangSwitch.isOn = false
            }
            
            if let cityStreet = userDic["cityStreet"]{
                //设置街区
                self.weizhiRightTitleLabel.text = cityStreet as? String
            }else{
                //没设置街区
                self.weizhiRightTitleLabel.text = "暂无定位信息"
            }
        }
    }
    
    deinit {
        
    }
    // MARK: - UITextFieldDelegate
    func textFieldDidEndEditing(_ textField: UITextField) {
        self.view.endEditing(true)
        if textField.text?.count ?? 0 > 0{
            self.savePhone()
        }
    }
    
    func savePhone(){
        if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
            userDic.updateValue(self.phoneTextFiled.text ?? "", forKey: "phone")
            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: - ButtonAction
    @objc func weiZhiTapAction(){
        self.getPlacemarkAddress()
    }
    func saveWeiZhi(cityStreet:String){
        if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
            userDic.updateValue(cityStreet, forKey: "cityStreet")
            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 locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        if status == .authorizedWhenInUse || status == .authorizedAlways {
            // 权限已授权,可以开始获取位置信息
            locationManager.startUpdatingLocation()
        }
    }

    // 代理方法:当位置更新时调用
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let location = locations.last else { return }
        
        // 停止更新位置以节省资源
        locationManager.stopUpdatingLocation()
        
        // 反向地理编码位置以获取地址信息
        let geocoder = CLGeocoder()
        geocoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) in
            if let error = error {
                print("Geocoding failed with error: \(error.localizedDescription)")
                return
            }
            
            if let placemark = placemarks?.first {
                print("市区:\(placemark.locality ?? "")")
                print("街道:\(placemark.thoroughfare ?? "")")
                // 你可以根据需要进一步处理placemark对象
                let cityStreet = (placemark.locality ?? "") + (placemark.thoroughfare ?? "")
                self.saveWeiZhi(cityStreet:cityStreet)
                self.weizhiRightTitleLabel.text = cityStreet
            }
        })
    }

    // 代理方法:处理定位错误(可选)
    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        print("Location manager failed with error: \(error.localizedDescription)")
    }
    func getPlacemarkAddress() {
        // 检查定位服务是否可用
        if CLLocationManager.locationServicesEnabled() {
            // 设置定位管理器的代理
            locationManager.delegate = self
            // 请求前台使用时的定位权限
            locationManager.requestWhenInUseAuthorization()
            // 配置定位管理器
            locationManager.desiredAccuracy = kCLLocationAccuracyBest
            locationManager.startUpdatingLocation()
        } else {
            // 定位服务不可用
            print("Location services are not enabled")
        }
        
    }
     
    @objc func canJiaTapAction(){
        MineInfoAlertView.showSelectView(showType: .selectDay) { [weak self] text in
            print("刷新之后的数据是=>\(text)")//"2024-06-18"
            if (text as! String).count > 0{
                let textStr = text as! String
                self?.canjiaRightTitleLabel.text = textStr
                self?.canjiaRightTitleLabel.textColor = HexColor("#333333")

                if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
                    userDic.updateValue(textStr, forKey: "selectDay")
                    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()
                }
                
                
            }else{
                self?.canjiaRightTitleLabel.text = "请选择"
                self?.canjiaRightTitleLabel.textColor = HexColor("#B4B4B4")
            }
        }
    }
    
    // MARK: - SwitchAction
    @objc func nianLingSwitchAction(sender: UISwitch) {
        self.saveShowSwitch(key: "showAge", isOn: sender.isOn)
    }
    @objc func phoneSwitchAction(sender: UISwitch) {
        self.saveShowSwitch(key: "showPhone", isOn: sender.isOn)
    }
    @objc func weiZhiSwitchAction(sender: UISwitch) {
        self.saveShowSwitch(key: "showWeiZhi", isOn: sender.isOn)
    }
    @objc func huoJiangSwitchAction(sender: UISwitch) {
        self.saveShowSwitch(key: "showHuoJiang", isOn: sender.isOn)
    }
    
    func saveShowSwitch(key:String,isOn:Bool){
        if var userDic = UserDefaults.standard.dictionary(forKey: UserInfoManager.shared.userInfo.uid){
            userDic.updateValue(isOn, forKey: key)
            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()
        }
    }
}