更新 attendance.html

master
wangsiyuan 2023-12-29 00:21:24 +08:00
parent dc66080c22
commit 68a126cb8b
1 changed files with 7 additions and 5 deletions

View File

@ -64,14 +64,16 @@
<script src="/static/js/logout.js"></script> <script src="/static/js/logout.js"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
let courseData = {};
// 获取课程名称或状态 // 获取课程名称或状态
$.get("/api/get-course-name", function (response) { $.get("/api/get-course-name", function (response) {
if (response.msg === "ok") { if (response.msg === "ok") {
// 如果后端返回课程名 // 如果后端返回课程名
$("#course-info").text("课程:" + response.data.course_name +" 在上课时间内,请及时签到"); $("#course-info").text("课程:" + response.data.course_name + "。在上课时间内,请及时签到!");
// 启用签到按钮 // 启用签到按钮
$("#sign-in-btn").prop('disabled', false); $("#sign-in-btn").prop('disabled', false);
courseData = response.data;
} else { } else {
// 根据不同的消息更新状态 // 根据不同的消息更新状态
$("#course-info").text(response.msg); // 显示没有课程的消息 $("#course-info").text(response.msg); // 显示没有课程的消息
@ -84,16 +86,16 @@
$("#sign-in-btn").click(function () { $("#sign-in-btn").click(function () {
if (!$(this).prop('disabled')) { if (!$(this).prop('disabled')) {
// 发送签到请求到后端 // 发送签到请求到后端
$.post("/api/student-sign-in", function (response) { $.post("/api/student-sign-in",courseData,function (response) {
// 处理签到后的响应 // 处理签到后的响应
if (response.success) { if (response.msg === 'ok') {
layer.msg('签到成功!'); layer.msg('签到成功!');
} else { } else {
layer.msg("签到失败!"); layer.msg(response.data);
} }
}); });
} else { } else {
alert("当前不可签到"); // Or handle disabled button click as needed layer.msg("当前不可签到"); // Or handle disabled button click as needed
} }
}); });
}); });