<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>指纹解锁特效</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
margin: 0;
}
.fingerprint-container {
position: relative;
width: 200px;
height: 200px;
display: flex;
flex-direction: column;
align-items: center;
}
.fingerprint {
width: 120px;
height: 160px;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20,30 Q30,20 40,30 Q50,40 60,30 Q70,20 80,30" stroke="black" fill="none" stroke-width="2"/><path d="M25,50 Q35,40 45,50 Q55,60 65,50 Q75,40 85,50" stroke="black" fill="none" stroke-width="2"/><path d="M30,70 Q40,60 50,70 Q60,80 70,70" stroke="black" fill="none" stroke-width="2"/></svg>');
background-repeat: no-repeat;
background-position: center;
position: relative;
}
.fingerprint::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 0;
background-color: rgba(0, 150, 255, 0.3);
transition: height 0.5s ease;
}
.fingerprint.active::after {
height: 100%;
}
.status {
margin-top: 20px;
font-size: 14px;
color: #666;
}
.success {
color: green;
}
.error {
color: red;
}
.fingerprint-btn {
margin-top: 20px;
padding: 8px 16px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.fingerprint-btn:hover {
background-color: #0069d9;
}
</style>
</head>
<body>
<div class="fingerprint-container">
<div class="fingerprint" id="fingerprint"></div>
<div class="status" id="status">请将手指放在指纹传感器上</div>
<button class="fingerprint-btn" id="scanBtn">开始扫描</button>
</div>
<script>
const fingerprint = document.getElementById('fingerprint');
const status = document.getElementById('status');
const scanBtn = document.getElementById('scanBtn');
// 模拟指纹扫描
function simulateFingerprintScan() {
status.textContent = "正在识别指纹...";
status.className = "status";
fingerprint.classList.add('active');
// 随机模拟成功或失败
setTimeout(() => {
const isSuccess = Math.random() > 0.3;
if (isSuccess) {
status.textContent = "指纹识别成功!";
status.className = "status success";
// 成功后3秒重置
setTimeout(resetScanner, 3000);
} else {
status.textContent = "指纹识别失败,请重试";
status.className = "status error";
fingerprint.classList.remove('active');
}
}, 2000);
}
function resetScanner() {
fingerprint.classList.remove('active');
status.textContent = "请将手指放在指纹传感器上";
status.className = "status";
}
scanBtn.addEventListener('click', simulateFingerprintScan);
// 简单的指纹识别功能
function getBrowserFingerprint() {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
ctx.textBaseline = 'top';
ctx.font = '14px Arial';
ctx.fillStyle = '#f60';
ctx.fillRect(125, 1, 62, 20);
ctx.fillStyle = '#069';
ctx.fillText('指纹识别', 2, 15);
ctx.fillStyle = 'rgba(102, 204, 0, 0.7)';
ctx.fillText('指纹识别', 4, 17);
return canvas.toDataURL();
}
// 页面加载时获取浏览器指纹
window.addEventListener('load', () => {
const fingerprintData = getBrowserFingerprint();
console.log('浏览器指纹数据:', fingerprintData);
});
</script>
</body>
</html>
743

被折叠的 条评论
为什么被折叠?



