//
|
// ProfileVC.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/6/28.
|
//
|
|
import UIKit
|
import QMUIKit
|
import JQTools
|
|
class ProfileVC: BaseVC {
|
@IBOutlet weak var btn_userProfile: UIButton!
|
@IBOutlet weak var label_username: UILabel!
|
@IBOutlet weak var label_contact: UILabel!
|
@IBOutlet weak var label_gender: UILabel!
|
@IBOutlet weak var label_birthday: UILabel!
|
@IBOutlet weak var label_address: UILabel!
|
@IBOutlet weak var label_vipDutime: UILabel!
|
@IBOutlet weak var view_vipExpired: UIView!
|
|
private var profileImg:UIImage?
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
title = "个人信息"
|
Services.userDetails().subscribe(onNext: {[weak self] data in
|
if let model = data.data{
|
self?.label_username.text = model.userName
|
self?.label_contact.text = model.userPhone
|
self?.label_gender.text = model.sex == .man ? "男":"女"
|
self?.label_birthday.text = model.birthday
|
self?.label_address.text = model.address
|
self?.label_vipDutime.text = model.memberLifespan
|
self?.btn_userProfile.sd_setImage(with: URL(string: model.userImage), for: .normal,placeholderImage: UIImage(named: "btn_userProfile"))
|
self?.view_vipExpired.isHidden = model.isVip == 0
|
}
|
|
}).disposed(by: disposeBag)
|
}
|
|
@IBAction func logoutAction(_ sender: UIButton) {
|
CommonAlertView.show(title: "退出登录", content: "是否退出当前账号?") { status in
|
if status{
|
UserViewModel.clearToken()
|
app.needLogin()
|
|
}
|
}
|
}
|
|
@IBAction func updateProfileAction(_ sender: UIButton) {
|
JQ_ImagePickerTool.getSharedInstance().singleImage({ image in
|
self.profileImg = image
|
self.btn_userProfile.setImage(image, for: .normal)
|
image.uploadImgToService().subscribe { text in
|
Services.updateUserProfile(text).subscribe(onNext: {_ in
|
alertSuccess(msg: "修改成功")
|
NotificationCenter.default.post(name: UpdateWelfare_Noti, object: nil)
|
}) { error in
|
alertError(msg: error.localizedDescription)
|
}.disposed(by: self.disposeBag)
|
} onError: { error in
|
alertError(msg: error.localizedDescription)
|
}.disposed(by: self.disposeBag)
|
}, clipSize: CGSize(width: JQ_ScreenW, height: JQ_ScreenW))
|
}
|
|
|
@IBAction func dismissAccountAction(_ sender: UIButton) {
|
|
}
|
}
|