| | |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var cons_tableHei: NSLayoutConstraint! |
| | | |
| | | private var items = [CourseItemModel]() |
| | | private var model:CourseModel? |
| | | |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | |
| | | cons_tableHei.constant = 0 |
| | | } |
| | | |
| | | func setItems(_ items:[CourseItemModel]){ |
| | | self.items = items |
| | | cons_tableHei.constant = 70.5 * Double(items.count) |
| | | 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) { |
| | | let vc = CourseDetialVideoVC(items: items, selectIndex: indexPath) |
| | | JQ_currentViewController().jq_push(vc: vc) |
| | | |
| | | guard let m = model else {return} |
| | | if m.chargeType == .free || (m.chargeType == .vipFree && UserViewModel.getAvatarInfo().isVip == .yes) || (m.chargeType == .payment && m.isBuy == .yes){ |
| | | let vc = CourseDetialVideoVC(items: model!.list, selectIndex: indexPath) |
| | | JQ_currentNavigationController().pushViewController(vc) |
| | | }else{ |
| | | let vc = PaymentOrderVC(courseId: m.id) |
| | | JQ_currentNavigationController().pushViewController(vc) |
| | | } |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return items.count |
| | | return model?.list.count ?? 0 |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = items[indexPath.row] |
| | | 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 |