Merge pull request '代码及文档' (#1) from chenyonghang_branch into master

pull/5/head
m94fc2tgb 6 months ago
commit ebf212d8d3

@ -0,0 +1,48 @@
body{
background-image: url(.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
width: 100%;
}
/* 样式化表格 */
table {
border-collapse: collapse; /* 合并边框 */
width: 90%; /* 表格宽度 */
margin: auto; /* 居中显示 */
}
th, td {
border: 1px solid #dddddd; /* 单元格边框 */
text-align: center; /* 文本居中 */
padding: 8px; /* 内边距 */
}
th {
background-color: #6f9775; /* 表头背景色 */
}
tr:nth-child(even) {
background-color: #887070; /* 斑马线条纹效果 */
}
tr:nth-child(odd) {
background-color: #5c61a8;
}
.a{
background-color: #4126a5; /* 设置按钮的背景颜色 */
color: white; /* 设置文本颜色 */
padding: 10px 20px; /* 设置内边距 */
border: none; /* 移除边框 */
border-radius: 5px; /* 设置边框圆角 */
cursor: pointer; /* 设置鼠标光标为指针形状 */
font-size: 16px; /* 设置字体大小 */
}
input.b{
border: 1px solid #041100;
border-radius: 5px;
text-align: center;
background-color: #c5d1cf;
color: #140000;
width: 150px;
height: 40px;
}

@ -0,0 +1,270 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel=" stylesheet" href="./jiemian.css">
<h1>主页面</h1>
<button class = "a" onclick = "pose()">全部药品</button>
<h1></h1>
<button class = "a" onclick="Find()">查找药品</button>
<input id = "6" type = "text" class = "b" placeholder="被查找药品的序号"></input>
<input id = "7" type = "text" class = "b" placeholder="被查找药品的类型"></input>
<input id = "8" type = "text" class = "b" placeholder="被查找药品的药名"></input>
<input id = "9" type = "text" class = "b" placeholder="被查找药品的价格"></input>
<input id = "10" type = "text" class = "b" placeholder="被查找药品的库存"></input>
<h1></h1>
<button class = "a" onclick="chance()">修改药品信息</button>
<input id = "1" type = "text" class = "b" placeholder="待修改药品的序号"></input>
<input id = "2" type = "text" class = "b" placeholder="将类型修改为"></input>
<input id = "3" type = "text" class = "b" placeholder="将药名修改为"></input>
<input id = "4" type = "text" class = "b" placeholder="将价格修改为"></input>
<input id = "5" type = "text" class = "b" placeholder="将库存修改为"></input>
<h1></h1>
<button class = "a" onclick="deletea()">删除药品</button>
<input id = "11" type = "text" class = "b" placeholder="待删除药品的序号(必填项)"></input>
<input id = "12" type = "text" class = "b" placeholder="待删除药品的药名(可不填)"></input>
<h1></h1>
<table id="yaopindan">
<thead>
<tr>
<th>序号</th>
<th>类型</th>
<th>药名</th>
<th>价格</th>
<th>库存</th>
</tr>
</thead>
</table>
</head>
<body>
<script>
function Find(){
var id1 = document.getElementById("6").value.trim();
var type1 = document.getElementById("7").value.trim();
var name1 = document.getElementById("8").value.trim();
var price1 = document.getElementById("9").value.trim();
var amount1 = document.getElementById("10").value.trim();
// if (type1==""){
// type1=null;
// }
// if (name1==''){
// name1=null;
// }
// if (amount1==''){
// amount1==null;
// }
// if (id1==''){
// id1=null;
// }
// if (price1==''){
// price1=null;
// }
// if (id1==null && type1==null && name1==null && price1==null && amount1==null ){
// alert("没有收到要查询的药品信息,请输入要查找的药品的相关信息!!!");
// }
// else{
console.log(id1,type1,name1,price1,amount1);
const requestBody = {"wenti":2,"id":parseInt(id1),"type":type1,"name":name1,"price":parseFloat(price1),"amount":parseInt(amount1)};
fetch('http://localhost:3000', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // 设置请求头为JSON
},
body: JSON.stringify(requestBody) // 将请求体转换为JSON字符串
})
.then(response =>
response.json())
.then(data => {
var table = document.getElementById("yaopindan");
for (ii=1;ii<table.rows.length;ii++){
var ia = table.rows[ii];
ia.innerHTML = '';
}
for (i=0;i<data.length;i++){
console.log(data[i]);
var row = table.insertRow();
var cell1 = row.insertCell(0);
cell1.innerHTML = data[i].id;
var cell2 = row.insertCell(1);
cell2.innerHTML = data[i].type;
var cell3 = row.insertCell(2);
cell3.innerHTML = data[i].name;
var cell4 = row.insertCell(3);
cell4.innerHTML = data[i].price;
var cell5 = row.insertCell(4);
cell5.innerHTML = data[i].amount;
}
}) // 打印服务器返回的数据
.catch(error => console.error('Error:', error)); // 捕获并打印错误信息
}
// }
function chance(){
var id2 = document.getElementById("1").value.trim();
var type2 = document.getElementById("2").value.trim();
var name2 = document.getElementById("3").value.trim();
var price2 = document.getElementById("4").value.trim();
var amount2 = document.getElementById("5").value.trim();
if (type2==''){
type2=null;
}
if (name2==''){
name2=null;
}
if (id2 ==''){
id2=null;
}
console.log(id2,type2,name2,price2,amount2);
if (id2 ==null){
alert("请输入要更改药品的序号!!!");
}
else{
const requestBody = {"wenti":3,"id":parseInt(id2),"type":type2,"name":name2,"price":parseFloat(price2),"amount":parseInt(amount2)};
console.log(JSON.stringify(requestBody));
fetch('http://localhost:3000', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // 设置请求头为JSON
},
body: JSON.stringify(requestBody) // 将请求体转换为JSON字符串
})
.then(response =>
response.json())
.then(data => {
var table = document.getElementById("yaopindan");
for (ii=1;ii<table.rows.length;ii++){
var ia = table.rows[ii];
ia.innerHTML = '';
}
for (i=0;i<data.length;i++){
console.log(data[i]);
var row = table.insertRow();
var cell1 = row.insertCell(0);
cell1.innerHTML = data[i].id;
var cell2 = row.insertCell(1);
cell2.innerHTML = data[i].type;
var cell3 = row.insertCell(2);
cell3.innerHTML = data[i].name;
var cell4 = row.insertCell(3);
cell4.innerHTML = data[i].price;
var cell5 = row.insertCell(4);
cell5.innerHTML = data[i].amount;
}
}) // 打印服务器返回的数据
.catch(error => console.error('Error:', error)); // 捕获并打印错误信息
}
}
function pose(){
const requestBody = {wenti:1,name:"陈永杭"};
fetch('http://localhost:3000', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // 设置请求头为JSON
},
body: JSON.stringify(requestBody) // 将请求体转换为JSON字符串
})
.then(response =>
response.json())
.then(data => {
var table = document.getElementById("yaopindan");
for (ii=1;ii<table.rows.length;ii++){
var ia = table.rows[ii];
ia.innerHTML = '';
}
for (i=0;i<data.length;i++){
console.log(data[i]);
var row = table.insertRow();
var cell1 = row.insertCell(0);
cell1.innerHTML = data[i].id;
var cell2 = row.insertCell(1);
cell2.innerHTML = data[i].type;
var cell3 = row.insertCell(2);
cell3.innerHTML = data[i].name;
var cell4 = row.insertCell(3);
cell4.innerHTML = data[i].price;
var cell5 = row.insertCell(4);
cell5.innerHTML = data[i].amount;
}
}) // 打印服务器返回的数据
.catch(error => console.error('Error:', error)); // 捕获并打印错误信息
}
function deletea(){
var id3 = document.getElementById("11").value.trim();
var name3 = document.getElementById("12").value.trim();
if (id3 == ''){
id3 = null;
}
if (name3 == ''){
name3 =null;
}
if (id3 == null){
alert("请输入要删除药品的序号(必填项)!!!");
}
else{
const requestBody = {"wenti":4,"id":parseInt(id3),"name":name3};
console.log(requestBody);
fetch('http://localhost:3000', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // 设置请求头为JSON
},
body: JSON.stringify(requestBody) // 将请求体转换为JSON字符串
})
.then(response =>
response.json())
.then(data => {
var table = document.getElementById("yaopindan");
for (ii=1;ii<table.rows.length;ii++){
var ia = table.rows[ii];
ia.innerHTML = '';
}
for (i=0;i<data.length;i++){
console.log(data[i]);
var row = table.insertRow();
var cell1 = row.insertCell(0);
cell1.innerHTML = data[i].id;
var cell2 = row.insertCell(1);
cell2.innerHTML = data[i].type;
var cell3 = row.insertCell(2);
cell3.innerHTML = data[i].name;
var cell4 = row.insertCell(3);
cell4.innerHTML = data[i].price;
var cell5 = row.insertCell(4);
cell5.innerHTML = data[i].amount;
}
}) // 打印服务器返回的数据
.catch(error => console.error('Error:', error)); // 捕获并打印错误信息
}
}
pose();
</script>
</body>
</html>

