| | |
| | | |
| | | import UIKit |
| | | import WebKit |
| | | import JQTools |
| | | |
| | | class WebVC: BaseVC { |
| | | |
| | | private var webView:WKWebView? |
| | | private(set) var url = "" |
| | | private(set) var htmlText = "" |
| | | private var type:AgreementType? |
| | | private(set) var url:String? |
| | | private(set) var htmlText:String? |
| | | private(set) var baseUrl:URL? |
| | | private var progressView = UIProgressView() |
| | | private let jsCode = """ |
| | |
| | | public convenience init(url:String) { |
| | | self.init() |
| | | self.url = url |
| | | } |
| | | |
| | | public convenience init(type:AgreementType){ |
| | | self.init() |
| | | self.type = type |
| | | } |
| | | |
| | | public convenience init(htmlText:String,baseURL:URL? = nil) { |
| | |
| | | make.height.equalTo(2) |
| | | } |
| | | |
| | | if type != nil{ |
| | | Services.agreementBy(type!).subscribe(onNext: {data in |
| | | if let model = data.data{ |
| | | self.webView?.loadHTMLString(model.content.jq_wrapHtml(), baseURL: nil) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | if !url.isEmpty { |
| | | let urlRequest = URLRequest(url: URL(string: url)!) |
| | | if url != nil { |
| | | let urlRequest = URLRequest(url: URL(string: url!)!) |
| | | webView?.load(urlRequest) |
| | | }else{ |
| | | webView?.loadHTMLString(htmlText, baseURL: baseUrl) |
| | | return |
| | | } |
| | | |
| | | if htmlText != nil{ |
| | | webView?.loadHTMLString(htmlText!, baseURL: baseUrl) |
| | | } |
| | | } |
| | | |