完成大作业服务端代码,新建管理端,管理端不可用

This commit is contained in:
2024-06-14 14:53:50 +08:00
parent ad767a806b
commit cfbaf585a7
80 changed files with 3563 additions and 128 deletions

View File

@@ -0,0 +1,238 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
width: 100%;
justify-content: space-between;
}
.logo {
font-size: 24px;
font-weight: bold;
margin-left: 20px;
}
.nav-buttons {
display: flex;
gap: 20px;
}
.nav-buttons a {
color: white;
text-decoration: none;
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.nav-buttons a:hover {
background-color: #155a8c;
}
.user-menu {
position: relative;
display: flex;
align-items: center;
margin-right: 20px;
}
.user-menu span {
margin-right: 10px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: rgba(28, 108, 178, 0.9);
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
right: 0; /* 确保下拉菜单靠右对齐 */
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
main {
flex: 1;
width: 80%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
h2 {
text-align: center;
color: #1c6cb2;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
.flight-row {
transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
}
.flight-row:hover {
transform: scale(1.02);
box-shadow: 0 0 10px rgba(28, 108, 178, 0.5);
border-radius: 10px;
}
.flight-info th, .flight-info td {
padding: 10px;
border: 1px solid #ccc;
}
form {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
}
.passenger {
margin-bottom: 20px;
transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
}
.passenger:hover {
transform: scale(1.02);
box-shadow: 0 0 10px rgba(28, 108, 178, 0.5);
border-radius: 10px;
}
.passenger h3 {
margin-top: 0;
}
.delete-btn {
background-color: #ff4d4d;
color: white;
border: none;
cursor: pointer;
padding: 5px 10px;
border-radius: 5px;
float: left;
}
.form-row {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
label {
flex: 1;
margin-right: 10px;
text-align: right;
line-height: 32px;
}
input, select {
flex: 2;
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.error-message {
color: red;
font-size: 12px;
margin-top: 5px;
}
.total-price {
font-size: 18px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 20px;
}
.btn {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
cursor: pointer;
margin-top: 10px;
}
.btn:hover {
background-color: #155a8c;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}

View File

@@ -0,0 +1,237 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
width: 100%;
justify-content: space-between;
}
.logo {
font-size: 24px;
font-weight: bold;
margin-left: 20px;
}
.nav-buttons {
display: flex;
gap: 20px;
}
.nav-buttons a {
color: white;
text-decoration: none;
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.nav-buttons a:hover {
background-color: #155a8c;
}
.user-menu {
position: relative;
display: flex;
align-items: center;
margin-right: 20px;
}
.user-menu span {
margin-right: 10px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: rgba(28, 108, 178, 0.9);
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
right: 0; /* 确保下拉菜单靠右对齐 */
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
main {
flex: 1;
width: 100%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
.slides {
position: relative;
width: 100%;
height: 620px;
overflow: hidden;
}
.slides ul {
display: flex;
padding: 0;
width: 100%;
height: 100%;
list-style: none;
margin: 0;
transition: transform 0.6s ease-in-out;
}
.slides li {
min-width: 100%;
box-sizing: border-box;
}
.slides img {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
text-align: center;
width: 80%;
max-width: 800px;
margin: -170px auto 20px;
position: relative;
}
.tabcontent {
display: block;
padding: 20px;
}
.form-row {
display: flex;
justify-content: flex-start; /* Left-align the form items */
margin-bottom: 15px;
}
.form-row label {
flex: 0 0 120px; /* Fixed width for labels */
margin-right: 10px;
text-align: right;
line-height: 32px;
}
.form-row input,
.form-row select {
flex: 1;
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-row.form-row-center {
justify-content: center; /* Center-align the button */
}
.passenger-input {
display: flex;
align-items: center;
gap: 5px;
}
.passenger-input button {
padding: 5px 10px;
font-size: 18px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.passenger-input button:hover {
background-color: #155a8c;
}
.passenger-input input {
width: 50px;
text-align: center;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.btn {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
cursor: pointer;
}
.btn:hover {
background-color: #155a8c;
}
.error-message {
color: red;
font-size: 12px;
margin-top: 5px;
text-align: left;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}

View File

@@ -0,0 +1,121 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #ffffff;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
}
header {
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px 0;
text-align: center;
width: 100%;
}
main {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
position: relative;
}
.slides {
position: relative;
width: 100%;
height: 600px;
overflow: hidden;
}
.slides ul {
display: flex;
padding: 0;
width: 100%;
height: 100%;
list-style: none;
margin: 0;
transition: transform 0.6s ease-in-out;
}
.slides li {
min-width: 100%;
box-sizing: border-box;
}
.slides img {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
text-align: center;
position: absolute;
}
h2 {
color: #1c6cb2;
}
.login-form {
margin-bottom: 20px;
}
.login-form input {
display: block;
margin: 10px auto;
padding: 10px;
font-size: 16px;
width: 80%;
max-width: 300px;
margin-bottom: 20px; /* 增加外边距 */
}
.buttons {
display: flex;
justify-content: center;
gap: 10px;
}
.login-form button,
.btn {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
line-height: 20px;
cursor: pointer;
}
.login-form button:hover,
.btn:hover {
background-color: #155a8c;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
}
.error-message {
color: red;
font-size: 12px;
text-align: left;
margin-top: -10px;
margin-bottom: 10px;
}

View File

@@ -0,0 +1,149 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
justify-content: space-between;
width: 90%;
margin: 0 auto;
position: relative;
}
.header-content .btn-back {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
}
.header-content .btn-back:hover {
background-color: #155a8c;
}
.header-content h1 {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.header-content .header-spacer {
width: 100px; /* 占位符,确保标题居中 */
}
main {
flex: 1;
width: 80%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
.content {
background-color: rgba(255, 255, 255, 0.9);
padding: 30px;
border-radius: 10px;
text-align: center;
width: 400px;
position: relative;
margin: auto;
}
h2 {
color: #1c6cb2;
}
form {
margin-top: 20px;
}
.tab {
display: flex;
justify-content: space-around;
margin-bottom: 20px;
}
.tab button {
background-color: #f1f1f1;
border: none;
outline: none;
cursor: pointer;
padding: 10px 20px;
transition: 0.3s;
font-size: 17px;
border-radius: 5px;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #1c6cb2;
color: white;
}
.tabcontent {
display: none;
}
.form-group {
margin-bottom: 15px;
text-align: left;
}
.form-group div {
margin-bottom: 5px;
font-weight: bold;
}
.form-group input {
width: 100%;
padding: 10px;
box-sizing: border-box;
}
button[type="submit"] {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
width: 100%;
font-size: 16px;
}
button[type="submit"]:hover {
background-color: #155a8c;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}

View File

@@ -0,0 +1,191 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
width: 100%;
justify-content: space-between;
}
.logo {
font-size: 24px;
font-weight: bold;
margin-left: 20px;
}
.nav-buttons {
display: flex;
gap: 20px;
}
.nav-buttons a {
color: white;
text-decoration: none;
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.nav-buttons a:hover {
background-color: #155a8c;
}
.user-menu {
position: relative;
display: flex;
align-items: center;
margin-right: 20px;
}
.user-menu span {
margin-right: 10px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: rgba(28, 108, 178, 0.9);
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
right: 0;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
main {
flex: 1;
width: 80%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
h2 {
text-align: center;
color: #1c6cb2;
}
.order-info, .passenger-info, .order-summary {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
margin-bottom: 20px;
}
.order-info p, .order-summary p {
margin: 5px 0;
}
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
.btn {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
cursor: pointer;
margin-top: 10px;
}
.btn:hover {
background-color: #155a8c;
}
.cancel-btn {
background-color: #ff4d4d;
}
.cancel-btn:hover {
background-color: #cc0000;
}
.back-btn {
background-color: #f2f2f2;
color: black;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
text-decoration: none;
display: inline-block;
margin: 10px 0;
}
.back-btn:hover {
background-color: #d9d9d9;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}

View File

@@ -0,0 +1,151 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
width: 100%;
justify-content: space-between;
}
.logo {
font-size: 24px;
font-weight: bold;
margin-left: 20px;
}
.nav-buttons {
display: flex;
gap: 20px;
}
.nav-buttons a {
color: white;
text-decoration: none;
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.nav-buttons a:hover {
background-color: #155a8c;
}
.user-menu {
position: relative;
display: flex;
align-items: center;
margin-right: 20px;
}
.user-menu span {
margin-right: 10px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: rgba(28, 108, 178, 0.9);
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
right: 0;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
main {
flex: 1;
width: 80%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
h2 {
text-align: center;
color: #1c6cb2;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}
.order-row {
transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
}
.order-row:hover {
transform: scale(1.02);
box-shadow: 0 0 10px rgba(28, 108, 178, 0.5);
border-radius: 10px;
}

View File

@@ -0,0 +1,251 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
min-height: 100vh;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(28, 108, 178, 0.9);
color: white;
padding: 20px;
width: 100%;
position: fixed;
top: 0;
z-index: 1000;
}
.header-content {
display: flex;
align-items: center;
width: 100%;
justify-content: space-between;
}
.logo {
font-size: 24px;
font-weight: bold;
margin-left: 20px;
}
.nav-buttons {
display: flex;
gap: 20px;
}
.nav-buttons a {
color: white;
text-decoration: none;
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.nav-buttons a:hover {
background-color: #155a8c;
}
.user-menu {
position: relative;
display: flex;
align-items: center;
margin-right: 20px;
}
.user-menu span {
margin-right: 10px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: rgba(28, 108, 178, 0.9);
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
right: 0; /* 确保下拉菜单靠右对齐 */
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
main {
flex: 1;
width: 80%;
margin: 20px auto;
padding-top: 80px; /* 给主内容增加顶部填充,以避免被固定导航栏遮挡 */
}
h2 {
text-align: center;
color: #1c6cb2;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
table, th, td {
border: 1px solid #ccc;
}
th, td {
padding: 10px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
.no-results {
text-align: center;
color: red;
font-size: 18px;
margin-top: 20px;
}
footer {
background-color: rgba(28, 108, 178, 0.9);
color: white;
text-align: center;
padding: 10px 0;
width: 100%;
position: relative;
margin-top: auto; /* 将footer推到页面底部 */
}
.content {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
border-radius: 10px;
text-align: center;
width: 80%;
max-width: 800px;
margin: 20px auto;
position: relative;
}
.tabcontent {
display: block;
padding: 20px;
}
.form-row {
display: flex;
justify-content: flex-start; /* Left-align the form items */
margin-bottom: 15px;
}
.form-row label {
flex: 0 0 120px; /* Fixed width for labels */
margin-right: 10px;
text-align: right;
line-height: 32px;
}
.form-row input,
.form-row select {
flex: 1;
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-row.form-row-center {
justify-content: center; /* Center-align the button */
}
.passenger-input {
display: flex;
align-items: center;
gap: 5px;
}
.passenger-input button {
padding: 5px 10px;
font-size: 18px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.passenger-input button:hover {
background-color: #155a8c;
}
.passenger-input input {
width: 50px;
text-align: center;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
.btn {
padding: 10px 20px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
text-decoration: none;
display: inline-block;
cursor: pointer;
}
.btn:hover {
background-color: #155a8c;
}
.error-message {
color: red;
font-size: 12px;
margin-top: 5px;
text-align: left;
}
/* Add animations for flight rows */
.flight-row {
transition: transform 0.3s ease, box-shadow 0.3s ease, border-radius 0.3s ease;
}
.flight-row:hover {
transform: scale(1.02);
box-shadow: 0 0 10px rgba(28, 108, 178, 0.5);
border-radius: 10px;
}

View File

@@ -0,0 +1,71 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #ffffff;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
}
form {
background-color: rgba(255, 255, 255, 0.9);
padding: 40px; /* 增加内边距 */
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px; /* 增大表单框的最大宽度 */
margin: auto;
margin-top: 100px;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
margin-bottom: 20px;
}
div {
display: flex;
flex-direction: column;
}
div div {
flex: 1;
padding-top: 5px;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background-color: #1c6cb2;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background-color: #155a8c;
}
.error-message {
color: red;
font-size: 12px;
height: 12px;
margin-top: 5px;
}

View File

@@ -0,0 +1,15 @@
var checkInfo = {};
checkInfo.checkMobileNo = function() {
let mobileNo = document.getElementById('mobileNo').value;
let regexMobileNo = /^1[3-9]\d{9}$/;
return regexMobileNo.test(mobileNo);
}
checkInfo.checkPassword = function() {
let password = document.getElementById('password').value;
let regexPassword = /^[A-Za-z0-9\W_]{6,20}$/;
let isValidPassword = regexPassword.test(password);
let confirmPassword = document.getElementById('confirmPassword').value;
return isValidPassword && (password === confirmPassword);
}

View File

@@ -0,0 +1,29 @@
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
function increment() {
var passengers = document.getElementById("passengers");
var value = parseInt(passengers.value, 10);
if (value < 50) {
passengers.value = value + 1;
}
}
function decrement() {
var passengers = document.getElementById("passengers");
var value = parseInt(passengers.value, 10);
if (value > 1) {
passengers.value = value - 1;
}
}

View File

@@ -0,0 +1,81 @@
window.onload = function() {
autoLogin();
};
var checkInfo = {};
checkInfo.checkMobileNo = function() {
let mobileNo = document.getElementById('mobileNo').value;
let regexMobileNo = /^1[3-9]\d{9}$/;
if (!regexMobileNo.test(mobileNo)) {
document.getElementById('mobileNoError').textContent = '手机号格式有误';
return false;
}
document.getElementById('mobileNoError').textContent = '';
return true;
}
checkInfo.checkPassword = function() {
let password = document.getElementById('password').value;
let regexPassword = /^[A-Za-z0-9\W_]{6,20}$/;
if (!regexPassword.test(password)) {
document.getElementById('loginError').textContent = "密码须为长度为6-20位字母、数字或符号";
return false;
}
document.getElementById('loginError').textContent = '';
return true;
}
function submitForm() {
if (checkInfo.checkMobileNo() && checkInfo.checkPassword()) {
document.getElementById('encryptedPassword').value = md5(
document.getElementById('password').value
);
login();
return true;
}
return false;
}
// 登录函数
async function login() {
const mobileNo = document.getElementById('mobileNo').value;
const encryptedPassword = document.getElementById('encryptedPassword').value;
try {
const response = await fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username: mobileNo, password: encryptedPassword }),
credentials: 'include' // 确保请求包含凭据cookies
});
const data = await response.json();
if (response.ok) {
alert('登录成功');
// 自动跳转到主页
window.location.href = data.redirect;
} else {
document.getElementById('loginError').textContent = data.message;
}
} catch (error) {
alert('数据库错误,请稍后再试');
}
}
// 自动登录函数
async function autoLogin() {
const token = localStorage.getItem('token');
if (token) {
const response = await fetch('http://localhost:5000/index', {
headers: {
'Authorization': 'Bearer ' + token
}
});
if (response.ok) {
document.getElementById('content').innerText = '已自动登录';
} else {
document.getElementById('content').innerText = '自动登录失败';
}
}
}

View File

@@ -0,0 +1,31 @@
var modify = {};
modify.showModifyPassword = function() {
let modifyType = document.querySelector('.tablinks.active').textContent;
let info = {
modifyPasswordLis: document.getElementsByClassName('modifyPassword'),
modifymobileNoLis: document.getElementsByClassName('modifymobileNo'),
modifyUsernameLis: document.getElementsByClassName('modifyUsername'),
}
for (let key in info) {
let elements = info[key];
for (let item of elements) {
item.style.display = 'none';
}
}
if (modifyType === "修改密码") {
for (let item of info.modifyPasswordLis) {
item.style.display = 'block';
}
} else if (modifyType === "修改手机号") {
for (let item of info.modifymobileNoLis) {
item.style.display = 'block';
}
} else if (modifyType === "修改用户名") {
for (let item of info.modifyUsernameLis) {
item.style.display = 'block';
}
}
}

View File

@@ -0,0 +1,42 @@
function validateForm() {
var departure = document.getElementById('departure').value;
var destination = document.getElementById('destination').value;
var warning = document.getElementById('destination-warning');
if (departure === destination) {
warning.textContent = '出发地和目的地不能相同';
return false;
} else {
warning.textContent = '';
}
return true;
}
function increment() {
var passengers = document.getElementById("passengers");
var value = parseInt(passengers.value, 10);
if (value < 50) {
passengers.value = value + 1;
}
}
function decrement() {
var passengers = document.getElementById("passengers");
var value = parseInt(passengers.value, 10);
if (value > 1) {
passengers.value = value - 1;
}
}
document.addEventListener('DOMContentLoaded', function() {
// Set default date to tomorrow
var departureDate = document.getElementById('departure-date');
if (!departureDate.value) {
var today = new Date();
var tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
var month = ('0' + (tomorrow.getMonth() + 1)).slice(-2);
var day = ('0' + tomorrow.getDate()).slice(-2);
var year = tomorrow.getFullYear();
departureDate.value = `${year}-${month}-${day}`;
}
});

View File

@@ -0,0 +1,32 @@
function submitForm() {
let isValid = true;
clearErrors();
if (!checkInfo.checkMobileNo()) {
document.getElementById('mobileNoError').innerText = '手机号格式有误';
isValid = false;
}
if (!checkInfo.checkPassword()) {
document.getElementById('passwordError').innerText = '密码须为长度为6-20位字母、数字或符号';
document.getElementById('confirmPasswordError').innerText = '两次输入的密码不一致';
isValid = false;
}
if (isValid) {
document.getElementById('encryptedPassword').value = md5(
document.getElementById('password').value
);
document.getElementById('encryptedConfirmPassword').value = md5(
document.getElementById('confirmPassword').value
);
return true;
}
return false;
}
function clearErrors() {
document.getElementById('mobileNoError').innerText = '';
document.getElementById('passwordError').innerText = '';
document.getElementById('confirmPasswordError').innerText = '';
}

View File

@@ -0,0 +1,14 @@
let slideIndex = 0;
const slides = document.getElementById('slide-container');
const totalSlides = slides.children.length;
function showSlides() {
slideIndex++;
if (slideIndex >= totalSlides) {
slideIndex = 0;
}
slides.style.transform = 'translateX(' + (-slideIndex * 100) + '%)';
setTimeout(showSlides, 5000); // Change image every 5 seconds
}
showSlides();