diff --git a/QuickLocation.xcworkspace/xcuserdata/yanghong.xcuserdatad/UserInterfaceState.xcuserstate b/QuickLocation.xcworkspace/xcuserdata/yanghong.xcuserdatad/UserInterfaceState.xcuserstate index 293485d..604eb0f 100644 Binary files a/QuickLocation.xcworkspace/xcuserdata/yanghong.xcuserdatad/UserInterfaceState.xcuserstate and b/QuickLocation.xcworkspace/xcuserdata/yanghong.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/QuickLocation/Assets.xcassets/Toast/Contents.json b/QuickLocation/Assets.xcassets/Toast/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/QuickLocation/Assets.xcassets/Toast/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuickLocation/Assets.xcassets/Toast/fail.imageset/Contents.json b/QuickLocation/Assets.xcassets/Toast/fail.imageset/Contents.json new file mode 100644 index 0000000..07179b6 --- /dev/null +++ b/QuickLocation/Assets.xcassets/Toast/fail.imageset/Contents.json @@ -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 + } +} diff --git a/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail.png b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail.png new file mode 100644 index 0000000..ef08667 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@2x.png b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@2x.png new file mode 100644 index 0000000..6998ac6 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@2x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@3x.png b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@3x.png new file mode 100644 index 0000000..bda72da Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/fail.imageset/fail@3x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/loading.imageset/Contents.json b/QuickLocation/Assets.xcassets/Toast/loading.imageset/Contents.json new file mode 100644 index 0000000..50f8631 --- /dev/null +++ b/QuickLocation/Assets.xcassets/Toast/loading.imageset/Contents.json @@ -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 + } +} diff --git a/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading.png b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading.png new file mode 100644 index 0000000..a784e5e Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@2x.png b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@2x.png new file mode 100644 index 0000000..d9c6bbe Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@2x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@3x.png b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@3x.png new file mode 100644 index 0000000..50d0b42 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/loading.imageset/loading@3x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/success.imageset/Contents.json b/QuickLocation/Assets.xcassets/Toast/success.imageset/Contents.json new file mode 100644 index 0000000..858785f --- /dev/null +++ b/QuickLocation/Assets.xcassets/Toast/success.imageset/Contents.json @@ -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 + } +} diff --git a/QuickLocation/Assets.xcassets/Toast/success.imageset/success.png b/QuickLocation/Assets.xcassets/Toast/success.imageset/success.png new file mode 100644 index 0000000..d375271 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/success.imageset/success.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/success.imageset/success@2x.png b/QuickLocation/Assets.xcassets/Toast/success.imageset/success@2x.png new file mode 100644 index 0000000..578d752 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/success.imageset/success@2x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/success.imageset/success@3x.png b/QuickLocation/Assets.xcassets/Toast/success.imageset/success@3x.png new file mode 100644 index 0000000..1ca13f7 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/success.imageset/success@3x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/warning.imageset/Contents.json b/QuickLocation/Assets.xcassets/Toast/warning.imageset/Contents.json new file mode 100644 index 0000000..acb4256 --- /dev/null +++ b/QuickLocation/Assets.xcassets/Toast/warning.imageset/Contents.json @@ -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 + } +} diff --git a/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning.png b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning.png new file mode 100644 index 0000000..86297a6 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@2x.png b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@2x.png new file mode 100644 index 0000000..ccea4a1 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@2x.png differ diff --git a/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@3x.png b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@3x.png new file mode 100644 index 0000000..ed8a4b5 Binary files /dev/null and b/QuickLocation/Assets.xcassets/Toast/warning.imageset/warning@3x.png differ diff --git a/QuickLocation/Main/BaseViewController/BaseViewController.swift b/QuickLocation/Main/BaseViewController/BaseViewController.swift index 5e6905d..fc53656 100644 --- a/QuickLocation/Main/BaseViewController/BaseViewController.swift +++ b/QuickLocation/Main/BaseViewController/BaseViewController.swift @@ -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 { diff --git a/QuickLocation/Main/Tabbar/MainTabBarController.swift b/QuickLocation/Main/Tabbar/MainTabBarController.swift index 304c0dd..190b70f 100644 --- a/QuickLocation/Main/Tabbar/MainTabBarController.swift +++ b/QuickLocation/Main/Tabbar/MainTabBarController.swift @@ -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) ]) } diff --git a/QuickLocation/Manager/App/ApiManager.swift b/QuickLocation/Manager/App/ApiManager.swift index fa98662..181b581 100644 --- a/QuickLocation/Manager/App/ApiManager.swift +++ b/QuickLocation/Manager/App/ApiManager.swift @@ -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): diff --git a/QuickLocation/Section/Login/LoginView.swift b/QuickLocation/Section/Login/LoginView.swift index 517203b..b98f635 100644 --- a/QuickLocation/Section/Login/LoginView.swift +++ b/QuickLocation/Section/Login/LoginView.swift @@ -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) { diff --git a/QuickLocation/Section/Login/LoginViewController.swift b/QuickLocation/Section/Login/LoginViewController.swift index 4b5faeb..2ce1409 100644 --- a/QuickLocation/Section/Login/LoginViewController.swift +++ b/QuickLocation/Section/Login/LoginViewController.swift @@ -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 { diff --git a/QuickLocation/Section/Login/LoginViewModel.swift b/QuickLocation/Section/Login/LoginViewModel.swift index 5d180e5..a60815e 100644 --- a/QuickLocation/Section/Login/LoginViewModel.swift +++ b/QuickLocation/Section/Login/LoginViewModel.swift @@ -11,6 +11,9 @@ import GeYanSdk final class LoginViewModel: BaseViewModel { + /// 验证码接口返回值 + var timestamp: String = "" + let oneClickLoginResult = PublishSubject() let loginSuccess = PublishSubject()