无故事王国
2023-10-19 eb795a6523edbc0fe3a3b1a3d3bea1063041efd5
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
//
//  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) {
 
    }
}