2 Star 0 Fork 0

友验技术团队/YoTest-Vue-SDK

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
YoTest.vue 2.00 KB
一键复制 编辑 原始数据 按行查看 历史
zyeros1991 提交于 2021-10-15 21:00 . [UPD] 与github保持同步
<template>
<div ref="captcha" class="yotest"></div>
</template>
<script>
import initYoTest from 'yotest-web-sdk';
export default {
data() {
return {
$captcha: null,
};
},
props: {
accessId: {
type: String,
required: true,
},
product: {
type: String,
default: "float",
},
area: String,
bgColor: String,
enforced: {
type: Boolean,
default: false,
},
},
created() {
initYoTest(
{
accessId: this.accessId,
product: this.product,
area: this.area,
bgColor: this.bgColor,
enforced: this.enforced,
},
(captcha) => {
this.$nextTick(() => this.onLoadedHandler(captcha));
}
);
},
methods: {
getValidate() {
if (!this.$captcha) {
return;
}
return this.$captcha.getValidate();
},
reset() {
if (!this.$captcha) {
return;
}
return this.$captcha.reset();
},
verify() {
if (!this.$captcha) {
return;
}
return this.$captcha.verify();
},
destroy() {
if (!this.$captcha) {
return;
}
this.$captcha.destroy();
this.$captcha = null;
},
onLoadedHandler(captcha) {
if (!captcha) {
this.$emit("error", { code: -1, message: "loaded error" });
return;
}
this.$captcha = captcha;
captcha.onReady(() => this.$emit("ready"));
captcha.onShow(() => this.$emit("show"));
captcha.onSuccess((data) => this.$emit("success", data));
captcha.onError((data) => this.$emit("error", data));
captcha.onClose(() => this.$emit("close"));
if (this.product !== "bind") {
const classId = `j_yotest_${Date.now()}_${(Math.random() * 1024) | 0}`;
const { captcha: $captcha } = this.$refs;
$captcha.className += ` ${classId}`;
this.$captcha.appendTo(`.${classId}`);
}
},
},
};
</script>
<style scoped>
.yotest {
width: 300px;
height: 40px;
}
</style>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yo-test-team/yo-test-vue-sdk.git
[email protected]:yo-test-team/yo-test-vue-sdk.git
yo-test-team
yo-test-vue-sdk
YoTest-Vue-SDK
master

搜索帮助