From c649531411191cd60591eafcd9c3b9a9fede13e4 Mon Sep 17 00:00:00 2001
From: 杨锴 <841720330@qq.com>
Date: 星期三, 20 十一月 2024 17:56:56 +0800
Subject: [PATCH] fix bug

---
 XQMuse/Root/Plans/PlanGuideVC.swift                  |    2 
 XQMuse/Root/Home/HomeVC.swift                        |  571 ++++++++++++++++++++++++++-------------------------
 XQMuse/Root/Course/CCell/CourseOfficialItemCCell.xib |    6 
 XQMuse/Root/Login/VC/UpdatePhoneVC.swift             |   15 +
 XQMuse/SceneDelegate.swift                           |   10 
 XQMuse/Root/Home/VC/PaymentOrderVC.swift             |    6 
 XQMuse/Root/Plans/PlanGuide_3_VC.swift               |   13 
 XQMuse/Root/Network/Services.swift                   |   11 
 8 files changed, 339 insertions(+), 295 deletions(-)

diff --git a/XQMuse/Root/Course/CCell/CourseOfficialItemCCell.xib b/XQMuse/Root/Course/CCell/CourseOfficialItemCCell.xib
index 80b4e70..047c766 100644
--- a/XQMuse/Root/Course/CCell/CourseOfficialItemCCell.xib
+++ b/XQMuse/Root/Course/CCell/CourseOfficialItemCCell.xib
@@ -17,11 +17,11 @@
                 <rect key="frame" x="0.0" y="0.0" width="114" height="109"/>
                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                 <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="course_1" translatesAutoresizingMaskIntoConstraints="NO" id="D7q-iI-B0n">
+                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="course_1" translatesAutoresizingMaskIntoConstraints="NO" id="D7q-iI-B0n">
                         <rect key="frame" x="39.666666666666664" y="29" width="34.999999999999993" height="31.666666666666671"/>
                         <constraints>
-                            <constraint firstAttribute="width" relation="lessThanOrEqual" constant="35" id="A6U-Ns-BoS"/>
-                            <constraint firstAttribute="height" relation="lessThanOrEqual" constant="31.5" id="xu0-nX-9PR"/>
+                            <constraint firstAttribute="width" relation="lessThanOrEqual" constant="43" id="A6U-Ns-BoS"/>
+                            <constraint firstAttribute="height" relation="lessThanOrEqual" constant="50" id="xu0-nX-9PR"/>
                         </constraints>
                     </imageView>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eyG-jG-ONh">
