CNLiveInfoShowViewController.swift
5.31 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
//
// CNLiveInfoShowViewController.swift
// metaCode
//
// Created by open on 2023/6/8.
//
import Foundation
import WebKit
enum ListShowInfoType {
case service
case privacy
case yinsi
case safety
case cancel
}
class CNLiveInfoShowViewController: CNLiveBaseViewController, WKNavigationDelegate, WKUIDelegate {
var _is_login:Bool!
var _show_type:ListShowInfoType!
init(show_type:ListShowInfoType,is_login:Bool) {
super.init(nibName:nil, bundle:nil)
_show_type = show_type
_is_login = is_login
}
override func viewWillAppear(_ animated: Bool) {
if _is_login {
if (self.presentingViewController != nil) {
//先设置一个默认返回按钮
let left_btn = UIButton.backItem(imageName: "mine_header_icon_close", target: self, action: #selector(changeCancelAction))
left_btn.backgroundColor = .white
let leftBtn_array : Array<UIButton> = [left_btn]
leftNavBtns = leftBtn_array
}
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var webView: WKWebView = {
let config = WKWebViewConfiguration()
let webView = WKWebView.init(frame: .zero, configuration: config)
webView.backgroundColor = .white
webView.allowsBackForwardNavigationGestures = true
webView.navigationDelegate = self
webView.uiDelegate = self
return webView
}()
override func viewDidLoad() {
super.viewDidLoad()
navigationBarHidden = false
var attrString = ""
switch _show_type {
case .service:
titleName = "用户协议"
attrString = "https://wjjh5.cnlive.com/yuanmaYhxy.html"
case .privacy:
titleName = "隐私政策"
attrString = "https://wjjh5.cnlive.com/yuanmaYszc.html"
case .yinsi:
titleName = "隐私协议"
attrString = "https://wjjh5.cnlive.com/yuanmaYszc.html"
case .safety:
titleName = "内容安全协议"
attrString = "https://wjj.ys1.cnliveimg.com/term/cnBNraqxy.html"
case .cancel:
titleName = "账号注销须知"
attrString = "https://wjjh5.cnlive.com/yuanmaLogout.html"
case .none:
break
}
view.addSubview(webView)
webView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(KNavigationHeight)
make.left.right.bottom.equalToSuperview()
}
webView.load(URLRequest(url: URL(string: attrString)!, cachePolicy: .returnCacheDataElseLoad))
}
@objc func changeCancelAction() {
if (self.presentingViewController != nil) {
self.dismiss(animated: true)
}else{
self.navigationController!.popViewController(animated: true)
}
}
// override func viewDidLoad() {
// super.viewDidLoad()
// var attrString = ""
// switch _show_type {
// case .service:
// titleName = "APP用户服务协议"
// attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限。 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
// case .privacy:
// titleName = "个人信息保护政策"
// attrString = "欢迎您使用元码,我们非常重视您的个人信息保护,并采取了有效措施保障您的信息安全,请您充分了解: \n为保障APP账号安全,元码APP需向您申请获取电话状态权限 \n请您务必阅读APP《个人信息保护政策》,以充分了解我们如何处理您的个人信息。"
// case .none:
// break
// }
//
// let paraph = NSMutableParagraphStyle()
// paraph.lineSpacing = 10
// let attributes = [NSAttributedString.Key.font:Font_16_Fit,
// NSAttributedString.Key.paragraphStyle: paraph]
// let h = attrString.boundingRect(with: CGSize(width: KSreenWidth - 40, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size.height + 40
// let textView = UITextView.init()
// textView.attributedText = NSAttributedString(string: attrString, attributes: attributes)
// textView.textColor = HexColor("#666666")
// textView.layer.cornerRadius = 10
// textView.layer.masksToBounds = true
// textView.textAlignment = .left
// textView.contentMode = .scaleAspectFill
// textView.contentInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
// textView.sizeToFit()
// view.addSubview(textView)
// textView.snp.makeConstraints { make in
// make.centerX.equalToSuperview()
// make.top.equalToSuperview().offset(get_system_nav_height() + 10)
// make.left.equalToSuperview().offset(10)
// make.right.equalToSuperview().offset(-10)
// make.height.equalTo(h)
// }
// }
}