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/CourseDetialVideoVC.swift | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift b/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift index 427dd57..17b5ef8 100644 --- a/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift +++ b/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift @@ -13,17 +13,29 @@ @IBOutlet weak var tableView: UITableView! private var videoView:VideoView? + private var items = [CourseItemModel]() + private var selectIndex:IndexPath! override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) (navigationItem.leftBarButtonItem?.customView as? UIButton)?.setImage(UIImage(named: "btn_back")?.withTintColor(.white), for: .normal) } + required init(items:[CourseItemModel],selectIndex:IndexPath) { + super.init(nibName: nil, bundle: nil) + self.items = items + self.selectIndex = selectIndex + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "课程详情" - videoView = VideoView(url: "http://vfx.mtime.cn/Video/2021/07/10/mp4/210710094507540173.mp4") + videoView = VideoView(url: items[selectIndex.row].videoUrl) view_bg_video.addSubview(videoView!) videoView!.snp.makeConstraints { make in make.edges.equalToSuperview() @@ -45,8 +57,9 @@ } extension CourseDetialVideoVC:UITableViewDataSource{ + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + return items.count } func numberOfSections(in tableView: UITableView) -> Int { @@ -60,11 +73,33 @@ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseDetail_2_Inner_TCell") as! CourseDetail_2_Inner_TCell + + cell.setModel(items[indexPath.row], index: indexPath) + + if items[indexPath.row].isOver == .yes{ + cell.btn_study.setTitle("已学习", for: .normal) + cell.btn_study.backgroundColor = UIColor(hexString: "#CDCDCD") + }else{ + cell.btn_study.setTitle("去学习", for: .normal) + cell.btn_study.backgroundColor = UIColor(hexString: "#8AAE65") + } + + if indexPath.row == selectIndex.row{ + cell.btn_study.setTitle("正在学习", for: .normal) + cell.btn_study.backgroundColor = UIColor(hexString: "#E3B25C") + } return cell } } extension CourseDetialVideoVC:UITableViewDelegate{ + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if selectIndex == indexPath{return} + + selectIndex = indexPath + videoView?.updateVideoUrl(items[indexPath.row].videoUrl) + tableView.reloadData() + } } -- Gitblit v1.7.1