| | |
| | | @IBOutlet weak var tf_email: QMUITextField! |
| | | @IBOutlet weak var image_placeholder: UIImageView! |
| | | |
| | | private var userClipAvar:UIImage? |
| | | |
| | | 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 |
| | | |
| | | let saveBtn = UIButton(type: .custom) |
| | | saveBtn.setTitle("保存", for: .normal) |
| | | saveBtn.titleLabel?.font = .systemFont(ofSize: 15) |
| | | saveBtn.setTitleColor(UIColor(hexString: "#353535"), for: .normal) |
| | | saveBtn.addTarget(self, action: #selector(saveAction), for: .touchUpInside) |
| | | navigationItem.rightBarButtonItem = UIBarButtonItem(customView: saveBtn) |
| | | |
| | | // image_placeholder.isHidden = !UserViewModel.getAvatarInfo().avatar.isEmpty |
| | | |
| | | if let url = URL(string: UserViewModel.getAvatarInfo().avatar){ |
| | | image_user.sd_setImage(with: url) |
| | |
| | | tf_birthland.text = UserViewModel.getAvatarInfo().hometown |
| | | tf_email.text = UserViewModel.getAvatarInfo().email |
| | | |
| | | 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 |
| | | tf_nickName.maximumTextLength = 12 |
| | | |
| | | 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{ |
| | | |
| | | CommonAlertView.show(title: "提示", content: "是否保存修改?",cancelStr: "不保存",completeStr: "保存") { state in |
| | | if state{ |
| | | 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) |
| | | } |
| | | } |
| | | }else{ |
| | | weakSelf.navigationController?.popViewController(animated: true) |
| | | } |
| | | } |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | image_user.addGestureRecognizer(tap) |
| | | } |
| | | |
| | | @objc func selectUserProfile(){ |
| | | CommonAlertSheetView.show(items: ["拍照","从相册选择"]) {[unowned self] index in |
| | | if index == 0{ |
| | | @objc func saveAction(){ |
| | | let nickname = tf_nickName.text |
| | | let realname = tf_realName.text |
| | | let signature = tf_sign.text |
| | | let gender = GenderType.GenderBy(tf_gender.text!) |
| | | let birthday = tf_birthday.text |
| | | let education = tf_degree.text |
| | | let industry = tf_industry.text |
| | | let company = tf_company.text |
| | | let occupation = tf_job.text |
| | | let location = tf_address.text |
| | | let hometown = tf_birthland.text |
| | | let email = tf_email.text |
| | | |
| | | guard UIImagePickerController.isSourceTypeAvailable(.camera) else{ |
| | | alertError(msg: "当前设备相机不可用");return |
| | | 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) |
| | | alertSuccess(msg: "修改成功") |
| | | }).disposed(by: disposeBag) |
| | | |
| | | userClipAvar?.uploadImg().subscribe(onNext: {[weak self]imageUrl in |
| | | guard let weakSelf = self else { return } |
| | | Services.updateUserAvatar(imageUrl).subscribe(onNext: {data in |
| | | weakSelf.image_user.sd_setImage(with: URL(string: imageUrl.jq_urlEncoded())!) |
| | | weakSelf.image_placeholder.isHidden = true |
| | | NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil) |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | let p = UIImagePickerController() |
| | | p.delegate = self |
| | | p.modalPresentationStyle = .fullScreen |
| | | p.allowsEditing = true |
| | | p.sourceType = .camera |
| | | p.cameraDevice = .front |
| | | self.present(p, animated: true) |
| | | }else{ |
| | | @objc func selectUserProfile(){ |
| | | CommonAlertSheetView.show(items: ["从相册选择"]) {[unowned self] index in |
| | | if index == 0{ |
| | | |
| | | let p = TZImagePickerController(maxImagesCount: 1, columnNumber: 3, delegate: self) |
| | | p!.modalPresentationStyle = .fullScreen |
| | | p!.allowTakeVideo = false |
| | |
| | | p!.allowCrop = true |
| | | p!.cropRect = self.clipFrame |
| | | self.present(p!, animated: true, completion: nil) |
| | | |
| | | // guard UIImagePickerController.isSourceTypeAvailable(.camera) else{ |
| | | // alertError(msg: "当前设备相机不可用");return |
| | | // } |
| | | // |
| | | // let p = UIImagePickerController() |
| | | // p.delegate = self |
| | | // p.modalPresentationStyle = .fullScreen |
| | | // p.allowsEditing = true |
| | | // p.sourceType = .camera |
| | | // p.cameraDevice = .front |
| | | // self.present(p, animated: true) |
| | | }else{ |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if textField == tf_gender{ |
| | | let items = ["男","女","保密"] |
| | | CommonAlertSheetView.show(items: items) { index in |
| | | CommonAlertSheetView.show(items: items,hiddenTitle: true) { index in |
| | | guard textField.text != items[index] else {return} |
| | | if items[index] == "保密"{ |
| | | textField.text = "" |
| | | }else{ |
| | | textField.text = items[index] |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return false |
| | | } |
| | | |
| | | return false |
| | | } |
| | | } |
| | |
| | | picker.selectedAssets = NSMutableArray(array: assets) |
| | | |
| | | if let photo = photos.first{ |
| | | 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: weakSelf.disposeBag) |
| | | }).disposed(by: disposeBag) |
| | | self.userClipAvar = photo.jq_scaled(to: CGSize(width: 250, height: 250)) |
| | | // self.image_placeholder.isHidden = true |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | unowned let weakSelf = self |
| | | corpperVC.imageCropperHandler { (vc, image) in |
| | | image.uploadImg().subscribe(onNext: {imageUrl 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) |
| | | weakSelf.userClipAvar = image |
| | | // weakSelf.image_placeholder.isHidden = true |
| | | } cancelClouse: { |
| | | corpperVC.dismiss(animated: true) { |
| | | |