杨锴
2024-09-14 6912d657ec6bb1db9683d5b5be8f0777f001ba11
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//
//  MeVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/12.
//
 
import UIKit
import QMUIKit
import JQTools
 
class MeVC: BaseVC {
 
                @IBOutlet weak var scrollView: UIScrollView!
                @IBOutlet weak var btn_collect: QMUIButton!
                @IBOutlet weak var btn_record: QMUIButton!
                @IBOutlet weak var btn_history: QMUIButton!
                @IBOutlet weak var btn_account: QMUIButton!
                @IBOutlet weak var btn_buy: QMUIButton!
                @IBOutlet weak var btn_customer: QMUIButton!
                @IBOutlet weak var btn_setting: QMUIButton!
                @IBOutlet weak var btn_share: QMUIButton!
                @IBOutlet weak var view_rank: GradientView!
                @IBOutlet weak var image_vipBg: UIImageView!
                @IBOutlet weak var label_expirtTime: UILabel!
                @IBOutlet weak var label_sustainDay: UILabel!
                @IBOutlet weak var label_today: UILabel!
                @IBOutlet weak var image_medal: UIImageView!
                
                @IBOutlet weak var image_userAvatar: UIImageView!
                @IBOutlet weak var label_userName: UILabel!
                @IBOutlet weak var label_phone: UILabel!
                @IBOutlet weak var label_vipInfo: UILabel!
                @IBOutlet weak var label_totalDay: UILabel!
                
