CNDownSlideSingleCourseCell.swift 27.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
//
//  CNDownSlideSingleCourseCell.swift
//  metaCode
//
//  Created by zx on 2023/10/16.
//  单课程大图专辑 | 全部课程列表 | 我的课程列表 | 短剧竖图一排2个 | 实时热榜


import Foundation
import UIKit

enum GlobalConstants {
    static let leftMargin: CGFloat = 20
    
    static let toDayCardRowH: CGFloat = 440
    static let toDayCardCornerRadius: CGFloat = 12.0
    static let todayCardSize: CGSize = CGSize(width: KSreenWidth - 2 * 15, height: DownSlideSingleCourseImgH)
    static let cardDetailTopImageH: CGFloat = 500
    
    static let iconBorderColor: CGColor = UIColor(red: 239/255.0, green: 240/255.0, blue: 241/255.0, alpha: 1).cgColor
    static let iconBorderWidth: CGFloat = 0.8
    static let iconCornerRadius: CGFloat = 17.5
    
    static let textBlueColor = UIColor(red: 0/255.0, green: 122/255.0, blue: 255/255.0, alpha: 1.0)   //007AFF
    static let speratorLineColor = UIColor(red: 224/255.0, green: 224/255.0, blue: 224/255.0, alpha: 1)

}

///全部课程 标题高度
let DownSlideAllCourseTitleH: CGFloat = 55
//全部课程 每row_topY间距
let DownSlideAllCourseRowTopYGap: CGFloat = 10
//全部课程 每row_topY间距
let DownSlideAllCourseRowBottomYGap: CGFloat = 20
//全部课程 每row_img宽高
let DownSlideAllCourseRowImageWH: CGFloat = 45

///全部课程 每row高度
let DownSlideAllCourseRowH: CGFloat = DownSlideAllCourseRowTopYGap+DownSlideAllCourseRowBottomYGap + DownSlideAllCourseRowImageWH
///全部课程 宽度
let DownSlideAllCourseW: CGFloat = KSreenWidth - DownSlideRecommendLeftGap*2

///单节课程 大图高度
let DownSlideSingleCourseImgH: CGFloat = 345
///单节课程 更多课程高度
let DownSlideSingleCourseMoreH: CGFloat = 60
///单节课程 宽度
let DownSlideSingleCourseW: CGFloat = KSreenWidth - DownSlideRecommendLeftGap*2
//竖版短剧 副标题与底部间距
let DownSlideTwoDuanJuBottomYGap: CGFloat = 25
///竖版短剧标题左间距
let DownSlideTwoDuanJuLeftGap: CGFloat = 10

class CNDownSlideSingleCourseCell: UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource {
    
    let bgBackView = UIView()
    let bgImageView = UIImageView()

    //slideModel
    var _slideModel : CNLiveDownSlideModel?
    var slideModel : CNLiveDownSlideModel? {
        get{
            _slideModel
        }
        set{
            _slideModel = newValue!
            self.setupNewUI(model: _slideModel!)
        }
    }
    
    //myCurriculum
    var _myCurriculum : CNLiveAlbumBaseModel?
    var myCurriculum : CNLiveAlbumBaseModel? {
        get{
            _myCurriculum
        }
        set{
            _myCurriculum = newValue!
            self.setupMyCurriculumUI(model: _myCurriculum!)
        }
    }
    
    //实时热榜的列表
    lazy var realHotArr: NSMutableArray = {
        var realHotArr = NSMutableArray()
        return realHotArr
    }()
    let kRealHotListCollectionViewCellIdentifier = "kRealHotListCollectionViewCellIdentifier"
    lazy var realHotCollectionView: UICollectionView = {
        let layout = UICollectionViewFlowLayout()
        layout.scrollDirection = .horizontal
        layout.itemSize = CGSizeMake(69, 100+24)
        layout.sectionInset = .init(top: 0, left: 0, bottom: 0, right: 0)
        layout.minimumLineSpacing = 6
        let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
        cv.delegate = self
        cv.dataSource = self
        cv.backgroundColor = .white
        cv.register(CNLiveDownSlideRealHotListCell.self, forCellWithReuseIdentifier: kRealHotListCollectionViewCellIdentifier)
        return cv
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        contentView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
    }
    
