CNLiveVodPayView.swift
5.9 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
//
// CNLiveVodPayView.swift
// metaCode
//
// Created by zx on 2025/4/1.
// 支付页面
import Foundation
import CNLiveBusinessTools
typealias CNLiveVodPayViewPayBlock = ()->Void
class CNLiveVodPayView:UIView,UIGestureRecognizerDelegate{
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.initGesture()
}
func initGesture(){
self.isMultipleTouchEnabled = true
// 双击手势
var doubleTapGesture = UITapGestureRecognizer(target: self, action: #selector(doubleTapAction))
doubleTapGesture.numberOfTapsRequired = 2 // 双击触发
doubleTapGesture.delaysTouchesBegan = true
doubleTapGesture.delaysTouchesEnded = true
doubleTapGesture.numberOfTouchesRequired = 1
var panGesture = UIPanGestureRecognizer(target: self, action: #selector(panAction))
panGesture.delaysTouchesBegan = true
panGesture.delaysTouchesEnded = true
panGesture.maximumNumberOfTouches = 1
panGesture.cancelsTouchesInView = true
var tapGesture = UITapGestureRecognizer(target: self, action: #selector(tapAction))
tapGesture.delaysTouchesBegan = true
tapGesture.delaysTouchesEnded = true
tapGesture.numberOfTouchesRequired = 1
tapGesture.numberOfTapsRequired = 1
tapGesture.require(toFail: doubleTapGesture)
tapGesture.require(toFail: panGesture)
self.addGestureRecognizer(tapGesture)
self.addGestureRecognizer(doubleTapGesture)
self.addGestureRecognizer(panGesture)
var pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(pinchAction))
pinchGesture.delaysTouchesBegan = true
self.addGestureRecognizer(pinchGesture)
// 长按手势
var longGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressAction))
longGesture.minimumPressDuration = 0.5// 长按触发时间(秒)
self.addGestureRecognizer(longGesture)
}
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(){
//拉起支付
if metaAppDelegate.isLogin{
self.payBlock?()
}else{
//游客模式未登录 提示登录
AlertTool.showSystemAlert(title: "是否登录?", message: "登录后能通过其他设备访问已付费内容", actionTitles: ["确定","取消"], style: .alert) { index in
if index == 1 {
//确定 //是->跳登录
metaAppDelegate.pushLoginVC()
}else if index == 2 {
//取消
//否->uuid内购购买
showLoading(message: "")
let uuid = CNLiveBusinessTools.uuid()
print("uuid:\(uuid)")
CNLiveLoginViewModel.requestUUIDLoginInDevice(uuid: uuid, frmld: "") { result, status in
if status == .success{
let uid = UserInfoManager.shared.userInfo.uid
self.payBlock?()
}
}
}
}
}
}
@objc func tapAction(){
// self.isHidden = true
print("tapAction")
}
@objc func pinchAction(){
// self.isHidden = true
print("pinchAction")
}
@objc func longPressAction(){
// self.isHidden = true
print("longPressAction")
}
@objc func doubleTapAction(){
// self.isHidden = true
print("doubleTapAction")
}
@objc func panAction(){
// self.isHidden = true
print("panAction")
}
@objc func landscapeBackBtnAction(){
let viewControllers = navigationViewController().viewControllers
if viewControllers.count > 1 {
if viewControllers.last == self {
navigationViewController().popViewController(animated: true)
}
}
}
}