-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
62 lines (49 loc) · 1.51 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>verify-code</title>
<link rel="stylesheet" href="./css/verify-code.css">
</head>
<body>
<div id="code-container" style="height: 200px;"></div>
<br>
<button onclick="handleClickInit()">初始化</button>
<button onclick="handleClickReset()">重置</button>
<button onclick="handleClickDestroy()">销毁</button>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="./js/verify-code.js"></script>
<script>
const verifyCodeEle = $('#code-container');
let verifyCode = null;
verifyCodeEle.on('ready', function() {
console.log('ready');
});
verifyCodeEle.on('success', function(event, time) {
console.log('success', time);
alert((time / 1000).toFixed(2) + 's 完成了');
});
verifyCodeEle.on('fail', function() {
console.log('fail');
});
// 初始化
function handleClickInit() {
if (verifyCode) return;
verifyCode = new VerifyCode(verifyCodeEle);
verifyCode.init();
}
// 重置
function handleClickReset() {
if (verifyCode) verifyCode.reset();
}
// 销毁
function handleClickDestroy() {
if (verifyCode) verifyCode.destroy();
verifyCode = null;
}
</script>
</body>
</html>