CNLiveAuthTool.swift
6.79 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//
// CNLiveAuthTool.swift
// metaCode
//
// Created by zx on 2024/6/12.
//
import Foundation
import QMUIKit
import SnapKit
typealias AuthToolHiddenBlock = () -> Void
class CNLiveAuthTool:NSObject{
static let shared = CNLiveAuthTool()
var authToolHiddenBlock:AuthToolHiddenBlock?
let delegate = UIApplication.shared.delegate as! AppDelegate
lazy var bgBtnView: UIButton = {
let bgBtnView = UIButton(frame: self.delegate.window!.bounds)
bgBtnView.backgroundColor = HexColor("#000000")
bgBtnView.alpha = 0.6
// bgBtnView.addTarget(self, action: #selector(bgBtnViewAction), for: .touchUpInside)
return bgBtnView
}()
lazy var bottomBgView :UIView = {
let bottomBgView = UIView(frame: CGRect(x: (KSreenWidth-adapt_length(length: 273))/2, y: (KSreenHeight-adapt_length(length: 597))/2, width: adapt_length(length: 273), height: adapt_length(length: 597)))
bottomBgView.backgroundColor = HexColor("#FFFFFF")
bottomBgView.layer.cornerRadius = 13
bottomBgView.clipsToBounds = true
bottomBgView.tag = integralAlertToolTag
return bottomBgView
}()
lazy var failTitleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .center
titleLabel.font = BoldFont_16
titleLabel.text = "实名认证失败"
return titleLabel
}()
lazy var jianchaView :UIView = {
let jianchaView = UIView(frame: CGRect(x: adapt_length(length: 14), y: adapt_length(length: 58), width: KSreenWidth-2*adapt_length(length: 14), height: adapt_length(length: 77)))
jianchaView.backgroundColor = HexColor("#F7F7F7")
jianchaView.layer.cornerRadius = 9.5
jianchaView.clipsToBounds = true
jianchaView.layer.borderWidth = 0.5
jianchaView.layer.borderColor = HexColor("#E1E1E1")?.cgColor
return jianchaView
}()
//请检查
lazy var jianchaTitleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textColor = HexColor("#333333")
titleLabel.textAlignment = .center
titleLabel.font = Font_12
titleLabel.text = "请检查"
return titleLabel
}()
lazy var firstImgView :UIImageView = {
let iconImgView = UIImageView(frame: CGRect(x: adapt_length(length: 13), y: adapt_length(length: 35), width: adapt_length(length: 11), height: adapt_length(length: 11)))
iconImgView.image = UIImage(named: "auth_1")
return iconImgView
}()
lazy var firstTitleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textColor = HexColor("#333333")
titleLabel.font = Font_10
titleLabel.text = "请确保人脸与身份信息证件照相符"
return titleLabel
}()
// lazy var secImgView :UIImageView = {
// let iconImgView = UIImageView(frame: CGRect(x: adapt_length(length: 13), y: adapt_length(length: 54), width: adapt_length(length: 11), height: adapt_length(length: 11)))
// iconImgView.image = UIImage(named: "auth_2")
// return iconImgView
// }()
// lazy var secTitleLabel: UILabel = {
// let titleLabel = UILabel.init()
// titleLabel.textColor = HexColor("#333333")
// titleLabel.font = Font_10
// titleLabel.text = "请确保人脸与身份信息证件照相符"
// return titleLabel
// }()
lazy var detailImgView :UIImageView = {
let iconImgView = UIImageView()
iconImgView.image = UIImage(named: "auth_fail")
return iconImgView
}()
lazy var xiugaiBtn: UIButton = {
let payBtn = UIButton(type: .custom)
payBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
payBtn.setTitle("去修改", for: .normal)
payBtn.titleLabel?.font = Font_18
payBtn.backgroundColor = HexColor("#1961FE")
payBtn.layer.cornerRadius = 21
payBtn.clipsToBounds = true
payBtn.addTarget(self, action: #selector(xiugaiBtnAction), for: .touchUpInside)
return payBtn
}()
// MARK: - show
///弹出实名失败弹窗
func showAuthFailAlert(){
delegate.window?.addSubview(self.bgBtnView)
delegate.window?.addSubview(self.bottomBgView)
self.bottomBgView.addSubview(self.xiugaiBtn)
self.xiugaiBtn.snp.makeConstraints { make in
make.height.equalTo(adapt_length(length: 39))
make.width.equalTo(adapt_length(length: 160))
make.bottom.equalToSuperview().offset(adapt_length(length: -15))
make.centerX.equalToSuperview()
}
self.bottomBgView.addSubview(self.failTitleLabel)
self.failTitleLabel.snp.makeConstraints { make in
make.top.equalTo(adapt_length(length: 20))
make.left.equalTo(15)
make.right.equalToSuperview().offset(-15)
make.height.equalTo(adapt_length(length: 23))
}
self.bottomBgView.addSubview(self.jianchaView)
self.jianchaView.addSubview(self.jianchaTitleLabel)
self.jianchaTitleLabel.snp.makeConstraints { make in
make.left.equalTo(adapt_length(length: 13))
make.top.equalTo(adapt_length(length: 10))
}
self.jianchaView.addSubview(self.firstImgView)
self.firstImgView.snp.makeConstraints { make in
make.left.equalTo(adapt_length(length: 13))
make.top.equalTo(adapt_length(length: 35))
make.width.equalTo(adapt_length(length: 11))
make.height.equalTo(adapt_length(length: 11))
}
self.jianchaView.addSubview(self.firstTitleLabel)
self.firstTitleLabel.snp.makeConstraints { make in
make.centerY.equalTo(self.firstImgView.snp.centerY)
make.left.equalTo(self.firstImgView.snp.right).offset(adapt_length(length: 1.5))
}
self.bottomBgView.addSubview(self.detailImgView)
self.detailImgView.snp.makeConstraints { make in
make.left.equalTo(adapt_length(length: 15))
make.top.equalTo(self.jianchaView.snp.bottom).offset(adapt_length(length: 10))
make.width.equalTo(adapt_length(length: 243))
make.height.equalTo(adapt_length(length: 384))
}
}
//隐藏弹窗
func hiddenIntegralAlert(){
self.authToolHiddenBlock?()
delegate.window?.subviews.forEach({ view in
if view.tag == integralAlertToolTag{
UIView.animate(withDuration: 0.25) {
view.removeFromSuperview()
self.bgBtnView.removeFromSuperview()
self.bottomBgView.removeFromSuperview()
}
}
})
}
// MARK: - BtnAction
@objc func xiugaiBtnAction(){
self.hiddenIntegralAlert()
}
}