@ -0,0 +1,427 @@
const express = require('express');
const app = express();
const mysql = require('mysql');
const http = require('http');
const querystring = require('querystring');
function dj(){
}
// 创建连接对象
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
// 开启连接
connection.connect();
var asd=' ';
// 执行查询
connection.query('Select * from 账户;', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
asd = results;
console.log(results);
});
// 关闭连接
connection.end();
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', 'http://127.0.0.1:5500'); // 替换为您的前端应用域名
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.setHeader("Content-Security-Policy", "default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'")
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
app.get('/', (req, res) => {
if (req.method === 'POST'){
console.log("ssssssssss");
let body = '';
req.on('data', chunk => {
body += chunk.toString(); // 转换为字符串
});
req.on('end', () => {
// 解析POST参数
const postParams = querystring.parse(body);
// 处理POST参数
console.log('POST parameters:', postParams);
// res.writeHead(OK, {'Content-Type': 'application/json'});
const responseData = { message: 'POST request received' };
// 发送响应数据
res.end(JSON.stringify(responseData));
});
}else{
res.send(asd);
console.log(req.method);
console.log("hello");
console.log(req.method);
}
// res.send(asd);
// console.log("hello")
});
const server = http.createServer((req,res) =>{
if (req.method === 'GET'){
res.end(asd);
console.log(req.method);
console.log("hello");
console.log(req.method);
}
});
app.post('/', (req, res) => {
if (req.method === 'POST'){
console.log("ssssssssss");
let body = '';
req.on('data', chunk => {
body += chunk.toString(); // 转换为字符串
});
req.on('end', () => {
// 解析POST参数
console.log(body);
const postParams = JSON.parse(body);
// 处理POST参数
console.log('POST parameters:', postParams);
var abc = ' ';
if (postParams.wenti == 1){
console.log("查询药库。");
console.log(postParams);
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
connection.connect();
connection.query('Select * from 主页面 '+';', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
abc = results;
res.writeHead(200, {'Content-Type': 'application/json'});
const responseData = abc ;
// 发送响应数据
res.end(JSON.stringify(responseData));
console.log(JSON.stringify(responseData));
});
connection.end();
}
if (postParams.wenti ==2){
console.log("查找药品。");
// console.log(postParams);
// var as = String(postParams.id);
// console.log(as);
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
var sortnum = 0;
findid1='';
if (postParams.id!=null){
console.log(postParams.id);
findid1+=' where id = ';
findid1+=String(postParams.id);
sortnum++;
}
findtype1='';
if (postParams.type!=null){
console.log(postParams.type);
if (sortnum!=0){
findtype1+=' and ';
findtype1+=' type like ';
findtype1+='"%'+String(postParams.type)+'%"';
sortnum++;
console.log(findtype1);
}
else{
findtype1+=' where type like ';
findtype1+='"%'+String(postParams.type)+'%"';
sortnum++;
}
}
findname1='';
if(postParams.name!=null){
console.log(postParams.name);
if (sortnum!=0){
findname1+=' and ';
findname1+=' name like ';
findname1+='"%'+String(postParams.name)+'%"';
sortnum++;
}
else{
findname1+=' where name like ';
findtype1+='"%'+String(postParams.name)+'%"';
sortnum++;
}
}
findprice1='';
if (postParams.price!=null){
console.log(postParams.price);
if (sortnum!=0){
findprice1+=' and ';
findprice1+=' price = ';
findprice1+=String(postParams.price);
sortnum++;
}
else{
findprice1+=' where price = ';
findprice1+=String(postParams.price);
sortnum++;
}
}
findamount1='';
if (postParams.amount!=null){
if (sortnum!=0){
findamount1+=' and ';
findamount1+=' amount =';
findamount1+=String(postParams.amount);
sortnum++;
}
else{
findamount1+=' where amount = ';
findamount1+=String(postParams.amount);
sortnum++;
}
}
connection.connect();
connection.query('Select * from 主页面'+findid1+findtype1+findname1+findprice1+findamount1+';', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
abc = results;
res.writeHead(200, {'Content-Type': 'application/json'});
const responseData = abc ;
// 发送响应数据
res.end(JSON.stringify(responseData));
console.log(JSON.stringify(responseData));
});
connection.end();
}
if (postParams.wenti ==3){
console.log("修改药品信息。");
console.log(postParams);
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
// connection.query('Select * from 主页面 '+';', (error, results, fields) => {
// if (error) throw error;
// console.log(results);
// // 处理查询结果
// });
if (postParams.type==null && postParams.name==null && postParams.price==null && postParams.amount==null ){
console.log('没有说明要修改的字段');
}
else{
sortnum2=0;
findid2 = '';
findid2 = String(postParams.id);
findtype2 = '';
if (postParams.type != null){
findtype2 += ' type = ';
findtype2 += ' "'+String(postParams.type)+'" ';
sortnum2++;
}
findname2 = '';
if (postParams.name != null){
if (sortnum2 == 0){
findname2 += 'name =';
findname2 += ' "'+String(postParams.name)+'" ';
sortnum2++;
}
else{
findname2 += ' , ';
findname2 += 'name =';
findname2 += ' "'+String(postParams.name)+'" ';
sortnum2++;
}
}
findprice2 = '';
if (postParams.price != null){
if (sortnum2 == 0){
findprice2 += 'price = ';
findprice2 += ' "'+String(postParams.price)+'" ';
sortnum2++;
}
else{
findprice2 += ' , ';
findprice2 += 'price = ';
findprice2 += ' "'+String(postParams.price)+'" ';
sortnum2++;
}
}
findamount2 = '';
if (postParams.amount != null){
if (sortnum2 == 0){
findamount2 += 'amount = ';
findamount2 += ' "'+String(postParams.amount)+'" ';
sortnum2++;
}
else{
findamount2 += ' , ';
findamount2 += 'amount = ';
findamount2 += ' "'+String(postParams.amount)+'" ';
sortnum2++;
}
}
if (sortnum2 != 0){
connection.query(' update 主页面 set ' + findtype2 + findname2 + findprice2 + findamount2 +' where id = '+findid2+';', (error, results, fields) => {
if (error) throw error;
console.log(results);
// 处理查询结果
});
}
}
connection.query('Select * from 主页面 '+';', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
abc = results;
res.writeHead(200, {'Content-Type': 'application/json'});
const responseData = abc ;
// 发送响应数据
res.end(JSON.stringify(responseData));
console.log(JSON.stringify(responseData));
console.log(results.length)
});
connection.end();
}
if (postParams.wenti ==4){
console.log("删除药品。");
console.log(postParams);
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
sortnum3 = 0;
if (postParams.id == null){
console.log('没有待删除的药品的序号');
}
else{
findid3 = ' where id = ';
if (postParams.id != null){
findid3 += String(postParams.id);
findid3 += ' ';
sortnum3++;
}
findname3 = '';
if (postParams.name != null){
if (sortnum3 != 0){
findname3 += ' and ';
findname3 += ' name = ';
findname3 += ' "';
findname3 += String(postParams.name);
findname3 += '" ';
}
}
connection.query(' delete from 主页面 ' + findid3 + findname3+';', (error, results, fields) => {
if (error) throw error;
console.log(results);
// 处理查询结果
});
}
connection.query('Select * from 主页面 '+';', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
abc = results;
res.writeHead(200, {'Content-Type': 'application/json'});
const responseData = abc ;
// 发送响应数据
res.end(JSON.stringify(responseData));
console.log(JSON.stringify(responseData));
console.log(results.length)
});
connection.end();
}
if (postParams.wenti == 5){
console.log("添加药品。");
console.log(postParams);
const connection = mysql.createConnection({
host: 'localhost', // 数据库服务器地址
user: 'root', // 数据库用户名
password: 'CYH123456', // 数据库密码
database: 'cyh1' // 要连接的数据库名
});
findid4 = String(postParams.id);
findtype4 = '"' + String(postParams.type)+ '"';
findname4 = '"' + String(postParams.name)+ '"';
findprice4 = String(postParams.price);
findamount4 = String(postParams.amount);
console.log(' insert into 主页面 values ('+ findid4 + ',' + findtype4 + ',' + findname4 + ',' + findprice4 + ',' + findamount4 +');');
connection.query(' insert into 主页面 values ('+ findid4 + ',' + findtype4 + ',' + findname4 + ',' + findprice4 + ',' + findamount4 +');', (error, results, fields) => {
if (error) throw error;
console.log(results);
// 处理查询结果
});
connection.query('Select * from 主页面 '+';', (error, results, fields) => {
if (error) throw error;
// 处理查询结果
abc = results;
res.writeHead(200, {'Content-Type': 'application/json'});
const responseData = abc ;
// 发送响应数据
res.end(JSON.stringify(responseData));
console.log(JSON.stringify(responseData));
});
connection.end();
}
// res.writeHead(200, {'Content-Type': 'application/json'});
// const responseData = {name:'POST request received'} ;
// // 发送响应数据
// res.end(JSON.stringify(responseData));
// console.log(JSON.stringify(responseData));
});
}
});
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

