//
|
// UserLoginOffVC.swift
|
// DolphinEnglishLearnStudent
|
//
|
// Created by 无故事王国 on 2024/7/19.
|
//
|
|
import UIKit
|
import WebKit
|
|
class UserLoginOffVC: BaseVC {
|
|
private var btn_loginOff:UIButton!
|
private var webView:WKWebView!
|
private var timer:Timer?
|
private var times = 10
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
yy_popBlock = {[weak self] () in
|
guard let weakSelf = self else { return }
|
var toVC:UIViewController?
|
for subVC in weakSelf.navigationController?.viewControllers ?? []{
|
if subVC.isKind(of: HomeListenVC.self){
|
toVC = subVC;break
|
}
|
}
|
|
if toVC != nil{
|
weakSelf.navigationController?.popToViewController(toVC!, animated: true)
|
}else{
|
weakSelf.navigationController?.popViewController(animated: true)
|
}
|
}
|
|
Services.getAgreement(type: .logout).subscribe(onNext: {data in
|
if let stringHTML = data.data{
|
self.webView.loadHTMLString(stringHTML.jq_wrapHtml(edge: UIEdgeInsets(top: 0, left: 10, bottom: 3, right: 0)), baseURL: nil)
|
}
|
}).disposed(by: disposeBag)
|
|
timer = Timer(timeInterval: 1, repeats: true) {[weak self] timer in
|
guard let weakSelf = self else { return }
|
weakSelf.times -= 1
|
weakSelf.btn_loginOff.setTitle("注销账号(\(weakSelf.times)s)", for: .normal)
|
|
if weakSelf.times <= 0{
|
print("----进入")
|
weakSelf.btn_loginOff.isEnabled = true
|
weakSelf.btn_loginOff.setTitle("注销账号", for: .normal)
|
weakSelf.btn_loginOff.backgroundColor = UIColor(hexStr: "#41A2EB")
|
weakSelf.timer?.invalidate()
|
}
|
}
|
timer?.fire()
|
RunLoop.current.add(timer!, forMode: .common)
|
}
|
|
override func viewDidDisappear(_ animated: Bool) {
|
super.viewDidDisappear(animated)
|
self.timer?.invalidate()
|
self.timer = nil
|
}
|
|
override func setUI() {
|
|
view.backgroundColor = .white
|
webView = WKWebView(frame: .zero)
|
view.addSubview(webView)
|
webView.snp.makeConstraints { make in
|
make.left.right.top.equalToSuperview()
|
make.bottom.equalToSuperview().offset(-150)
|
}
|
|
|
btn_loginOff = UIButton(type: .custom)
|
btn_loginOff.setTitle("注销账号", for: .normal)
|
btn_loginOff.setTitleColor(.white, for: .normal)
|
btn_loginOff.isEnabled = false
|
btn_loginOff.backgroundColor = UIColor(hexStr: "#41A2EB")
|
btn_loginOff.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
btn_loginOff.addTarget(self, action: #selector(loginOffAction), for: .touchUpInside)
|
btn_loginOff.jq_cornerRadius = 8
|
view.addSubview(btn_loginOff)
|
btn_loginOff.snp.makeConstraints { make in
|
make.width.equalTo(316)
|
make.height.equalTo(49)
|
make.bottom.equalTo(-91)
|
make.centerX.equalToSuperview()
|
}
|
}
|
|
@objc func loginOffAction(){
|
CommonAlertView.show(content: "确认注销当前登录账户吗?", completeTitle: "确认") {[weak self] () in
|
guard let weakSelf = self else { return }
|
Services.loginOff().subscribe(onNext: {data in
|
sceneDelegate?.needLogin()
|
}).disposed(by: weakSelf.disposeBag)
|
} cancelClouse: {
|
|
}
|
}
|
}
|