diff --git a/XQMuse/Root/Home/HomeVC.swift b/XQMuse/Root/Home/HomeVC.swift
index 4d0b98a..31dccd1 100644
--- a/XQMuse/Root/Home/HomeVC.swift
+++ b/XQMuse/Root/Home/HomeVC.swift
@@ -18,28 +18,28 @@
 let ReloadData_Noti = Notification.Name.init("ReloadData_Noti")
 
 struct TitleItem{
-				var id = 0
-				var title = ""
-				var subTitle = ""
-				var hasMore:Bool = false
-				var coverImage:String?
+    var id = 0
+    var title = ""
+    var subTitle = ""
+    var hasMore:Bool = false
+    var coverImage:String?
 }
 
 class HomeViewModel{
-				var homeTopMenuItems = [HomeTopMenuItem]()
-				var homeBottomMenuItems = [HomeTopMenuItem]()
-				var todyModel:ToDayMeditationModel?
-				var privateTodyModels = [MeditationModel]()
-				var meditationList = [MeditationListModel]()
+    var homeTopMenuItems = [HomeTopMenuItem]()
+    var homeBottomMenuItems = [HomeTopMenuItem]()
+    var todyModel:ToDayMeditationModel?
+    var privateTodyModels = [MeditationModel]()
+    var meditationList = [MeditationListModel]()
 }
 
 class HomeVC: BaseVC {
-				private var tableView:UITableView!
-				private let topMenuView = HomeTopMenuView.jq_loadNibView()
-				private var titleItems = [TitleItem]()
-				private var viewModel = HomeViewModel()
+    private var tableView:UITableView!
+    private let topMenuView = HomeTopMenuView.jq_loadNibView()
+    private var titleItems = [TitleItem]()
+    private var viewModel = HomeViewModel()
     private var timer:Timer?
-    private var needPopToTree:Bool = false //是否需要跳转到树苗
+    private var needPopToTree:Bool = false //是否需跳转到树苗
 
     private var cellularData:CTCellularData!
 
@@ -84,20 +84,20 @@
     override func viewDidLoad() {
         super.viewDidLoad()
 
-								titleItems.removeAll()
+        titleItems.removeAll()
 
         timer = Timer.scheduledTimer(timeInterval: 30, target: self, selector: #selector(autoUpdate), userInfo: nil, repeats: true)
         RunLoop.current.add(timer!, forMode: .default)
 
-								titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation"))
-								titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Customization",hasMore: true))
-								titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide"))
+        titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation"))
+        titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Customization",hasMore: true))
+        titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide"))
 
-								if let setting = UserDefaultSettingViewModel.getSetting(){
-												if let audioFile = setting.bgm?.audioFile{
-																AudioPlayer.getSharedInstance().playSceneAt(audioFile)
-												}
-								}
+        if let setting = UserDefaultSettingViewModel.getSetting(){
+            if let audioFile = setting.bgm?.audioFile{
+                AudioPlayer.getSharedInstance().playSceneAt(audioFile)
+            }
+        }
 
         tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {
             self.getData()
@@ -107,7 +107,7 @@
             topMenuView.image_top.sd_setImage(with: URL(string: m.imageUrl.jq_urlEncoded()))
         }
 
-								getData()
+        getData()
 
         cellularData = CTCellularData()
         cellularData.cellularDataRestrictionDidUpdateNotifier = {[weak self] state in
@@ -142,95 +142,95 @@
         }
     }
 
-				override func setUI() {
-								super.setUI()
+    override func setUI() {
+        super.setUI()
 
-								let titleView = UIView()
-								titleView.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
-								let titleL = UILabel()
-								titleL.font = Def_SourceHanSansCN_Regular(fontSize: 21)
-								titleL.text = "心 泉 疗 愈"
-								titleL.textAlignment = .center
-								titleL.textColor = UIColor(hexStr: "#252A23")
-								titleL.frame = CGRect(x: 0, y: 0, width: 100, height: 19)
+        let titleView = UIView()
+        titleView.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
+        let titleL = UILabel()
+        titleL.font = Def_SourceHanSansCN_Regular(fontSize: 21)
+        titleL.text = "心 泉 疗 愈"
+        titleL.textAlignment = .center
+        titleL.textColor = UIColor(hexStr: "#252A23")
+        titleL.frame = CGRect(x: 0, y: 0, width: 100, height: 19)
 
-								let subTitleL = UILabel()
-								subTitleL.font = Def_Agenda_Light(fontSize: 8)
-								subTitleL.text = "XIN QUAN"
-								subTitleL.textAlignment = .center
-								subTitleL.textColor = UIColor(hexStr: "#252A23")
-								subTitleL.frame = CGRect(x: 0, y: 20, width: 100, height: 19)
+        let subTitleL = UILabel()
+        subTitleL.font = Def_Agenda_Light(fontSize: 8)
+        subTitleL.text = "XIN QUAN"
+        subTitleL.textAlignment = .center
+        subTitleL.textColor = UIColor(hexStr: "#252A23")
+        subTitleL.frame = CGRect(x: 0, y: 20, width: 100, height: 19)
 
 
-								titleView.addSubview(titleL)
-								titleView.addSubview(subTitleL)
+        titleView.addSubview(titleL)
+        titleView.addSubview(subTitleL)
 
 
-								navigationItem.titleView = titleView
+        navigationItem.titleView = titleView
 
-								 let search = UIButton(type: .custom)
-								search.setImage(UIImage(named: "btn_search"), for: .normal)
-								search.addTarget(self, action: #selector(searchAction), for: .touchUpInside)
-								search.bounds = CGRect(origin: .zero, size:CGSize(width: 50, height: 30))
-								navigationItem.leftBarButtonItem = UIBarButtonItem(customView: search)
+        let search = UIButton(type: .custom)
+        search.setImage(UIImage(named: "btn_search"), for: .normal)
+        search.addTarget(self, action: #selector(searchAction), for: .touchUpInside)
+        search.bounds = CGRect(origin: .zero, size:CGSize(width: 50, height: 30))
+        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: search)
 
 
-								let voices = UIButton(type: .custom)
-								voices.setImage(UIImage(named: "btn_voices"), for: .normal)
-								voices.addTarget(self, action: #selector(settingvoiceAction), for: .touchUpInside)
-								voices.bounds = CGRect(origin: .zero, size:CGSize(width: 50, height: 30))
-								navigationItem.rightBarButtonItem = UIBarButtonItem(customView: voices)
+        let voices = UIButton(type: .custom)
+        voices.setImage(UIImage(named: "btn_voices"), for: .normal)
+        voices.addTarget(self, action: #selector(settingvoiceAction), for: .touchUpInside)
+        voices.bounds = CGRect(origin: .zero, size:CGSize(width: 50, height: 30))
+        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: voices)
 
-								tableView = UITableView(frame: .zero, style: .plain)
-								tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 40, right: 0)
-								tableView.showsVerticalScrollIndicator = false
-								DispatchQueue.main.async {
-												let h = 119 + 20.5 + JQ_ScreenW * 0.913
-												self.topMenuView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: h)
-												self.tableView.tableHeaderView = self.topMenuView
-								}
+        tableView = UITableView(frame: .zero, style: .plain)
+        tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 40, right: 0)
+        tableView.showsVerticalScrollIndicator = false
+        DispatchQueue.main.async {
+            let h = 119 + 20.5 + JQ_ScreenW * 0.913
+            self.topMenuView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: h)
+            self.tableView.tableHeaderView = self.topMenuView
+        }
 
-								tableView.tableHeaderView = topMenuView
+        tableView.tableHeaderView = topMenuView
 
-								tableView.register(UINib(nibName: "Home_Style_1_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_1_TCell")
-								tableView.register(UINib(nibName: "Home_Style_2_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_2_TCell")
-								tableView.register(UINib(nibName: "Home_Style_3_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_3_TCell")
-								tableView.register(UINib(nibName: "Home_Style_4_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_4_TCell")
+        tableView.register(UINib(nibName: "Home_Style_1_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_1_TCell")
+        tableView.register(UINib(nibName: "Home_Style_2_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_2_TCell")
+        tableView.register(UINib(nibName: "Home_Style_3_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_3_TCell")
+        tableView.register(UINib(nibName: "Home_Style_4_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_4_TCell")
 
-								tableView.register(UINib(nibName: "Home_Style_5_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_5_TCell")
+        tableView.register(UINib(nibName: "Home_Style_5_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_5_TCell")
 
-								tableView.separatorStyle = .none
-								tableView.delegate = self
-								tableView.dataSource = self
-								if #available(iOS 15.0, *) {
-												tableView.sectionHeaderTopPadding = 0
-								} else {
+        tableView.separatorStyle = .none
+        tableView.delegate = self
+        tableView.dataSource = self
+        if #available(iOS 15.0, *) {
+            tableView.sectionHeaderTopPadding = 0
+        } else {
 
-								}
-								tableView.register(HomeHeaderView.self, forHeaderFooterViewReuseIdentifier: "_HomeHeaderView")
-								view.addSubview(tableView)
-								tableView.snp.makeConstraints { make in
-												make.edges.equalToSuperview()
-								}
-				}
+        }
+        tableView.register(HomeHeaderView.self, forHeaderFooterViewReuseIdentifier: "_HomeHeaderView")
+        view.addSubview(tableView)
+        tableView.snp.makeConstraints { make in
+            make.edges.equalToSuperview()
+        }
+    }
 
-				override func setRx() {
-								topMenuView.clickItemAt {[unowned self] item in
+    override func setRx() {
+        topMenuView.clickItemAt {[unowned self] item in
             let vc = HomeItemListVC(topTitle: item.title, id: item.id, showType:.vertical)
-												self.push(vc: vc)
-								}
+            self.push(vc: vc)
+        }
 
-								NotificationCenter.default.rx.notification(SetBGMSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
-												self.topMenuView.resetTopImage()
-								}).disposed(by: disposeBag)
+        NotificationCenter.default.rx.notification(SetBGMSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
+            self.topMenuView.resetTopImage()
+        }).disposed(by: disposeBag)
 
-								NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in
+        NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in
             guard let weakSelf = self else { return }
 
             weakSelf.needPopToTree = data.object as? Bool ?? false
             weakSelf.getData()
 
-								}).disposed(by: disposeBag)
+        }).disposed(by: disposeBag)
 
         NotificationCenter.default.rx.notification(LoginSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
             self.getData()
@@ -244,40 +244,40 @@
         NotificationCenter.default.rx.notification(ReloadData_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
             self.tableView.reloadData()
         }).disposed(by: disposeBag)
-				}
+    }
 
-				private func getData(){
+    private func getData(){
         tableView.mj_header?.endRefreshing()
 
-								Services.getCategoryListByType(type: 1).subscribe(onNext: { data in
-												var items = [HomeTopMenuItem]()
-												for v in data.data ?? []{
+        Services.getCategoryListByType(type: 1).subscribe(onNext: { data in
+            var items = [HomeTopMenuItem]()
+            for v in data.data ?? []{
                 let model = HomeTopMenuItem(id: v.id, title: v.categoryName, image: v.firstIconUrl.jq_urlEncoded(), imageFrom: .url)
-																items.append(model)
-												}
+                items.append(model)
+            }
 
-												self.viewModel.homeTopMenuItems = items
-												let h = ceil(Double(items.count) / 4.0) * 119 + 20.5 + JQ_ScreenW * 0.913
-												self.topMenuView.menu_height.constant = ceil(Double(items.count) / 4.0) * 119
-												self.tableView.tableHeaderView?.frame = CGRect(origin: .zero, size: CGSizeMake(JQ_ScreenW, h))
-												self.topMenuView.resetItems(items)
-												self.topMenuView.menu_collectionView.reloadData()
-								}).disposed(by: disposeBag)
+            self.viewModel.homeTopMenuItems = items
+            let h = ceil(Double(items.count) / 4.0) * 119 + 20.5 + JQ_ScreenW * 0.913
+            self.topMenuView.menu_height.constant = ceil(Double(items.count) / 4.0) * 119
+            self.tableView.tableHeaderView?.frame = CGRect(origin: .zero, size: CGSizeMake(JQ_ScreenW, h))
+            self.topMenuView.resetItems(items)
+            self.topMenuView.menu_collectionView.reloadData()
+        }).disposed(by: disposeBag)
 
-								Services.getCategoryListByType(type: 2).subscribe(onNext: { data in
-												var items = [HomeTopMenuItem]()
-												for v in data.data ?? []{
+        Services.getCategoryListByType(type: 2).subscribe(onNext: { data in
+            var items = [HomeTopMenuItem]()
+            for v in data.data ?? []{
                 let model = HomeTopMenuItem(id: v.id, title: v.categoryName, image: v.secondIconUrl.jq_urlEncoded(), imageFrom: .url)
-																items.append(model)
-												}
+                items.append(model)
+            }
             self.viewModel.homeBottomMenuItems = items
-												self.tableView.reloadRows(at: [IndexPath(row: 4, section: 0)], with: .none)
-								}).disposed(by: disposeBag)
+            self.tableView.reloadRows(at: [IndexPath(row: 4, section: 0)], with: .none)
+        }).disposed(by: disposeBag)
 
-								Services.getTopdayMedita().subscribe(onNext: { data in
-												self.viewModel.todyModel = data.data
-												self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
-								}).disposed(by: disposeBag)
+        Services.getTopdayMedita().subscribe(onNext: { data in
+            self.viewModel.todyModel = data.data
+            self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
+        }).disposed(by: disposeBag)
 
 
 
@@ -285,36 +285,36 @@
         let m = MeditationModel()
         m.id = 0
         self.viewModel.privateTodyModels = [m]
-//        if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){
-            Services.getPersonalityPlan().subscribe(onNext: { data in
-                if let m = data.data{
-                    if m.count > 0{
-                        self.viewModel.privateTodyModels = m
-                    }
-                    self.tableView.reloadRows(at: [IndexPath(row: 1, section: 0)], with: .none)
+        //        if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){
+        Services.getPersonalityPlan().subscribe(onNext: { data in
+            if let m = data.data{
+                if m.count > 0{
+                    self.viewModel.privateTodyModels = m
                 }
-            }).disposed(by: disposeBag)
-//        }else{
-//            self.tableView.reloadData()
-//        }
+                self.tableView.reloadRows(at: [IndexPath(row: 1, section: 0)], with: .none)
+            }
+        }).disposed(by: disposeBag)
+        //        }else{
+        //            self.tableView.reloadData()
+        //        }
 
-								Services.getMeditationAndCateList().subscribe(onNext: { data in
-												if let m = data.data{
-																self.viewModel.meditationList.removeAll()
+        Services.getMeditationAndCateList().subscribe(onNext: { data in
+            if let m = data.data{
+                self.viewModel.meditationList.removeAll()
                 self.titleItems.removeAll()
                 self.titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation"))
                 self.titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Customization",hasMore: true))
                 self.titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide"))
 
 
-																self.viewModel.meditationList = m
+                self.viewModel.meditationList = m
                 for v in self.viewModel.meditationList{
                     if v.clientMeditationCategoryVO?.categoryName.isEmpty ?? true{continue}
-																				self.titleItems.append(TitleItem(title: v.clientMeditationCategoryVO?.categoryName ?? "", subTitle: v.clientMeditationCategoryVO?.description ?? "",hasMore:true))
-																}
-																self.tableView.reloadData()
-												}
-								}).disposed(by: disposeBag)
+                    self.titleItems.append(TitleItem(title: v.clientMeditationCategoryVO?.categoryName ?? "", subTitle: v.clientMeditationCategoryVO?.description ?? "",hasMore:true))
+                }
+                self.tableView.reloadData()
+            }
+        }).disposed(by: disposeBag)
 
         Services.getLunchPage().subscribe(onNext: {data in
 
@@ -340,106 +340,120 @@
             }
 
         }).disposed(by: disposeBag)
-				}
+    }
 
 
-    @objc func autoUpdate(){
-        guard !(viewModel.todyModel?.endPlayTime.isEmpty ?? true) else {return}
+    @objc func autoUpdate() {
+        guard let endPlayTime = viewModel.todyModel?.endPlayTime, !endPlayTime.isEmpty else { return }
 
-        let todayEndDay = Date().jq_format("yyyy-MM-dd") + " \(viewModel.todyModel!.endPlayTime)"
-        let endDayInterval = Date.jq_StringToTimeInterval(todayEndDay,"yyyy-MM-dd HH:mm:ss")
+        let todayEndDay = Date().jq_format("yyyy-MM-dd") + " \(endPlayTime)"
+        let endDayInterval = Date.jq_StringToTimeInterval(todayEndDay, "yyyy-MM-dd HH:mm:ss")
 
-        if Date().timeIntervalSince1970 > endDayInterval{
-            Services.getTopdayMedita().subscribe(onNext: { data in
+        if Date().timeIntervalSince1970 > endDayInterval {
+            Services.getTopdayMedita().subscribe(onNext: { [weak self] data in
+                guard let self = self else { return }
                 self.viewModel.todyModel = data.data
                 self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none)
             }).disposed(by: disposeBag)
         }
     }
 
-				@objc func searchAction(){
+    @objc func searchAction(){
         let vc = SearchVC(serchType: .muse)
-								push(vc: vc)
-				}
+        push(vc: vc)
+    }
 
-				@objc func settingvoiceAction(){
+    @objc func settingvoiceAction(){
         let vc = BackgroundVoiceVC(isFromFist: false)
-								push(vc: vc)
-				}
+        push(vc: vc)
+    }
 
-				@objc func jumpMoreAction(_ sender:UIButton){
-								switch sender.tag {
-												case 201:
-																//跳转计划引导
+    @objc func jumpMoreAction(_ sender:UIButton){
+        switch sender.tag {
+            case 201:
+                //跳转计划引导
                 let nav	= BaseNav(rootViewController: PlanGuideVC(isFromFist: false))
-																nav.modalPresentationStyle = .fullScreen
-																present(nav, animated: true)
-																break
-												default:
-																 let topTitle = titleItems[sender.tag - 200].title
-																let m = viewModel.meditationList[sender.tag - 200 - 3]
-																if let id = m.clientMeditationCategoryVO?.id{
+                nav.modalPresentationStyle = .fullScreen
+                present(nav, animated: true)
+                break
+            default:
+                let topTitle = titleItems[sender.tag - 200].title
+                let m = viewModel.meditationList[sender.tag - 200 - 3]
+                if let id = m.clientMeditationCategoryVO?.id{
                     let vc = HomeItemListVC(topTitle: topTitle, id: id,showType: .vertical)
-																				push(vc: vc)
-																}
-								}
-				}
+                    push(vc: vc)
+                }
+        }
+    }
+
+    deinit {
+        // 使定时器失效
+        timer?.invalidate()
+
+        // 移除通知中心观察者
+        NotificationCenter.default.removeObserver(self)
+    }
+
 }
 
 extension HomeVC:UITableViewDelegate & UITableViewDataSource{
 
-				func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
 
         if indexPath.section == 0{
-            if let m = viewModel.todyModel,let detailId = m.clientMeditationVO?.id{
-                if AudioPlayer.getSharedInstance().meditationModel?.id == m.meditationId{
-                    if AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .paused{
-                        AudioPlayer.getSharedInstance().bgmPlayer?.play()
-                        AudioPlayer.getSharedInstance().masterPlayer?.play()
-                        PayMusicVC.updateStatus(.playing)
-                        self.viewModel.todyModel?.playAtMe = true
-                    }else{
-                        AudioPlayer.getSharedInstance().bgmPlayer?.pause()
-                        AudioPlayer.getSharedInstance().masterPlayer?.pause()
-                        PayMusicVC.updateStatus(.pause)
-                        self.viewModel.todyModel?.playAtMe = false
+            guard let m = viewModel.todyModel, let detailId = m.clientMeditationVO?.id else {
+                alert(msg: "平台暂未设置今日疗愈")
+                return
+            }
+            
+            let audioPlayer = AudioPlayer.getSharedInstance()
+            let isSameMeditation = audioPlayer.meditationModel?.id == m.meditationId
+            let isPaused = audioPlayer.bgmPlayer?.timeControlStatus == .paused
+            
+            if isSameMeditation {
+                if isPaused {
+                    audioPlayer.bgmPlayer?.play()
+                    audioPlayer.masterPlayer?.play()
+                    PayMusicVC.updateStatus(.playing)
+                    viewModel.todyModel?.playAtMe = true
+                } else {
+                    audioPlayer.bgmPlayer?.pause()
+                    audioPlayer.masterPlayer?.pause()
+                    PayMusicVC.updateStatus(.pause)
+                    viewModel.todyModel?.playAtMe = false
+                }
+                DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
+                    self.tableView.reloadData()
+                }
+            } else {
+                // 游客模式都能播放
+                Services.getMeditationDetail(id: detailId).subscribe(onNext: { [weak self] data in
+                    guard let self = self, let m = data.data else { return }
+                    
+                    if audioPlayer.meditationModel?.id == m.id && audioPlayer.bgmPlayer?.timeControlStatus == .playing {
+                        return
                     }
-                    DispatchQueue.main.asyncAfter(delay: 0.4) {
+                    audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self)
+                    PayMusicVC.show(model: m, isHidden: false)
+                    self.viewModel.todyModel?.playAtMe = true
+                    DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
                         self.tableView.reloadData()
                     }
-                }else{
-                    //游客模式都能播放
-                    Services.getMeditationDetail(id: detailId).subscribe(onNext: {[weak self]data in
-                        if let m = data.data{
-
-                            if AudioPlayer.getSharedInstance().meditationModel?.id == m.id && AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .playing{
-                                return
-                            }
-                            AudioPlayer.getSharedInstance().playBGMAt(firstPlayIndex: 0, model: m, delegate: self)
-                            PayMusicVC.show(model: m,isHidden: false)
-                            self?.viewModel.todyModel?.playAtMe = true
-                            DispatchQueue.main.asyncAfter(delay: 1.0) {
-                                self?.tableView.reloadData()
-                            }
-                        }
-                    }).disposed(by: disposeBag)
-                }
-            }else{
-                alert(msg: "平台暂未设置今日疗愈")
+                }).disposed(by: disposeBag)
             }
         }
 
-								if indexPath.section == 2{
-												let vc = WebVC(type: .guide)
-												vc.title = "泉疗愈"
-												push(vc: vc)
-								}
-				}
+        if indexPath.section == 2{
+            let vc = WebVC(type: .guide)
+            vc.title = "泉疗愈"
+            push(vc: vc)
+        }
+    }
 
-				func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         if indexPath.section == 0 && indexPath.row == 0{
             //每日疗愈
-												let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_1_TCell") as! Home_Style_1_TCell
+            let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_1_TCell") as! Home_Style_1_TCell
             if viewModel.todyModel?.id != 0{
                 cell.model = viewModel.todyModel
                 cell.view_data.isHidden = false
@@ -449,109 +463,108 @@
             }
 
             cell.setplaying()
-												return cell
-								}else if indexPath.section == 1 && indexPath.row == 0{
+            return cell
+        }else if indexPath.section == 1 && indexPath.row == 0{
             //私人定制
-												let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell
-												cell.style = .style1
+            let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell
+            cell.style = .style1
             cell.setModels(viewModel.privateTodyModels,showType: .horizontal)
-												return cell
-								}else if indexPath.section == 2 && indexPath.row == 0{
+            return cell
+        }else if indexPath.section == 2 && indexPath.row == 0{
             // 新手冥想指南
-												let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_2_TCell") as! Home_Style_2_TCell
+            let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_2_TCell") as! Home_Style_2_TCell
             cell.imgView.image = UIImage(named: "bg_guide_home")
-												cell.view_shadow.isHidden = true
-												return cell
-								}else {
+            cell.view_shadow.isHidden = true
+            return cell
+        }else {
 
-												let index = indexPath.section - 3
-												if index == 0 && indexPath.row != 0{
-																let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_5_TCell") as! Home_Style_5_TCell
+            let index = indexPath.section - 3
+            if index == 0 && indexPath.row != 0{
+                let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_5_TCell") as! Home_Style_5_TCell
                 cell.setHomeTopMenuItem(viewModel.homeBottomMenuItems)
-																return cell
-												}else{
-																let m = viewModel.meditationList[index]
-																if m.clientMeditationCategoryVO!.showType == .horizontal{
-																				let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell
-																				cell.style = .style2
+                return cell
+            }else{
+                let m = viewModel.meditationList[index]
+                if m.clientMeditationCategoryVO!.showType == .horizontal{
+                    let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell
+                    cell.style = .style2
                     cell.setModels(m.clientMeditationVOList,showType: .horizontal)
-																				return cell
-																}else if m.clientMeditationCategoryVO!.showType == .vertical{
-																				let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_3_TCell") as! Home_Style_3_TCell
+                    return cell
+                }else if m.clientMeditationCategoryVO!.showType == .vertical{
+                    let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_3_TCell") as! Home_Style_3_TCell
                     cell.setModels(m.clientMeditationVOList,showType: .vertical)
-																				return cell
-																}
-												}
-												return UITableViewCell()
-								}
-				}
+                    return cell
+                }
+            }
+            return UITableViewCell()
+        }
+    }
 
