//
|
// CommonWebVC.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2023/9/11.
|
//
|
|
import UIKit
|
import WebKit
|
|
class CommonWebVC: BaseVC {
|
|
private var type:AgreentType!
|
private var content:String!
|
@IBOutlet weak var webView: WKWebView!
|
|
init(type:AgreentType,content:String? = nil) {
|
super.init(nibName: nil, bundle: nil)
|
self.type = type
|
self.content = content
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
if type != .other{
|
title = type.titleStr
|
Services.queryProtocol(type,progress: false).subscribe(onNext: {[weak self] result in
|
if let text = result.data?.jq_wrapHtml(){
|
self?.webView.loadHTMLString(text, baseURL: nil)
|
}
|
}).disposed(by: disposeBag)
|
}else{
|
webView.loadHTMLString(content?.jq_wrapHtml() ?? "", baseURL: nil)
|
}
|
}
|
|
@IBAction func readAction(_ sender: UIButton) {
|
UserDefaults.standard.set(object: true, forKey: type.titleStr)
|
UserDefaults.standard.synchronize()
|
navigationController?.popViewController()
|
}
|
|
override var preferredStatusBarStyle: UIStatusBarStyle{
|
return .darkContent
|
}
|
|
override var shouldAutorotate: Bool{
|
return false
|
}
|
}
|