Browse Source

【会员系统】验证码登录模块,补充验证码输入规则限制逻辑

wanjun 4 months ago
parent
commit
b032886598

+ 10 - 0
PDF Office/PDF Master/MemberCenter/View/KMSignUpView.swift

@@ -324,6 +324,16 @@ class KMSignUpView: KMBaseXibView {
                 self?.sendBoxRefresh()
             }
             .store(in: &cancellables)
+        viewModel.$verificationCode
+            .receive(on: RunLoop.main)
+            .sink { [weak self] newValue in
+                if newValue.count <= 6 && newValue.count >= 0 {
+                    self?.viewModel.passwordErrorMessage = ""
+                } else {
+                    self?.viewModel.passwordErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
+                }
+            }
+            .store(in: &cancellables)
     }
         
     // MARK: Action Method

+ 2 - 10
PDF Office/PDF Master/MemberCenter/ViewModel/KMSignUpViewModel.swift

@@ -164,25 +164,17 @@ class KMSignUpViewModel: ObservableObject {
      @param
      */
     func signUpAction() -> Void {
-        if email.count <= 0 || email.count > 100 {
-            emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
-            return
-        }
-        if !isValidEmail() {
+        if email.count <= 0 || email.count > 100 || !isValidEmail() {
             emailErrorMessage = NSLocalizedString("Please enter the correct email format", tableName: "MemberCenterLocalizable", comment: "")
             return
         }
         
         var code: String = ""
         if signUpState == .verificationCode {
-            if verificationCode.count <= 0 {
+            if verificationCode.count <= 0 || verificationCode.count > 6 {
                 passwordErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
                 return
             }
-            if verificationCode.count <= 0 {
-                emailErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
-                return
-            }
             code = verificationCode
         } else if signUpState == .password {
             if password.count <= 0 {