杨锴
2024-11-09 5415b6659e542b21058428bbc0d38e7f5783815b
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,19 +144,16 @@
            }
            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)
                style = .style1
                pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0)
                    //是否需要购买
                    var  needPayment:Bool = true
@@ -168,24 +165,23 @@
                    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)
                    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)
                    studyBtn.setAttributedTitle(attribute, for: .normal)
                    }
                    weakSelf.setFootView()
                setFootView()
                                                }else{
                    weakSelf.style = .style2
                style = .style2
                    DispatchQueue.main.asyncAfter(delay: 0.5) {
                        weakSelf.headerView.setVideo(url: m.detailUrl, coverImageUrl: m.coverUrl.jq_urlEncoded(), delegate: self!)
                    self.headerView.setVideo(url: m.detailUrl, coverImageUrl: m.coverUrl.jq_urlEncoded(), delegate: self)
                    }
                    weakSelf.pageMenu.setItems(["简介"], selectedItemIndex: 0)
                pageMenu.setItems(["简介"], selectedItemIndex: 0)
                                                }
                weakSelf.tableView?.reloadData()
            tableView?.reloadData()
                                    }
                        }).disposed(by: disposeBag)
            }
            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)
                                    }