Browse Source

feat(Creat):注册时邮箱验证

liyangbin 2 years ago
parent
commit
37110729e2
1 changed files with 32 additions and 24 deletions
  1. 32 24
      src/views/Create.vue

+ 32 - 24
src/views/Create.vue

@@ -165,31 +165,39 @@ export default {
         })
       }
     },
-    sendEmail() {
-      let timerId = setInterval(() => {
-        this.CountDown--
-        this.isDisabled = true
-        this.buttonName = this.CountDown + 's'
-        if (this.CountDown <= 0) {
-          clearInterval(timerId)
-          this.buttonName = 'send'
-          this.CountDown = 60
-          this.isDisabled = false
-        }
-      }, 1000)
-      if (!this.isDisabled) {
-        //发送邮件
-        get(
-          '/pdf-tech/auth/getVerifyCode?action=0&type=0&receiver=' +
-            this.ruleForm.email
-        ).then((res) => {
-          if(res.data.code === 200){
-            this.$message({
-              message: 'Email sent successfully',
-              type: "success"
-            })
-          }
+    sendEmail(){
+      const regEmail = /^([A-Za-z0-9_\-.])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,4})$/
+      if(!regEmail.test(this.ruleForm.email)){
+        this.$message({
+          message: 'Invalid Email Addresses',
+          type: "error"
         })
+      } else {
+        let timerId = setInterval(() => {
+          this.CountDown--
+          this.isDisabled = true
+          this.buttonName = this.CountDown + 's'
+          if (this.CountDown <= 0) {
+            clearInterval(timerId)
+            this.buttonName = 'send'
+            this.CountDown = 60
+            this.isDisabled = false
+          }
+        }, 1000)
+        if (!this.isDisabled) {
+          //发送邮件
+          get(
+            '/pdf-tech/auth/getVerifyCode?action=0&type=0&receiver=' +
+              this.ruleForm.email
+          ).then((res) => {
+            if(res.data.code === 200){
+              this.$message({
+                message: 'Email sent successfully',
+                type: "success"
+              })
+            }
+          })
+        }
       }
     },
     changeEmail() {