//
|
// CommonWebVC.swift
|
// DolphinEnglishLearnManager
|
//
|
// Created by 无故事王国 on 2024/5/14.
|
//
|
|
import UIKit
|
import WebKit
|
|
class CommonWebVC: BaseVC {
|
|
enum CommonWebType{
|
case logoff
|
case userAgreement
|
case privacyAgreement
|
case userGuide
|
}
|
|
private var type:CommonWebType!
|
|
init(type:CommonWebType) {
|
super.init(nibName: nil, bundle: nil)
|
self.type = type
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
}
|
|
override func setUI() {
|
super.setUI()
|
|
|
if type == .logoff{
|
let completeBtn = UIButton(type: .custom)
|
completeBtn.jq_cornerRadius = 8
|
completeBtn.addTarget(self, action: #selector(handleAction), for: .touchUpInside)
|
completeBtn.setTitleColor(.white, for: .normal)
|
completeBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .medium)
|
completeBtn.setTitle("确认(10s)", for: .normal)
|
completeBtn.backgroundColor = UIColor(hexStr: "#41A2EB")
|
view.addSubview(completeBtn)
|
completeBtn.snp.makeConstraints { make in
|
make.width.equalTo(316)
|
make.centerX.equalToSuperview()
|
make.bottom.equalToSuperview().offset(-91)
|
make.height.equalTo(47)
|
}
|
|
var time = 10 //倒计时时间
|
let queue = DispatchQueue.global()
|
let timer = DispatchSource.makeTimerSource(flags: [], queue: queue)
|
timer.schedule(wallDeadline: DispatchWallTime.now(), repeating: .seconds(1));
|
timer.setEventHandler(handler: {
|
if time <= 0 {
|
timer.cancel()
|
DispatchQueue.main.async(execute: {
|
completeBtn.setTitle("确认", for: .normal)
|
completeBtn.isUserInteractionEnabled = true
|
completeBtn.backgroundColor = UIColor(hexStr: "#41A2EB")
|
});
|
}else {
|
DispatchQueue.main.async(execute: {
|
completeBtn.setTitle("确认\(time)s", for: .normal)
|
completeBtn.isUserInteractionEnabled = false
|
completeBtn.backgroundColor = .gray
|
});
|
}
|
time -= 1
|
});
|
timer.resume()
|
}
|
}
|
|
@objc func handleAction(sender:UIButton){
|
CommonAlertView.show(content:"确认注销当前登录账户吗?") {
|
|
}
|
}
|
}
|