| | |
| | | @IBOutlet weak var tf_address: QMUITextField! |
| | | @IBOutlet weak var tf_birthland: QMUITextField! |
| | | @IBOutlet weak var tf_email: QMUITextField! |
| | | |
| | | @IBOutlet weak var image_placeholder: UIImageView! |
| | | |
| | | private var clipSize = CGSize(width: JQ_ScreenW, height: JQ_ScreenW) //裁剪大小 |
| | | private var clipFrame:CGRect{ |
| | | get{ |
| | |
| | | super.viewDidLoad() |
| | | title = "个人资料" |
| | | |
| | | image_placeholder.isHidden = !UserViewModel.getAvatarInfo().avatar.isEmpty |
| | | image_user.sd_setImage(with: URL(string: UserViewModel.getAvatarInfo().avatar)!) |
| | | tf_nickName.text = UserViewModel.getAvatarInfo().nickname |
| | | tf_realName.text = UserViewModel.getAvatarInfo().realname |
| | | tf_sign.text = UserViewModel.getAvatarInfo().signature |
| | |
| | | tf_address.text = UserViewModel.getAvatarInfo().location |
| | | tf_birthland.text = UserViewModel.getAvatarInfo().hometown |
| | | tf_email.text = UserViewModel.getAvatarInfo().email |
| | | } |
| | | |
| | | override func viewDidDisappear(_ animated: Bool) { |
| | | super.viewDidDisappear(animated) |
| | | yy_popBlock = {[weak self] in |
| | | guard let weakSelf = self else { return } |
| | | let nickname = weakSelf.tf_nickName.text |
| | | let realname = weakSelf.tf_realName.text |
| | | let signature = weakSelf.tf_sign.text |
| | | let gender = GenderType.GenderBy(weakSelf.tf_gender.text!) |
| | | let birthday = weakSelf.tf_birthday.text |
| | | let education = weakSelf.tf_degree.text |
| | | let industry = weakSelf.tf_industry.text |
| | | let company = weakSelf.tf_company.text |
| | | let occupation = weakSelf.tf_job.text |
| | | let location = weakSelf.tf_address.text |
| | | let hometown = weakSelf.tf_birthland.text |
| | | let email = weakSelf.tf_email.text |
| | | |
| | | let nickname = tf_nickName.text == UserViewModel.getAvatarInfo().nickname ? nil:tf_nickName.text |
| | | let realname = tf_realName.text == UserViewModel.getAvatarInfo().realname ? nil:tf_realName.text |
| | | let signature = tf_sign.text == UserViewModel.getAvatarInfo().signature ? nil:tf_sign.text |
| | | let gender = tf_gender.text == UserViewModel.getAvatarInfo().gender.rawTitle ? nil:GenderType.GenderBy(tf_gender.text!) |
| | | let birthday = tf_birthday.text == UserViewModel.getAvatarInfo().birthday ? nil:tf_birthday.text |
| | | let education = tf_degree.text == UserViewModel.getAvatarInfo().education ? nil:tf_degree.text |
| | | let industry = tf_industry.text == UserViewModel.getAvatarInfo().industry ? nil:tf_industry.text |
| | | let company = tf_company.text == UserViewModel.getAvatarInfo().company ? nil:tf_company.text |
| | | let occupation = tf_job.text == UserViewModel.getAvatarInfo().occupation ? nil:tf_job.text |
| | | let location = tf_address.text == UserViewModel.getAvatarInfo().location ? nil:tf_address.text |
| | | let hometown = tf_birthland.text == UserViewModel.getAvatarInfo().hometown ? nil:tf_birthland.text |
| | | let email = tf_email.text == UserViewModel.getAvatarInfo().email ? nil:tf_email.text |
| | | |
| | | if nickname != nil || realname != nil || signature != nil || gender != nil || birthday != nil || education != nil || industry != nil || company != nil || occupation != nil || location != nil || hometown != nil || email != nil{ |
| | | Services.updateUserInfo(birthday: birthday, company: company, education: education, email: email, gender: gender, hometown: hometown, industry: industry, location: location, nickname: nickname, realname: realname, occupation: occupation, signature: signature).subscribe(onNext: {data in |
| | | NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil) |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | if nickname != UserViewModel.getAvatarInfo().nickname |
| | | || realname != UserViewModel.getAvatarInfo().realname |
| | | || signature != UserViewModel.getAvatarInfo().signature |
| | | || gender != UserViewModel.getAvatarInfo().gender |
| | | || birthday != UserViewModel.getAvatarInfo().birthday |
| | | || education != UserViewModel.getAvatarInfo().education |
| | | || industry != UserViewModel.getAvatarInfo().industry |
| | | || company != UserViewModel.getAvatarInfo().company |
| | | || occupation != UserViewModel.getAvatarInfo().occupation |
| | | || location != UserViewModel.getAvatarInfo().location |
| | | || hometown != UserViewModel.getAvatarInfo().hometown |
| | | || email != UserViewModel.getAvatarInfo().email{ |
| | | Services.updateUserInfo(birthday: birthday, company: company, education: education, email: email, gender: gender, hometown: hometown, industry: industry, location: location, nickname: nickname, realname: realname, occupation: occupation, signature: signature).subscribe(onNext: {data in |
| | | NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil) |
| | | weakSelf.navigationController?.popViewController(animated: true) |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | }else{ |
| | | weakSelf.navigationController?.popViewController(animated: true) |
| | | } |
| | | } |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | |
| | | if textField == tf_birthday{ |
| | | view.endEditing(true) |
| | | BitrhdayPickerView.show(title: "", type: .YMD) { date in |
| | | |
| | | BitrhdayPickerView.show(title: "", type: .YMD) {[weak self] date in |
| | | self?.tf_birthday.text = date.jq_format("yyyy-MM-dd") |
| | | } |
| | | return false |
| | | } |
| | |
| | | picker.selectedAssets = NSMutableArray(array: assets) |
| | | |
| | | if let photo = photos.first{ |
| | | photo.jq_scaled(to: CGSize(width: 250, height: 250)).uploadImg().subscribe(onNext: {imageUrl in |
| | | Services.updateUserInfo(avatar:imageUrl).subscribe(onNext: {data in |
| | | photo.jq_scaled(to: CGSize(width: 250, height: 250)).uploadImg().subscribe(onNext: {[weak self]imageUrl in |
| | | guard let weakSelf = self else { return } |
| | | Services.updateUserAvatar(imageUrl).subscribe(onNext: {data in |
| | | weakSelf.image_placeholder.isHidden = true |
| | | weakSelf.image_user.sd_setImage(with: URL(string: imageUrl)!) |
| | | NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil) |
| | | }).disposed(by: self.disposeBag) |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | |
| | | unowned let weakSelf = self |
| | | corpperVC.imageCropperHandler { (vc, image) in |
| | | image.uploadImg().subscribe(onNext: {imageUrl in |
| | | Services.updateUserInfo(avatar:imageUrl).subscribe(onNext: {data in |
| | | Services.updateUserAvatar(imageUrl).subscribe(onNext: {data in |
| | | weakSelf.image_user.sd_setImage(with: URL(string: imageUrl)!) |
| | | weakSelf.image_placeholder.isHidden = true |
| | | NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil) |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | }).disposed(by: weakSelf.disposeBag) |