-				func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 
-								if section - 3 == 0{
-												return 2
-								}
-								return 1
-				}
+        if section - 3 == 0{
+            return 2
+        }
+        return 1
+    }
 
-				func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-								if indexPath.section == 0 || indexPath.section == 1 || indexPath.section == 2{
-												return JQ_ScreenW * 0.551
-								}else{
-												let index = indexPath.section - 3
-												let m = viewModel.meditationList[index]
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        if indexPath.section == 0 || indexPath.section == 1 || indexPath.section == 2{
+            return JQ_ScreenW * 0.551
+        }else{
+            let index = indexPath.section - 3
+            let m = viewModel.meditationList[index]
 
-												if index == 0 && indexPath.row != 0 {
-																return 236
-												}
+            if index == 0 && indexPath.row != 0 {
+                return 236
+            }
 
-												if m.clientMeditationCategoryVO?.showType == .horizontal{
-																return 328
-												}else{
-																return 213
-												}
-								}
-				}
+            if m.clientMeditationCategoryVO?.showType == .horizontal{
+                return 328
+            }else{
+                return 213
+            }
+        }
+    }
 
-				func numberOfSections(in tableView: UITableView) -> Int {
-								return titleItems.count
-				}
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return titleItems.count
+    }
 
-				func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
-								return 80.5
-				}
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+        return 80.5
+    }
 
