From 19a3cec9bbafe352d67a57ae9a1c4c601c73b6c0 Mon Sep 17 00:00:00 2001
From: younger_times <841720330@qq.com>
Date: 星期四, 27 七月 2023 22:19:27 +0800
Subject: [PATCH] fix

---
 WanPai/Root/Course/VC/CourseInfoVC.swift |  136 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 128 insertions(+), 8 deletions(-)

diff --git a/WanPai/Root/Course/VC/CourseInfoVC.swift b/WanPai/Root/Course/VC/CourseInfoVC.swift
index 4ff3af3..6e9705e 100644
--- a/WanPai/Root/Course/VC/CourseInfoVC.swift
+++ b/WanPai/Root/Course/VC/CourseInfoVC.swift
@@ -33,12 +33,17 @@
     @IBOutlet weak var btn_record: UIButton!
     @IBOutlet weak var view_schedule: UIView!
     @IBOutlet weak var tableView: UITableView!
+    @IBOutlet weak var cons_tableHei: NSLayoutConstraint!
     @IBOutlet weak var mentalCollectionView: UICollectionView!
     @IBOutlet weak var cons_mentalViewHei: NSLayoutConstraint!
     @IBOutlet weak var exerciseCollectionView: UICollectionView!
     @IBOutlet weak var label_weeklyScope: UILabel!
+    @IBOutlet weak var label_totalNums: UILabel!
+    @IBOutlet weak var label_deductedNums: UILabel!
+    @IBOutlet weak var label_remainingNums: UILabel!
 
     var startClouseHomeModel:StartClouseHomeModel?
+    var weeklyCourseModels = [WeeklyCourseModel]()
     private var currentDate = Date()
 
     private var mentals = [StudentMedalModel]()
@@ -114,6 +119,11 @@
                 pageMenu.setItems(m.courseList.map({$0.courseName}), selectedItemIndex: 0)
             }
 
+            exerciseCollectionView.reloadData()
+            label_totalNums.text = "总课时数\( m.courseList.first?.totalNums ?? 0)"
+            label_deductedNums.text = "已扣学时数\( m.courseList.first?.deductedNums ?? 0)"
+            label_remainingNums.text = "剩余学时数\( m.courseList.first?.remainingNums ?? 0)"
+
 
             Services.studMedalList(studentId: m.stuId).subscribe(onNext: {[weak self] data in
                 guard let weakSelf = self else { return }
@@ -124,6 +134,8 @@
                     weakSelf.cons_mentalViewHei.constant = he
                 }
             }).disposed(by: disposeBag)
+
+            getSelectDayData()
         }
     }
 
@@ -153,6 +165,11 @@
         tableView.delegate = self
         tableView.dataSource = self
         tableView.isScrollEnabled = false
+        if #available(iOS 15.0, *) {
+            tableView.sectionHeaderTopPadding = 0
+        } else {
+
+        }
         tableView.separatorStyle = .none
         tableView.register(UINib(nibName: "CourseBookingTCell", bundle: nil), forCellReuseIdentifier: "_CourseBookingTCell")
 
@@ -205,7 +222,11 @@
 
     @IBAction func detailAction(_ sender: UIButton) {
         guard (startClouseHomeModel?.courseList.count ?? 0) > 0 else {return}
-        let vc = StudentCourseDetailVC()
+
+        let index = pageMenu.selectedItemIndex
+        let models = startClouseHomeModel!.courseList
+        let studentModel = StudentSimpleProfileModel(stuId: startClouseHomeModel!.stuId, stuName: startClouseHomeModel!.stuName, stuImage: startClouseHomeModel!.stuImg)
+        let vc = StudentCourseDetailVC(models: models,defaultIndex: index,studentModel: studentModel)
         push(vc: vc)
     }
 
@@ -217,8 +238,21 @@
 
 
     @IBAction func remarkAction(_ sender: UIButton) {
-        let vc = StudentRemarkListVC()
+        guard startClouseHomeModel != nil else {return}
+        let vc = StudentRemarkListVC(stuId: startClouseHomeModel!.stuId)
         push(vc: vc)
+    }
+
+    private func getSelectDayData(){
+        if let model = startClouseHomeModel{
+            Services.weeksOfCourseDetails(stuId: model.stuId, time: currentDate).subscribe(onNext: {[weak self] data in
+                if let models = data.data{
+                    self?.weeklyCourseModels = models
+                    self?.cons_tableHei.constant = Double(models.flatMap({$0.courses}).count) * 70 + 58 * Double(models.count)
+                    self?.tableView.reloadData()
+                }
+            }).disposed(by: disposeBag)
+        }
     }
 
     override var preferredStatusBarStyle: UIStatusBarStyle{
@@ -238,16 +272,90 @@
 extension CourseInfoVC:UITableViewDataSource{
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseBookingTCell") as! CourseBookingTCell
+        cell.contentView.backgroundColor = UIColor(hexStr: "#F2F6F9")
+
+        if indexPath.row == 0 && weeklyCourseModels[indexPath.section].courses.count == 1{
+            cell.contentView.jq_addCorners(corner: [.allCorners], radius: 16,width: JQ_ScreenW - 48,height: 70)
+        }else if indexPath.row == 0 && weeklyCourseModels[indexPath.section].courses.count != 1{
+            cell.contentView.jq_addCorners(corner: [.topLeft,.topRight], radius: 16,width: JQ_ScreenW - 48,height: 70)
+        }else if indexPath.row == weeklyCourseModels[indexPath.section].courses.count - 1{
+            cell.contentView.jq_addCorners(corner: [.bottomLeft,.bottomRight], radius: 16,width: JQ_ScreenW - 48,height: 70)
+        }else{
+            cell.contentView.jq_addCorners(corner: [.allCorners], radius: 0,width: JQ_ScreenW - 48,height: 70)
+        }
+        cell.weeklyCourseItemModel = weeklyCourseModels[indexPath.section].courses[indexPath.row]
+        cell.clickClouse = {m in
+            print("--->")
+        }
 
         return cell
     }
 
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return 1
+        return weeklyCourseModels[section].courses.count
+}
+
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return weeklyCourseModels.count
     }
 
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
         return 70
