Explorar o código

添加本地验证

wenglk %!s(int64=6) %!d(string=hai) anos
pai
achega
51dc711b73
Modificáronse 1 ficheiros con 150 adicións e 81 borrados
  1. 150 81
      src/views/home/mBanner.vue

+ 150 - 81
src/views/home/mBanner.vue

@@ -298,7 +298,6 @@
           password:'',
           code:'',
           type:'sms',
-          type:'',
           mobile:'',
           area:86,
           platkey:'zhaobi',
@@ -458,39 +457,61 @@
       },
       toLogin: function(){
         const Form = this.loginform;
-        console.log(Form);
         const param = new URLSearchParams();
         for(let item in Form){
           param.append(item,Form[item]);
         }
-
-        this.axios.post('https://dev407.33.cn/api/broker/login',param).then((res)=>{
-          const result = res.data;
-          if(result.code!=200){
-            console.log(result.message);
+        if(this.loginform.mobile=='' && this.loginform.email==''){
+          if(this.loginform.type=='sms'){
             this.$notify({
               title:'提示',
-              message: result.message,
-              type:'warning',
+              message: '请输入您的手机号码',
+              type:'warning'
             })
           }else{
             this.$notify({
-                title:'成功',
-                message:'登陆成功',
-                type:'success'
+              title: '提示',
+              message: '请输入您的邮箱',
+              type: 'warning'
             })
-            this.username = result.data.username;
-            this.usertip = 1;
-            this.regshow = 4;
-            this.Authorization = 'Bearer '+result.data.access_token;
-            sessionStorage.setItem('regshow',this.regshow);
-            sessionStorage.setItem('usertip',this.usertip);
-            sessionStorage.setItem('username',this.username);
-            sessionStorage.setItem('token_code',this.Authorization);
-            console.log('登陆成功');
-            this.loadapplymsg();
           }
-        })
+        }else{
+          if (this.loginform.password=='') {
+            this.$notify({
+              title: '提示',
+              message: '请输入您的密码',
+              type: 'warning',
+            })
+          }else{
+            this.axios.post('https://dev407.33.cn/api/broker/login',param).then((res)=>{
+            const result = res.data;
+            if(result.code!=200){
+              console.log(result.message);
+              this.$notify({
+                title:'提示',
+                message: result.message,
+                type:'warning',
+              })
+            }else{
+              this.$notify({
+                  title:'成功',
+                  message:'登陆成功',
+                  type:'success'
+              })
+              this.username = result.data.username;
+              this.usertip = 1;
+              this.regshow = 4;
+              this.Authorization = 'Bearer '+result.data.access_token;
+              sessionStorage.setItem('regshow',this.regshow);
+              sessionStorage.setItem('usertip',this.usertip);
+              sessionStorage.setItem('username',this.username);
+              sessionStorage.setItem('token_code',this.Authorization);
+              console.log('登陆成功');
+              this.loadapplymsg();
+            }
+            })
+          }
+        }
       },
       toRegister: function(checked){
         const Form = this.regform;
@@ -499,40 +520,72 @@
         for (let item in Form){
           param.append(item,Form[item]);
         }
-        if(checked==false){
-                this.$notify({
-                title:'提示',
-                message: '请阅读风险提示!',
-                type:'warning',
-                })
-        }else{        
-          this.axios.post('https://dev407.33.cn/api/broker/register',param).then((res)=>{
-            const result = res.data;
-              if(result.code!=200){
-                console.log(result.message);
+        if(this.regform.mobile=='' && this.regform.email==''){
+          if(this.regform.type=='sms'){
+            this.$notify({
+              title: '提示',
+              message: '请输入您的手机号码',
+              type: 'warning',
+            })
+          }else{
+            this.$notify({
+              title: '提示',
+              message: '请输入您的邮箱',
+              type: 'warning'
+            })
+          }
+        }else{
+          if(this.regform.code==''){
+            this.$notify({
+              title: '提示',
+              message: '请输入验证码',
+              type: 'warning'
+            })
+          }else{
+            if(this.regform.password==''){
+              this.$notify({
+                title: '提示',
+                message: '请输入您的密码',
+                type: 'warning'
+              })
+            }else{
+              if(checked==false){
                 this.$notify({
-                  title:'提示',
-                  message: result.message,
-                  type:'warning',
+                  title: '提示',
+                  message: '请阅读风险提示!',
+                  type: 'warning'
                 })
               }else{
-                this.$notify({
-                title:'成功',
-                message:'注册成功',
-                type:'success'
+                this.axios.post('https://dev407.33.cn/api/broker/register',param).then((res)=>{
+                const result = res.data;
+                  if(result.code!=200){
+                    console.log(result.message);
+                    this.$notify({
+                      title:'提示',
+                      message: result.message,
+                      type:'warning',
+                    })
+                  }else{
+                    this.$notify({
+                    title:'成功',
+                    message:'注册成功',
+                    type:'success'
+                    })
+                    this.username = this.regform.email!=''? this.regform.email:this.regform.mobile;
+                    this.usertip = 1;
+                    this.regshow = 4;
+                    this.Authorization = 'Bearer '+result.data.access_token;
+                    sessionStorage.setItem('regshow',this.regshow);
+                    sessionStorage.setItem('usertip',this.usertip);
+                    sessionStorage.setItem('username',this.username);
+                    sessionStorage.setItem('token_code',this.Authorization);
+                    console.log('注册成功')
+                  }
                 })
-                this.username = this.regform.email!=''? this.regform.email:this.regform.mobile;
-                this.usertip = 1;
-                this.regshow = 4;
-                this.Authorization = 'Bearer '+result.data.access_token;
-                sessionStorage.setItem('regshow',this.regshow);
-                sessionStorage.setItem('usertip',this.usertip);
-                sessionStorage.setItem('username',this.username);
-                sessionStorage.setItem('token_code',this.Authorization);
-                console.log('注册成功')
               }
-          })
-        }
+            }
+          }
+        }   
       },
       toLoginOut: function(){
         this.axios({
@@ -570,21 +623,30 @@
         for (let item in Form){
           param.append(item,Form[item]);
         }
-        this.axios.post('https://dev407.33.cn/api/send/newsms',param).then((res)=>{
-          const result = res.data;
-          if(result.code!=200){
-            console.log(result.message);
-            this.$notify({
-              title:'提示',
-              message: result.message,
-              type:'warning',
-            })
-          }else{
-            this.username = result.data.username;
-            this.regshow = 4;
-            console.log('注册成功')
-          }
-        })
+        console.log(param);
+        if (this.regform.mobile==''){
+          this.$notify({
+            title:'提示',
+            message:'请输入你的手机号码',
+            type:'warning'
+          })
+        }else{
+          this.axios.post('https://dev407.33.cn/api/send/newsms',param).then((res)=>{
+            const result = res.data;
+            if(result.code!=200){
+              console.log(result.message);
+              this.$notify({
+                title:'提示',
+                message: result.message,
+                type:'warning',
+              })
+            }else{
+              this.username = result.data.username;
+              this.regshow = 4;
+              console.log('注册成功')
+            }
+          })
+        }
       },
       sendMail: function(){
         const Form = this.regform;
@@ -592,20 +654,27 @@
         for (let item in Form){
           param.append(item,Form[item]);
         }
-
-        this.axios.post('https://dev407.33.cn/api/send/newmail',param).then((res)=>{
-          const result = res.data;
-          if(result.code!=200){
-            console.log(result.message);
-            this.$notify({
-              title:'提示',
-              message: result.message,
-              type:'warning',
-            })
-          }else{
-            console.log('发送成功')
-          }
-        })
+        if(this.regform.email==''){
+          this.$notify({
+            title:'提示',
+            message: '请输入您的邮箱',
+            type:'warning',
+          })
+        }else{
+          this.axios.post('https://dev407.33.cn/api/send/newmail',param).then((res)=>{
+            const result = res.data;
+            if(result.code!=200){
+              console.log(result.message);
+              this.$notify({
+                title:'提示',
+                message: result.message,
+                type:'warning',
+              })
+            }else{
+              console.log('发送成功')
+            }
+          })
+        }
       },
       changemsg: function(){
         this.regshow = sessionStorage.getItem('regshow')? sessionStorage.getItem('regshow'):2;