浏览代码

忘记密码返回上一步bug,增加手机号、邮箱登录表单验证

cxmo 1 年之前
父节点
当前提交
bc53e8687b

+ 11 - 1
src/views/Login.vue

@@ -290,12 +290,20 @@ export default {
         handleClick(tab) {
             //调用对应model的init方法
             this.$refs[tab.name]&&this.$refs[tab.name].modelInit()
+            this.$refs[tab.name]&&this.$refs[tab.name].$refs.modelForm.clearValidate()
             if(tab.name==='ordinaryModel'){
-                this.getRememberedInfo()
+                this.$nextTick(()=>{
+                    this.getRememberedInfo()
+                })
             }
         },
         changeModel(model){
             this.activeModel = model
+            if(model!=='forgetPassModel'){
+                this.$nextTick(()=>{
+                    this.getRememberedInfo()
+                })
+            }
         },
         handleLogin(){
             //先进行判空的表单验证
@@ -378,6 +386,7 @@ export default {
                 if(res.Ret!==200){
                     //刷新图形验证码
                     this.$refs[model].getCodePic()
+                    this.$refs[model].form.picCode = ''
                     model==='mobileModel'&&(this.logining = false)
                     model!=='mobileModel'&&(this.checkLogining = false)
                     return
@@ -396,6 +405,7 @@ export default {
                 if(res.Ret!==200){
                     //刷新图形验证码
                     this.$refs[model].getCodePic()
+                    this.$refs[model].form.picCode = ''
                     model==='emailModel'&&(this.logining = false)
                     model!=='emailModel'&&(this.checkLogining = false)
                     return

+ 15 - 2
src/views/login_manage/EmailModel.vue

@@ -6,7 +6,7 @@
             label-width="0px"
             :model="form"
             :rules="rules">
-            <el-form-item prop="mobile">
+            <el-form-item prop="email">
                 <el-input
                     type="text"
                     v-model="form.email"
@@ -78,7 +78,20 @@ export default {
                 picCode:'',
                 checkCode:''
             },
-            rules:{},
+            rules:{
+                email:[
+                    {required:true,message:'请输入邮箱',trigger:'blur'},
+                    {validator:(rule,value,callback)=>{
+                        if(!patternEmail.test(value)){
+                            callback(new Error("请输入正确的邮箱格式"))
+                        }else{
+                            callback()
+                        }
+                    },trigger:'blur'}
+                ],
+                picCode:[{required:true,message:'请输入图形验证码',trigger:'blur'}],
+                checkCode:[{required:true,message:'请输入短信验证码',trigger:'blur'}]
+            },
             hintMessage:''
         };
     },

+ 4 - 0
src/views/login_manage/ForgetPassModel.vue

@@ -251,6 +251,10 @@ export default {
         changeModel(){
             if(this.currentStep>0){
                 this.currentStep--
+                if(this.currentStep===0){
+                    this.getCodePic()
+                    this.form.picCode = ''
+                }
             }else{
                 this.$emit('changeModel')
             }

+ 16 - 1
src/views/login_manage/MobileModel.vue

@@ -88,7 +88,22 @@ export default {
                 picCode:'',
                 checkCode:''
             },
-            rules:{}
+            rules:{
+                mobile:[
+                    {required: true,message: "请输入手机号",trigger: "blur"},
+                    {validator:(rule,value,callback)=>{
+                        if(this.areaCodeSelect==='86'&&!isMobileNo(value)){
+                            callback(new Error('请输入正确的手机号格式'));
+                        }else if(this.areaCodeSelect!=='86'&&isNaN(value.trim())){
+                            callback(new Error('请输入正确的手机号格式'));
+                        }else{
+                            callback()
+                        }
+                    },trigger:'blur'}
+                ],
+                picCode:[{required:true,message:'请输入图形验证码',trigger:'blur'}],
+                checkCode:[{required:true,message:'请输入短信验证码',trigger:'blur'}]
+            }
         };
     },
     methods: {