杨锴
10 小时以前 876bce3064536c036112dd1834fb0d0013a57d16
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
//
//  MeVC.swift
//  DolphinEnglishLearnStudent
//
//  Created by 无故事王国 on 2024/5/22.
//
 
import UIKit
import QMUIKit
 
let MeUserInfoUpdate_Noti = Notification.Name.init("MeUserInfoUpdate_Noti")
 
class MeVC: BaseVC {
                @IBOutlet weak var btn_address: QMUIButton!
                @IBOutlet weak var btn_coinRecord: QMUIButton!
                @IBOutlet weak var btn_exchangeRecord: QMUIButton!
                @IBOutlet weak var btn_share: QMUIButton!
                @IBOutlet weak var btn_etudyRecord: QMUIButton!
                @IBOutlet weak var btn_loginoff: QMUIButton!
                @IBOutlet weak var imge_cover: UIImageView!
                @IBOutlet weak var label_name: UILabel!
                @IBOutlet weak var label_info: UILabel!
                
    override func viewDidLoad() {
        super.viewDidLoad()
                                getData()
    }
 
                override func setUI() {
                                super.setUI()
                                label_info.text = ""
                                btn_address.spacingBetweenImageAndTitle = 11
                                btn_coinRecord.spacingBetweenImageAndTitle = 11
                                btn_exchangeRecord.spacingBetweenImageAndTitle = 11
                                btn_share.spacingBetweenImageAndTitle = 11
                                btn_etudyRecord.spacingBetweenImageAndTitle = 11
                                btn_loginoff.spacingBetweenImageAndTitle = 11
 
                                btn_address.imagePosition = .top
                                btn_coinRecord.imagePosition = .top
                                btn_exchangeRecord.imagePosition = .top
                                btn_share.imagePosition = .top
                                btn_etudyRecord.imagePosition = .top
                                btn_loginoff.imagePosition = .top
 
                }
 
                override func setRx() {
                                NotificationCenter.default.rx.notification(MeUserInfoUpdate_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in
                                                self?.getData()
                                }).disposed(by: disposeBag)
                }
 
                private func getData(){
                                Services.userInfo().subscribe(onNext: {result in
                                                var items = Array<String>()
 
                                                if let model = result.data?.user{
                                                                self.imge_cover.sd_setImage(with: URL(string: model.headImg))
                                                                self.label_name.text = model.name
                                                                items.append("剩余积分:\(model.integral)")
                                                                UserViewModel.saveUserInfo(result.data!)
                                                }
 
                                                if let model = result.data?.userStudy{
                                                                items.append("学习进度:周目\(model.week.jq_cn)")
                                                                items.append("学习总时长:\(model.totalStudy)小时")
                                                }
                                                self.label_info.text = items.joined(separator: "|")
 
                                }).disposed(by: disposeBag)
                }
 
                /// 地址管理
                @IBAction func addressManageAction(_ sender: QMUIButton) {
                                let vc = AddressManageVC(type: .handle)
                                vc.title = "地址管理"
                                push(vc: vc)
                }
 
                @IBAction func coinHistoryAction(_ sender: QMUIButton) {
                                let vc = CoinRecordHistoryVC()
                                vc.title = "积分明细"
                                push(vc: vc)
                }
 
                @IBAction func exchangeHistoryAction(_ sender: QMUIButton) {
                                let vc = ExchangeRecordHistoryVC()
                                vc.title = "兑换记录"
                                push(vc: vc)
                }
 
                @IBAction func studyRecord(_ sender: QMUIButton) {
                                let vc = StudyVC()
                                vc.title = "学习记录"
                                push(vc: vc)
                }
 
                @IBAction func shareAction(_ sender: QMUIButton) {
                                if WXApi.isWXAppInstalled(){
                                                ShareView.show()
                                }else{
                                                let urlStr = "https://dollearn.com/"
                                                if let url = URL(string: urlStr) {
                                                                let activityVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)
                                                                activityVC.popoverPresentationController?.sourceView = self.view
 
                                                                let senderCenter = sender.convert(sender.bounds, to: self.view)
                                                                activityVC.popoverPresentationController?.sourceRect = CGRect(origin:senderCenter.center, size: CGSize(width: 1, height: 1))
                                                                present(activityVC, animated: true, completion: nil)
                                                }
                                }
                }
 
                @IBAction func quitAction(_ sender: UIButton) {
                                CommonAlertView.show(content: "确认退出当前账户吗?") {
                                                sceneDelegate?.needLogin()
                                                Services.logoutStudy().subscribe(onNext: {result in
 
                                                }).disposed(by: self.disposeBag)
                                }
                }
 
                @IBAction func loginoffAction(_ sender: UIButton) {
                                let vc = UserLoginOffVC()
                                vc.title = "注销账号"
                                push(vc: vc)
                }
                
 
                @IBAction func becomeVIPAction(_ sender: Any) {
                                let vc = VIPCenterVC()
                                vc.title = "会员中心"
                                push(vc: vc)
                }
}