ITEyes/psw.html

152 lines
5.6 KiB
HTML
Raw Permalink Normal View History

<!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>
/* 样式定义 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
font-family: Arial, sans-serif;
}
.container {
background-color: white;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 10px;
width: 300px;
margin-bottom: 20px;
}
h2 {
text-align: center;
}
input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
.button-container {
display: flex;
justify-content: space-between;
}
button {
padding: 10px 20px;
background-color: #333;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #555;
}
.function-buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 20px;
}
.function-buttons button {
width: 130px;
margin: 10px;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="container">
<h2>智眼-密码设置</h2>
<label for="password">输入密码</label>
<input type="password" id="password" oncopy="return false" oncut="return false" onpaste="return false" ondragstart="return false" ondrop="return false">
<div class="button-container">
<button id="confirm" style="display: block;">确认</button>
<button id="reset" style="display: none;">重置</button>
</div>
<br>
<div id="reset-section" class="hidden">
<label for="old-password">输入旧密码进行重置</label>
<input type="password" id="old-password" oncopy="return false" oncut="return false" onpaste="return false" ondragstart="return false" ondrop="return false">
<button id="confirm-reset">确认重置</button>
</div>
</div>
<!-- 功能按钮部分 -->
<div class="container">
<div class="function-buttons">
<a href="index.html"><button id="home">启动首页</button></a>
<a href="psw.html"><button id="unlock">解锁密码设置</button></a>
<a href="gncs.html"><button id="test">功能测试</button></a>
<a href="setting.html"><button id="settings">软件设置</button></a>
</div>
</div>
<script>
currentPassword = '123';
// 当用户点击确认按钮时,保存密码并隐藏确认按钮
document.getElementById('confirm').addEventListener('click', function() {
const password = document.getElementById('password').value;
if (password) {
currentPassword = password;
console.log(password)
sendMessage({
"ClientEvent": "SetPassword",
"Content": {
"Password": password
}
}).then(() => {
alert('密码已设置');
document.getElementById('password').setAttribute('disabled', true); // 禁用输入框
document.getElementById('confirm').style.display = 'none'; // 隐藏确认按钮
document.getElementById('reset').style.display = 'block'; // 显示重置按钮
})
} else {
alert('请输入密码');
}
});
// 当用户点击重置按钮时,显示输入旧密码的区域
document.getElementById('reset').addEventListener('click', function() {
document.getElementById('reset-section').classList.remove('hidden');
});
// 确认重置密码
document.getElementById('confirm-reset').addEventListener('click', function() {
const oldPassword = document.getElementById('old-password').value;
if (oldPassword === currentPassword) {
currentPassword = ''; // 清空当前密码
document.getElementById('password').value = ''; // 清空密码输入框
document.getElementById('old-password').value = ''; // 清空旧密码输入框
document.getElementById('password').removeAttribute('disabled'); // 重新启用密码输入框
document.getElementById('confirm').style.display = 'block'; // 重新显示确认按钮
document.getElementById('reset').style.display = 'none'; // 隐藏重置按钮
document.getElementById('reset-section').classList.add('hidden'); // 隐藏重置部分
alert('密码已重置');
} else {
alert('旧密码不正确');
}
});
</script>
</body>
</html>