r
4 天以前 24182a847205ad81c759a0d173cc0e12fcd5a149
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
//
//  LogOffVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/11/15.
//
 
import UIKit
import WebKit
 
class LogOffVC: BaseVC {
                
                @IBOutlet weak var webView: WKWebView!
                
                private var timer:Timer?
                private var time:Int = 6
                @IBOutlet weak var btn_complete: UIButton!
                
                override func viewDidLoad() {
                                super.viewDidLoad()
                                title = "注销账号"
                                btn_complete.isEnabled = false
                                btn_complete.backgroundColor = .gray.withAlphaComponent(0.5)
                                Services.queryProtocol(.other,progress: false).subscribe(onNext: {[weak self] result in
                                                if let text = result.data?.jq_wrapHtml(edge: .init(top: 5, left: 3, bottom: 0, right: 3)){
                                                                self?.webView.loadHTMLString(text, baseURL: nil)
                                                }
                                }).disposed(by: disposeBag)
                                
                                timer = Timer(timeInterval: 1.0, repeats: true, block: {[weak self] t in
                                                guard let weakSelf = self else { return }
                                                self?.time -= 1
                                                self?.btn_complete.setTitle("确认(\(weakSelf.time))", for: .normal)
                                                if self?.time == 0{
                                                                t.invalidate()
                                                                self?.btn_complete.isEnabled = true
                                                                self?.btn_complete.backgroundColor = Def_ThemeColor
                                                                self?.btn_complete.setTitle("确认", for: .normal)
                                                }
                                })
                                timer?.fire()
                                RunLoop.current.add(timer!, forMode: .common)
                }
                
                @IBAction func cancelAction(_ sender: UIButton) {
                                navigationController?.popViewController()
                }
                
                @IBAction func completeAction(_ sender: Any) {
                                CommonAlertView.show(title: "提示", content: "确认注销账号?") { status in
                                                if status{
                                                                Services.logOff().subscribe(onNext: {data in
                                                                                app.needLogin()
                                                                }).disposed(by: self.disposeBag)
                                                }
                                }
                }
}