From 731a5d58da1d182ded7b389ce0f391623978995c Mon Sep 17 00:00:00 2001
From: 杨锴 <841720330@qq.com>
Date: 星期三, 30 十月 2024 17:43:33 +0800
Subject: [PATCH] fix

---
 XQMuse/Root/Course/VC/CourseDetialVC.swift |   99 +++++++++++++++++++++++++++----------------------
 1 files changed, 55 insertions(+), 44 deletions(-)

diff --git a/XQMuse/Root/Course/VC/CourseDetialVC.swift b/XQMuse/Root/Course/VC/CourseDetialVC.swift
index acb976c..6503f1f 100644
--- a/XQMuse/Root/Course/VC/CourseDetialVC.swift
+++ b/XQMuse/Root/Course/VC/CourseDetialVC.swift
@@ -129,40 +129,46 @@
 				}
 
 				private func getData(){
-								Services.getCourseDetail(courseId: courseId).subscribe(onNext: {data in
+								Services.getCourseDetail(courseId: courseId).subscribe(onNext: {[weak self] data in
+            guard let weakSelf = self else { return }
 												if let m = data.data{
-																self.courseDetailModel = m
-                self.collect_bitem.image = m.isCollect == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect")
-                self.collect_bitem.tintColor = m.isCollect == .yes ? UIColor(hexString: "#fe5b60"):.white
-																self.headerView.setCourseModel(m)
-																self.section1TCell.setItems(m)
-																self.section2TCell.setItems(m.list2)
+                weakSelf.courseDetailModel = m
+                weakSelf.collect_bitem.image = m.isCollect == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect")
+                weakSelf.collect_bitem.tintColor = m.isCollect == .yes ? UIColor(hexString: "#fe5b60"):.white
+                weakSelf.headerView.setCourseModel(m)
+                weakSelf.section1TCell.setItems(m)
+                weakSelf.section2TCell.setItems(m.list2)
 
-                //是否需要购买
-                var  needPayment:Bool = true
-                switch m.chargeType{
-                    case .free:needPayment = false
-                    case .payment:needPayment = !(m.isBuy == .yes)
-                    case .vipFree:needPayment = !(UserViewModel.getAvatarInfo().isVip == .yes)
-                }
+                if m.courseType == .online{
+                    weakSelf.style = .style1
+                    weakSelf.pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0)
 
-                if needPayment{
-																				let attribute	= AttributedStringbuilder.build().add(string: "    疗愈币", withFont: .systemFont(ofSize: 12,weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "\(m.generalPrice.jq_formatFloat)", withFont: .systemFont(ofSize: 21.71, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "  立即购买     ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString
-																				self.studyBtn.setAttributedTitle(attribute, for: .normal)
-                }else{
-                    let attribute = AttributedStringbuilder.build().add(string: "    立即学习    ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString
-                    self.studyBtn.setAttributedTitle(attribute, for: .normal)
-                }
+                    //是否需要购买
+                    var  needPayment:Bool = true
+                    switch m.chargeType{
+                        case .free:needPayment = false
+                        case .payment:needPayment = !(m.isBuy == .yes)
+                        case .vipFree:needPayment = !(UserViewModel.getAvatarInfo().isVip == .yes)
+                    }
 
-																if m.detailUrl.jq_isVideo{
-																				self.style = .style1
-																				self.pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0)
+                    if needPayment{
+                        let attribute    = AttributedStringbuilder.build().add(string: "    疗愈币", withFont: .systemFont(ofSize: 12,weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "\(m.generalPrice.jq_formatFloat)", withFont: .systemFont(ofSize: 21.71, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "  立即购买     ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString
+                        weakSelf.studyBtn.setAttributedTitle(attribute, for: .normal)
+                    }else{
+                        let attribute = AttributedStringbuilder.build().add(string: "    立即学习    ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString
+                        weakSelf.studyBtn.setAttributedTitle(attribute, for: .normal)
+                    }
+
+                    weakSelf.setFootView()
+
 																}else{
-																				self.style = .style2
-																				self.pageMenu.setItems(["简介"], selectedItemIndex: 0)
+                    weakSelf.style = .style2
+                    DispatchQueue.main.asyncAfter(delay: 0.5) {
+                        weakSelf.headerView.setVideo(url: m.detailUrl, coverImageUrl: m.coverUrl, delegate: self!)
+                    }
+                    weakSelf.pageMenu.setItems(["简介"], selectedItemIndex: 0)
 																}
-																self.tableView?.reloadData()
-                self.setFootView()
+                weakSelf.tableView?.reloadData()
 												}
 								}).disposed(by: disposeBag)
 				}
@@ -212,31 +218,31 @@
 																return size.height
 												}
 												return nil
-								}.subscribe(onNext: { [unowned self](height) in
+								}.subscribe(onNext: { [weak self](height) in
 												if let height = height{
-																if height > section0Height{
-																				self.section0Height = height
-																				self.tableView?.reloadData()
+                if height > self?.section0Height ?? 0{
+																				self?.section0Height = height
+																				self?.tableView?.reloadData()
 																}
 												}
 								}).disposed(by: disposeBag)
 
-								NotificationCenter.default.rx.notification(CourseRefresh_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in
-												self.getData()
+								NotificationCenter.default.rx.notification(CourseRefresh_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in
+												self?.getData()
 								}).disposed(by: disposeBag)
 				}
 
     @objc func collectionAction(){
-        Services.clouseFavorite(id: courseId).subscribe(onNext: {data in
-            self.courseDetailModel?.isCollect.troggle()
-            if self.courseDetailModel?.isCollect == .yes{
+        Services.clouseFavorite(id: courseId).subscribe(onNext: {[weak self]data in
+            self?.courseDetailModel?.isCollect.troggle()
+            if self?.courseDetailModel?.isCollect == .yes{
                 alertSuccess(msg: "收藏成功")
-                self.collect_bitem.image = UIImage(named: "btn_collect_1_s")
-                self.collect_bitem.tintColor = UIColor(hexString: "fe5b60")
+                self?.collect_bitem.image = UIImage(named: "btn_collect_1_s")
+                self?.collect_bitem.tintColor = UIColor(hexString: "fe5b60")
             }else{
                 alertSuccess(msg: "已取消收藏")
-                self.collect_bitem.image = UIImage(named: "btn_collect")
-                self.collect_bitem.tintColor = .white
+                self?.collect_bitem.image = UIImage(named: "btn_collect")
+                self?.collect_bitem.tintColor = .white
             }
         }).disposed(by: disposeBag)
     }
@@ -257,7 +263,8 @@
 																let vc = CourseDetialVideoVC(items: m.list, selectIndex: IndexPath(row: 0, section: 0))
 																push(vc: vc);return
 												}
-												let vc = PaymentOrderVC(courseId: m.id)
+
+												let vc = PaymentOrderVC(id: m.id, type: .course)
 												push(vc: vc)
 								}
 				}
@@ -265,7 +272,7 @@
 				@objc func sendGift(_ btn:QMUIButton){
 								if let price = courseDetailModel?.generalPrice{
 												CourseSendGiftView.show(price:price) {
-																let vc = PaymentOrderVC(courseId: self.courseDetailModel!.id,giftToOther: true)
+                let vc = PaymentOrderVC(id: self.courseDetailModel!.id,type: .course,giftToOther: true)
 																self.push(vc: vc)
 												}
 								}
@@ -359,7 +366,7 @@
 												(navigationItem.leftBarButtonItem?.customView as? UIButton)?.setImage(UIImage(named: "btn_back")?.withTintColor(.black.withAlphaComponent(v)), for: .normal)
 
             (navigationItem.rightBarButtonItem?.customView as? UIButton)?.setImage(UIImage(named: "btn_back")?.withTintColor(.black.withAlphaComponent(v)), for: .normal)
-            collect_bitem.tintColor = UIColor(hexString: "#fe5b60")
+            collect_bitem.tintColor = .black
             share_bitem.tintColor = .black
 
 												self.navigationController?.navigationBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor.withAlphaComponent(v),.font:Def_NavFont]
@@ -416,3 +423,7 @@
 								}
 				}
 }
+
+extension CourseDetialVC:CLPlayerDelegate{
+
+}

--
Gitblit v1.7.1