| | |
| | | |
| | | var collectionView:UICollectionView! |
| | | private let topView = PaymentOrderResultTopView.jq_loadNibView() |
| | | private var courseId:Int! |
| | | private var id:Int! |
| | | private var type:PaymentOrderVC.PaymentOrderType! |
| | | private var price:Double! |
| | | private var models = [CourseModel]() |
| | | private var models = [Any]() |
| | | |
| | | init(courseId:Int,price:Double) { |
| | | init(type:PaymentOrderVC.PaymentOrderType,id:Int,price:Double) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.courseId = courseId |
| | | self.id = id |
| | | self.type = type |
| | | self.price = price |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | topView.setPrice(courseId: courseId, price: price) |
| | | topView.setPrice(type: type, id: id, price: price) |
| | | |
| | | Services.paymentSuccess(courseId: courseId).subscribe(onNext: {data in |
| | | self.models = data.data ?? [] |
| | | self.collectionView.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | if type == .course{ |
| | | Services.coursePaymentSuccess(courseId: id).subscribe(onNext: {data in |
| | | self.models = data.data ?? [] |
| | | self.collectionView.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | if type == .muse{ |
| | | Services.musePaymentSuccess(meditationId: id).subscribe(onNext: {data in |
| | | self.models = data.data ?? [] |
| | | self.collectionView.reloadData() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | let model = models[indexPath.row] |
| | | let vc = CourseDetialVC(courseId: model.id) |
| | | push(vc: vc) |
| | | |
| | | switch type { |
| | | case .course: |
| | | let model = models[indexPath.row] as! CourseModel |
| | | let vc = CourseDetialVC(courseId: model.id) |
| | | push(vc: vc) |
| | | case .muse: |
| | | let model = models[indexPath.row] as! MeditationModel |
| | | let vc = HomeItemDetailVC(id: model.id) |
| | | push(vc: vc) |
| | | case .none:break |
| | | } |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell |
| | | let model = models[indexPath.row] |
| | | cell.setCourseModel(model) |
| | | |
| | | if let m = model as? CourseModel{ |
| | | cell.setCourseModel(m) |
| | | } |
| | | |
| | | if let m = model as? MeditationModel{ |
| | | cell.setMeditationModel(m) |
| | | } |
| | | return cell |
| | | } |
| | | |