CNLiveShopClassilyIconTableViewCell.swift 3.01 KB
//
//  CNLiveShopClassilyIconTableViewCell.swift
//  metaCode
//
//  Created by zx on 2023/11/18.
//

import Foundation

///上传图片成功
typealias uploadImageViewSuceessBlock = (_ imageUrl:String)->Void

///店铺分类图标cell
class CNLiveShopClassilyIconTableViewCell: UITableViewCell {
    var _selectUploadImageView:CNLiveAddGoodsSelectUploadImageView?
    var selectUploadImageView:CNLiveAddGoodsSelectUploadImageView?{
        get{
            if _selectUploadImageView == nil{
                _selectUploadImageView = CNLiveAddGoodsSelectUploadImageView()
                _selectUploadImageView?.maxSelectImageCount = 1
                _selectUploadImageView?.isAbleSelectVideo = false
                _selectUploadImageView?.deleteImage = UIImage(named: "DS_happ_daren_dynamic_delete")
                _selectUploadImageView?.endUploadImageCallBack = {
                    let imageUrl = self.selectUploadImageView?.getCurrentSelectImageUrls().first
                    self.uploadImageSuceessBlock!(imageUrl ?? "")
                }
                
            }
            return _selectUploadImageView
        }
        set{
            _selectUploadImageView = newValue
            
        }
    }
    var uploadImageSuceessBlock:uploadImageViewSuceessBlock?
    
    // MARK: - Lazy
    lazy var titlelab: UILabel = {
        let titlelab = UILabel.init()
        titlelab.textColor = HexColor("#999999")
        titlelab.textAlignment = .left
        titlelab.font = Font_12
        titlelab.numberOfLines = 2
        var att = NSMutableAttributedString(string: "分类图标 (注:手机端专用,建议上传正方形图片 100*100)")
        att.addAttribute(NSAttributedString.Key.font, value: Font_14, range: NSRange(location: 0, length: 4))
        att.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")! as UIColor, range: NSRange(location: 0, length: 4))
        titlelab.attributedText = att
        return titlelab
    }()
    lazy var star: UILabel = {
        let star = UILabel.init(frame: CGRect(x: 5, y: 0, width: 6, height: 40))
        star.textColor = HexColor("#FF725C")
        star.textAlignment = .left
        star.text = "*"
        star.font = Font_12
        return star
    }()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    // MARK: - 初始化UI
    func initUI(){
        self.contentView.addSubview(self.titlelab)
        self.contentView.addSubview(self.star)
        self.contentView.addSubview(self.selectUploadImageView!)
        self.p_massony()
    }
    func p_massony(){
        self.titlelab.snp.makeConstraints { make in
            make.left.equalTo(15)
            make.top.equalTo(0)
            make.height.equalTo(40)
        }
        self.selectUploadImageView?.frame = CGRect(x: 0, y: 40, width: 120, height: 120)
    }    
}