| | |
| | | class CourseDetialVC: BaseVC { |
| | | |
| | | private var tableView:UITableView? |
| | | private var collect_bitem:UIBarButtonItem! |
| | | private let studyBtn = QMUIButton(type: .custom) |
| | | private var headerView = CourseDetailHeaderView.jq_loadNibView() |
| | | private var barStyle:UIStatusBarStyle = .lightContent |
| | |
| | | self.tableView!.tableHeaderView = self.headerView |
| | | } |
| | | |
| | | setFootView() |
| | | collect_bitem = UIBarButtonItem(image: UIImage(named: "btn_collect"), style: .plain, target: self, action: #selector(collectionAction)) |
| | | collect_bitem.tintColor = .white |
| | | let share_bitem = UIBarButtonItem(image: UIImage(named: "btn_share"), style: .plain, target: self, action: #selector(shareAction)) |
| | | share_bitem.tintColor = .white |
| | | share_bitem.imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 15) |
| | | navigationItem.rightBarButtonItems = [share_bitem,collect_bitem] |
| | | } |
| | | |
| | | private func getData(){ |
| | |
| | | self.section1TCell.setItems(m) |
| | | self.section2TCell.setItems(m.list2) |
| | | |
| | | if m.isBuy != .yes{ |
| | | //是否需要购买 |
| | | var needPayment:Bool = true |
| | | switch m.chargeType{ |
| | | case .free:needPayment = false |
| | | case .payment:needPayment = !(m.isBuy == .yes) |
| | | case .vipFree:needPayment = !(UserViewModel.getAvatarInfo().isVip == .yes) |
| | | } |
| | | |
| | | if needPayment{ |
| | | let attribute = AttributedStringbuilder.build().add(string: " 疗愈币", withFont: .systemFont(ofSize: 12,weight: .bold), withColor: UIColor(hexString: "#F6F6F6")!).add(string: "\(m.generalPrice.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 |
| | | self.studyBtn.setAttributedTitle(attribute, for: .normal) |
| | | } |
| | |
| | | self.pageMenu.setItems(["简介"], selectedItemIndex: 0) |
| | | } |
| | | self.tableView?.reloadData() |
| | | self.setFootView() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | |
| | | make.height.equalTo(84) |
| | | } |
| | | |
| | | let giftBtn = QMUIButton(type: .custom) |
| | | giftBtn.imagePosition = .left |
| | | giftBtn.spacingBetweenImageAndTitle = 7.5 |
| | | giftBtn.setTitleColor(UIColor(hexString: "#464646"), for: .normal) |
| | | giftBtn.setImage(UIImage(named: "btn_sendGift"), for: .normal) |
| | | giftBtn.setTitle("赠送好友", for: .normal) |
| | | giftBtn.addTarget(self, action: #selector(sendGift(_:)), for: .touchUpInside) |
| | | giftBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .bold) |
| | | footView.addSubview(giftBtn) |
| | | giftBtn.snp.makeConstraints { make in |
| | | make.left.equalTo(26) |
| | | make.top.equalTo(26.5) |
| | | } |
| | | if courseDetailModel?.chargeType == .payment{ |
| | | let giftBtn = QMUIButton(type: .custom) |
| | | giftBtn.imagePosition = .left |
| | | giftBtn.spacingBetweenImageAndTitle = 7.5 |
| | | giftBtn.setTitleColor(UIColor(hexString: "#464646"), for: .normal) |
| | | giftBtn.setImage(UIImage(named: "btn_sendGift"), for: .normal) |
| | | giftBtn.setTitle("赠送好友", for: .normal) |
| | | giftBtn.addTarget(self, action: #selector(sendGift(_:)), for: .touchUpInside) |
| | | giftBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .bold) |
| | | footView.addSubview(giftBtn) |
| | | giftBtn.snp.makeConstraints { make in |
| | | make.left.equalTo(26) |
| | | make.top.equalTo(26.5) |
| | | } |
| | | } |
| | | |
| | | studyBtn.setTitleColor(UIColor.white, for: .normal) |
| | | studyBtn.setTitle(" 立即学习 ", for: .normal) |
| | |
| | | footView.addSubview(studyBtn) |
| | | studyBtn.snp.makeConstraints { make in |
| | | make.right.equalTo(-20) |
| | | make.centerY.equalTo(giftBtn) |
| | | make.top.equalTo(22) |
| | | make.height.equalTo(34) |
| | | } |
| | | } |
| | |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @objc func collectionAction(){ |
| | | Services.meditationFavorite(id: courseId).subscribe(onNext: {data in |
| | | self.courseDetailModel?.isCollect.troggle() |
| | | if self.courseDetailModel?.isCollect == .yes{ |
| | | alertSuccess(msg: "收藏成功") |
| | | self.collect_bitem.image = UIImage(named: "btn_collect_1_s") |
| | | self.collect_bitem.tintColor = UIColor(hexString: "fe5b60") |
| | | }else{ |
| | | alertSuccess(msg: "已取消收藏") |
| | | self.collect_bitem.image = UIImage(named: "btn_collect") |
| | | self.collect_bitem.tintColor = .white |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @objc func shareAction(){ |
| | | ShareView.show() |
| | | } |
| | | |
| | | @objc func handleAction(_ btn:QMUIButton){ |
| | | |
| | | if let m = courseDetailModel{ |
| | | if m.chargeType == .free || (m.chargeType == .vipFree && UserViewModel.getAvatarInfo().isVip == .yes) || (m.chargeType == .payment && m.isBuy == .yes){ |
| | | guard m.list.count != 0 else { |
| | | alertError(msg: "课程目录异常");return |
| | | } |
| | | let vc = CourseDetialVideoVC(items: m.list, selectIndex: IndexPath(row: 0, section: 0)) |
| | | push(vc: vc);return |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | let offSetY = scrollView.contentOffset.y + CGRectGetHeight(scrollView.frame) / 2; |
| | | |
| | | if let currentIndex = tableView?.indexPathForRow(at: CGPoint(x: 0, y: offSetY)){ |
| | | print(scrollView.isDragging) |
| | | |
| | | if !isAnimationing{ |
| | | if currentShowIndex != currentIndex{ |