From 09a372bc45fde16fd42257ab6f78b8deeecf720b Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期三, 16 四月 2025 16:38:05 +0800 Subject: [PATCH] fix bug --- XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift | 72 ++++++++++++++++++++++++++--------- 1 files changed, 53 insertions(+), 19 deletions(-) diff --git a/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift b/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift index 593cece..f8cd103 100644 --- a/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift +++ b/XQMuse/Root/Course/VC/CourseVCOfficalCommentVC.swift @@ -12,10 +12,13 @@ class CourseVCOfficalViewModel:RefreshInnerModel<CourseModel>{ var cateId = BehaviorRelay<Int?>(value: nil) + var search = BehaviorRelay<String?>(value: nil) override func api() -> (Observable<BaseResponse<BaseResponseList<CourseModel>>>)? { - return Services.getCoursePageList(page: page) + return Services.getCoursePageList(page: page,cateId: cateId.value, courseTitle: search.value) } } + +let CourseOfficalComment_Noti = Notification.Name.init("CourseOfficalComment_Noti") class CourseVCOfficalCommentVC: BaseVC { @@ -25,6 +28,16 @@ private var bannerModels = [CommonBannerModel]() private var viewModel = CourseVCOfficalViewModel() + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + Services.getCourseBannerList().subscribe(onNext: {data in + for (index,v) in (data.data ?? []).enumerated(){ + self.bannerModels.append(CommonBannerModel(index: index, id: v.id, name: v.name, resource:v.imageUrl.jq_urlEncoded(), mediaType: .imageUrl,courseId: v.courseId)) + } + self.collectionView.reloadData() + }).disposed(by: disposeBag) + } + override func viewDidLoad() { super.viewDidLoad() @@ -33,17 +46,12 @@ Services.getCourseCategory().subscribe(onNext: {data in for v in data.data ?? []{ - self.subTitleItems.append(TitleItem(id:v.id,title: v.name,coverImage: v.imageUrl)) + self.subTitleItems.append(TitleItem(id:v.id,title: v.name,coverImage: v.imageUrl.jq_urlEncoded())) } self.collectionView.reloadData() }).disposed(by: disposeBag) - Services.getCourseBannerList().subscribe(onNext: {data in - for (index,v) in (data.data ?? []).enumerated(){ - self.bannerModels.append(CommonBannerModel(index: index, id: v.id, name: v.name, resource:v.imageUrl, mediaType: .imageUrl)) - } - self.collectionView.reloadData() - }).disposed(by: disposeBag) + viewModel.configure(collectionView) viewModel.beginRefresh() @@ -68,6 +76,12 @@ } } + override func setRx() { + NotificationCenter.default.rx.notification(CourseOfficalComment_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in + self?.viewModel.beginRefresh() + }).disposed(by: disposeBag) + } + override var shouldAutorotate: Bool{ return false } @@ -77,17 +91,31 @@ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let model = viewModel.dataSource.value!.list[indexPath.row] - let vc = CourseDetialVC(courseId: model.id) - JQ_currentViewController().jq_push(vc: vc) -// let isVip = UserViewModel.getAvatarInfo().isVip == .yes -// if model.isBuy == .yes || model.chargeType == .free || (model.chargeType == .vipFree && isVip){ -// -// return -// }else{ -// let vc = CourseDetialVC(courseId: model.id) -// JQ_currentViewController().jq_push(vc: vc) -// } + if model.courseType == .online{ + if model.chargeType == .vipFree || model.chargeType == .payment{ + 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() + JQ_currentViewController().jq_push(vc: vc) + }else if m.courseType == .online{ + let vc = CourseDetialVC(courseModel: m) + JQ_currentViewController().jq_push(vc: vc) + }else{ + let vc = CourseDetialOfflineVC(courseId: m.id) + JQ_currentViewController().jq_push(vc: vc) + } + } + }).disposed(by: disposeBag) + }else{ + let vc = CourseDetialOfflineVC(courseId: model.id) + JQ_currentViewController().jq_push(vc: vc) + } } @@ -119,6 +147,9 @@ let model = viewModel.dataSource.value!.list[indexPath.row] let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell cell.setCourseModel(model) + cell.label_title.font = UIFont.systemFont(ofSize: 19, weight: .bold) + cell.cons_title_top.constant = 14 + cell.cons_title_left.constant = 16.5 return cell } @@ -138,7 +169,7 @@ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { if indexPath.section == 0{ - let h = ceil(subTitleItems.count.double / 4.0) * 101.25 + floor(subTitleItems.count.double / 4.0) * 5 + 208.5 + let h = ceil(subTitleItems.count.double / 4.0) * 103.75 + floor(subTitleItems.count.double / 4.0) * 5 + 208.5 return CGSize(width: JQ_ScreenW, height: h) } @@ -156,6 +187,9 @@ } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { + if section == 0{ + return .zero + } return CGSize(width: JQ_ScreenW, height: 80.5) } } -- Gitblit v1.7.1