Update choice.html

main
luoyonghuang 2 months ago
parent 06e46f5383
commit a10f391f85

@ -55,24 +55,22 @@
<script> <script>
// 获取URL中的参数名字 // 获取URL中的参数名字
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const name = urlParams.get('name'); const name = urlParams.get('student_name');
const id = urlParams.get('student_id');
// 显示被抽中的名字 // 显示被抽中的名字
const nameDisplay = document.querySelector('#nameDisplay'); const nameDisplay = document.querySelector('#nameDisplay');
nameDisplay.textContent = ` ${name} 你的选择是:`; nameDisplay.textContent = ` ${name} 你的选择是:`;
// 初始化用户的积分
let userPoints = localStorage.getItem(name) ? parseInt(localStorage.getItem(name)) : 0;
if (!localStorage.getItem(name)) {
localStorage.setItem(name, 0); // 如果没有积分记录,初始化为 0
}
// 回答问题功能,跳转到回答问题页面 // 回答问题功能,跳转到回答问题页面
document.querySelector('#answerButton').addEventListener('click', () => { document.querySelector('#answerButton').addEventListener('click', () => {
window.location.href = `answer.html?name=${encodeURIComponent(name)}`; window.location.href = `answer.html?student_name=${encodeURIComponent(name)}&student_id=${encodeURIComponent(id)}`;
}); });
// 抽奖功能,跳转到抽奖页面 // 抽奖功能,跳转到抽奖页面
document.querySelector('#lotteryButton').addEventListener('click', () => { document.querySelector('#lotteryButton').addEventListener('click', () => {
window.location.href = `lottery.html?name=${encodeURIComponent(name)}`; window.location.href = `lottery.html?student_name=${encodeURIComponent(name)}&student_id=${encodeURIComponent(id)}`;
}); });
</script> </script>

Loading…
Cancel
Save