    func setupNewUI(model:CNLiveDownSlideModel){
        contentView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        bgBackView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        bgImageView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        
        if model.type == SlideModelTypeAllCourse12 {
            //全部课程列表
            contentView.addSubview(bgBackView)

            bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:CGFloat(model.cellH)-DownSlideRecommendLeftGap)
            // 设置阴影效果
            bgBackView.layer.masksToBounds = false
            //定义view的阴影颜色
            bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
            //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
            bgBackView.layer.shadowOpacity = 1
            //定义view的阴影宽度,模糊计算的半径
            bgBackView.layer.shadowRadius = 10.0
            //阴影偏移量
            bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0)
            bgBackView.layer.cornerRadius = 12
            bgBackView.backgroundColor = .white
            
            var titleTop:CGFloat = DownSlideRecommendLeftGap
            if model.blockSubTitle.count > 0{
                let subtitleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 17))
                subtitleLbl.text = model.blockSubTitle
                subtitleLbl.font = Font_12
                subtitleLbl.textColor = HexColor("#999999")
                bgBackView.addSubview(subtitleLbl)
                titleTop = DownSlideRecommendLeftGap+17+1
            }
            let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: titleTop, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
            titleLbl.text = model.blockName ?? "全部课程"
            titleLbl.font = BoldFont_21
            titleLbl.textColor = HexColor("#333333")
            bgBackView.addSubview(titleLbl)
            
            //总块数
            let contentsNum = model.contents.count
            //model行数
            let row = model.rowNum
            //总显示块数
            var totalNum = (contentsNum >= row) ? row : contentsNum
            if row == 0{//row为0 , contents全部显示
                totalNum = contentsNum
            }
            for i in 0..<totalNum{//i是第几行
                let contentMdl = model.contents[i]
                
                //小icon
                let imageView = UIImageView(frame: CGRectMake(DownSlideRecommendLeftGap, titleLbl.bottom+DownSlideRecommendLeftGap+CGFloat(i)*(DownSlideAllCourseRowTopYGap+DownSlideAllCourseRowImageWH+DownSlideAllCourseRowBottomYGap), CGFloat(DownSlideAllCourseRowImageWH), CGFloat(DownSlideAllCourseRowImageWH)))
                imageView.kf.setImage(with: URL(string:contentMdl.poster ))
                imageView.layer.cornerRadius = 12
                imageView.clipsToBounds = true
                imageView.contentMode = .scaleAspectFill
                bgBackView.addSubview(imageView)
                
                let titleLbl = UILabel(frame: CGRect(x: imageView.right+DownSlideRecommendLeftGap, y: imageView.top, width: DownSlideSingleCourseW-90-imageView.right, height: 21))
                titleLbl.text = contentMdl.title 
                titleLbl.font = Font_15
                titleLbl.textColor = HexColor("#333333")
                bgBackView.addSubview(titleLbl)
                
                let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y:titleLbl.bottom+3 , width: titleLbl.width, height: 17))
                subTitleLbl.text =  contentMdl.subTitle 
                subTitleLbl.font = Font_12
                subTitleLbl.textColor = HexColor("#999999")
                bgBackView.addSubview(subTitleLbl)
                
                let enterBtn = UIButton(type: .custom)
                enterBtn.frame = CGRect(x: bgBackView.right-25-65, y: 0, width: 65, height: 30)
                enterBtn.centerY = imageView.centerY
                enterBtn.setBackgroundImage(UIImage(named: "homepage_down_enter"), for: .normal)
                if contentMdl.model == kCNDownSlideContentsModelModelAlbum_ugc{
                    enterBtn.setTitle("播放", for: .normal)
                }else{
                    enterBtn.setTitle("进入", for: .normal)
                }
                
                enterBtn.titleLabel?.font = BoldFont_13
                enterBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
                enterBtn.addTarget(self, action: #selector(enterBtnAction(_:)), for: .touchUpInside)
                enterBtn.tag = i
                bgBackView.addSubview(enterBtn)
            }
        }else if model.type == SlideModelTypeOneCourse75 {
            //单图课程
            contentView.addSubview(bgBackView)
            bgBackView.addSubview(bgImageView)
            
            bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseMoreH+DownSlideSingleCourseImgH)
            
            // 设置阴影效果
            bgBackView.layer.masksToBounds = false
            //定义view的阴影颜色
            bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
            //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
            bgBackView.layer.shadowOpacity = 1
            //定义view的阴影宽度,模糊计算的半径
            bgBackView.layer.shadowRadius = 10.0
            //阴影偏移量
            bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0)
            bgBackView.layer.cornerRadius = 12
            bgBackView.backgroundColor = .white
            
            bgImageView.frame = CGRect(x: 0, y: 0,width:DownSlideSingleCourseW , height:DownSlideSingleCourseImgH)
            bgImageView.contentMode = .scaleAspectFill
            bgImageView.layer.cornerRadius = GlobalConstants.toDayCardCornerRadius
            bgImageView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
            bgImageView.layer.masksToBounds = true
            if model.background.count > 0{
                bgImageView.kf.setImage(with: URL(string: model.background))
            }else{
                bgImageView.kf.setImage(with: URL(string: model.contents[0].poster ?? ""))
            }
                        
            let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
            titleLbl.text = model.contents[0].title ?? ""
            titleLbl.font = BoldFont_21
            titleLbl.textColor = HexColor("#FFFFFF")
