CNLiveHomeSearchResultJuJiCell.swift 4.03 KB
//
//  CNLiveHomeSearchResultJuJiCell.swift
//  metaCode
//
//  Created by zx on 2025/3/10.
//  剧集/单集

import Foundation

class CNLiveHomeSearchResultJuJiCell: UITableViewCell {
    //
    var _resModel : CNLiveHomeSearchResultListModel?
    var resModel : CNLiveHomeSearchResultListModel? {
        get{
            _resModel
        }
        set{
            _resModel = newValue!
            self.setupNewUI(model: _resModel!)
        }
    }
    lazy var iconImgView :UIImageView = {
        let iconImgView = UIImageView()
        iconImgView.contentMode = .scaleAspectFill
        iconImgView.clipsToBounds = true
        iconImgView.layer.cornerRadius = 9
        return iconImgView
    }()

    lazy var titleLabel: UILabel = {
        let titleLbl = UILabel()
        titleLbl.font = BoldFont_14
        titleLbl.textColor = HexColor("#333333")
        titleLbl.text = "标题"
        return titleLbl
    }()
    lazy var subTitleLabel: UILabel = {
        let titleLbl = UILabel()
        titleLbl.font = Font_12
        titleLbl.textColor = HexColor("#999999")
        titleLbl.text = "副标题"
        return titleLbl
    }()
    //付费角标
    lazy var payIconView :UIImageView = {
        let layerView = UIImageView()
        layerView.image = UIImage(named: "home_player_pay")
        layerView.frame = CGRect(x: 0, y: 0, width: 26, height: 15)
        return layerView
    }()


    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        contentView.backgroundColor = .white
        contentView.clipsToBounds = true
        
        self.contentView.addSubview(self.iconImgView)
        iconImgView.snp.makeConstraints { make in
            make.left.top.equalTo(15)
            make.width.equalTo(106)
            make.height.equalTo(60)
        }
        self.iconImgView.addSubview(self.payIconView)

        self.contentView.addSubview(self.titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(self.iconImgView.snp.right).offset(20)
            make.top.equalTo(self.iconImgView.snp.top).offset(6)
            make.right.equalToSuperview().offset(-10)
        }
        self.contentView.addSubview(self.subTitleLabel)
        subTitleLabel.snp.makeConstraints { make in
            make.left.equalTo(self.iconImgView.snp.right).offset(20)
            make.top.equalTo(self.titleLabel.snp.bottom).offset(10)
            make.right.equalToSuperview().offset(-10)
        }

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupNewUI(model:CNLiveHomeSearchResultListModel){
        if model.model == kCNDownSlideContentsModelModel1{
            self.titleLabel.text = model.title
            self.subTitleLabel.text = model.subTitle
            self.iconImgView.kf.setImage(with: URL(string: model.poster))

        }else if model.model == kCNDownSlideContentsModelModelAlbum_video{
            self.titleLabel.text = model.name
            self.subTitleLabel.text = model.subTitle
            self.iconImgView.kf.setImage(with: URL(string: model.icon))

        }else{
            
        }
        
        let isPaid = CNLivePlayerTool.isShowPaidIcon(product: model.product)
        if isPaid{
            payIconView.isHidden = false
        }else{
            payIconView.isHidden = true
        }
//        if model.product?.productType == "2" || model.product?.productType == "5"{//付费
//            payIconView.isHidden = false
//        }else{
//            if model.product?.check == true {
//                //免费或者付过费了
//                self.payIconView.isHidden = true
//            } else {
//                if model.product?.productType == "4" {
//                    //这里表示可以进行试听
//                    self.payIconView.isHidden = true
//                } else {
//                    self.payIconView.isHidden = true
//                }
//            }
//        }

    }
        
}