杨锴
2024-10-25 098286ed0313b1d3f1141113b371f8b17b8b26b5
XQMuse/Root/Me/MeVC.swift
@@ -78,48 +78,53 @@
                                    self.queryNotice()
                        }).disposed(by: disposeBag)
        NotificationCenter.default.rx.notification(LoginSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
            self.getData()
            self.queryNotice()
        }).disposed(by: disposeBag)
            }
            private func getData(){
                        Services.getUserDetail().subscribe(onNext: {data in
                        Services.getUserInfo().subscribe(onNext: {[weak self] data in
                                    if let model = data.data{
                                                UserViewModel.saveAvatarInfo(model)
                UserViewModel.saveAvatarInfo(model)
                self?.setUserUI(model: 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)
        },onError: {[weak self]error in
            let model = UserViewModel.getAvatarInfo()
            if model.id > 0{
                self?.setUserUI(model: model)
            }
        }).disposed(by: disposeBag)
            }
    private func setUserUI(model:UserInfoModel){
        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 = "你还未开通会员服务"
        }
    }
            @objc func rankAction(){
                        let vc = WebVC()
@@ -128,17 +133,20 @@
            }
            @IBAction func vipCenterAction(_ sender: Any) {
        guard sceneDelegate!.checkisLoginState() else {return}
                         let vc = VIPCenterVC()
                        push(vc: vc)
            }
            
            @IBAction func userProfileAction(_ sender: UIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let profileVC = UserProfileVC()
                        jq_push(vc: profileVC)
            }
            @IBAction func studyLevelAction(_ sender: TapBtn) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let vc = LevelVC()
                        push(vc: vc)
            }
@@ -155,6 +163,7 @@
            
            //学习记录
            @IBAction func studyAction(_ sender: UIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let vc = StudyListVC()
                        push(vc: vc)
            }
@@ -162,24 +171,28 @@
            //我的账户
            @IBAction func myAccountAction(_ sender: QMUIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                         let vc = WalletVC()
                        push(vc: vc)
            }
            //观看历史
            @IBAction func watchHistoryAction(_ sender: QMUIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let vc = WatchHistoryVC(type: .history)
                        push(vc: vc)
            }
            //我的收藏
            @IBAction func myColletAction(_ sender: QMUIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let vc = WatchHistoryVC(type: .collect)
                        push(vc: vc)
            }
            /// 我的已购
            @IBAction func paymentCourseAction(_ sender: QMUIButton) {
        guard sceneDelegate!.checkisLoginState() else {return}
                        let vc = WatchHistoryVC(type: .payment)
                        push(vc: vc)
            }