| | |
| | | import RxRelay |
| | | import RxSwift |
| | | |
| | | class WatchHistoryViewModel:RefreshInnerModel<CourseModel>{ |
| | | class WatchHistoryViewModel:RefreshModel<CourseModel>{ |
| | | |
| | | let state = BehaviorRelay<Int>(value: 1) |
| | | var type = BehaviorRelay<WatchType>(value: .collect) |
| | | |
| | | override func api() -> (Observable<BaseResponse<BaseResponseList<CourseModel>>>)? { |
| | | switch type.value { |
| | | case .history:Services.lookHistory(page: page, pageSize: 20, state: state.value) |
| | | case .collect:Services.myCollect(page: page, pageSize: 20, state: state.value) |
| | | case .payment:Services.myOrderCourse(page: page, pageSize: 20, state: state.value) |
| | | } |
| | | } |
| | | override func api() -> (Observable<BaseResponse<[CourseModel]>>)? { |
| | | switch type.value { |
| | | case .history:return Services.lookHistory(page: page, pageSize: 20, state: state.value) |
| | | case .collect:return Services.myCollect(page: page, pageSize: 20, state: state.value) |
| | | case .payment:return Services.myOrderCourse(page: page, pageSize: 20, state: state.value) |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | extension WatchHistoryDetailVC:UICollectionViewDelegate & UICollectionViewDataSource{ |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return viewModel.dataSource.value?.list.count ?? 0 |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBannerCCell", for: indexPath) as! HomeRelaxBannerCCell |
| | | let m = viewModel.dataSource.value!.list[indexPath.row] |
| | | let m = viewModel.dataSource.value[indexPath.row] |
| | | cell.setCourseModel(m) |
| | | return cell |
| | | } |
| | |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | |
| | | let m = viewModel.dataSource.value!.list[indexPath.row] |
| | | let m = viewModel.dataSource.value[indexPath.row] |
| | | if viewModel.state.value == 1{ |
| | | let vc = HomeItemDetailVC(id: m.id) |
| | | let vc = HomeItemDetailVC(id: m.businessId) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | }else{ |
| | | let vc = CourseDetialVC(courseId: m.id) |
| | | let vc = CourseDetialVC(courseId: m.businessId) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | } |
| | | } |