CNLiveShopBodyDetailView.swift 9.2 KB
//
//  CNLiveShopBodyDetailView.swift
//  metaCode
//
//  Created by open on 2023/11/1.
//

import Foundation

/// 头视图
class ShopBodyOrderDetailHeaderView: UIView {
    
    lazy var iconView: UIImageView = {
        let iconView = UIImageView.init()
        iconView.backgroundColor = .white
        iconView.contentMode = .scaleAspectFill
        return iconView
    }()
    
    lazy var smallView: UIImageView = {
        let smallView = UIImageView.init()
        smallView.backgroundColor = .clear
        smallView.contentMode = .scaleAspectFill
        return smallView
    }()
    
    lazy var smallLabel: UILabel = {
        let smallLabel = UILabel.init()
        smallLabel.textColor = .white
        smallLabel.font = BoldFont_18_Fit
        return smallLabel
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(iconView)
        iconView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.left.right.equalToSuperview()
            make.height.equalTo(50)
        }
        iconView.addSubview(smallView)
        smallView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.size.equalTo(20)
        }
        iconView.addSubview(smallLabel)
        smallLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(smallView.snp.right).offset(10)
            make.right.equalToSuperview().offset(-15)
        }
    }
    func setupDataSource(dict: NSDictionary) {
        iconView.image = UIImage(named: dict["back_image"] as! String)
        smallView.image = UIImage(named: (dict["icon_image"] as! String))
        smallLabel.text = dict["statues"] as? String
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

/// 列表图
class ShopBodyOrderDetailOneTableViewCell: UITableViewCell {
    
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("0x222833")
        titleLabel.font = regular_adapt_font(pointSize: 15)
        titleLabel.numberOfLines = 1
        return titleLabel
    }()
    
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.textColor = HexColor("#959595")
        descLabel.font = regular_adapt_font(pointSize: 13)
        descLabel.numberOfLines = 2
        return descLabel
    }()
    
    lazy var phoneButton: UIButton = {
        let phoneButton = UIButton(type: .custom)
        phoneButton.setTitleColor(HexColor("4A90E2"), for: .normal)
        phoneButton.titleLabel?.font = regular_adapt_font(pointSize: 14)
        phoneButton.addTarget(self, action: #selector(phoneCallBtnClick), for: .touchUpInside)
        return phoneButton
    }()
    
    lazy var phoneView: UIImageView = {
        let phoneView = UIImageView.init()
        phoneView.backgroundColor = .white
        phoneView.image = UIImage(named: "DS_order_phone")
        return phoneView
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        
    }
    
    @objc func phoneCallBtnClick() {
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

/// 列表图
class ShopBodyOrderDetailTwoTableViewCell: UITableViewCell {
    lazy var titleLabel: UILabel = {
        let titleLabel = UILabel.init()
        titleLabel.textColor = HexColor("#333333")
        titleLabel.font = BoldFont_16_Fit
        titleLabel.numberOfLines = 2
        titleLabel.lineBreakMode = .byTruncatingTail
        return titleLabel
    }()
    
    lazy var statueLable: UILabel = {
        let statueLabel = UILabel.init()
        statueLabel.textColor = HexColor("#F5A623")
        statueLabel.font = Font_13_Fit
        statueLabel.textAlignment = .left
        return statueLabel
    }()
    
    lazy var numberLabel: UILabel = {
        let numberLabel = UILabel.init(frame: CGRect.zero)
        numberLabel.font = Font_12_Fit
        numberLabel.textColor = HexColor("#65656")
        return numberLabel
    }()
    
    lazy var originalPriceLab: UILabel = {
        let originalPriceLab = UILabel.init()
        originalPriceLab.textColor = HexColor("#9c9c9c")
        originalPriceLab.font = Font_10_Fit
        return originalPriceLab
    }()
    
    lazy var priceLab: UILabel = {
        let priceLab = UILabel.init()
        priceLab.textColor = HexColor("FF415F")
        priceLab.font = BoldFont_18_Fit
        return priceLab
    }()
    
    lazy var descLabel: UILabel = {
        let descLabel = UILabel.init()
        descLabel.textColor = HexColor("9c9c9c")
        descLabel.font = Font_14_Fit
        descLabel.numberOfLines = 1
        descLabel.lineBreakMode = .byTruncatingTail
        return descLabel
    }()
    
    lazy var refundLab: UILabel = {
        let refundLab = UILabel.init()
        refundLab.font = Font_13_Fit
        refundLab.textColor = HexColor("#F5A623")
        refundLab.textAlignment = .right
        return refundLab
    }()
    
    lazy var iconView: UIImageView = {
        let iconView = UIImageView.init()
        iconView.backgroundColor = .white
        iconView.layer.cornerRadius = 5
        iconView.layer.masksToBounds = true
        iconView.image = UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 90, height: 90))
        return iconView
    }()
    
    lazy var lineLabel: UILabel = {
        let lineLabel = UILabel.init()
        lineLabel.backgroundColor = HexColor("#EAEAEA")
        return lineLabel
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = .clear
        selectionStyle = .none
        
        addSubview(titleLabel)
        addSubview(numberLabel)
        addSubview(iconView)
        addSubview(lineLabel)
        addSubview(statueLable)
        addSubview(originalPriceLab)
        addSubview(priceLab)
        addSubview(refundLab)
        addSubview(descLabel)
        
        setConstrainta()
    }
    
    func setupDataSource(goodsModel: ShopOrderListGoodsModel, isHiddenLine: Bool, isRefund: Bool, isState: Bool) {
        titleLabel.text = goodsModel.title
        descLabel.text = goodsModel.ads
        priceLab.text = "\(goodsModel.price ?? "")"
        iconView.kf.setImage(with: URL(string: goodsModel.simg!), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 90, height: 90)))
        
        lineLabel.isHidden = isHiddenLine
