验证码登录接口
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "fail.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "fail@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "fail@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 759 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "loading.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "loading@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "loading@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 927 B |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "success.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "success@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "success@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 401 B |
|
After Width: | Height: | Size: 723 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "warning.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "warning@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "warning@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 578 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
|
@ -133,7 +133,7 @@ extension BaseViewController {
|
|||
}, onError: { _ in }).disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
private func startCountDown(_ sendBtn: UIButton, _ countDownService: CountDownService) {
|
||||
func startCountDown(_ sendBtn: UIButton, _ countDownService: CountDownService) {
|
||||
countDownService.startTimer()
|
||||
countDownService.currentTime.subscribe(onNext: { time in
|
||||
DispatchQueue.main.async {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class MainTabBarController: UITabBarController {
|
|||
NSLayoutConstraint.activate([
|
||||
customTabBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
customTabBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
customTabBar.bottomAnchor.constraint(equalToConstant: view.bottomAnchor),
|
||||
customTabBar.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
customTabBar.heightAnchor.constraint(equalToConstant: tabBarHeight)
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,10 +100,10 @@ extension ApiManager {
|
|||
handlePopView(message)
|
||||
default:
|
||||
/// 统一提示错误
|
||||
let code = GatewayStatusCode(rawValue: code ?? -9999) ?? .unknownError
|
||||
if code == .unknownError, handle {
|
||||
// let code = GatewayStatusCode(rawValue: code ?? -9999) ?? .unknownError
|
||||
// if code == .unknownError, handle {
|
||||
DLToast.show(text: combineMessage)
|
||||
}
|
||||
// }
|
||||
}
|
||||
return .failure(handleError(with: code, domain: "Data Error", message: combineMessage, data: response))
|
||||
case let .failure(error):
|
||||
|
|
|
|||
|
|
@ -38,21 +38,6 @@ class LoginView: UIView {
|
|||
}
|
||||
.bind(to: smsCodeBtn.rx.isEnabled)
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
// phoneLoginBtn.rx.controlEvent(.touchUpInside).subscribe { [weak self] _ in
|
||||
// guard let self = self else { return }
|
||||
// self.oneTapLogin = !self.oneTapLogin
|
||||
// self.otherPhoneView.isHidden = self.oneTapLogin
|
||||
// self.loginButton.setTitle(self.oneTapLogin ? "本机号码一键登录" : "立即登录", for: .normal)
|
||||
// self.phoneNumberLabel.isHidden = !self.oneTapLogin
|
||||
// self.carrierLabel.isHidden = !self.oneTapLogin
|
||||
// if self.oneTapLogin, let model = GyContentModel.current() {
|
||||
// self.setupAgreementTextWithCarrier(carrier: model.term)
|
||||
// }
|
||||
// else {
|
||||
// self.setupAgreementTextWithCarrier(carrier: "")
|
||||
// }
|
||||
// }.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
func setupAgreementTextWithCarrier(carrier: String) {
|
||||
|
|
|
|||
|
|
@ -42,39 +42,9 @@ class LoginViewController: BaseViewController {
|
|||
|
||||
private func reactiveAction() {
|
||||
rootView.smsCodeBtn.rx.controlEvent(.touchUpInside).subscribe { [weak self] _ in
|
||||
guard let self = self, let phone = self.rootView.phoneInputTF.text else { return }
|
||||
self.requestSmsCode(phone: phone,
|
||||
sendBtn: rootView.smsCodeBtn,
|
||||
countDownService: self.countDownService)
|
||||
}.disposed(by: rootView.disposeBag)
|
||||
|
||||
rootView.phoneLoginBtn.rx.controlEvent(.touchUpInside).subscribe { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
|
||||
let oneTapLoginView = OneTapLoginView(frame: self.view.bounds)
|
||||
let list = [oneTapLoginView.phoneNumberLabel,
|
||||
oneTapLoginView.carrierLabel,
|
||||
oneTapLoginView.loginButton,
|
||||
oneTapLoginView.checkBox,
|
||||
oneTapLoginView.agreementLabel]
|
||||
GeYanSdk.oneTapLogin(self,
|
||||
viewModel: self.viewModel.gyAuthVM,
|
||||
contentView: oneTapLoginView,
|
||||
subViewList: list) { data in
|
||||
guard let responseData = data,
|
||||
let code = responseData["code"] as? Int else { return }
|
||||
print(responseData)
|
||||
if code == 30000 { // 成功
|
||||
let gyuid = responseData["gyuid"]
|
||||
let token = responseData["token"]
|
||||
let requestData = ["gyuid" : gyuid, "token": token]
|
||||
self.viewModel.loginAction(type: "onekey", data: requestData)
|
||||
}
|
||||
else {
|
||||
DLToast.showError(text: responseData["msg"] as? String ?? "运营商返回失败")
|
||||
}
|
||||
}
|
||||
}.disposed(by: disposeBag)
|
||||
self.requestSmsCodeAPI()
|
||||
}.disposed(by: rootView.disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - Bindings
|
||||
|
|
@ -95,15 +65,20 @@ class LoginViewController: BaseViewController {
|
|||
return
|
||||
}
|
||||
|
||||
if let phone = self.rootView.phoneInputTF.text, phone.isEmpty {
|
||||
guard let phone = self.rootView.phoneInputTF.text, !phone.isEmpty else {
|
||||
DLToast.showError(text: "请输入手机号码")
|
||||
return
|
||||
}
|
||||
else if let smsCode = self.rootView.smsCodeTF.text, smsCode.isEmpty {
|
||||
|
||||
guard let smsCode = self.rootView.smsCodeTF.text, !smsCode.isEmpty else {
|
||||
DLToast.showError(text: "请输入验证码")
|
||||
return
|
||||
}
|
||||
else {
|
||||
self.viewModel.loginAction(type: "phone", data: ["TODO": ""])
|
||||
}
|
||||
|
||||
let requestData = ["timestamp": self.viewModel.timestamp,
|
||||
"phone": phone,
|
||||
"code": smsCode]
|
||||
self.viewModel.loginAction(type: "phone", data: requestData)
|
||||
})
|
||||
.disposed(by: disposeBag)
|
||||
|
||||
|
|
@ -137,6 +112,19 @@ class LoginViewController: BaseViewController {
|
|||
})
|
||||
.disposed(by: disposeBag)
|
||||
}
|
||||
|
||||
// MARK: - API 验证码
|
||||
func requestSmsCodeAPI() {
|
||||
DLToast.showLoading()
|
||||
SystemService.sendSmsCode(phone: rootView.phoneInputTF.text ?? "").subscribe(onNext: { [weak self] response in
|
||||
DLToast.showSuccess(text: "发送成功")
|
||||
guard let self = self, let responseData = response.result as? [String : Any] else { return }
|
||||
self.startCountDown(self.rootView.smsCodeBtn, self.countDownService)
|
||||
if let timestamp = responseData["timestamp"] as? String {
|
||||
self.viewModel.timestamp = timestamp
|
||||
}
|
||||
}, onError: { _ in }).disposed(by: disposeBag)
|
||||
}
|
||||
}
|
||||
|
||||
extension LoginViewController: UITextViewDelegate {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ import GeYanSdk
|
|||
|
||||
final class LoginViewModel: BaseViewModel {
|
||||
|
||||
/// 验证码接口返回值
|
||||
var timestamp: String = ""
|
||||
|
||||
let oneClickLoginResult = PublishSubject<Bool>()
|
||||
let loginSuccess = PublishSubject<Void>()
|
||||
|
||||
|
|
|
|||