vue 接入腾讯放水墙

发表时间:2020-01-16 02:49:13
摘要信息

vue 接入腾讯放水墙

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)
}
},


验证吗初始化

handleLogin() {
let captcha = new TencentCaptcha('15645314', (rsp) => {
console.log(rsp)
if (rsp.ret === 0) {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
this.$store.dispatch('user/login', this.loginForm)
.then(() => {
this.$router.push({ path: this.redirect || '/', query: this.otherQuery })
this.loading = false
})
.catch(() => {
this.loading = false
})
} else {
console.log('error submit!!')
return false
}
})
} else {
this.$message({
message: '验证不通过',
type: 'warning'
})
}
}, {})
captcha.show()
},


40% Complete (success)