|
@@ -137,3 +137,124 @@ extension PQServerProtocalView: TYAttributedLabelDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// MARK: - 绑定手机号提示
|
|
|
|
+
|
|
|
|
+/// 绑定手机号提示
|
|
|
|
+public class PQBandingPhoneRemindView: UIView {
|
|
|
|
+ public var bandingPhoneRemindHandle: ((_ sender: UIButton) -> Void)?
|
|
|
|
+ public var remindBlock: ((_ sender: UIButton?, _ webUrl: String?) -> Void)?
|
|
|
|
+
|
|
|
|
+ lazy var contentView: UIView = {
|
|
|
|
+ let contentView = UIView()
|
|
|
|
+ contentView.backgroundColor = UIColor.white
|
|
|
|
+ contentView.addCorner(corner: 4)
|
|
|
|
+ return contentView
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ lazy public var protocolLab: TYAttributedLabel = {
|
|
|
|
+ let protocolLab = TYAttributedLabel()
|
|
|
|
+ protocolLab.highlightedLinkBackgroundColor = UIColor.white
|
|
|
|
+ protocolLab.delegate = self
|
|
|
|
+ protocolLab.numberOfLines = 0
|
|
|
|
+ protocolLab.font = UIFont.systemFont(ofSize: 18)
|
|
|
|
+ protocolLab.text = "应"
|
|
|
|
+ protocolLab.textColor = UIColor.black
|
|
|
|
+ protocolLab.appendLink(withText: "《互联网跟帖评论服务管理规定》", linkFont: UIFont.systemFont(ofSize: 18), linkColor: UIColor.hexColor(hexadecimal: "#07C160"), underLineStyle: CTUnderlineStyle(), linkData: cNetManagePrivacy)
|
|
|
|
+ protocolLab.appendLink(withText: ",发言评论和上传视频需绑定手机号", linkFont: UIFont.systemFont(ofSize: 18), linkColor: UIColor.black, underLineStyle: CTUnderlineStyle(), linkData: nil)
|
|
|
|
+ return protocolLab
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ lazy public var cancelBtn: UIButton = {
|
|
|
|
+ let cancelBtn = UIButton(type: .custom)
|
|
|
|
+ cancelBtn.setTitle("暂不绑定", for: .normal)
|
|
|
|
+ cancelBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#999999"), for: .normal)
|
|
|
|
+ cancelBtn.tag = 1
|
|
|
|
+ cancelBtn.addTarget(self, action: #selector(btnClck(sender:)), for: .touchUpInside)
|
|
|
|
+ cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
|
|
|
|
+ return cancelBtn
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ lazy public var confirmBtn: UIButton = {
|
|
|
|
+ let confirmBtn = UIButton(type: .custom)
|
|
|
|
+ confirmBtn.setTitle("去绑定", for: .normal)
|
|
|
|
+ confirmBtn.setTitleColor(UIColor.hexColor(hexadecimal: "#07C160"), for: .normal)
|
|
|
|
+ confirmBtn.tag = 2
|
|
|
|
+ confirmBtn.addTarget(self, action: #selector(btnClck(sender:)), for: .touchUpInside)
|
|
|
|
+ confirmBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
|
|
|
|
+ return confirmBtn
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ override public init(frame: CGRect) {
|
|
|
|
+ super.init(frame: frame)
|
|
|
|
+ addSubview(contentView)
|
|
|
|
+ contentView.addSubview(protocolLab)
|
|
|
|
+ contentView.addSubview(cancelBtn)
|
|
|
|
+ contentView.addSubview(confirmBtn)
|
|
|
|
+ backgroundColor = UIColor(hue: 0, saturation: 0, brightness: 0, alpha: 0.6)
|
|
|
|
+ let ges = UITapGestureRecognizer(target: self, action: #selector(removeView))
|
|
|
|
+ addGestureRecognizer(ges)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ required init?(coder _: NSCoder) {
|
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override public func layoutSubviews() {
|
|
|
|
+ super.layoutSubviews()
|
|
|
|
+ let normalH: CGFloat = cDefaultMargin * 2.5
|
|
|
|
+ let protocolH: CGFloat = protocolLab.getSizeWithWidth(cScreenWidth - normalH * 6).height
|
|
|
|
+ let contentH = cDefaultMargin * 2 + protocolH + cDefaultMargin * 3 + normalH + 15
|
|
|
|
+ contentView.snp.makeConstraints { make in
|
|
|
|
+ make.center.equalToSuperview()
|
|
|
|
+ make.height.equalTo(contentH)
|
|
|
|
+ make.left.equalToSuperview().offset(normalH * 2)
|
|
|
|
+ make.right.equalToSuperview().offset(-normalH * 2)
|
|
|
|
+ }
|
|
|
|
+ protocolLab.snp.makeConstraints { make in
|
|
|
|
+ make.top.equalToSuperview().offset(cDefaultMargin * 2)
|
|
|
|
+ make.height.equalTo(protocolH)
|
|
|
|
+ make.left.equalToSuperview().offset(normalH)
|
|
|
|
+ make.right.equalToSuperview().offset(-normalH)
|
|
|
|
+ }
|
|
|
|
+ confirmBtn.snp.makeConstraints { make in
|
|
|
|
+ make.right.equalToSuperview().offset(-normalH)
|
|
|
|
+ make.height.equalTo(normalH)
|
|
|
|
+ make.bottom.equalToSuperview().offset(-15)
|
|
|
|
+ }
|
|
|
|
+ cancelBtn.snp.makeConstraints { make in
|
|
|
|
+ make.right.equalTo(confirmBtn.snp_left).offset(-normalH)
|
|
|
|
+ make.centerY.height.equalTo(confirmBtn)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc public func removeView() {
|
|
|
|
+ removeFromSuperview()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc public func btnClck(sender: UIButton) {
|
|
|
|
+ removeFromSuperview()
|
|
|
|
+ if bandingPhoneRemindHandle != nil {
|
|
|
|
+ bandingPhoneRemindHandle!(sender)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+extension PQBandingPhoneRemindView: TYAttributedLabelDelegate {
|
|
|
|
+ public func attributedLabel(_: TYAttributedLabel!, textStorageClicked textStorage: TYTextStorageProtocol!, at _: CGPoint) {
|
|
|
|
+ var link: String? = (textStorage as? TYLinkTextStorage)?.linkData as? String ?? ""
|
|
|
|
+ if link == nil || (link?.count ?? 0) <= 0 {
|
|
|
|
+ let range = (textStorage as? TYLinkTextStorage)?.range
|
|
|
|
+ if range?.length == 11 {
|
|
|
|
+ link = cUserProtocol
|
|
|
|
+ } else if range?.length == 6 {
|
|
|
|
+ link = cPrivacy
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if link != nil, (link?.count ?? 0) > 0, remindBlock != nil {
|
|
|
|
+ remindBlock!(nil, link)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|