//
|
// 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)
|
}
|
}
|