CNLiveDigitalSecCollectionCell.swift 4.16 KB
//
//  CNLiveDigitalSecCollectionCell.swift
//  metaCode
//
//  Created by zx on 2024/6/18.
//

import Foundation
import Kingfisher

class CNLiveDigitalSecCollectionCell: UICollectionViewCell {
        
    var _authListModel : MineAuthListModel?
    var authListModel : MineAuthListModel? {
        get{
            _authListModel
        }
        set{
            _authListModel = newValue!
            setupNewUI(model: _authListModel!)
        }
    }
    
    lazy var iconImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
        iconImgView.clipsToBounds = true
        iconImgView.layer.cornerRadius = 30
        iconImgView.contentMode = .scaleAspectFill
        iconImgView.clipsToBounds = true
        return iconImgView
    }()
    lazy var bottomTitleLabel: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(0, 47, 60, 16))
        titleLabel.textColor = .white
        titleLabel.textAlignment = .center
        titleLabel.layer.cornerRadius = 8
        titleLabel.clipsToBounds = true
        titleLabel.font = Font_14
        titleLabel.text = "审核中"
        titleLabel.backgroundColor = HexColor("#FFD20B")
        titleLabel.adjustsFontSizeToFitWidth=true
        return titleLabel
    }()

    //是否选中
    var _cellIsSelected : Bool = false
    var cellIsSelected : Bool {
        get{
            _cellIsSelected
        }
        set{
            _cellIsSelected = newValue
             
            if _cellIsSelected == true{
                //选中
                self.iconImgView.layer.borderWidth = 1
                self.iconImgView.layer.borderColor = HexColor("#1961FE")?.cgColor
            }else{
                //未选中
                self.iconImgView.layer.borderWidth = 0
                self.iconImgView.layer.borderColor = HexColor("#1961FE")?.cgColor
            }
            
                
//            self.rightIconImgView.isHidden = !_cellIsSelected
        }
    }
    
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init(frame: CGRectMake(0, self.iconImgView.bottom+8, 60, 17))
        titleLabel.textColor = HexColor("#1961FE")
        titleLabel.textAlignment = .center
        titleLabel.adjustsFontSizeToFitWidth = true
        titleLabel.font = Font_12
        return titleLabel
    }()
    
    lazy var addBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.frame = CGRect(x: 0, y: 0, width: 60, height: 60)
        closeBtn.setImage(UIImage(named: "auth_add"), for: .normal)
        closeBtn.addTarget(self, action: #selector(addBtnAction), for: .touchUpInside)
        return closeBtn
    }()

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(self.iconImgView)
//        self.iconImgView.addSubview(self.rightIconImgView)
        self.contentView.addSubview(self.titleLabel)
        self.contentView.addSubview(self.addBtn)
        self.contentView.addSubview(self.bottomTitleLabel)
        self.bottomTitleLabel.isHidden = true
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupNewUI(model:MineAuthListModel){
        self.bottomTitleLabel.isHidden = true
        if model.identityId != 0{
            self.titleLabel.text = model.name
            self.iconImgView.kf.setImage(with: URL(string: model.icon ?? ""))
            self.addBtn.isHidden = true
            self.titleLabel.isHidden = false
            self.iconImgView.isHidden = false
            
            if model.userStatus == 0{
                //审核中
                self.bottomTitleLabel.isHidden = false
            }else if model.userStatus == 1{
                //审核成功
                self.bottomTitleLabel.isHidden = true
            }else{
                self.bottomTitleLabel.isHidden = true
            }
        }else{
            self.addBtn.isHidden = false
            self.titleLabel.isHidden = true
            self.iconImgView.isHidden = true
        }
    }
    
    @objc func addBtnAction(){
        navigationViewController().pushViewController(CNLiveIdentityRepositoryController(), animated: true)
    }
}