+    }
+
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+        let m = weeklyCourseModels[section]
+       var headerView  = tableView.dequeueReusableHeaderFooterView(withIdentifier: "header")
+        if headerView == nil{
+            headerView = UITableViewHeaderFooterView(reuseIdentifier: "header")
+
+            let contentView = UIView()
+            contentView.borderColor = UIColor(hexStr: "#E7E3E3")
+            contentView.borderWidth = 1
+            contentView.cornerRadius = 11
+            headerView?.contentView.addSubview(contentView)
+            contentView.snp.makeConstraints { make in
+                make.center.equalToSuperview()
+                make.left.right.equalToSuperview()
+                make.height.equalTo(22)
+            }
+
+            let label_address = UILabel()
+            label_address.tag = 1000
+            label_address.text = "成都非遗玩湃全科体育公园   0.0km"
+            label_address.font = UIFont.systemFont(ofSize: 10, weight: .medium)
+            label_address.textColor = UIColor(hexStr: "#AFB4BC")
+            contentView.addSubview(label_address)
+            label_address.snp.makeConstraints { make in
+                make.left.equalToSuperview().offset(12)
+                make.centerY.equalToSuperview()
+                make.right.equalTo(-50)
+            }
+
+            let btn_detial = QMUIButton(type: .custom)
+            btn_detial.setTitle("位置详情", for: .normal)
+            btn_detial.titleLabel?.font = UIFont.systemFont(ofSize: 10)
+            btn_detial.setTitleColor(UIColor(hexStr: "#AFB4BC"), for: .normal)
+            btn_detial.setImage(UIImage(named: "icon_pop"), for: .normal)
+            btn_detial.imagePosition = .left
+            btn_detial.spacingBetweenImageAndTitle = 3
+            contentView.addSubview(btn_detial)
+            btn_detial.snp.makeConstraints { make in
+                make.right.equalTo(-10)
+                make.centerY.equalToSuperview()
+            }
+        }
+
+        if let label = headerView?.contentView.viewWithTag(1000) as? UILabel{
+            label.text = String(format: "%@ %.1km", m.areaName,m.siteDistance)
+        }
+
+        headerView?.contentView.backgroundColor = .white
+        return headerView
+    }
+
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+        return 58
     }
 }
 
@@ -268,7 +376,12 @@
 
 extension CourseInfoVC:UICollectionViewDataSource{
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return mentals.count
+
+        if collectionView.tag == 1000{
+            return mentals.count
+        }else{
+            return startClouseHomeModel?.exerciseVideoList.count ?? 0
+        }
     }
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
@@ -279,7 +392,9 @@
             cell.t2.text = mentals[indexPath.row].medalType.title
             return cell
         } else{
+            let model = startClouseHomeModel!.exerciseVideoList[indexPath.row]
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_StudentVideoCCell", for: indexPath) as! StudentVideoCCell
+            cell.videoListModel = model
             return cell
         }
     }
@@ -315,7 +430,12 @@
 
 extension CourseInfoVC:SPPageMenuDelegate{
     func pageMenu(_ pageMenu: SPPageMenu, itemSelectedAt index: Int) {
-        
+        guard startClouseHomeModel != nil else {return}
+        if let m = startClouseHomeModel?.courseList[index]{
+            label_totalNums.text = "总课时数\( m.totalNums)"
+            label_deductedNums.text = "已扣学时数\( m.deductedNums)"
+            label_remainingNums.text = "剩余学时数\( m.remainingNums)"
+        }
     }
 }
 
@@ -335,9 +455,9 @@
     }
 
     func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController {
-        let vc = CourseInfoScheduleVC(index: page) { date in
-            self.currentDate = date
-
+        let vc = CourseInfoScheduleVC(index: page) {[weak self] date in
+            self?.currentDate = date
+            self?.getSelectDayData()
         }
         return vc
     }

--
Gitblit v1.7.1