//        if !isRefund && isState {
//            if (goodsModel.send_num == "0" || (Int(goodsModel.num) - Int(goodsModel.send_num)) + Int(goodsModel.refund_num) == Int(goodsModel.num)) {
//                statueLable.text = "全部已发货"
//            } else {
//                statueLable.text = "\(Int(goodsModel.num) - Int(goodsModel.send_num))/\(goodsModel.num)已发货"
//            }
//        }
    }
    
    func setConstrainta() {
        iconView.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.top.equalToSuperview().offset(10)
            make.size.equalTo(90)
        }
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(iconView.snp.right).offset(10)
            make.right.equalToSuperview().offset(-15)
            make.top.equalTo(iconView.snp.top).offset(5)
        }
        numberLabel.snp.makeConstraints { make in
            make.centerY.equalTo(originalPriceLab)
            make.right.equalToSuperview().offset(-15)
        }
        refundLab.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(15)
            make.top.equalTo(iconView.snp.bottom).offset(10)
        }
        priceLab.snp.makeConstraints { make in
            make.left.equalTo(iconView.snp.right).offset(10)
            make.bottom.equalTo(iconView.snp.bottom).offset(-5)
        }
        originalPriceLab.snp.makeConstraints { make in
            make.left.equalTo(priceLab.snp.right).offset(10)
            make.bottom.equalTo(iconView.snp.bottom).offset(-5)
        }
        descLabel.snp.makeConstraints { make in
            make.left.equalTo(iconView.snp.right).offset(10)
            make.top.equalTo(titleLabel.snp.bottom).offset(5)
        }
        lineLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.bottom.equalToSuperview().offset(-1)
            make.height.equalTo(1)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

/// 列表图
class ShopBodyOrderDetailThreeTableViewCell: UITableViewCell {
    
}

/// 尾视图
class ShopBodyOrderDetailFooterViewCell: UITableViewHeaderFooterView {
    
}