You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.9 KiB

<!DOCTYPE html>
<html lang="en">
<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;
height: 100vh;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #6e45e2, #88d3ce);
color: white;
}
.container {
text-align: center;
background-color: rgba(255, 255, 255, 0.1);
padding: 30px;
border-radius: 15px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
#question {
font-size: 2em;
margin-bottom: 20px;
}
button {
padding: 12px 30px;
font-size: 1.1em;
border: none;
border-radius: 50px;
background-color: #ff5722;
color: white;
cursor: pointer;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s ease, box-shadow 0.3s ease;
margin: 10px;
}
button:hover {
background-color: #ff3d00;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<div class="container">
<div id="question">你需要回答问题 结果是:</div>
<button id="correctButton">正确</button>
<button id="wrongButton">错误</button>
<button class="back-button" onclick="window.location.href='select.html'">返回点名页面</button>
<div id="result"></div>
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const name = urlParams.get('name');
const correctButton = document.querySelector('#correctButton');
const wrongButton = document.querySelector('#wrongButton');
const resultDisplay = document.querySelector('#result');
// 初始化积分
let userPoints = parseInt(localStorage.getItem(name));
// 正确答案处理
correctButton.addEventListener('click', () => {
userPoints += 10; // 正确回答加 10 分
localStorage.setItem(name, userPoints); // 保存更新后的积分
resultDisplay.textContent = `正确!${name} 的当前积分: ${userPoints}`;
});
// 错误答案处理
wrongButton.addEventListener('click', () => {
userPoints -= 5;
localStorage.setItem(name, userPoints); // 保存更新后的积分
resultDisplay.textContent = `错误!${name} 的当前积分: ${userPoints}`;
});
</script>
</body>
</html>