                override func viewDidLoad() {
        super.viewDidLoad()
 
                                let tap = UITapGestureRecognizer(target: self, action: #selector(rankAction))
                                view_rank.isUserInteractionEnabled = true
                                view_rank.addGestureRecognizer(tap)
 
                                getData()
    }
 
                override func setUI() {
                                super.setUI()
                                view.backgroundColor = UIColor(hexString: "#fafafa")
                                scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
                                scrollView.showsVerticalScrollIndicator = false
                                btn_collect.imagePosition = .top
                                btn_record.imagePosition = .top
                                btn_history.imagePosition = .top
                                btn_account.imagePosition = .top
 
                                btn_buy.imagePosition = .top
                                btn_customer.imagePosition = .top
                                btn_setting.imagePosition = .top
                                btn_share.imagePosition = .top
                }
 
                override func setRx() {
                                NotificationCenter.default.rx.notification(UpdateUserProfile_Noti, object: nil).take(until: self.rx.deallocated).subscribe(onNext: { _ in
                                                self.getData()
                                }).disposed(by: disposeBag)
                }
 
 
                private func getData(){
                                Services.getUserDetail().subscribe(onNext: {data in
                                                if let model = data.data{
                                                                UserViewModel.saveAvatarInfo(model)
                                                }
                                }).disposed(by: self.disposeBag)
 
 
                                Services.getUserInfo().subscribe(onNext: {data in
                                                if let model = data.data{
                                                                self.image_userAvatar.sd_setImage(with: URL(string: model.avatar))
                                                                self.label_userName.text = model.nickname
                                                                self.label_phone.text = model.cellPhone.jq_blotOutPhone()
 
                                                                self.label_totalDay.attributedText = AttributedStringbuilder.build().add(string: "\(model.cumulative)", withFont: UIFont.init(name: "PingFang-SC-Regular", size: 60)!, withColor: UIColor(hexString: "#152715")!).add(string: "天", withFont: .systemFont(ofSize: 16), withColor: UIColor(hexString: "#152715")!).mutableAttributedString
 
                                                                self.label_sustainDay.attributedText = AttributedStringbuilder.build().add(string: "\(model.continuity)", withFont: .systemFont(ofSize: 23), withColor: UIColor(hexString: "#152715")!).add(string: "天", withFont: .systemFont(ofSize: 12), withColor: UIColor(hexString: "#152715")!).mutableAttributedString
 
                                                                self.image_medal.sd_setImage(with: URL(string: model.levelIcon))
 
                                                                let timeTurple = Date.jq_formateToTime_tuple(model.today * 60)
 
                                                                self.label_today.attributedText = AttributedStringbuilder.build().add(string: "\(timeTurple.hour)", withFont: .systemFont(ofSize: 23), withColor: UIColor(hexString: "#152715")!).add(string: "时", withFont: .systemFont(ofSize: 12), withColor: UIColor(hexString: "#152715")!).add(string: "\(timeTurple.minute)", withFont: .systemFont(ofSize: 23), withColor: UIColor(hexString: "#152715")!).add(string: "分", withFont: .systemFont(ofSize: 12), withColor: UIColor(hexString: "#152715")!).mutableAttributedString
 
 
 
                                                                if model.isVip == .yes{
                                                                                self.image_vipBg.image = UIImage(named: "bg_vip")
                                                                                self.label_vipInfo.text = "你已是高级会员"
                                                                                self.label_expirtTime.text = model.vipExpireTime + "到期"
                                                                }else{
                                                                                self.image_vipBg.image = UIImage(named: "bg_vip_u")
                                                                                self.label_vipInfo.text = "升级为高级会员,解锁全部体验"
                                                                                self.label_expirtTime.text = "你还未开通会员服务"
                                                                }
                                                }
                                }).disposed(by: disposeBag)
                }
 
                @objc func rankAction(){
                                let vc = WebVC()
                                vc.title = "爱心榜单"
                                push(vc: vc)
                }
 
                @IBAction func vipCenterAction(_ sender: Any) {
                                 let vc = VIPCenterVC()
                                push(vc: vc)
                }
                
 
                @IBAction func userProfileAction(_ sender: UIButton) {
                                let profileVC = UserProfileVC()
                                jq_push(vc: profileVC)
                }
 
                @IBAction func studyLevelAction(_ sender: TapBtn) {
                                let vc = LevelVC()
                                push(vc: vc)
                }
 
                @IBAction func systemMessageAction(_ sender: UIButton) {
                                let vc = NoticeCenterVC()
                                push(vc: vc)
                }
 
                @IBAction func settingAction(_ sender: UIButton) {
                                let vc = SettingVC()
                                push(vc: vc)
                }
                
                //学习记录
                @IBAction func studyAction(_ sender: UIButton) {
                                let vc = StudyListVC()
                                push(vc: vc)
                }
 
 
                //我的账户
                @IBAction func myAccountAction(_ sender: QMUIButton) {
                                 let vc = WalletVC()
                                push(vc: vc)
                }
 
                //观看历史
                @IBAction func watchHistoryAction(_ sender: QMUIButton) {
                                let vc = WatchHistoryVC(type: .history)
                                push(vc: vc)
                }
 
                //我的收藏
                @IBAction func myColletAction(_ sender: QMUIButton) {
                                let vc = WatchHistoryVC(type: .collect)
                                push(vc: vc)
                }
 
                /// 我的已购
                @IBAction func paymentCourseAction(_ sender: QMUIButton) {
                                let vc = WatchHistoryVC(type: .payment)
                                push(vc: vc)
                }
 
                /// 联系客服
                @IBAction func customerAction(_ sender: QMUIButton) {
                                let vc = ContactCustomerVC()
                                push(vc: vc)
                }
                
                ///分享
                @IBAction func shareAction(_ sender: QMUIButton) {
 
                }
}
 
class GradientView:UIView{
 
                override init(frame: CGRect) {
                                super.init(frame: frame)
 
                                jq_gradientColor(colorArr: [UIColor(hexString: "#F3FFF8")!.cgColor,UIColor.white.cgColor])
                }
                
                required init?(coder: NSCoder) {
                                super.init(coder: coder)
 
                }
                
                override func awakeFromNib() {
                                super.awakeFromNib()
                                jq_gradientColor(colorArr: [UIColor(hexString: "#F3FFF8")!.cgColor,UIColor.white.cgColor], cornerRadius: 10, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: nil, locations: nil)
                }
}