| | |
| | | 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! |
| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | 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(){ |
| | |
| | | } |
| | | |
| | | @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{ |
| | |
| | | @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) |
| | | } |
| | |
| | | |
| | | 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) |
| | | } |