@ -0,0 +1,66 @@
h1{
font-family: "Arial", sans-serif;
text-align:center;
color: #0c1c3be7;
}
body{
background-image: url(.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
width: 100%;
}
/* input[type='text'] {
display:block;
margin: 0 auto;
text-align:center;
} */
.a{
display: flex;
align-items: center;
justify-content: center;
height:100%
}
input.custom-name-box {
width: 400px;
height: 40px;
text-align: center;
box-sizing: border-box;
border: 1px solid #dcdfe6;
border-radius: 4px;
outline: none;
padding: 0 15px;
color: #606266;
}
input.custom-name-box:focus {
border-color: #409eff;
}
input.custom-mima-box {
width: 400px;
height: 40px;
text-align: center;
box-sizing: border-box;
border: 1px solid #dcdfe6;
border-radius: 4px;
outline: none;
padding: 0 15px;
color: #010c0c;
}
input.custom-mima-box:focus {
border-color: #409eff;
}
::-webkit-input-placeholder {
color: #141518;
}
.button{
position: absolute;
top: 70%;
left: 49%;
}

@ -0,0 +1,27 @@
const button = document.getElementById('3');
button.addEventListener('click',function(){
const name = document.getElementById("1").value;
const mima = document.getElementById("2").value;
if (name != "" && mima != ""){
const zhanghao=confirm("确认密码:" + name + "\n" +
"确认密码:" + mima);
if (zhanghao){
console.log(name);
console.log(mima);
}else{
document.getElementById("1").value = null;
document.getElementById("2").value = null;
}
}
if (name == "" || mima == ""){
alert("请完整输入用户名和密码!!!");
}
})
function ID(name,mima){
}

@ -0,0 +1,202 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录界面</title>
<link rel=" stylesheet" href="./登录界面.css">
<h1>请登录您的账号</h1>
<!-- <script>
// function fetchLocalData(name,mima) {
// fetch('http://localhost:3000')
// .then(response => response.json())
// .then(data => {
// console.log(name);
// console.log(mima);
// alert(data[0].用户名 + "\n"+ data[0].密码);
// })
// .catch(error => console.error('Error:', error));
// }
function load(){
const name = document.getElementById("1").value;
const mima = document.getElementById("2").value;
if (name != "" && mima != ""){
const zhanghao=confirm("确认密码:" + name + "\n" +
"确认密码:" + mima);
if (zhanghao){
console.log(name);
console.log(mima);
fetch('http://localhost:3000')
.then(response => response.json())
.then(data => {
console.log(name);
console.log(mima);
for (i=0;i<data.length;i++){
console.log(data[i])
}
})
.catch(error => console.error('Error:', error));
// fetchLocalData(name,mima);
}else{
document.getElementById("1").value = null;
document.getElementById("2").value = null;
}
}
if (name == "" || mima == ""){
alert("请完整输入用户名和密码!!!");
}
}
</script> -->
</head>
<body>
<div class="background"></div>
<div class="a">
<input id = "1" type = "text" class="custom-name-box" placeholder="请输入用户名"></input>
<input id = "2" type = "text" class="custom-mima-box" placeholder="请输入密码"></input>
<button id = "3" type = "button" class="button" onclick="load()">登录</button>
</div>
<!-- <script type = "module" src = '登录界面.js'></script> -->
<script>
function load(){
const name = document.getElementById("1").value;
const mima = document.getElementById("2").value;
if (name != "" && mima != ""){
const zhanghao=confirm("确认密码:" + name + "\n" +
"确认密码:" + mima);
if (zhanghao){
console.log(name);
console.log(mima);
var aai = 0;
fetch('http://localhost:3000')
.then(response => response.json())
.then(data => {
console.log(name);
console.log(mima);
var i = 0;
for (i=0;i<data.length;i++){
console.log(data[i])
if (name == data[i].用户名 && mima == data[i].密码){
aai=1;
const zhano=confirm("登录成功!!!");
if (zhano){
console.log(aai);
window.location.href = "jiemian.html";
}
break;
}
}
alert("用户名或者密码错误!!!");
})
.catch(error => console.error('Error:', error));
console.log(aai);
// fetchLocalData(name,mima);
}else{
document.getElementById("1").value = null;
document.getElementById("2").value = null;
}
}
if (name == "" || mima == ""){
alert("请完整输入用户名和密码!!!");
}
}
</script>
<!-- <script>
var hh = " ";
function fetchLocalData() {
fetch('http://localhost:3000')
.then(response => response.json())
.then(data => {
// console.log(data[0].用户名 + "\n"+
// data[0].密码);
// // 处理获取的数据
hh = data;
})
.catch(error => console.error('Error:', error));
}
function load(){
const name = document.getElementById("1").value;
const mima = document.getElementById("2").value;
if (name != "" && mima != ""){
const zhanghao=confirm("确认密码:" + name + "\n" +
"确认密码:" + mima);
if (zhanghao){
console.log(name);
console.log(mima);
var hh = " ";
fetchLocalData();
console.log(hh);
}else{
document.getElementById("1").value = null;
document.getElementById("2").value = null;
}
}
if (name == "" || mima == ""){
alert("请完整输入用户名和密码!!!");
}
}
// const button = document.getElementById('3');
// button.addEventListener('click',function(){
// const name = document.getElementById("1").value;
// const mima = document.getElementById("2").value;
// if (name != "" && mima != ""){
// const zhanghao=confirm("确认密码:" + name + "\n" +
// "确认密码:" + mima);
// if (zhanghao){
// console.log(name);
// console.log(mima);
// var hh = " ";
// fetchLocalData();
// console.log(hh);
// }else{
// document.getElementById("1").value = null;
// document.getElementById("2").value = null;
// }
// }
// if (name == "" || mima == ""){
// alert("请完整输入用户名和密码!!!");
// }
// })
</script> -->
</body>
</html>
Loading…
Cancel
Save