-				func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
-								let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "_HomeHeaderView") as! HomeHeaderView
-								headerView.setTitle(titleItems[section].title, subTitle: titleItems[section].subTitle)
-								headerView.btn_more.isHidden = !titleItems[section].hasMore
-								headerView.btn_more.tag = section + 200
-								headerView.btn_more.addTarget(self, action: #selector(jumpMoreAction(_:)), for: .touchUpInside)
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+        let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "_HomeHeaderView") as! HomeHeaderView
+        headerView.setTitle(titleItems[section].title, subTitle: titleItems[section].subTitle)
+        headerView.btn_more.isHidden = !titleItems[section].hasMore
+        headerView.btn_more.tag = section + 200
+        headerView.btn_more.addTarget(self, action: #selector(jumpMoreAction(_:)), for: .touchUpInside)
 
-								if section == 1{
-												headerView.btn_more.setImage(UIImage(named: "btn_more"), for: .normal)
-								}else{
-												headerView.btn_more.setImage(UIImage(named: "icon_exchange"), for: .normal)
-								}
-								return headerView
-				}
-
+        if section == 1{
+            headerView.btn_more.setImage(UIImage(named: "btn_more"), for: .normal)
+        }else{
+            headerView.btn_more.setImage(UIImage(named: "icon_exchange"), for: .normal)
+        }
+        return headerView
+    }
 
 }
 
 extension HomeVC:UIScrollViewDelegate{
-				func scrollViewDidScroll(_ scrollView: UIScrollView) {
-//								let v = min(scrollView.contentOffset.y / JQ_NavBarHeight, 1)
-//								navigationController?.navigationBar.standardAppearance.backgroundColor = .white.withAlphaComponent(v)
+    func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        //								let v = min(scrollView.contentOffset.y / JQ_NavBarHeight, 1)
+        //								navigationController?.navigationBar.standardAppearance.backgroundColor = .white.withAlphaComponent(v)
         navigationController?.navigationBar.standardAppearance.backgroundColor = .white
         navigationController?.navigationBar.scrollEdgeAppearance?.backgroundColor = .white
-				}
+    }
 }
 
 extension HomeVC:PayMusicDelegate{
     func playState(_ state: PlayMusicState) {
 
     }
-    
+
 
 }
