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