Ver código fonte

短信校验码失败

y595705120 3 dias atrás
pai
commit
aca1be5733
1 arquivos alterados com 29 adições e 7 exclusões
  1. 29 7
      src/containers/register/register.vue

+ 29 - 7
src/containers/register/register.vue

@@ -31,15 +31,16 @@
             <el-button class="auth-code" type="primary" disabled v-else>{{count}} s</el-button>
 
 
-            <span class="formver ng-scope" style="font-size: 13px;" v-if="err.indexOf('校验码')>-1">
+            <span class="formver ng-scope" style="font-size: 13px;color: green;" v-if="errCodeMsg=='校验成功'">
               <span class="p-ico ico-formver"></span>
-              <span class="p-ico ico-worm"></span>{{err}}
+              <span class="p-ico ico-passed ml20"></span>短信校验成功
+            </span>
+
+            <span class="formver ng-scope" style="font-size: 13px;" v-else-if="errCodeMsg">
+              <span class="p-ico ico-formver"></span>
+              <span class="p-ico ico-worm"></span>短信校验失败
             </span>
 
-            <!-- <span class="formver ng-scope" v-if="phone.length==11 && code.length<4">
-                    <span class="p-ico ico-formver"></span>
-                    <span class="p-ico ico-worm"></span>请输入校验码
-                  </span> -->
           </li>
 
           <li class="mt10">
@@ -144,7 +145,10 @@
           nickname: ''
         },
         count: 0,
+        errCount: 0,
         name: '',
+        isCodeOk: false,
+        errCodeMsg: "",
         passwordLevel: 'sick',
         password: '',
         educationList: window.baseConfig.educationList,
@@ -158,6 +162,22 @@
       };
     },
     watch: {
+      code(code){
+        if(code.length != 5 || this.errCount>3) {
+          this.isCodeOk = false;
+          return;
+        }
+        if(this.isCodeOk) return;
+        let param = {phone:this.phone, code: this.code}
+        httpServer("Auth.isPhoneOk", param).then(res => {
+          this.isCodeOk = false;
+          this.errCount ++;
+          this.errCodeMsg = res.msg||'';
+          if( res.code != 200) return;
+          this.isCodeOk = true;
+          this.errCodeMsg = "校验成功"
+        })
+      },
       password(val) {
         if (val.length < 6) {
           this.passwordLevel = 'sick';
@@ -230,6 +250,7 @@
 
         httpServer("Auth.getCode", {phone,type}).then(res => {
           if (res.code == 200) {
+            this.errCount = 0
             this.$message.successMsg("发送成功", 1)
             this.startTimer()
           }
@@ -250,7 +271,7 @@
         }, 1000)
       },
       is_ok_card( cardId ){
-        if( !cardId ) return false;
+        if( !cardId ) return true;
         if( cardId.indexOf('H')>-1 || cardId.indexOf('W') >-1){
             return cardId.length==9 || cardId.length ==11;
         }
@@ -259,6 +280,7 @@
       },
       cansubmit() {
         if (this.isPhoneErr()) return false;
+        if(!this.isCodeOk) return false;
         if (!this.is_ok_card(this.cardId)) return false;
         if (!this.name) return false;
         if (!this.password || this.password != this.confirmPassword) return false;