2024-02-21 21:30:13 +08:00
|
|
|
|
//
|
|
|
|
|
// AuthLoginVC.swift
|
|
|
|
|
// yinmeng-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by MaiMang on 2024/2/21.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
import SnapKit
|
2024-02-24 13:49:51 +08:00
|
|
|
|
import NSObject_Rx
|
2024-02-21 21:30:13 +08:00
|
|
|
|
|
|
|
|
|
class AuthLoginVC: BaseViewController, HiddenNavigationBarProtocol {
|
2024-02-24 13:49:51 +08:00
|
|
|
|
var countdownSeconds = 60
|
|
|
|
|
var timer: Timer?
|
|
|
|
|
var viewModel:AuthViewModel = AuthViewModel()
|
|
|
|
|
var phone:String = ""
|
|
|
|
|
var code:String = ""
|
|
|
|
|
|
2024-02-21 21:30:13 +08:00
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
loadSubViews()
|
2024-02-24 13:49:51 +08:00
|
|
|
|
viewModel.data.subscribe(onNext: { [weak self] success in
|
|
|
|
|
if success {
|
2024-02-25 12:53:56 +08:00
|
|
|
|
HUDTool.show(with: "验证码已发送\n+86\(self?.phone ?? "")")
|
2024-02-24 13:49:51 +08:00
|
|
|
|
self?.startCountdown()
|
|
|
|
|
}
|
|
|
|
|
}).disposed(by: rx.disposeBag)
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func loadSubViews() {
|
|
|
|
|
view.addSubview(backImgView)
|
|
|
|
|
view.addSubview(backBtn)
|
|
|
|
|
view.addSubview(phoneLoginBtn)
|
|
|
|
|
view.addSubview(pwdLoginBtn)
|
|
|
|
|
view.addSubview(segmentBtn)
|
|
|
|
|
view.addSubview(phoneView)
|
|
|
|
|
view.addSubview(idLoginView)
|
|
|
|
|
view.addSubview(confirmBtn)
|
|
|
|
|
|
|
|
|
|
phoneView.addSubview(phoneNumView)
|
|
|
|
|
phoneView.addSubview(codeView)
|
|
|
|
|
|
|
|
|
|
phoneNumView.addSubview(areaLb)
|
|
|
|
|
phoneNumView.addSubview(phonetextFiled)
|
|
|
|
|
|
|
|
|
|
codeView.addSubview(codetextFiled)
|
|
|
|
|
codeView.addSubview(sepView)
|
|
|
|
|
codeView.addSubview(getCodeBtn)
|
|
|
|
|
|
|
|
|
|
idLoginView.addSubview(idView)
|
|
|
|
|
idLoginView.addSubview(pwdView)
|
|
|
|
|
idLoginView.addSubview(forgetBtn)
|
|
|
|
|
|
|
|
|
|
idView.addSubview(idTextFiled)
|
|
|
|
|
pwdView.addSubview(pwdTextFiled)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
backImgView.snp.makeConstraints { make in
|
|
|
|
|
make.edges.equalTo(view)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
backBtn.snp.makeConstraints { make in
|
|
|
|
|
make.size.equalTo(CGSize(width: 20, height: 20))
|
|
|
|
|
make.left.equalTo(view).offset(16)
|
|
|
|
|
make.top.equalTo(view).offset(StatusBarHeight + 12)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phoneLoginBtn.snp.makeConstraints { make in
|
|
|
|
|
make.height.equalTo(22)
|
|
|
|
|
make.top.equalTo(view).offset(StatusBarHeight + 88)
|
|
|
|
|
make.right.equalTo(view.snp.centerX).offset(-47)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pwdLoginBtn.snp.makeConstraints { make in
|
|
|
|
|
make.centerY.height.equalTo(phoneLoginBtn)
|
|
|
|
|
make.left.equalTo(view.snp.centerX).offset(47)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
segmentBtn.snp.makeConstraints { make in
|
|
|
|
|
make.size.equalTo(CGSize(width: 43, height: 12))
|
|
|
|
|
make.centerX.equalTo(phoneLoginBtn)
|
|
|
|
|
make.top.equalTo(phoneLoginBtn.snp.bottom).offset(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phoneView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.equalTo(view).inset(0)
|
|
|
|
|
make.bottom.equalTo(codeView.snp.bottom).offset(0)
|
|
|
|
|
make.top.equalTo(phoneLoginBtn.snp.bottom).offset(52)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phoneNumView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.equalTo(phoneView).inset(36)
|
|
|
|
|
make.height.equalTo(52)
|
|
|
|
|
make.top.equalTo(phoneView).offset(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
areaLb.snp.makeConstraints { make in
|
|
|
|
|
make.centerY.equalTo(phoneNumView)
|
|
|
|
|
make.left.equalTo(phoneNumView).offset(20)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phonetextFiled.snp.makeConstraints { make in
|
|
|
|
|
make.top.bottom.equalTo(phoneNumView)
|
|
|
|
|
make.left.equalTo(phoneNumView).offset(82)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
codeView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.height.equalTo(phoneNumView)
|
|
|
|
|
make.top.equalTo(phoneNumView.snp.bottom).offset(20)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
codetextFiled.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(codeView).offset(20)
|
|
|
|
|
make.top.bottom.equalTo(codeView)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sepView.snp.makeConstraints { make in
|
|
|
|
|
make.size.equalTo(CGSize(width: 1, height: 20))
|
|
|
|
|
make.centerY.equalTo(codeView)
|
|
|
|
|
make.right.equalTo(getCodeBtn.snp.left).offset(-16)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCodeBtn.snp.makeConstraints { make in
|
|
|
|
|
make.top.bottom.equalTo(codeView)
|
|
|
|
|
make.right.equalTo(codeView).offset(-18)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idLoginView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.top.equalTo(phoneView)
|
|
|
|
|
make.bottom.equalTo(forgetBtn.snp.bottom).offset(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.equalTo(idLoginView).inset(36)
|
|
|
|
|
make.height.equalTo(52)
|
|
|
|
|
make.top.equalTo(idLoginView).offset(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idTextFiled.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(idView).offset(20)
|
|
|
|
|
make.top.bottom.equalTo(idView)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pwdView.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.equalTo(idLoginView).inset(36)
|
|
|
|
|
make.height.equalTo(52)
|
|
|
|
|
make.top.equalTo(idView.snp.bottom).offset(20)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pwdTextFiled.snp.makeConstraints { make in
|
|
|
|
|
make.left.equalTo(pwdView).offset(20)
|
|
|
|
|
make.top.bottom.equalTo(pwdView)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
forgetBtn.snp.makeConstraints { make in
|
|
|
|
|
make.height.equalTo(20)
|
|
|
|
|
make.right.equalTo(idView)
|
|
|
|
|
make.top.equalTo(pwdView.snp.bottom).offset(8)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
confirmBtn.snp.makeConstraints { make in
|
|
|
|
|
make.left.right.equalTo(view).inset(36)
|
|
|
|
|
make.height.equalTo(52)
|
|
|
|
|
make.top.equalTo(phoneView.snp.bottom).offset(44)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var backImgView: UIImageView = {
|
|
|
|
|
let imageView = UIImageView()
|
|
|
|
|
imageView.image = UIImage(named: "auth_login_bg")
|
|
|
|
|
imageView.isUserInteractionEnabled = true
|
|
|
|
|
imageView.layer.masksToBounds = true
|
|
|
|
|
imageView.contentMode = .scaleAspectFill
|
|
|
|
|
return imageView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var backBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setImage(UIImage(named: "public_back_white"), for: .normal)
|
|
|
|
|
button.setImage(UIImage(named: "public_back_white"), for: .selected)
|
|
|
|
|
button.addTarget(self, action: #selector(backBtnAction), for: .touchUpInside)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var phoneLoginBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setTitle("手机号登录", for: .normal)
|
|
|
|
|
button.setTitleColor(UIColor.white, for: .normal)
|
|
|
|
|
button.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
|
|
button.addTarget(self, action: #selector(phoneLoginBtnAction), for: .touchUpInside)
|
2024-02-24 13:49:51 +08:00
|
|
|
|
button.isSelected = true
|
2024-02-21 21:30:13 +08:00
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var pwdLoginBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setTitle("账号登录", for: .normal)
|
|
|
|
|
button.setTitleColor(UIColor.white, for: .normal)
|
|
|
|
|
button.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
|
|
button.addTarget(self, action: #selector(pwdLoginBtnAction), for: .touchUpInside)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var segmentBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setImage(UIImage(named: "auth_segment_bg"), for: .normal)
|
|
|
|
|
button.setImage(UIImage(named: "auth_segment_bg"), for: .selected)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var phoneView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .clear
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var phoneNumView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .white
|
|
|
|
|
view.layer.masksToBounds = true
|
|
|
|
|
view.layer.cornerRadius = 26
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var areaLb: UILabel = {
|
|
|
|
|
let label = UILabel()
|
|
|
|
|
label.textColor = .firstText
|
|
|
|
|
label.text = "+86"
|
|
|
|
|
label.font = UIFont.systemFont(ofSize: 16)
|
|
|
|
|
return label
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
lazy var phonetextFiled:UITextField = {
|
|
|
|
|
let view = UITextField()
|
|
|
|
|
view.textColor = .firstText
|
|
|
|
|
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.addTarget(self, action: #selector(phoneTextFiledDidChange), for: .editingChanged)
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var codeView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .white
|
|
|
|
|
view.layer.masksToBounds = true
|
|
|
|
|
view.layer.cornerRadius = 26
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lazy var codetextFiled:UITextField = {
|
|
|
|
|
let view = UITextField()
|
|
|
|
|
view.textColor = .firstText
|
|
|
|
|
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.addTarget(self, action: #selector(codeTextFiledDidChange), for: .editingChanged)
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var sepView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .clear
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var getCodeBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setTitle("获取验证码", for: .normal)
|
|
|
|
|
button.setTitleColor(ThemeColor(hexStr: "#9552FF"), for: .normal)
|
|
|
|
|
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
|
|
|
|
|
button.addTarget(self, action: #selector(getCodeBtnAction), for: .touchUpInside)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private lazy var idLoginView: UIView = {
|
|
|
|
|
let view = UIView()
|
2024-02-22 19:59:38 +08:00
|
|
|
|
view.backgroundColor = .clear
|
2024-02-21 21:30:13 +08:00
|
|
|
|
view.isHidden = true
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var idView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .white
|
|
|
|
|
view.layer.cornerRadius = 26
|
|
|
|
|
view.layer.masksToBounds = true
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
lazy var idTextFiled:UITextField = {
|
|
|
|
|
let view = UITextField()
|
|
|
|
|
view.textColor = .firstText
|
|
|
|
|
view.font = UIFont.systemFont(ofSize: 16)
|
|
|
|
|
let attribute = NSMutableAttributedString(string: "请输入账号/ID", 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.addTarget(self, action: #selector(idTextFiledDidChange), for: .editingChanged)
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var pwdView: UIView = {
|
|
|
|
|
let view = UIView()
|
|
|
|
|
view.backgroundColor = .white
|
|
|
|
|
view.layer.cornerRadius = 26
|
|
|
|
|
view.layer.masksToBounds = true
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
lazy var pwdTextFiled:UITextField = {
|
|
|
|
|
let view = UITextField()
|
|
|
|
|
view.textColor = .firstText
|
|
|
|
|
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.addTarget(self, action: #selector(pwdTextFiledDidChange), for: .editingChanged)
|
|
|
|
|
return view
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var forgetBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setTitle("忘记密码?", for: .normal)
|
|
|
|
|
button.setTitleColor(ThemeColor(hexStr: "#FFFFFF", alpha: 0.8), for: .normal)
|
|
|
|
|
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium)
|
|
|
|
|
button.addTarget(self, action: #selector(forgetBtnAction), for: .touchUpInside)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private lazy var confirmBtn: UIButton = {
|
|
|
|
|
let button = UIButton(type: .custom)
|
|
|
|
|
button.setBackgroundImage(UIImage.gradient(hexsString: ["#FF60FD", "#8974FF", "#69EBFF"]), for: .normal)
|
|
|
|
|
button.setImage(UIImage(named: "auth_login_confirm"), for: .normal)
|
|
|
|
|
button.layer.masksToBounds = true
|
|
|
|
|
button.layer.cornerRadius = 26
|
|
|
|
|
button.addTarget(self, action: #selector(confirmBtnAction), for: .touchUpInside)
|
|
|
|
|
return button
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extension AuthLoginVC {
|
|
|
|
|
@objc func backBtnAction() {
|
|
|
|
|
self.navigationController?.popViewController(animated: true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func phoneLoginBtnAction() {
|
|
|
|
|
phoneLoginBtn.isSelected = true
|
|
|
|
|
pwdLoginBtn.isSelected = false
|
|
|
|
|
phoneView.isHidden = false
|
|
|
|
|
idLoginView.isHidden = true
|
|
|
|
|
phoneLoginBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
|
|
pwdLoginBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
|
|
|
|
|
segmentBtn.snp.remakeConstraints { make in
|
|
|
|
|
make.size.equalTo(CGSize(width: 43, height: 12))
|
|
|
|
|
make.centerX.equalTo(phoneLoginBtn)
|
|
|
|
|
make.top.equalTo(phoneLoginBtn.snp.bottom).offset(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func pwdLoginBtnAction() {
|
|
|
|
|
pwdLoginBtn.isSelected = true
|
|
|
|
|
phoneLoginBtn.isSelected = false
|
|
|
|
|
phoneView.isHidden = true
|
|
|
|
|
idLoginView.isHidden = false
|
|
|
|
|
phoneLoginBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
|
|
|
|
|
pwdLoginBtn.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
|
|
|
|
|
segmentBtn.snp.remakeConstraints { make in
|
|
|
|
|
make.size.equalTo(CGSize(width: 43, height: 12))
|
|
|
|
|
make.centerX.equalTo(pwdLoginBtn)
|
|
|
|
|
make.top.equalTo(pwdLoginBtn.snp.bottom).offset(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func getCodeBtnAction() {
|
2024-02-24 13:49:51 +08:00
|
|
|
|
if phone.count > 0 {
|
|
|
|
|
viewModel.getSmsCode(phone: phone, type: 1)
|
|
|
|
|
} else {
|
2024-02-25 12:53:56 +08:00
|
|
|
|
HUDTool.show(with: "请输入正确的手机号码")
|
2024-02-24 13:49:51 +08:00
|
|
|
|
}
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func confirmBtnAction() {
|
2024-02-24 13:49:51 +08:00
|
|
|
|
if self.phoneLoginBtn.isSelected == true {
|
|
|
|
|
viewModel.authPhoneCode(phone: phone, code: code)
|
|
|
|
|
} else {
|
|
|
|
|
//TODO: id登录
|
|
|
|
|
}
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func forgetBtnAction() {
|
2024-02-22 19:59:38 +08:00
|
|
|
|
self.navigationController?.pushViewController(AuthFillDataVC(), animated: true)
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func phoneTextFiledDidChange(_ textField: UITextField) {
|
2024-02-24 13:49:51 +08:00
|
|
|
|
if let text = textField.text {
|
|
|
|
|
if text.count > 11 {
|
|
|
|
|
textField.text = text.substring(start: 0, 11)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
phone = textField.text ?? ""
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func codeTextFiledDidChange(_ textField: UITextField) {
|
2024-02-24 13:49:51 +08:00
|
|
|
|
if let text = textField.text {
|
|
|
|
|
if text.count > 11 {
|
|
|
|
|
textField.text = text.substring(start: 0, 11)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
code = textField.text ?? ""
|
2024-02-21 21:30:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func idTextFiledDidChange(_ textField: UITextField) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func pwdTextFiledDidChange(_ textField: UITextField) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-24 13:49:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension AuthLoginVC {
|
|
|
|
|
|
|
|
|
|
func startCountdown() {
|
|
|
|
|
if timer != nil {
|
|
|
|
|
timer?.invalidate()
|
|
|
|
|
timer = nil
|
|
|
|
|
}
|
|
|
|
|
countdownSeconds = 60
|
|
|
|
|
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateCountdown), userInfo: nil, repeats: true)
|
|
|
|
|
timer!.fire()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc func updateCountdown() {
|
|
|
|
|
countdownSeconds -= 1
|
|
|
|
|
|
|
|
|
|
if countdownSeconds <= 0 {
|
|
|
|
|
getCodeBtn.setTitle("重新获取验证码", for: .normal)
|
|
|
|
|
getCodeBtn.isEnabled = true
|
|
|
|
|
stopCountdown()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getCodeBtn.isHidden = false
|
|
|
|
|
let seconds = countdownSeconds % 60
|
|
|
|
|
getCodeBtn.setTitle("重新获取验证码(\(seconds)s)", for: .disabled)
|
|
|
|
|
getCodeBtn.isEnabled = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func stopCountdown() {
|
|
|
|
|
timer?.invalidate()
|
|
|
|
|
timer = nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|