杨锴
2024-11-25 b0222c34dcbc7ae27949a605fb4c7cea473844b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
//  PurchaseMethodView.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/11/25.
//
 
import UIKit
import JQTools
 
class PurchaseMethodView: UIView,JQNibView{
    @IBOutlet weak var view_content: UIView!
    @IBOutlet weak var img_1: UIImageView!
    @IBOutlet weak var img_2: UIImageView!
 
    @IBOutlet weak var img_select_1: UIImageView!
    @IBOutlet weak var img_select_2: UIImageView!
 
    @IBOutlet weak var label_1: UILabel!
    @IBOutlet weak var label_2: UILabel!
 
    @IBOutlet weak var btn_complete: UIButton!
    @IBOutlet weak var cons_bottom: NSLayoutConstraint!
    private var clouse:((TapType)->Void)?
 
    var tapType:TapType = .t2
 
    override func awakeFromNib() {
        super.awakeFromNib()
        img_1.image = UIImage(named: "btn_aP_1")
        img_2.image = UIImage(named: "btn_wxP_1")
        label_1.text = "支".appending("付").appending("宝").appending("支").appending("付")
        label_2.text = "微".appending("信").appending("支").appending("付")
        cons_bottom.constant = -JQ_ScreenW / 2
        alpha = 0
 
        layoutIfNeeded()
    }
 
    static func show(_ clouse:@escaping (TapType)->Void){
        let purchageView = PurchaseMethodView.jq_loadNibView()
        purchageView.clouse = clouse
        purchageView.frame = sceneDelegate?.window?.frame ?? .zero
        sceneDelegate?.window?.addSubview(purchageView)
 
        purchageView.cons_bottom.constant = 0
        UIView.animate(withDuration: 0.4) {
            purchageView.alpha = 1.0
            purchageView.layoutIfNeeded()
        }
    }
 
    @IBAction func closeAction(_ sender: Any) {
        cons_bottom.constant = -JQ_ScreenW / 2
        UIView.animate(withDuration: 0.4) {
            self.alpha = 0
            self.layoutIfNeeded()
        } completion: { _ in
            self.removeFromSuperview()
        }
    }
    
    @IBAction func tapAction(_ sender: TapBtn) {
        if sender.tag == 2100{
            tapType = .t2
            img_select_1.image = UIImage(named: "icon_choose_small_s")
            img_select_2.image = UIImage(named: "icon_choose_small_1")
        }else{
            tapType = .t3
            img_select_1.image = UIImage(named: "icon_choose_small_1")
            img_select_2.image = UIImage(named: "icon_choose_small_s")
        }
    }
 
    @IBAction func completeAction(_ sender: UIButton) {
        clouse?(tapType)
        cons_bottom.constant = -JQ_ScreenW / 2
        UIView.animate(withDuration: 0.4) {
            self.alpha = 0
            self.layoutIfNeeded()
        } completion: { _ in
            self.removeFromSuperview()
        }
    }
 
 
    override func layoutSubviews() {
        super.layoutSubviews()
 
        view_content.jq_addCorners(corner: [.topLeft,.topRight], radius: 20,width: JQ_ScreenW,height: 265)
 
        btn_complete.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 90, height: 40))
    }
}