-
Notifications
You must be signed in to change notification settings - Fork 0
/
frontend.html
96 lines (86 loc) · 2.81 KB
/
frontend.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<title>抗原检测结果查询</title>
<script src="main.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f1f1f1;
padding: 20px;
}
h1 {
color: #333;
}
p {
color: #666;
}
label {
display: block;
margin-top: 10px;
}
input[type="text"] {
width: 300px;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 20px;
background-color: #3498db;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
#result {
margin-top: 10px;
font-weight: bold;
}
.success {
color: green;
}
.error {
color: red;
}
</style>
<script>
async function searchResult() {
const queryCode = document.getElementById("query_code").value;
const response = await fetch("/search", {
method: "POST",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: `query_code=${encodeURIComponent(queryCode)}`
});
const data = await response.json();
if (data.status === "success") {
document.getElementById("result").innerText = `检测结果:${data.result}`;
document.getElementById("result").classList.add("success");
} else if (data.status === "not_found") {
document.getElementById("result").innerText = "查询码无效。";
document.getElementById("result").classList.add("error");
} else if (data.status === "C") {
document.getElementById("result").innerText = "检测结果:阴性";
} else if (data.status === "CT") {
document.getElementById("result").innerText = "检测结果:阳性";
} else if (data.status === "T") {
document.getElementById("result").innerText = "检测结果:无效结果";
} else {
document.getElementById("result").innerText = "查询出错,请重试";
document.getElementById("result").classList.add("error");
}
}
</script>
</head>
<body>
<center>
<h1>抗原检测结果查询</h1>
<p>结果说明:C(阴性);T(无效结果);CT(阳性)</p>
<p>输入查询码查询抗原检测结果:</p>
<input type="text" id="query_code">
<button onclick="searchResult()">查询</button>
<p id="result"></p>
<p id="ban"></p>
</center>
</body>
</html>