| | |
| | | |
| | | import UIKit |
| | | import JQTools |
| | | import EmptyDataSet_Swift |
| | | |
| | | class CourseMenuVC: BaseVC { |
| | | |
| | |
| | | make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(18) |
| | | make.bottom.equalTo(tableView) |
| | | } |
| | | |
| | | collectionView.emptyDataSetSource = self |
| | | collectionView.emptyDataSetDelegate = self |
| | | collectionView.emptyDataSetView { v in |
| | | |
| | | if let sub = v.viewWithTag(10010){ |
| | | |
| | | |
| | | }else{ |
| | | let v1 = UIView() |
| | | v1.tag = 10010 |
| | | v1.bounds = CGRect(x: 0, y: 0, width: 100, height: 100) |
| | | v1.center = CGPoint(x: v.center.x - 20, y: v.center.y - 150) |
| | | v.addSubview(v1) |
| | | |
| | | let image = UIImageView(image: UIImage(named: "bg_empty")) |
| | | image.contentMode = .scaleAspectFill |
| | | v1.addSubview(image) |
| | | image.snp.makeConstraints { make in |
| | | make.top.left.right.equalToSuperview() |
| | | } |
| | | |
| | | let label = UILabel(text: "暂未找到相关内容哦~") |
| | | label.font = .systemFont(ofSize: 14, weight: .medium) |
| | | label.textColor = .gray |
| | | v1.addSubview(label) |
| | | label.snp.makeConstraints { make in |
| | | make.centerX.equalTo(image) |
| | | make.top.equalTo(image.snp.bottom).offset(8) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func setTitleItem(_ items:[TitleItem],defaultSelectIndex:Int = 0){ |
| | |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | let model = viewModel.dataSource.value!.list[indexPath.row] |
| | | let vc = CourseDetialVC(courseId: model.id) |
| | | push(vc: vc) |
| | | |
| | | if model.courseType == .online{ |
| | | |
| | | if model.chargeType == .payment || model.chargeType == .vipFree{ |
| | | guard sceneDelegate!.checkisLoginState() else {return} |
| | | } |
| | | |
| | | Services.getCourseDetail(courseId: model.id).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | if m.isVip == .no && m.chargeType == .vipFree{ |
| | | let vc = VIPCenterVC() |
| | | self.push(vc: vc) |
| | | }else if m.courseType == .online{ |
| | | let vc = CourseDetialVC(courseModel: m) |
| | | self.push(vc: vc) |
| | | }else{ |
| | | let vc = CourseDetialOfflineVC(courseId: m.id) |
| | | self.push(vc: vc) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | }else{ |
| | | let vc = CourseDetialOfflineVC(courseId: model.id) |
| | | push(vc: vc) |
| | | } |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let model = viewModel.dataSource.value!.list[indexPath.row] |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell |
| | | cell.backgroundColor = .jq_randomColor |
| | | cell.setCourseModel(model) |
| | | return cell |
| | | } |
| | |
| | | return CGSize(width: w, height: w * 1.313) |
| | | } |
| | | } |
| | | |
| | | extension CourseMenuVC:EmptyDataSetSource{ |
| | | |
| | | } |
| | | |
| | | extension CourseMenuVC:EmptyDataSetDelegate{ |
| | | |
| | | } |