无故事王国
2023-10-25 158f3707711ad4be78a55dc73a98aa1c9acda0dd
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
//  LoginVC.swift
//  BrokerDriver
//
//  Created by 无故事王国 on 2023/4/24.
//
 
import UIKit
 
class LoginVC: BaseViewController {
 
    @IBOutlet weak var tf_email: QMUITextField!
    @IBOutlet weak var tf_pwd: QMUITextField!
 
 
    override func viewDidLoad() {
        super.viewDidLoad()
 
 
#if DEBUG
        tf_email.text = "testdriver@gmail.com"
        tf_pwd.text = "111111"
 
#endif
 
    }
 
    @IBAction func forgotAction(_ sender: UIButton) {
        let pwdVC = ForgotPwdVC()
        push(vc: pwdVC)
    }
 
 
    @IBAction func registerAction(_ sender: UIButton) {
        let vc = ResgiterVC()
        push(vc: vc)
    }
 
 
    @IBAction func loginAction(_ sender: UIButton) {
 
#if !DEBUG
        guard !tf_email.isEmpty else {
            alert(msg: "Please input email");return
        }
 
        guard tf_email.text!.jq_isEmail else {
            alert(msg: "Please enter the correct email");return
        }
 
        guard !tf_pwd.text!.isEmpty else {
            alert(msg: "Please enter password");return
        }
#endif
 
        Services.companyLogin(username: tf_email.text!, password: tf_pwd.text!).subscribe(onNext: { data in
            if let model = data.data{
                UserViewModel.saveUserInfo(model)
                let snapView = screnDelegate?.window?.snapshotView(afterScreenUpdates: true)
                let nav = BaseNavigationController(rootViewController: HomeVC())
                screnDelegate?.window?.rootViewController = nav
                screnDelegate?.window?.rootViewController?.view.addSubview(snapView!)
 
                UIView.animate(withDuration: 1.5) {
                    snapView?.alpha = 0
                    snapView?.transform3D = CATransform3DMakeScale(1.5, 1.5, 1.5)
                } completion: { _ in
                    snapView?.removeFromSuperview()
                    UserViewModel.publishLoginSuccess()
                }
            }
        }) { error in
            
        }.disposed(by: disposeBag)
    }
}