diff --git a/XQMuse/Root/Home/VC/PaymentOrderVC.swift b/XQMuse/Root/Home/VC/PaymentOrderVC.swift
index bd894d3..68b1cc4 100644
--- a/XQMuse/Root/Home/VC/PaymentOrderVC.swift
+++ b/XQMuse/Root/Home/VC/PaymentOrderVC.swift
@@ -172,7 +172,7 @@
 												alertError(msg: "请输入正确的手机号");return
 								}
 
-								Services.searchUserByPhone(tf_phone.text!).subscribe(onNext: { data in
+        Services.searchUserByPhone(tf_phone.text!,ignoreAlert: false).subscribe(onNext: { data in
 												self.view_searchUserResult.isHidden = false
 												if let m = data.data,m.id != 0{
 																self.giftUserId = m.id
@@ -229,6 +229,10 @@
         if let m = museModel{
             money = m.iosPrice
             id = m.id
+
+            guard id != UserViewModel.getAvatarInfo().id else {
+                alertError(msg: "不能赠送给自己");return
+            }
         }
 
         guard btn_isRead.isSelected else {
diff --git a/XQMuse/Root/Login/VC/UpdatePhoneVC.swift b/XQMuse/Root/Login/VC/UpdatePhoneVC.swift
index 6ab3a5c..f177d1f 100644
--- a/XQMuse/Root/Login/VC/UpdatePhoneVC.swift
+++ b/XQMuse/Root/Login/VC/UpdatePhoneVC.swift
@@ -119,11 +119,20 @@
         }
 
 
-        Services.confirmByApple(cellPhone: tf_phone.text!, captcha: tf_code.text!, loginType: threePlantformLoginType, wxOrAppleId: unionId,name: formatName, mail: credential!.email).subscribe(onNext: {data in
+        Services.confirmByApple(cellPhone: tf_phone.text!, captcha: tf_code.text!, loginType: threePlantformLoginType, wxOrAppleId: unionId,name: formatName, mail: credential?.email).subscribe(onNext: {data in
             if var model = data.data{
-                model.loginByAppleToken = String(data: self.credential!.identityToken!, encoding: .utf8)
+
+                if threePlantformLoginType == .apple{
+                    model.loginByAppleToken = String(data: self.credential!.identityToken!, encoding: .utf8)
+                    model.appleId = self.credential!.user
+                }
+
+                if threePlantformLoginType == .wechat{
+                    model.wechatOpenId = unionId
+                }
+
                 model.accessToken = model.accessToken
-                model.appleId = self.credential!.user
+
                 UserViewModel.saveLoginInfo(model)
 
                 Services.getUserInfo().subscribe(onNext: {data in
diff --git a/XQMuse/Root/Network/Services.swift b/XQMuse/Root/Network/Services.swift
index 80b49f4..0eee923 100644
--- a/XQMuse/Root/Network/Services.swift
+++ b/XQMuse/Root/Network/Services.swift
@@ -13,8 +13,8 @@
 import CoreLocation
 
 #if DEBUG
-//let All_Url = "https://xq.xqzhihui.com/api"
-let All_Url = "http://192.168.110.64:9000"
+let All_Url = "https://xq.xqzhihui.com/api"
+//let All_Url = "http://192.168.110.64:9000"
 //let All_Url = "https://mock.apipost.net/mock/31b303c60464000"
 #else
 let All_Url = "https://xq.xqzhihui.com/api"
@@ -416,12 +416,12 @@
 
 ///用户相关
 extension Services{
-				class func searchUserByPhone(_ phone:String)->Observable<BaseResponse<UserInfoModel>>{
+    class func searchUserByPhone(_ phone:String,ignoreAlert:Bool)->Observable<BaseResponse<UserInfoModel>>{
 								let params = ParamsAppender.build(url: All_Url)
 								params.interface(url: "/user/client/app-user/getUserByPhone")
 												.append(key: "phone", value: phone)
 												.append(key: "apipost_id", value: "2e763463799135")
-        return NetworkRequest.request(params: params, method: .post, progress: true,ignoreAlert: true)
+        return NetworkRequest.request(params: params, method: .post, progress: true,ignoreAlert: ignoreAlert)
 				}
 
 				/// 获取用户信息
@@ -499,11 +499,12 @@
 								return NetworkRequest.request(params: params, method: .get, progress: true)
 				}
 
-				class func saveUserAnswers(_ model:ResponseUserAnswerModel)->Observable<BaseResponse<SimpleModel>>{
+    class func saveUserAnswers(_ model:ResponseUserAnswerModel,device:String)->Observable<BaseResponse<SimpleModel>>{
 								let params = ParamsAppender.build(url: All_Url)
 								params.interface(url: "/user/client/app-user/saveUserAnswers")
 												.append(dic: model.toJSON()!)
 												.append(key: "apipost_id", value: "25c3dab9f0e025")
+            .append(key: "device", value: device)
         return NetworkRequest.request(params: params, method: .post,encoding: JSONEncoding(), progress: true)
 				}
 
diff --git a/XQMuse/Root/Plans/PlanGuideVC.swift b/XQMuse/Root/Plans/PlanGuideVC.swift
index b6373e6..b20941e 100644
--- a/XQMuse/Root/Plans/PlanGuideVC.swift
+++ b/XQMuse/Root/Plans/PlanGuideVC.swift
@@ -98,7 +98,7 @@
 								label_title.font = Def_FlyFlowerSong(fontSize: 35)
 								label_title.textColor = .white
 
-								label_subTitle.attributedText = 	AttributedStringbuilder.build().add(string: "亲爱的家人,温暖喜悦问候您\n我是心泉老师\n欢迎来到泉疗愈空间\n愿这一方空间为您带来\n平和 喜悦 放松 宁静", withFont: Def_SourceHanSerif_Regular(fontSize: 17), withColor: .white,lineSpace: 10).mutableAttributedString
+								label_subTitle.attributedText = 	AttributedStringbuilder.build().add(string: "亲爱的家人,温暖喜悦问候您\n我是心泉老师\n欢迎来到泉疗愈空间\n愿这一方空间为您带来\n放松 平和 宁静 与喜悦", withFont: Def_SourceHanSerif_Regular(fontSize: 17), withColor: .white,lineSpace: 10).mutableAttributedString
 								label_subTitle.textAlignment = .center
 
 
diff --git a/XQMuse/Root/Plans/PlanGuide_3_VC.swift b/XQMuse/Root/Plans/PlanGuide_3_VC.swift
index f96cef5..9ef8a43 100644
--- a/XQMuse/Root/Plans/PlanGuide_3_VC.swift
+++ b/XQMuse/Root/Plans/PlanGuide_3_VC.swift
@@ -70,9 +70,16 @@
 
 				@IBAction func nextAction(_ sender: UIButton) {
         responseUserAnswerModel.tagIds = selectModels.map({"\($0.id)"}).joined(separator: ",")
-								Services.saveUserAnswers(responseUserAnswerModel).subscribe(onNext: { data in
-												NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: true)
-								}).disposed(by: disposeBag)
+
+        if UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true{
+            UserDefaults.standard.set(responseUserAnswerModel.toJSONString(), forKey: "saveUserAnswers")
+            UserDefaults.standard.synchronize()
+            NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: true)
+        }else{
+            Services.saveUserAnswers(responseUserAnswerModel, device: UserViewModel.DeviceUUID).subscribe(onNext: { data in
+                NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: true)
+            }).disposed(by: disposeBag)
+        }
 				}
 
 				@IBAction func previousAction(_ sender: UIButton) {
diff --git a/XQMuse/SceneDelegate.swift b/XQMuse/SceneDelegate.swift
index 64ec8bb..04ee6b8 100644
--- a/XQMuse/SceneDelegate.swift
+++ b/XQMuse/SceneDelegate.swift
@@ -87,6 +87,15 @@
 
 				func loginSuccess(){
         NotificationCenter.default.post(name: LoginSuccess_Noti, object: nil)
+
+        if let jsonString = UserDefaults.standard.value(forKey: "saveUserAnswers") as? String{
+            if let model = ResponseUserAnswerModel.deserialize(from: jsonString){
+                Services.saveUserAnswers(model, device: UserViewModel.DeviceUUID).subscribe(onNext: { data in
+                    UserDefaults.standard.set(nil, forKey: "saveUserAnswers")
+                    NotificationCenter.default.post(name: LoginSuccess_Noti, object: nil, userInfo: nil)
+                }).disposed(by: JQ_disposeBag)
+            }
+        }
 				}
 
     func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
@@ -114,6 +123,7 @@
                                                     Services.getUserInfo().subscribe(onNext: {data in
                                                         if let model = data.data{
                                                             UserViewModel.saveAvatarInfo(model)
+                                                            sceneDelegate?.loginSuccess()
                                                         }
                                                     }).disposed(by: JQ_disposeBag)
                                                 }else{

--
Gitblit v1.7.1