From e15c976316feef72ff9bcabce38e0a078f9505db Mon Sep 17 00:00:00 2001
From: 杨锴 <841720330@qq.com>
Date: 星期四, 12 九月 2024 18:18:03 +0800
Subject: [PATCH] fix API

---
 XQMuse/Root/Course/TCell/CourseDetail_3_TCell.swift |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/XQMuse/Root/Course/TCell/CourseDetail_3_TCell.swift b/XQMuse/Root/Course/TCell/CourseDetail_3_TCell.swift
index 4ad3240..7c04393 100644
--- a/XQMuse/Root/Course/TCell/CourseDetail_3_TCell.swift
+++ b/XQMuse/Root/Course/TCell/CourseDetail_3_TCell.swift
@@ -14,6 +14,8 @@
 				private let CellW  = (JQ_ScreenW - 21.5 * 2 - 13.5) / 2
 				private let CellH = ((JQ_ScreenW - 21.5 * 2 - 13.5) / 2) * 1.313
 
+				var items = [CourseModel]()
+
 				override func awakeFromNib() {
 								super.awakeFromNib()
 								backgroundColor = .clear
@@ -25,20 +27,33 @@
 								collectionView.contentInset = UIEdgeInsets(top: 0, left: 21.5, bottom: 0, right: 21.5)
 								collectionView.register(UINib(nibName: "HomeRelaxBanner_2_CCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBanner_2_CCell")
 
-								cons_hei.constant = ceil(5.0 / 2.0) * CellH + floor(5.0 / 2.0) * 13.5
+								cons_hei.constant = 0
+				}
+
+				func setItems(_ items:[CourseModel]){
+								self.items = items
+								cons_hei.constant = ceil(Double(items.count) / 2.0) * CellH + floor(Double(items.count) / 2.0) * 13.5
+								collectionView.reloadData()
 				}
 }
 
 extension CourseDetail_3_TCell:UICollectionViewDelegate & UICollectionViewDataSource{
 				func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-								return 5
+								return items.count
 				}
 				
 				func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
 								let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell
+								cell.setCourseModel(items[indexPath.row])
 								cell.backgroundColor = .jq_randomColor
 								return cell
 				}
+
+				func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+								let model = items[indexPath.row]
+								let vc = CourseDetialVC(courseId: model.id)
+								JQ_currentViewController().jq_push(vc: vc)
+				}
 }
 
 extension CourseDetail_3_TCell:UICollectionViewDelegateFlowLayout{

--
Gitblit v1.7.1