CNLiveVodPayView.swift 2.79 KB
//
//  CNLiveVodPayView.swift
//  metaCode
//
//  Created by zx on 2025/4/1.
//  支付页面

import Foundation

typealias CNLiveVodPayViewPayBlock = ()->Void

class CNLiveVodPayView:UIView{
    
    var payBlock:CNLiveVodPayViewPayBlock?
    //MARK: - 懒加载
    lazy var titleLabel: UILabel = {
        let titleLbl = UILabel()
        titleLbl.font = Font_12
        titleLbl.textColor = HexColor("#FFFFFF")
        titleLbl.text = "应版权方要求,本专辑所有用户均需付费"
        return titleLbl
    }()
    lazy var payBtn: UIButton = {
        let  closeBtn = UIButton(type: .custom)
        closeBtn.backgroundColor = HexColor("#F5A623", alpha: 0.14)
        closeBtn.layer.borderColor = HexColor("#F5A623")?.cgColor
        closeBtn.layer.borderWidth = 0.5
        closeBtn.clipsToBounds = true
        closeBtn.layer.cornerRadius = 6
        closeBtn.setTitleColor(HexColor("#F5A623"), for: .normal)
        closeBtn.setTitle("元购买本专辑", for: .normal)
        closeBtn.titleLabel?.font = Font_12
        closeBtn.addTarget(self, action: #selector(payBtnAction), for: .touchUpInside)
        return closeBtn
    }()

    lazy var landscapeBackBtn: UIButton = {
        let backBtn = UIButton.backItem(imageName: ("mine_header_icon_white_back"), target: self, action: #selector(landscapeBackBtnAction))
        backBtn.frame = CGRect(x: 15, y: KStatusBarHeight, width: 60, height: 30)
        return backBtn
    }()

    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = HexColor("#000000", alpha: 0.7)
        self.isUserInteractionEnabled = true
        self.initUI()
        self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapAction)))
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func initUI(){
        
//        self.addSubview(self.landscapeBackBtn)

        self.addSubview(self.titleLabel)
        
        self.addSubview(self.payBtn)
        payBtn.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(117)
            make.height.equalTo(30)
        }
        titleLabel.snp.makeConstraints { make in
            make.bottom.equalTo(self.payBtn.snp.top).offset(-15)
            make.centerX.equalToSuperview()
        }
    }
    
    @objc func payBtnAction(){
        //拉起支付
        self.payBlock?()
    }

    @objc func tapAction(){
//        self.isHidden = true
    }
    
    @objc func landscapeBackBtnAction(){
        let viewControllers = navigationViewController().viewControllers
        if viewControllers.count > 1 {
            if viewControllers.last == self {
                navigationViewController().popViewController(animated: true)
            }
        }
    }
}