登录流程完善
This commit is contained in:
@@ -12,9 +12,11 @@ import NSObject_Rx
|
||||
class AuthLoginVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
var countdownSeconds = 60
|
||||
var timer: Timer?
|
||||
var viewModel:AuthViewModel = AuthViewModel()
|
||||
var viewModel:AuthViewModel = AuthViewModel.authVM
|
||||
var phone:String = ""
|
||||
var code:String = ""
|
||||
var id:String = ""
|
||||
var password:String = ""
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
@@ -279,6 +281,7 @@ class AuthLoginVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setTitle("获取验证码", for: .normal)
|
||||
button.setTitleColor(ThemeColor(hexStr: "#9552FF"), for: .normal)
|
||||
button.setTitleColor(ThemeColor(hexStr: "#878B9C"), for: .disabled)
|
||||
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
|
||||
button.addTarget(self, action: #selector(getCodeBtnAction), for: .touchUpInside)
|
||||
return button
|
||||
@@ -326,8 +329,8 @@ class AuthLoginVC: BaseViewController, HiddenNavigationBarProtocol {
|
||||
view.font = UIFont.systemFont(ofSize: 16)
|
||||
let attribute = NSMutableAttributedString(string: "请输入密码", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.placeholderText])
|
||||
view.attributedPlaceholder = attribute
|
||||
view.keyboardType = .numberPad
|
||||
view.tintColor = ThemeColor(hexStr: "#282828")
|
||||
view.isSecureTextEntry = true
|
||||
view.addTarget(self, action: #selector(pwdTextFiledDidChange), for: .editingChanged)
|
||||
return view
|
||||
}()
|
||||
@@ -396,14 +399,30 @@ extension AuthLoginVC {
|
||||
|
||||
@objc func confirmBtnAction() {
|
||||
if self.phoneLoginBtn.isSelected == true {
|
||||
viewModel.authPhoneCode(phone: phone, code: code)
|
||||
if phone.count > 0 {
|
||||
if code.count > 0 {
|
||||
viewModel.authPhoneCode(phone: phone, code: code)
|
||||
} else {
|
||||
HUDTool.show(with: "请输入验证码")
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "请输入正确的手机号")
|
||||
}
|
||||
} else {
|
||||
//TODO: id登录
|
||||
if id.count > 0 {
|
||||
if password.count > 0 {
|
||||
viewModel.authIDPassword(account: id, password: password)
|
||||
} else {
|
||||
HUDTool.show(with: "请输入密码")
|
||||
}
|
||||
} else {
|
||||
HUDTool.show(with: "请输入账号")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func forgetBtnAction() {
|
||||
self.navigationController?.pushViewController(AuthFillDataVC(), animated: true)
|
||||
self.navigationController?.pushViewController(AuthForgetVC(), animated: true)
|
||||
}
|
||||
|
||||
@objc func phoneTextFiledDidChange(_ textField: UITextField) {
|
||||
@@ -425,11 +444,21 @@ extension AuthLoginVC {
|
||||
}
|
||||
|
||||
@objc func idTextFiledDidChange(_ textField: UITextField) {
|
||||
|
||||
if let text = textField.text {
|
||||
if text.count > 11 {
|
||||
textField.text = text.substring(start: 0, 11)
|
||||
}
|
||||
}
|
||||
id = textField.text ?? ""
|
||||
}
|
||||
|
||||
@objc func pwdTextFiledDidChange(_ textField: UITextField) {
|
||||
|
||||
if let text = textField.text {
|
||||
if text.count > 16 {
|
||||
textField.text = text.substring(start: 0, 16)
|
||||
}
|
||||
}
|
||||
password = textField.text ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,14 +479,14 @@ extension AuthLoginVC {
|
||||
countdownSeconds -= 1
|
||||
|
||||
if countdownSeconds <= 0 {
|
||||
getCodeBtn.setTitle("重新获取验证码", for: .normal)
|
||||
getCodeBtn.setTitle("获取验证码", for: .normal)
|
||||
getCodeBtn.isEnabled = true
|
||||
stopCountdown()
|
||||
return
|
||||
}
|
||||
getCodeBtn.isHidden = false
|
||||
let seconds = countdownSeconds % 60
|
||||
getCodeBtn.setTitle("重新获取验证码(\(seconds)s)", for: .disabled)
|
||||
getCodeBtn.setTitle("\(seconds)s", for: .disabled)
|
||||
getCodeBtn.isEnabled = false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user