//            bgImageView.addSubview(titleLbl)
            
            let subTitleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y:titleLbl.bottom , width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
            subTitleLbl.text = model.contents[0].subTitle ?? ""
            subTitleLbl.font = Font_12
            subTitleLbl.textColor = HexColor("#FFFFFF")
//            bgImageView.addSubview(subTitleLbl)
            
            //单节底部视图
            let singleCourseBottomView = UIView(frame: CGRect(x: 0, y: DownSlideSingleCourseImgH, width: DownSlideSingleCourseW, height: DownSlideSingleCourseMoreH))
            singleCourseBottomView.layer.cornerRadius = 12
            singleCourseBottomView.layer.maskedCorners = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
            singleCourseBottomView.backgroundColor = .white
            singleCourseBottomView.isUserInteractionEnabled = true
            bgBackView.addSubview(singleCourseBottomView)
            
            let moreLabel = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: 15, width: DownSlideSingleCourseW - 50 - DownSlideRecommendLeftGap   , height: 30))
            moreLabel.text = model.blockName ?? "更多"
            moreLabel.font = BoldFont_15_Fit
            moreLabel.textColor = HexColor("#333333")
            singleCourseBottomView.addSubview(moreLabel)
            
            let moreImgView = UIImageView(image: UIImage(named: "homepage_down_more"))
            moreImgView.left = moreLabel.right
            moreImgView.centerY = moreLabel.centerY
            singleCourseBottomView.addSubview(moreImgView)
        }else if model.type == SlideModelTypeTwoDuanJu5 {
            //竖版短剧 1排2个
            contentView.addSubview(bgBackView)

            bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:CGFloat(model.cellH)-DownSlideRecommendLeftGap)
            // 设置阴影效果
            bgBackView.layer.masksToBounds = false
            //定义view的阴影颜色
            bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
            //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
            bgBackView.layer.shadowOpacity = 1
            //定义view的阴影宽度,模糊计算的半径
            bgBackView.layer.shadowRadius = 10.0
            //阴影偏移量
            bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0)
            bgBackView.layer.cornerRadius = 12
            bgBackView.backgroundColor = .white
            
            var titleTop:CGFloat = DownSlideRecommendLeftGap
            if model.blockSubTitle.count > 0{
                let subtitleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: DownSlideRecommendLeftGap, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 17))
                subtitleLbl.text = model.blockSubTitle
                subtitleLbl.font = Font_12
                subtitleLbl.textColor = HexColor("#999999")
                bgBackView.addSubview(subtitleLbl)
                titleTop = DownSlideRecommendLeftGap+17+1
            }
            let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: titleTop, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
            titleLbl.text = model.blockName 
            titleLbl.font = BoldFont_21
            titleLbl.textColor = HexColor("#333333")
            bgBackView.addSubview(titleLbl)
            
            //总块数
            let contentsNum = model.contents.count
            //model行数
            let row = model.rowNum
            //总显示块数
            var totalNum = (contentsNum >= row*2) ? row*2 : contentsNum
            if row == 0{//row为0 , contents全部显示
                totalNum = contentsNum
            }
            //lieIndex 当前是contents的第0列还是第1列
            var lieIndex = 0
            //hangIndex 当前是第几行,1...n
            var hangIndex = 1

            for i in 0..<totalNum{//i是第几行
                var contentMdl = model.contents[i]
                var imageX:CGFloat = 0
                var imageY:CGFloat = 0
                
                if lieIndex == 0{
                    //显示左边的块
                    contentMdl = model.contents[(hangIndex-1)*2+(lieIndex)]
                    imageX = DownSlideRecommendLeftGap
                    imageY = titleLbl.bottom+DownSlideRecommendLeftGap+CGFloat(hangIndex-1)*(DownSlideTwoDuanJuImageH+DownSlideAllCourseRowTopYGap+56+DownSlideTwoDuanJuBottomYGap)
                    lieIndex = 1
                }else{
                    //lieIndex==1显示右边的块
                    contentMdl = model.contents[(hangIndex-1)*2+(lieIndex)]
                    imageX = CGFloat(DownSlideRecommendLeftGap*2)+CGFloat(DownSlideTwoDuanJuImageW)
                    imageY = titleLbl.bottom+DownSlideRecommendLeftGap+CGFloat(hangIndex-1)*(DownSlideTwoDuanJuImageH+DownSlideAllCourseRowTopYGap+56+DownSlideTwoDuanJuBottomYGap)
                    lieIndex = 0
                    hangIndex += 1
                }
                let imageView = UIImageView(frame: CGRectMake(imageX, imageY, CGFloat(DownSlideTwoDuanJuImageW), CGFloat(DownSlideTwoDuanJuImageH)))
                imageView.kf.setImage(with: URL(string:contentMdl.poster ))
                let path = UIBezierPath.init(roundedRect: CGRect(x: 0, y: 0, width: imageView.width, height:imageView.height ), byRoundingCorners: [.topLeft,.topRight], cornerRadii: CGSizeMake(10, 10))
                let masklayer = CAShapeLayer()
                masklayer.path = path.cgPath
                imageView.layer.mask = masklayer
                imageView.clipsToBounds = true
                imageView.tag = i
                imageView.contentMode = .scaleAspectFill
                imageView.isUserInteractionEnabled = true
                imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(pushWebAction)))
                bgBackView.addSubview(imageView)
                
                
                let grayBgView = UIView(frame: CGRect(x: imageView.left, y: imageView.bottom, width: imageView.width, height: 0))
                grayBgView.backgroundColor = HexColor(kCNDownSlideBackgroundColorHex)
                bgBackView.addSubview(grayBgView)
                grayBgView.snp.makeConstraints { make in
                    make.left.equalTo(imageView.snp.left)
                    make.top.equalTo(imageView.snp.bottom)
                    make.width.equalTo(imageView.snp.width)
                    make.bottom.equalToSuperview().offset(-DownSlideRecommendLeftGap)
                }
                
                let titleLbl = UILabel(frame: CGRect(x: imageView.left+DownSlideTwoDuanJuLeftGap, y: imageView.bottom+DownSlideTwoDuanJuLeftGap, width:imageView.width-2*DownSlideTwoDuanJuLeftGap, height: 20))
                titleLbl.text = contentMdl.title
                titleLbl.font = Font_14
                titleLbl.textColor = HexColor("#333333")
                bgBackView.addSubview(titleLbl)
                
                let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y:titleLbl.bottom+3 , width: titleLbl.width, height: 33))
                subTitleLbl.text =  contentMdl.subTitle
                subTitleLbl.font = Font_12
                subTitleLbl.textColor = HexColor("#999999")
                subTitleLbl.sizeToFit()
                let subLblWidth = subTitleLbl.bounds.size.width
                if subLblWidth > titleLbl.width{
                    subTitleLbl.numberOfLines = 2
                    subTitleLbl.width = titleLbl.width
                    subTitleLbl.height = 33
                }else{
                    subTitleLbl.numberOfLines = 1
                    subTitleLbl.width = titleLbl.width
                    subTitleLbl.height = subTitleLbl.bounds.size.height
                }
                bgBackView.addSubview(subTitleLbl)
                
            }
        }else if model.type == SlideModelTypeRealHotList7 {
            //实时热榜
            contentView.addSubview(bgBackView)

            bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:CGFloat(model.cellH)-DownSlideRecommendLeftGap)
            // 设置阴影效果
            bgBackView.layer.masksToBounds = false
            //定义view的阴影颜色
            bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
            //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
            bgBackView.layer.shadowOpacity = 1
            //定义view的阴影宽度,模糊计算的半径
            bgBackView.layer.shadowRadius = 10.0
            //阴影偏移量
            bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0)
            bgBackView.layer.cornerRadius = 12
            bgBackView.backgroundColor = .white
            
            let imageView = UIImageView(frame: CGRectMake(0, 0, bgBackView.width, CGFloat(bgBackView.width*140/345.0)))
            imageView.kf.setImage(with: URL(string:model.background))
            let path = UIBezierPath.init(roundedRect: CGRect(x: 0, y: 0, width: imageView.width, height:imageView.height), byRoundingCorners: [.topLeft,.topRight], cornerRadii: CGSizeMake(10, 10))
            let masklayer = CAShapeLayer()
            masklayer.path = path.cgPath
            imageView.layer.mask = masklayer
            imageView.clipsToBounds = true
            imageView.contentMode = .scaleAspectFill
            bgBackView.addSubview(imageView)
            
            bgBackView.addSubview(self.realHotCollectionView)
            self.realHotCollectionView.frame = CGRect(x: DownSlideRecommendLeftGap, y: imageView.bottom, width: imageView.width-2*DownSlideRecommendLeftGap, height: bgBackView.height-imageView.height)
            self.realHotArr = NSMutableArray(array: model.contents)
            self.realHotCollectionView.reloadData()
        }
    }
    
    // MARK: - 实时热榜里横向列表
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        self.realHotArr.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kRealHotListCollectionViewCellIdentifier, for: indexPath) as! CNLiveDownSlideRealHotListCell
        cell.num = indexPath.row+1
        // 加载和设置图片到 cell.imageView
        cell.contentsModel = self.realHotArr[indexPath.row] as? CNLiveDownSlideContentsModel
        return cell

    }
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        if let contentMdl = self.realHotArr[indexPath.row] as? CNLiveDownSlideContentsModel{
            //实时热榜点击短剧
            CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model , contentId: contentMdl.contentId , pid: contentMdl.pid , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.thirdUrl , title: contentMdl.title , s_to: contentMdl.s_to ,trailerId: contentMdl.trailerId , controller: nil, slideModel: self.slideModel)
        }
    }
    
    
    func setupMyCurriculumUI(model:CNLiveAlbumBaseModel){
        contentView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        bgBackView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        bgImageView.subviews.forEach { view in
            view.removeFromSuperview()
        }
        //全部课程列表
        contentView.addSubview(bgBackView)

        let contentsNum = model.list.count
        if contentsNum == 0{
            return
        }
        //总显示块数/循环数
        var totalNum = (contentsNum >= 4) ? 4 : contentsNum
        var cellH = DownSlideAllCourseTitleH + DownSlideAllCourseRowH * CGFloat(totalNum)+DownSlideRecommendLeftGap
        
        bgBackView.frame = CGRect(x: DownSlideRecommendLeftGap, y: 0,width:DownSlideSingleCourseW , height:cellH-DownSlideRecommendLeftGap)
        // 设置阴影效果
        bgBackView.layer.masksToBounds = false
        //定义view的阴影颜色
        bgBackView.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.1).cgColor
        //定义view的阴影透明度,注意:如果view没有设置背景色阴影也是不会显示的
        bgBackView.layer.shadowOpacity = 1
        //定义view的阴影宽度,模糊计算的半径
        bgBackView.layer.shadowRadius = 10.0
        //阴影偏移量
        bgBackView.layer.shadowOffset = CGSize(width: 0, height: 0)
        bgBackView.layer.cornerRadius = 12
        bgBackView.backgroundColor = .white
        
        var titleTop:CGFloat = DownSlideRecommendLeftGap
        let titleLbl = UILabel(frame: CGRect(x: DownSlideRecommendLeftGap, y: titleTop, width: DownSlideSingleCourseW-DownSlideRecommendLeftGap*2, height: 30))
        titleLbl.text = "我的课程"
        titleLbl.font = BoldFont_21
        titleLbl.textColor = HexColor("#333333")
        bgBackView.addSubview(titleLbl)
        
        for i in 0..<totalNum{//i是第几行
            let contentMdl = model.list[i]
            
            //小icon
            let imageView = UIImageView(frame: CGRectMake(DownSlideRecommendLeftGap, titleLbl.bottom+DownSlideRecommendLeftGap+CGFloat(i)*(DownSlideAllCourseRowTopYGap+DownSlideAllCourseRowImageWH+DownSlideAllCourseRowBottomYGap), CGFloat(DownSlideAllCourseRowImageWH), CGFloat(DownSlideAllCourseRowImageWH)))
            imageView.kf.setImage(with: URL(string:contentMdl.poster ))
            imageView.layer.cornerRadius = 12
            imageView.clipsToBounds = true
            imageView.contentMode = .scaleAspectFill
            bgBackView.addSubview(imageView)
            
            let titleLbl = UILabel(frame: CGRect(x: imageView.right+DownSlideRecommendLeftGap, y: imageView.top, width: DownSlideSingleCourseW-90-imageView.right, height: 21))
            titleLbl.text = contentMdl.title 
            titleLbl.font = Font_15
            titleLbl.textColor = HexColor("#333333")
            bgBackView.addSubview(titleLbl)
            
            let subTitleLbl = UILabel(frame: CGRect(x: titleLbl.left, y:titleLbl.bottom+3 , width: titleLbl.width, height: 17))
            subTitleLbl.text =  contentMdl.subTitle 
            subTitleLbl.font = Font_12
            subTitleLbl.textColor = HexColor("#999999")
            bgBackView.addSubview(subTitleLbl)
            
            let enterBtn = UIButton(type: .custom)
            enterBtn.frame = CGRect(x: bgBackView.right-25-65, y: 0, width: 65, height: 30)
            enterBtn.centerY = imageView.centerY
            enterBtn.setBackgroundImage(UIImage(named: "homepage_down_enter"), for: .normal)
            enterBtn.setTitle("进入", for: .normal)
            enterBtn.titleLabel?.font = BoldFont_13
            enterBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
            enterBtn.addTarget(self, action: #selector(enterBtnAction(_:)), for: .touchUpInside)
            enterBtn.tag = i
            bgBackView.addSubview(enterBtn)
        }
    }
    //MARK: - 事件
    @objc func enterBtnAction(_ sender: UIButton){
        
        let tag = sender.tag
        if self.myCurriculum?.list.count ?? 0 > 0{
            let albumMdl = self.myCurriculum?.list[tag]
            CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: albumMdl?.model ?? "", contentId: albumMdl?.contentId ?? "", pid: albumMdl?.pid ?? "", shareUrl: albumMdl?.shareUrl ?? "", thirdUrl: albumMdl?.thirdUrl ?? "", title: albumMdl?.title ?? "", s_to: albumMdl?.s_to ?? "",trailerId: albumMdl?.trailerId ?? "", controller: nil, slideModel: nil)
        }else if self.slideModel?.contents.count ?? 0 > 0{
            let contentMdl = self.slideModel?.contents[tag]
            CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl?.model ?? "", contentId: contentMdl?.contentId ?? "", pid: contentMdl?.pid ?? "", shareUrl: contentMdl?.shareUrl ?? "", thirdUrl: contentMdl?.thirdUrl ?? "", title: contentMdl?.title ?? "", s_to: contentMdl?.s_to ?? "",trailerId: contentMdl?.trailerId ?? "", controller: nil, slideModel: nil)
        }
    }
    @objc func pushWebAction(ges: UITapGestureRecognizer){
        let imageView = ges.view as! UIImageView
        let i = imageView.tag
        let contentMdl = (self.slideModel?.contents[i])!
        CNLiveDownSlideTool.pushWebVCWithContentsMdl(model: contentMdl.model , contentId: contentMdl.contentId , pid: contentMdl.pid , shareUrl: contentMdl.shareUrl , thirdUrl: contentMdl.thirdUrl , title: contentMdl.title , s_to: contentMdl.s_to ,trailerId: contentMdl.trailerId , controller: nil, slideModel: nil)
    }
}