//
|
// Home_Style_3_TCell.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/12.
|
//
|
|
import UIKit
|
import JQTools
|
|
class Home_Style_3_TCell: UITableViewCell {
|
|
@IBOutlet weak var collectionView: UICollectionView!
|
var meditationModels = [MeditationModel]()
|
private var showType:DisplayType!
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
selectionStyle = .none
|
|
collectionView.collectionViewLayout = TestLeftRightCollectionViewFlowLayout(width: JQ_ScreenW, height: 213.5)
|
collectionView.delegate = self
|
collectionView.dataSource = self
|
collectionView.isPagingEnabled = false
|
collectionView.bounces = false
|
collectionView.showsHorizontalScrollIndicator = false
|
collectionView.register(UINib(nibName: "HomeRelaxBannerCCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBannerCCell")
|
// collectionView.scrollToItem(at: IndexPath(row: 2, section: 0), at: .centeredHorizontally, animated: true)
|
collectionView.contentInset = UIEdgeInsets(top: 0, left: 100 , bottom: 0, right: 100)
|
|
}
|
|
func setModels(_ items:[MeditationModel],showType: DisplayType){
|
self.showType = showType
|
self.meditationModels = items
|
collectionView.reloadData()
|
}
|
}
|
|
extension Home_Style_3_TCell:UICollectionViewDelegate & UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return meditationModels.count
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBannerCCell", for: indexPath) as! HomeRelaxBannerCCell
|
cell.setMeditationModel(meditationModels[indexPath.row],showType: showType)
|
return cell
|
}
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
let m = meditationModels[indexPath.row]
|
|
let isVip = UserViewModel.getAvatarInfo().isVip
|
|
if m.chargeType == .free || (isVip == .yes && m.chargeType == .vipFree) || (m.chargeType == .payment && m.isBuy == .yes){
|
let vc = HomeItemDetailVC(id: m.id)
|
JQ_currentViewController().jq_push(vc: vc)
|
return
|
}
|
|
if m.chargeType == .payment && m.isBuy == .no{
|
let vc = PaymentOrderVC(museItemModel: m,type: .muse)
|
JQ_currentViewController().jq_push(vc: vc)
|
return
|
}
|
|
if m.chargeType == .vipFree{
|
let vc = VIPCenterVC()
|
JQ_currentViewController().jq_push(vc: vc)
|
return
|
}
|
}
|
}
|
|
extension Home_Style_3_TCell:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
return CGSize(width: 148.25, height: 213.45)
|
}
|
}
|