vueプロジェクトに限界検証を導入

2716 ワード

1. public index.htmlはjsを導入する:


2. なものvueのdataで するパラメータを
codeParams:{

          product: 'bind',

          https:false,

          success:'',

          gt:'',

          challenge:'',

          new_captcha:''

      },

3. コードパラメータの
 getCodeParams(){

            var round = parseInt(Math.random()*10+1);

            this.$get('xxx',{code:round}).then((res)=>{ //              

                if(res.success==1){

                  this.codeParams.success = res.success

                  this.codeParams.gt = res.gt

                  this.codeParams.challenge = res.challenge

                  this.codeParams.new_captcha = res.new_captcha

                  initGeetest(this.codeParams,this.getCode);

                }

            })

        },

4. コードの
getCode(captchaObj){

            let vm = this;

            if(document.getElementById('numberCodes')){

                document.getElementById('numberCodes').addEventListener('click', function ()  {

                    let handleTelBlur = vm.handleTelBlur();

                    if (handleTelBlur) {

                        if(vm.telPhone.indexOf('@') > -1){

                            vm.$get('xxx',{keyWordType:2,email:vm.telPhone}).then((response)=>{

                                if(response.enterpriseStatus == 0){

                                    Toast('     ',2);

                                    return false;

                                }else{

                                         captchaObj.verify(); //    

                                }

                            })

                        }

                    }

                });

                captchaObj.onSuccess(function () {

                    if(vm.telPhone.indexOf('@') > -1){

                      vm.$post('xxxx',{email:vm.telPhone,codeType:1}).then((response)=>{

                        })

                    }

                    vm.showGetCodeBtn = false;

                    var timer = setInterval(function(){

                        vm.time -- ;

                        if(vm.time<=0){

                            vm.time = 60;

                            vm.showGetCodeBtn = true;

                            clearInterval(timer);

                            vm.codeMobileValue = "    "

                        }

                    },1000)

                })

            }

        },

5.
created(){

        this.getCodeParams();

    },