vue 接入腾讯防水墙(验证码)

发表时间:2020-05-08 05:21:34
摘要信息

接入腾讯的防水墙 vue

腾讯防水墙 申请地址:https://007.qq.com/


先在页面插入js

created() {
// window.addEventListener('storage', this.afterQRScan)
if (window.TencentCaptcha === undefined) {
let script = document.createElement('script')
let head = document.getElementsByTagName('head')[0]
script.type = 'text/javascript'
script.charset = 'UTF-8'
script.src = 'https://ssl.captcha.qq.com/TCaptcha.js'
head.appendChild(script)
}
},


methods

handleLogin() {
let captcha = new TencentCaptcha('xxxxxxxx', (rsp) => {
console.log(rsp)
if (rsp.ret === 0) {
this.loginForm.Ticket = rsp.ticket
this.loginForm.Randstr = rsp.randstr
} else {
this.$message({
message: '放弃了验证',
type: 'warning'
})
}
})
captcha.show()
}

后端有sdk 选择对应语言安装 然后在接口中调用就OK了

40% Complete (success)