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/VC/CourseVCOfficalCommentVC.swift |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift b/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift
index 627777c..af899b8 100644
--- a/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift
+++ b/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift
@@ -7,12 +7,23 @@
 
 import UIKit
 import JQTools
+import RxRelay
+import RxSwift
+
+class CourseVCOfficalViewModel:RefreshInnerModel<CourseModel>{
+				var cateId = BehaviorRelay<Int?>(value: nil)
+				override func api() -> (Observable<BaseResponse<BaseResponseList<CourseModel>>>)? {
+								return Services.getCoursePageList(page: page)
+				}
+}
 
 class CourseVCOfficalCommentVC: BaseVC {
 
 				private var collectionView:UICollectionView!
 				private var titleItems = [TitleItem]()
 				private var subTitleItems = [TitleItem]()
+				private var bannerModels = [CommonBannerModel]()
+				private var viewModel = CourseVCOfficalViewModel()
 
 				override func viewDidLoad() {
 								super.viewDidLoad()
@@ -20,14 +31,22 @@
 								titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide"))
 								titleItems.append(TitleItem(title: "推荐课程", subTitle: "与内心的宁静与喜悦入睡"))
 
-								subTitleItems.append(TitleItem(title: "会员专区",coverImage: "course_1"))
-								subTitleItems.append(TitleItem(title: "免费专区",coverImage: "course_2"))
-								subTitleItems.append(TitleItem(title: "付费专区",coverImage: "course_3"))
-								subTitleItems.append(TitleItem(title: "线下课程",coverImage: "course_4"))
-								subTitleItems.append(TitleItem(title: "疗愈",coverImage: "course_5"))
-								subTitleItems.append(TitleItem(title: "关系",coverImage: "course_6"))
-								subTitleItems.append(TitleItem(title: "财富",coverImage: "course_7"))
-								subTitleItems.append(TitleItem(title: "分类",coverImage: "course_8"))
+								Services.getCourseCategory().subscribe(onNext: {data in
+												for v in data.data ?? []{
+																self.subTitleItems.append(TitleItem(id:v.id,title: v.name,coverImage: v.imageUrl))
+												}
+												self.collectionView.reloadData()
+								}).disposed(by: disposeBag)
+
+								Services.getCourseBannerList().subscribe(onNext: {data in
+												for (index,v) in (data.data ?? []).enumerated(){
+																self.bannerModels.append(CommonBannerModel(index: index, id: v.id, name: v.name, resource:v.imageUrl, mediaType: .imageUrl))
+												}
+												self.collectionView.reloadData()
+								}).disposed(by: disposeBag)
+
+								viewModel.configure(collectionView)
+								viewModel.beginRefresh()
 
 				}
 
@@ -57,7 +76,8 @@
 extension CourseVCOfficalCommentVC:UICollectionViewDelegate & UICollectionViewDataSource{
 
 				func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-								let vc = CourseDetialVC(courseSytle: .style1)
+								let model = viewModel.dataSource.value!.list[indexPath.row]
+								let vc = CourseDetialVC(courseId: model.id)
 								JQ_currentViewController().jq_push(vc: vc)
 				}
 
@@ -67,6 +87,7 @@
 												let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath) as! HomeHeaderView_1
 												let m = titleItems[indexPath.section]
 												headerView.setTitle(m.title, subTitle: m.subTitle)
+												headerView.btn_more.isHidden = true
 												return headerView
 								}
 								return UICollectionReusableView()
@@ -77,16 +98,19 @@
 								if indexPath.section == 0{
 												let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CourseOfficalCommendTopCCell", for: indexPath) as! CourseOfficalCommendTopCCell
 												cell.setTitles(subTitleItems)
+												cell.setBanners(bannerModels)
 												cell.clickAtClouse { index in
 																let vc = CourseMenuVC()
+																vc.setTitleItem(self.subTitleItems,defaultSelectIndex: index)
 																vc.hidesBottomBarWhenPushed = true
 																JQ_currentNavigationController().pushViewController(vc, animated: true)
 												}
 												return cell
 								}
-
+								let model = viewModel.dataSource.value!.list[indexPath.row]
 								let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell
 								cell.backgroundColor = .jq_randomColor
+								cell.setCourseModel(model)
 								return cell
 				}
 
@@ -94,7 +118,7 @@
 								if section == 0{
 												return 1
 								}
-								return 20
+								return viewModel.dataSource.value?.list.count ?? 0
 				}
 
 				func numberOfSections(in collectionView: UICollectionView) -> Int {

--
Gitblit v1.7.1