//
|
// CourseDetail_2_TCell.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/16.
|
//
|
|
import UIKit
|
import JQTools
|
|
class CourseDetail_2_TCell: UITableViewCell {
|
|
@IBOutlet weak var tableView: UITableView!
|
@IBOutlet weak var cons_tableHei: NSLayoutConstraint!
|
|
private var model:CourseModel?
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
backgroundColor = .clear
|
selectionStyle = .none
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.isScrollEnabled = false
|
tableView.backgroundColor = UIColor(hexString: "f6f6f6")
|
tableView.separatorStyle = .none
|
tableView.register(UINib(nibName: "CourseDetail_2_Inner_TCell", bundle: nil), forCellReuseIdentifier: "_CourseDetail_2_Inner_TCell")
|
cons_tableHei.constant = 0
|
}
|
|
func setItems(_ model:CourseModel){
|
self.model = model
|
cons_tableHei.constant = 70.5 * Double(model.list.count)
|
self.tableView.reloadData()
|
}
|
}
|
|
extension CourseDetail_2_TCell:UITableViewDelegate & UITableViewDataSource{
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
guard let m = model else {return}
|
let isVip = UserViewModel.getAvatarInfo().checkVip()
|
|
if m.chargeType == .free || (m.chargeType == .vipFree && isVip) || (m.chargeType == .payment && m.isBuy == .yes){
|
let vc = CourseDetialVideoVC(items: model!.list, selectIndex: indexPath)
|
JQ_currentNavigationController().pushViewController(vc)
|
}else{
|
if m.chargeType == .vipFree{
|
let vc = VIPCenterVC()
|
JQ_currentViewController().jq_push(vc: vc)
|
}else{
|
guard sceneDelegate!.checkisLoginState() else{return}
|
let vc = PaymentOrderVC(courseItemModel: m,type: .course,giftToOther: false,showType: .horizontal)
|
JQ_currentViewController().jq_push(vc:vc)
|
}
|
}
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return model?.list.count ?? 0
|
}
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let model = model!.list[indexPath.row]
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_CourseDetail_2_Inner_TCell", for: indexPath) as! CourseDetail_2_Inner_TCell
|
cell.setModel(model, index: indexPath)
|
cell.backgroundColor = .clear
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
return 70.5
|
}
|
}
|