Browse Source

添加验证码

tenggouwa 6 years ago
parent
commit
6dbd3b685f
2 changed files with 47 additions and 9 deletions
  1. 13 0
      src/assets/js/common.js
  2. 34 9
      src/views/home/login.vue

+ 13 - 0
src/assets/js/common.js

@@ -221,12 +221,18 @@ var sendCode=function(that,params,success){
       success(res);
     }
     if(res.code==200){
+      if(res.data.isShow == 1){
+        sessionStorage.setItem('alertStatus','true');
+        sessionStorage.setItem('dataSrc',res.data.data.jsUrl);
+        sessionStorage.setItem('businessId',res.data.data.businessId);
+      }
       that.$notify({
         title: '提示',
         message: '发送成功',
         type: 'success',
         duration:'2000'
       });
+      
       that.codestate=1;
       that.secondNum=60;
       clearInterval(that.reltime);
@@ -251,12 +257,19 @@ var sendEmail=function(that,params,success){
       success(res);
     }
     if(res.code==200){
+      if(res.data.isShow == 1){
+        // that.alertStatus = true;
+        sessionStorage.setItem('alertStatus','true')
+        sessionStorage.setItem('dataSrc',data.data.data.jsUrl)
+        sessionStorage.setItem('businessId',data.data.data.businessId)
+      }
       that.$notify({
         title: '提示',
         message: '发送成功',
         type: 'success',
         duration:'2000'
       });
+      
       //that.gid = res.data.gid;
       that.codestate=1;
       that.secondNum=60;

+ 34 - 9
src/views/home/login.vue

@@ -269,6 +269,7 @@ export default{
       businessId:'',
       dataSrc:'',
       fuckfuck:false,
+      alertStatus:false,
     }
   },
   components:{
@@ -290,6 +291,10 @@ export default{
     area(val){
       // console.log(val);
     },
+    // alertStatus(val){
+     
+    //   this.addscript();
+    // },
     operateType(val){
       for(let x in this.loginParam){
         this.loginParam[x]="";
@@ -326,6 +331,7 @@ export default{
     }
   },
   mounted(){
+    // console.log(this.alertStatus);
     this.$nextTick(()=>{
       let token=getcookie("token");
       if(token){
@@ -353,7 +359,7 @@ export default{
       setTimeout(()=>{
         let capOption={callback :this.cbfn,type:'popup'};
         capInit(document.getElementById("TCaptcha"), capOption);
-      },1000)
+      },2000)
     },
     //删除script标签
     // deletescript(){
@@ -377,12 +383,19 @@ export default{
         this.ticketNum = retJson.ticket;
         this.pwdSend();
         this.fuckfuck=false;
+        sessionStorage.setItem('alertStatus','')
+        sessionStorage.setItem('dataSrc','')
+        sessionStorage.setItem('businessId','')
         // 销毁上一个验证
         capDestroy();
       }else{       
         //用户关闭验证码页面,没有验证
         capDestroy();
         this.fuckfuck=false;
+        sessionStorage.setItem('alertStatus','')
+        sessionStorage.setItem('dataSrc','')
+        sessionStorage.setItem('businessId','')
+
       }
     },
     toForgetPassWord(){
@@ -473,12 +486,12 @@ export default{
       //this.operateType = "email"
       // console.log("this.operateType :"+this.operateType);
       if(this.setParam.username==""){
-        this.$notify({
-          title: '提示',
-          message: this.tipWord,
-          type: 'warning',
-          duration:'1500'
-        })
+        // this.$notify({
+        //   title: '提示',
+        //   message: this.tipWord,
+        //   type: 'warning',
+        //   duration:'1500'
+        // })
         return false;
       }
       let param={
@@ -568,7 +581,8 @@ export default{
           codetype:'validate',
           platkey:'zhaobi'
         };
-        sendEmail(this,sparam,(data)=>{});
+        sendEmail(this,sparam,(data)=>{
+        });
       }
       else{
         sparam={
@@ -578,8 +592,19 @@ export default{
           area:this.area,
           platkey:'zhaobi',
         };       
-        sendCode(this,sparam,(data)=>{});
+        sendCode(this,sparam,(data)=>{
+        });
+        
+        
+      }
+      if(sessionStorage.getItem('alertStatus') == 'true'){
+        this.alertStatus = true;
+        this.dataSrc = sessionStorage.getItem('dataSrc');
+        this.businessId = sessionStorage.getItem('businessId');
+        this.addscript();
+        console.log( this.dataSrc, this.businessId)
       }
+      
     },
     //登录时~发送验证码
     sendLoginCode(){