From 3d8ce4866799bea7e66699acdeb86b60b0ba033c Mon Sep 17 00:00:00 2001 From: 无故事王国 <841720330@qq.com> Date: 星期一, 03 六月 2024 19:51:06 +0800 Subject: [PATCH] add --- DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenMenuVC.swift | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenMenuVC.swift b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenMenuVC.swift index d22fedc..366d310 100644 --- a/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenMenuVC.swift +++ b/DolphinEnglishLearnStudent/Moudle/Home/Listen/VC/HomeListenMenuVC.swift @@ -9,15 +9,27 @@ class HomeListenMenuVC: BaseVC { + @IBOutlet weak var tableView: UITableView! @IBOutlet weak var collectionView: UICollectionView! + private var repeatColors = ["#F8A169","#92CADB","#9E8ADB","#6DD1BA","#37C06E","#DEB975","#C54A59","#5DA0D3","#F0C433","#DC4827"] private var titleItems = ["第一季","第二季","第三季","第四季"] private var selectIndexPath:IndexPath = IndexPath(row: 0, section: 0) + private var dataItems = Array<[ListenWeekModel]>(repeating: [], count: 4) + override func viewDidLoad() { super.viewDidLoad() + getData() + } + + private func getData(){ + Services.weekList(quarter: selectIndexPath.row).subscribe(onNext: {result in + self.dataItems[self.selectIndexPath.row] = result.data ?? [] + self.collectionView.reloadData() + }).disposed(by: disposeBag) } override func setUI() { @@ -53,7 +65,7 @@ } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 20 + return dataItems[selectIndexPath.row].count } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { @@ -74,6 +86,10 @@ extension HomeListenMenuVC:UITableViewDataSource,UITableViewDelegate{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { selectIndexPath = indexPath + + if dataItems[indexPath.row].count == 0{ + getData() + } tableView.reloadData() } -- Gitblit v1.7.1