created() {
const url = 'https://ssl.captcha.qq.com/TCaptcha.js'
const script = document.createElement('script')
script.type = 'text/javascript'
script.src = url
document.body.appendChild(script)
script.onload = () => {
console.log(window.TencentCaptcha, 'script已经成功加载')
this.getAppid()
}
},
varify() {
// 生成一个滑块验证码对象
const appid = this.captchaAppId.toString()
// eslint-disable-next-line
let captcha = new window.TencentCaptcha(appid, res => {
// 用户滑动结束或者关闭弹窗,腾讯返回的内容
if (res.ret === 0) {
this.randstr = res.randstr
this.ticket = res.ticket
// 验证成功
console.log('验证成功')
} else {
// 提示用户完成验证
console.log('验证失败')
}
})
// 滑块显示
captcha.show()
}