CNLiveMineMineOrderCell.swift 15.9 KB
//
//  CNLiveMineMineOrderCell.swift
//  metaCode
//
//  Created by zx on 2025/3/15.
//  我的订单

import Foundation
class CNLiveMineMineOrderCell : UITableViewCell {
    
    lazy var mainView: UIView = {
        let mainView = UIView.init()
        mainView.backgroundColor = .white
        mainView.layer.cornerRadius = 15
        mainView.layer.masksToBounds = true
        return mainView
    }()
    lazy var playIconView: UIImageView = {
        let headerView = UIImageView.init()
        headerView.backgroundColor = .clear
        headerView.image = UIImage(named: "mine_mineOrder")
        headerView.contentMode = .scaleToFill
        return headerView
    }()

    lazy var nameLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = .black
        nameLabel.font = BoldFont_16_Fit
        nameLabel.text = "我的订单"
        nameLabel.backgroundColor = .clear
        return nameLabel
    }()
    lazy var moreBtn: UIButton = {
        let moreBtn = UIButton.init(type: .custom)
        moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
        moreBtn.layer.masksToBounds = true
        moreBtn.layer.cornerRadius = 15
        moreBtn.isUserInteractionEnabled = false
        return moreBtn
    }()
    lazy var iconImgView1 :UIImageView = {
        let imageView = UIImageView()
        imageView.tag = 1000
        imageView.layer.cornerRadius = 9
        imageView.clipsToBounds = true
        imageView.contentMode = .scaleAspectFill
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
        return imageView
    }()
    
    lazy var allOrderBtn: UIButton = {
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.frame = CGRect(x: 0, y: 0, width: 31, height: 50)
        expandBtn.setTitle("订单", for: .normal)
        expandBtn.setTitle("订单", for: .selected)
        expandBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_allOrder"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_allOrder"), for: .selected)
        expandBtn.titleLabel?.font = Font_10
        expandBtn.titleLabel?.textAlignment = .center
        expandBtn.setupButtonImageAndTitlePossitionWith(padding: 10, style: .top)
        expandBtn.addTarget(self, action: #selector(allOrderBtnAction), for: .touchUpInside)
        return expandBtn
    }()
    lazy var waitPayBtn: UIButton = {
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.frame = CGRect(x: 0, y: 0, width: 31, height: 50)
        expandBtn.setTitle("待付款", for: .normal)
        expandBtn.setTitle("待付款", for: .selected)
        expandBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_waitPay"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_waitPay"), for: .selected)
        expandBtn.titleLabel?.font = Font_10
        expandBtn.titleLabel?.textAlignment = .center
        expandBtn.setupButtonImageAndTitlePossitionWith(padding: 10, style: .top)
        expandBtn.addTarget(self, action: #selector(waitPayBtnAction), for: .touchUpInside)
        return expandBtn
    }()
    lazy var waitFaHuoBtn: UIButton = {
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.frame = CGRect(x: 0, y: 0, width: 31, height: 50)
        expandBtn.setTitle("待发货", for: .normal)
        expandBtn.setTitle("待发货", for: .selected)
        expandBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_waitFaHuo"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_waitFaHuo"), for: .selected)
        expandBtn.titleLabel?.font = Font_10
        expandBtn.titleLabel?.textAlignment = .center
        expandBtn.setupButtonImageAndTitlePossitionWith(padding: 10, style: .top)
        expandBtn.addTarget(self, action: #selector(waitFaHuoBtnAction), for: .touchUpInside)
        return expandBtn
    }()
    lazy var yiFaHuoBtn: UIButton = {
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.frame = CGRect(x: 0, y: 0, width: 31, height: 50)
        expandBtn.setTitle("已发货", for: .normal)
        expandBtn.setTitle("已发货", for: .selected)
        expandBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_yiFaHuo"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_yiFaHuo"), for: .selected)
        expandBtn.titleLabel?.font = Font_10
        expandBtn.titleLabel?.textAlignment = .center
        expandBtn.setupButtonImageAndTitlePossitionWith(padding: 10, style: .top)
        expandBtn.addTarget(self, action: #selector(yiFaHuoBtnAction), for: .touchUpInside)
        return expandBtn
    }()
    lazy var shouHouBtn: UIButton = {
        let expandBtn = UIButton.init(type: .custom)
        expandBtn.backgroundColor = .clear
        expandBtn.frame = CGRect(x: 0, y: 0, width: 31, height: 50)
        expandBtn.setTitle("售后", for: .normal)
        expandBtn.setTitle("售后", for: .selected)
        expandBtn.setTitleColor(HexColor("#3A3A3A"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_ShouHou"), for: .normal)
        expandBtn.setImage(UIImage(named: "mine_ShouHou"), for: .selected)
        expandBtn.titleLabel?.font = Font_10
        expandBtn.titleLabel?.textAlignment = .center
        expandBtn.setupButtonImageAndTitlePossitionWith(padding: 10, style: .top)
        expandBtn.addTarget(self, action: #selector(shouHouBtnAction), for: .touchUpInside)
        return expandBtn
    }()
    
    lazy var lineView :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 35, y: 0, width: KSreenWidth-35*2, height: 0.5))
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()

    lazy var carIconView: UIImageView = {
        let headerView = UIImageView.init()
        headerView.backgroundColor = .clear
        headerView.image = UIImage(named: "mine_payCar")
        headerView.contentMode = .scaleToFill
        return headerView
    }()

    lazy var carLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = .black
        nameLabel.font = BoldFont_16_Fit
        nameLabel.text = "购物车"
        nameLabel.backgroundColor = .clear
        return nameLabel
    }()
    lazy var carMoreBtn: UIButton = {
        let moreBtn = UIButton.init(type: .custom)
        moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
        moreBtn.layer.masksToBounds = true
        moreBtn.layer.cornerRadius = 15
        moreBtn.isUserInteractionEnabled = false
        return moreBtn
    }()
    lazy var iconImgView2 :UIImageView = {
        let imageView = UIImageView()
        imageView.tag = 1001
        imageView.layer.cornerRadius = 9
        imageView.clipsToBounds = true
        imageView.contentMode = .scaleAspectFill
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
        return imageView
    }()
    
    lazy var lineView2 :UIView = {
        let bottomNavView = UIView(frame: CGRect(x: 35, y: 0, width: KSreenWidth-35*2, height: 0.5))
        bottomNavView.backgroundColor = HexColor("#EAEAEA")
        return bottomNavView
    }()
    lazy var addressIconView: UIImageView = {
        let headerView = UIImageView.init()
        headerView.backgroundColor = .clear
        headerView.image = UIImage(named: "mine_list_sub_set_poistion")
        headerView.contentMode = .scaleToFill
        return headerView
    }()

    lazy var addressLabel: UILabel = {
        let nameLabel = UILabel.init()
        nameLabel.textColor = .black
        nameLabel.font = BoldFont_16_Fit
        nameLabel.text = "地址管理"
        nameLabel.backgroundColor = .clear
        return nameLabel
    }()
    lazy var addressMoreBtn: UIButton = {
        let moreBtn = UIButton.init(type: .custom)
        moreBtn.setImage(UIImage(named: "mine_list_icon_right_more"), for: .normal)
        moreBtn.layer.masksToBounds = true
        moreBtn.layer.cornerRadius = 15
        moreBtn.isUserInteractionEnabled = false
        return moreBtn
    }()
    lazy var iconImgView3 :UIImageView = {
        let imageView = UIImageView()
        imageView.tag = 1002
        imageView.layer.cornerRadius = 9
        imageView.clipsToBounds = true
        imageView.contentMode = .scaleAspectFill
        imageView.isUserInteractionEnabled = true
        imageView.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(imgTapAction)))
        return imageView
    }()

    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        addSubview(mainView)
        mainView.addSubview(playIconView)
        mainView.addSubview(nameLabel)
        mainView.addSubview(moreBtn)
        mainView.addSubview(iconImgView1)
        self.contentView.clipsToBounds = true

        mainView.addSubview(allOrderBtn)
        mainView.addSubview(waitPayBtn)
        mainView.addSubview(waitFaHuoBtn)
        mainView.addSubview(yiFaHuoBtn)
        mainView.addSubview(shouHouBtn)

        mainView.addSubview(lineView)
        mainView.addSubview(carIconView)
        mainView.addSubview(carLabel)
        mainView.addSubview(carMoreBtn)
        mainView.addSubview(iconImgView2)
        
        mainView.addSubview(lineView2)
        mainView.addSubview(addressIconView)
        mainView.addSubview(addressLabel)
        mainView.addSubview(addressMoreBtn)
        mainView.addSubview(iconImgView3)


        setupConstraints()
        
    }
    
    private func setupConstraints() {
        mainView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
        }
        playIconView.snp.makeConstraints { make in
            make.left.equalTo(15)
            make.top.equalTo(15)
            make.height.equalTo(19)
            make.width.equalTo(19)
        }
        nameLabel.snp.makeConstraints { make in
            make.centerY.equalTo(playIconView.snp.centerY)
            make.left.equalTo(playIconView.snp.right).offset(10)
        }
        moreBtn.snp.makeConstraints { make in
            make.top.equalTo(0)
            make.right.equalToSuperview()
            make.height.equalTo(12+30)
            make.width.equalTo(12+30)
        }
        iconImgView1.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(50)
        }
        let btnWidth:CGFloat = 32.0
        let padding:CGFloat = (KSreenWidth-5.0*btnWidth)/6.0
        allOrderBtn.snp.makeConstraints { make in
            make.top.equalTo(self.playIconView.snp.bottom).offset(20)
            make.left.equalTo(padding)
            make.height.equalTo(50)
            make.width.equalTo(btnWidth)
        }
        waitPayBtn.snp.makeConstraints { make in
            make.top.equalTo(self.playIconView.snp.bottom).offset(20)
            make.left.equalTo(self.allOrderBtn.snp.right).offset(padding)
            make.height.equalTo(50)
            make.width.equalTo(self.allOrderBtn.snp.width)
        }
        waitFaHuoBtn.snp.makeConstraints { make in
            make.top.equalTo(self.playIconView.snp.bottom).offset(20)
            make.left.equalTo(self.waitPayBtn.snp.right).offset(padding)
            make.height.equalTo(50)
            make.width.equalTo(self.allOrderBtn.snp.width)
        }
        yiFaHuoBtn.snp.makeConstraints { make in
            make.top.equalTo(self.playIconView.snp.bottom).offset(20)
            make.left.equalTo(self.waitFaHuoBtn.snp.right).offset(padding)
            make.height.equalTo(50)
            make.width.equalTo(self.allOrderBtn.snp.width)
        }
        shouHouBtn.snp.makeConstraints { make in
            make.top.equalTo(self.playIconView.snp.bottom).offset(20)
            make.left.equalTo(self.yiFaHuoBtn.snp.right).offset(padding)
            make.height.equalTo(50)
            make.width.equalTo(self.allOrderBtn.snp.width)
        }

        lineView.snp.makeConstraints { make in
            make.top.equalTo(self.shouHouBtn.snp.bottom).offset(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(0.5)
            make.width.equalToSuperview().offset(-30)
        }
        
        carIconView.snp.makeConstraints { make in
            make.left.equalTo(self.playIconView.snp.left)
            make.top.equalTo(self.lineView.snp.bottom).offset(18)
            make.height.equalTo(19)
            make.width.equalTo(19)
        }
        carLabel.snp.makeConstraints { make in
            make.centerY.equalTo(carIconView.snp.centerY)
            make.left.equalTo(carIconView.snp.right).offset(10)
        }
        carMoreBtn.snp.makeConstraints { make in
            make.centerY.equalTo(carIconView.snp.centerY)
            make.right.equalToSuperview()
            make.height.equalTo(12+30)
            make.width.equalTo(12+30)
        }
        iconImgView2.snp.makeConstraints { make in
            make.top.equalTo(self.lineView.snp.bottom)
            make.left.right.equalToSuperview()
            make.height.equalTo(52)
        }
        
        lineView2.snp.makeConstraints { make in
            make.top.equalTo(self.carLabel.snp.bottom).offset(15)
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(0.5)
            make.width.equalToSuperview().offset(-30)
        }
        
        addressIconView.snp.makeConstraints { make in
            make.left.equalTo(self.playIconView.snp.left)
            make.top.equalTo(self.lineView2.snp.bottom).offset(17)
            make.height.equalTo(16)
            make.width.equalTo(14)
        }
        addressLabel.snp.makeConstraints { make in
            make.centerY.equalTo(addressIconView.snp.centerY)
            make.left.equalTo(addressIconView.snp.right).offset(10)
        }
        addressMoreBtn.snp.makeConstraints { make in
            make.centerY.equalTo(addressIconView.snp.centerY)
            make.right.equalToSuperview()
            make.height.equalTo(12+30)
            make.width.equalTo(12+30)
        }
        iconImgView3.snp.makeConstraints { make in
            make.top.equalTo(self.lineView2.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
    }
            
    @objc func allOrderBtnAction(){
        CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0")
    }
    @objc func waitPayBtnAction(){
        CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "1")
    }
    @objc func waitFaHuoBtnAction(){
        CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "2")
    }
    @objc func yiFaHuoBtnAction(){
        CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "3")
    }
    @objc func shouHouBtnAction(){
        CNLiveDownSlideTool.pushShopH5WithType(type: "4", state: "")
    }
       
    @objc func imgTapAction(ges: UITapGestureRecognizer){
        let imageView = ges.view as! UIImageView
        let i = imageView.tag-1000
        if i == 0{
            //我的订单
            CNLiveDownSlideTool.pushShopH5WithType(type: "1", state: "0")
        }else if i == 1{
            //购物车
            CNLiveDownSlideTool.pushShopH5WithType(type: "2", state: "")
        }else if i == 2{
            //地址管理
            CNLiveDownSlideTool.pushShopH5WithType(type: "3", state: "")
        }
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}