From 5415b6659e542b21058428bbc0d38e7f5783815b Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期六, 09 十一月 2024 21:05:29 +0800 Subject: [PATCH] fix bug --- XQMuse/Root/Course/VC/CourseDetialVC.swift | 81 ++++++++++++++++++++-------------------- 1 files changed, 40 insertions(+), 41 deletions(-) diff --git a/XQMuse/Root/Course/VC/CourseDetialVC.swift b/XQMuse/Root/Course/VC/CourseDetialVC.swift index f755278..0e5df32 100644 --- a/XQMuse/Root/Course/VC/CourseDetialVC.swift +++ b/XQMuse/Root/Course/VC/CourseDetialVC.swift @@ -29,7 +29,7 @@ private var currentShowIndex:IndexPath = IndexPath(row: 0, section: 0) var isAnimationing = false private var style:CourseDetialStyle = .style1 - private var courseId:Int! +// private var courseId:Int! private var courseDetailModel:CourseModel? private var section0TCell:CourseDetail_1_TCell! @@ -73,9 +73,9 @@ navigationController?.navigationBar.standardAppearance.backgroundColor = .clear } - init(courseId:Int) { + init(courseModel:CourseModel) { super.init(nibName: nil, bundle: nil) - self.courseId = courseId + self.courseDetailModel = courseModel } required init?(coder: NSCoder) { @@ -144,48 +144,44 @@ } private func getData(){ - Services.getCourseDetail(courseId: courseId).subscribe(onNext: {[weak self] data in - guard let weakSelf = self else { return } - if let m = data.data{ - weakSelf.courseDetailModel = m - weakSelf.collect_bitem.image = m.isCollect == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect") - weakSelf.collect_bitem.tintColor = m.isCollect == .yes ? UIColor(hexString: "#fe5b60"):.white - weakSelf.headerView.setCourseModel(m) - weakSelf.section1TCell.setItems(m) - weakSelf.section2TCell.setItems(m.list2) + if let m = courseDetailModel{ + collect_bitem.image = m.isCollect == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect") + collect_bitem.tintColor = m.isCollect == .yes ? UIColor(hexString: "#fe5b60"):.white + headerView.setCourseModel(m) + section1TCell.setItems(m) + section2TCell.setItems(m.list2) - if m.courseType == .online{ - weakSelf.style = .style1 - weakSelf.pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0) + if m.courseType == .online{ + style = .style1 + pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0) - //是否需要购买 - var needPayment:Bool = true - switch m.chargeType{ - case .free:needPayment = false - case .payment:needPayment = !(m.isBuy == .yes) - case .vipFree:needPayment = !UserViewModel.getAvatarInfo().checkVip() - } + //是否需要购买 + var needPayment:Bool = true + switch m.chargeType{ + case .free:needPayment = false + case .payment:needPayment = !(m.isBuy == .yes) + case .vipFree:needPayment = !UserViewModel.getAvatarInfo().checkVip() + } - if needPayment{ - let attribute = AttributedStringbuilder.build().add(string: " 疗愈币", withFont: .systemFont(ofSize: 12,weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "\(m.iosPrice.jq_formatFloat)", withFont: .systemFont(ofSize: 21.71, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: " 立即购买 ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString - weakSelf.studyBtn.setAttributedTitle(attribute, for: .normal) - }else{ - let attribute = AttributedStringbuilder.build().add(string: " 立即学习 ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString - weakSelf.studyBtn.setAttributedTitle(attribute, for: .normal) - } + if needPayment{ + let attribute = AttributedStringbuilder.build().add(string: " 疗愈币", withFont: .systemFont(ofSize: 12,weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "\(m.iosPrice.jq_formatFloat)", withFont: .systemFont(ofSize: 21.71, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: " 立即购买 ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString + studyBtn.setAttributedTitle(attribute, for: .normal) + }else{ + let attribute = AttributedStringbuilder.build().add(string: " 立即学习 ", withFont: .systemFont(ofSize: 16, weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).mutableAttributedString + studyBtn.setAttributedTitle(attribute, for: .normal) + } - weakSelf.setFootView() + setFootView() - }else{ - weakSelf.style = .style2 - DispatchQueue.main.asyncAfter(delay: 0.5) { - weakSelf.headerView.setVideo(url: m.detailUrl, coverImageUrl: m.coverUrl.jq_urlEncoded(), delegate: self!) - } - weakSelf.pageMenu.setItems(["简介"], selectedItemIndex: 0) - } - weakSelf.tableView?.reloadData() - } - }).disposed(by: disposeBag) + }else{ + style = .style2 + DispatchQueue.main.asyncAfter(delay: 0.5) { + self.headerView.setVideo(url: m.detailUrl, coverImageUrl: m.coverUrl.jq_urlEncoded(), delegate: self) + } + pageMenu.setItems(["简介"], selectedItemIndex: 0) + } + tableView?.reloadData() + } } private func setFootView(){ @@ -235,6 +231,8 @@ } @objc func collectionAction(){ + guard let courseId = courseDetailModel?.id else { return } + Services.clouseFavorite(id: courseId).subscribe(onNext: {[weak self]data in self?.courseDetailModel?.isCollect.troggle() if self?.courseDetailModel?.isCollect == .yes{ @@ -278,6 +276,7 @@ @objc func sendGift(_ btn:QMUIButton){ if let price = courseDetailModel?.iosPrice{ CourseSendGiftView.show(price:price) { + guard sceneDelegate!.checkisLoginState() else{return} let vc = PaymentOrderVC(courseItemModel: self.courseDetailModel!,type: .course,giftToOther: true, showType: .horizontal) self.push(vc: vc) } @@ -396,7 +395,7 @@ if let table = scrollView as? UITableView{ if v > 0{ - table.contentInset = UIEdgeInsets(top: JQ_NavBarHeight + 9, left: 0, bottom: 118, right: 0) + table.contentInset = UIEdgeInsets(top: JQ_NavBarHeight, left: 0, bottom: 118, right: 0) }else{ table.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 118, right: 0) } -- Gitblit v1.7.1