| | |
| | | import RxRelay |
| | | import RxSwift |
| | | |
| | | let WatchHistory_Noti = Notification.Name.init("WatchHistory_Noti") |
| | | |
| | | class WatchHistoryViewModel:RefreshModel<CourseModel>{ |
| | | |
| | | let state = BehaviorRelay<Int>(value: 1) |
| | |
| | | viewModel.configure(collectionView) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(WatchHistory_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in |
| | | self?.viewModel.beginRefresh() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | extension WatchHistoryDetailVC:UICollectionViewDelegate & UICollectionViewDataSource{ |
| | |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | |
| | | let m = viewModel.dataSource.value[indexPath.row] |
| | | |
| | | if m.paymentStatus == .yes{ |
| | | //todo |
| | | |
| | | return |
| | | } |
| | | |
| | | let item = viewModel.dataSource.value[indexPath.row] |
| | | |
| | | if viewModel.state.value == 1{ |
| | | Services.getMeditationDetail(id: m.businessId).subscribe(onNext: {data in |
| | | //待支付 |
| | | if item.paymentStatus == .yes{ |
| | | Services.getMeditationDetail(id: item.businessId).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | let vc = PaymentOrderVC(museItemModel: m, type: .muse, giftToOther: false, showType: .horizontal,businessId: item.id) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | return |
| | | } |
| | | |
| | | |
| | | Services.getMeditationDetail(id: item.businessId).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | let vc = HomeItemDetailVC(model: m) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | }else{ |
| | | if m.courseType == .online{ |
| | | // let vc = CourseDetialVC(courseId: m.businessId) |
| | | // JQ_currentViewController().jq_push(vc: vc) |
| | | Services.getCourseDetail(courseId: m.businessId).subscribe(onNext: {data in |
| | | if item.courseType == .online{ |
| | | |
| | | //待支付 |
| | | if item.paymentStatus == .yes{ |
| | | Services.getCourseDetail(courseId: item.businessId).subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | let vc = PaymentOrderVC(courseItemModel: m, type: .course, giftToOther: false, showType: .horizontal,businessId: item.id) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | return |
| | | } |
| | | |
| | | |
| | | Services.getCourseDetail(courseId: item.businessId).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | if m.isVip == .no && m.chargeType == .vipFree{ |
| | | let vc = VIPCenterVC() |
| | |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | }else{ |
| | | let vc = CourseDetialOfflineVC(courseId: m.businessId) |
| | | let vc = CourseDetialOfflineVC(courseId: item.businessId) |
| | | push(vc: vc) |
| | | } |
| | | } |