From 3e3bfd1ad307ec2ea42f66e298ccb24cec26955f Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期三, 26 七月 2023 18:13:33 +0800 Subject: [PATCH] 新增 --- WanPai/Root/Course/VC/CourseVideoDetailVC.swift | 88 +++++++++++++++++++++++++++++++------------ 1 files changed, 63 insertions(+), 25 deletions(-) diff --git a/WanPai/Root/Course/VC/CourseVideoDetailVC.swift b/WanPai/Root/Course/VC/CourseVideoDetailVC.swift index cacd2c6..beeaeaa 100644 --- a/WanPai/Root/Course/VC/CourseVideoDetailVC.swift +++ b/WanPai/Root/Course/VC/CourseVideoDetailVC.swift @@ -13,7 +13,8 @@ class CourseVideoDetailVC: BaseVC { @IBOutlet weak var view_videoContainer: UIView! - private var id:Int! + private var id:Int? + private var model:ExerciseVideoModel? @IBOutlet weak var label_name: UILabel! @IBOutlet weak var label_introduce: UILabel! @@ -31,9 +32,14 @@ }() - required init(id:Int) { + init(id:Int) { super.init(nibName: nil, bundle: nil) self.id = id + } + + init(model:ExerciseVideoModel){ + super.init(nibName: nil, bundle: nil) + self.model = model } required init?(coder: NSCoder) { @@ -43,33 +49,65 @@ override func viewDidLoad() { super.viewDidLoad() - Services.benefitsVideoDetail(id: id).subscribe(onNext: { [weak self] data in - if let model = data.data{ - self?.playerVC.player = AVPlayer(url: URL(string: model.courseVideo)!) - self?.playerVC.player?.play() + if let id { + Services.benefitsVideoDetail(id: id).subscribe(onNext: { [weak self] data in + if let model = data.data{ + self?.playerVC.player = AVPlayer(url: URL(string: model.courseVideo)!) + self?.playerVC.player?.play() - self?.label_name.text = model.name - self?.label_coin.text = "\(model.integral)积分" - self?.label_introduce.text = model.introduce - if model.study == 1{ - self?.label_studyState.text = "已学习" - self?.label_studyState.backgroundColor = UIColor(hexStr: "#318C10").withAlphaComponent(0.29) - self?.label_studyState.textColor = UIColor(hexStr: "#318C10") - }else{ - self?.label_studyState.text = "未学习" - self?.label_studyState.backgroundColor = UIColor(hexStr: "#FD9331").withAlphaComponent(0.29) - self?.label_studyState.textColor = Def_ThemeColor - } + self?.label_name.text = model.name + self?.label_coin.text = "\(model.integral)积分" + self?.label_introduce.text = model.introduce + if model.study == 1{ + self?.label_studyState.text = "已学习" + self?.label_studyState.backgroundColor = UIColor(hexStr: "#318C10").withAlphaComponent(0.29) + self?.label_studyState.textColor = UIColor(hexStr: "#318C10") + }else{ + self?.label_studyState.text = "未学习" + self?.label_studyState.backgroundColor = UIColor(hexStr: "#FD9331").withAlphaComponent(0.29) + self?.label_studyState.textColor = Def_ThemeColor + } - SDWebImageDownloader.shared.downloadImage(with: URL(string: model.introductionDrawing)) { image, data, error, state in - if let img = image{ - self?.img_introduceCover.image = img - let radio = img.size.width / img.size.height - self?.cons_imgHei.constant = JQ_ScreenW * radio + SDWebImageDownloader.shared.downloadImage(with: URL(string: model.introductionDrawing)) { image, data, error, state in + if let img = image{ + self?.img_introduceCover.image = img + let radio = img.size.width / img.size.height + self?.cons_imgHei.constant = JQ_ScreenW * radio + } } } - } - }).disposed(by: disposeBag) + }).disposed(by: disposeBag) + } + + if let model{ + Services.exerciseCourseDetail(coursePackageId: model.coursePackageId, videoId: model.videoId).subscribe(onNext: {[weak self] data in + if let model = data.data{ + self?.playerVC.player = AVPlayer(url: URL(string: model.videoURL)!) + self?.playerVC.player?.play() + + self?.label_name.text = model.packageName + self?.label_coin.text = "\(model.integral)积分" + self?.label_introduce.text = model.synopsis + if model.studyStatus == 1{ + self?.label_studyState.text = "已学习" + self?.label_studyState.backgroundColor = UIColor(hexStr: "#318C10").withAlphaComponent(0.29) + self?.label_studyState.textColor = UIColor(hexStr: "#318C10") + }else{ + self?.label_studyState.text = "未学习" + self?.label_studyState.backgroundColor = UIColor(hexStr: "#FD9331").withAlphaComponent(0.29) + self?.label_studyState.textColor = Def_ThemeColor + } + + SDWebImageDownloader.shared.downloadImage(with: URL(string: model.detailedDiagram)) { image, data, error, state in + if let img = image{ + self?.img_introduceCover.image = img + let radio = img.size.width / img.size.height + self?.cons_imgHei.constant = JQ_ScreenW * radio + } + } + } + }).disposed(by: disposeBag) + } } override func setUI() { -- Gitblit v1.7.1