CNLiveDuanJuDetailCell.swift 5.63 KB
//
//  CNLiveDuanJuDetailCell.swift
//  metaCode
//
//  Created by zx on 2024/5/16.
//  1排2个短剧列表cell

import Foundation
import QMUIKit

class CNLiveDuanJuDetailCell:UITableViewCell{
    
    
    var cellType:CNLiveHomePageCellType = .playletList

    //AlbumModel
    var _albumModel : CNLiveAlbumModel?
    var albumModel : CNLiveAlbumModel? {
        get{
            _albumModel
        }
        set{
            _albumModel = newValue!
            self.setupNewUI(model: _albumModel!)
        }
    }
    
    //AlbumModel
    var _rightAlbumModel : CNLiveAlbumModel?
    var rightAlbumModel : CNLiveAlbumModel? {
        get{
            _rightAlbumModel
        }
        set{
            _rightAlbumModel = newValue!
            self.setupRightNewUI(model: _rightAlbumModel!)
        }
    }
    //MARK: - 懒加载
    lazy var iconImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 15, y: 15, width: DuanJuDetailImageWidth, height: DuanJuDetailImageHeight))
        iconImgView.layer.cornerRadius = 5
        iconImgView.clipsToBounds = true
        iconImgView.contentMode = .scaleAspectFill
        return iconImgView
    }()
    ///标题
    lazy var titleLabl: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.left+10, self.iconImgView.bottom+10, self.iconImgView.width-20, 20))
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_14
        titleLabel.text = "标题"
        return titleLabel
    }()
    ///副标题
    lazy var subTitleLabel: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(self.iconImgView.left+10, self.titleLabl.bottom+3, self.iconImgView.width-20, 33))
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.font = Font_12
        titleLabel.text = "副标题"
        return titleLabel
    }()
    
    lazy var rightIconImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 15+DuanJuDetailImageWidth+15, y: 15, width: DuanJuDetailImageWidth, height: DuanJuDetailImageHeight))
        iconImgView.layer.cornerRadius = 5
        iconImgView.clipsToBounds = true
        iconImgView.contentMode = .scaleAspectFill
        return iconImgView
    }()
    ///标题
    lazy var rightTitleLabl: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(self.rightIconImgView.left+10, self.rightIconImgView.bottom+10, self.rightIconImgView.width-20, 20))
        titleLabel.textColor = HexColor("#333333")
        titleLabel.textAlignment = .left
        titleLabel.font = BoldFont_14
        titleLabel.text = ""
        return titleLabel
    }()
    ///副标题
    lazy var rightSubTitleLabel: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(self.rightIconImgView.left+10, self.rightTitleLabl.bottom+3, self.rightIconImgView.width-20, 33))
        titleLabel.textColor = HexColor("#999999")
        titleLabel.textAlignment = .left
        titleLabel.font = Font_12
        titleLabel.text = ""
        return titleLabel
    }()
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.contentView.addSubview(self.iconImgView)
        self.contentView.addSubview(self.titleLabl)
        self.contentView.addSubview(self.subTitleLabel)
        self.contentView.addSubview(self.rightIconImgView)
        self.contentView.addSubview(self.rightTitleLabl)
        self.contentView.addSubview(self.rightSubTitleLabel)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setupNewUI(model:CNLiveAlbumModel){
        self.titleLabl.text = model.title
        self.subTitleLabel.text = model.subTitle
        self.iconImgView.kf.setImage(with: URL(string: model.poster))
    }
    func setupRightNewUI(model:CNLiveAlbumModel){
        self.rightTitleLabl.text = model.title
        self.rightSubTitleLabel.text = model.subTitle
        self.rightIconImgView.kf.setImage(with: URL(string: model.poster))
    }
  
//    @objc func playBtnAction(){
//        var aid = ""
//        if self.albumModel != nil{
//            aid = self.albumModel!.contentId
//        }else if self.albumMsgModel != nil{
//            aid = self.albumMsgModel!.albumId
//        }else{
//            aid = ""
//        }
//        if (self.albumModel != nil){
//            if (self.albumModel?.model == kCNDownSlideContentsModelModel1 || self.albumModel?.model == kCNDownSlideContentsModelModel2 || self.albumModel?.model == kCNDownSlideContentsModelModel3 || self.albumModel?.model == kCNDownSlideContentsModelModel4){
//                //课程-跳转h5网页
//                self.enterBlock!(self.albumModel!)
//            }else if self.albumModel?.model == kCNDownSlideContentsModelModelAlbum_ugc{
//                //短剧-跳转短剧播放页
//                CNLiveDownSlideTool.pushShortVideoController(contentId: aid, navigationVC: navigationViewController().visibleViewController?.navigationController)
//            }else if self.albumModel?.model == kCNDownSlideContentsModelModelAlbum_video{
//                //课程-跳转h5视频专辑页
//                self.enterBlock!(self.albumModel!)
//            }else{
//                
//            }
//        }else if (self.albumMsgModel != nil){
//            //短剧-跳转短剧播放页
//            CNLiveDownSlideTool.pushShortVideoController(contentId: aid, navigationVC: navigationViewController().visibleViewController?.navigationController)
//
//        }
//        
//    }
}