ADD file via upload

master
m94fc2tgb 5 months ago
parent 5f08ef76d0
commit ac09d15c04

@ -0,0 +1,180 @@
<!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="./load.css">
<h1>药品管理系统</h1>
<h2 id="H1">请登录您的账号</h2>
</head>
<body>
<div id="Load" class="deng">
<h1>登录</h1>
<h1></h1>
<div class="group">
<input id="1" required="" type="text" class="input">
<span class="highlight"></span>
<span class="bar"></span>
<label>用户名</label>
</div>
<h1></h1>
<div class="group">
<input id="2" required="" type="text" class="input">
<span class="highlight"></span>
<span class="bar"></span>
<label>密码</label>
</div>
<h1></h1>
<button type = "button" class="button-name" onclick="load()">登 录</button>
<!-- <button type = "button" class="button-name" onclick="add()">注册</button> -->
<h1>没有账号?点击注册!</h1>
<button class="Btn" onclick="dd()">
注册
<svg viewBox="0 0 512 512" class="svg">
<path
d="M410.3 231l11.3-11.3-33.9-33.9-62.1-62.1L291.7 89.8l-11.3 11.3-22.6 22.6L58.6 322.9c-10.4 10.4-18 23.3-22.2 37.4L1 480.7c-2.5 8.4-.2 17.5 6.1 23.7s15.3 8.5 23.7 6.1l120.3-35.4c14.1-4.2 27-11.8 37.4-22.2L387.7 253.7 410.3 231zM160 399.4l-9.1 22.7c-4 3.1-8.5 5.4-13.3 6.9L59.4 452l23-78.1c1.4-4.9 3.8-9.4 6.9-13.3l22.7-9.1v32c0 8.8 7.2 16 16 16h32zM362.7 18.7L348.3 33.2 325.7 55.8 314.3 67.1l33.9 33.9 62.1 62.1 33.9 33.9 11.3-11.3 22.6-22.6 14.5-14.5c25-25 25-65.5 0-90.5L453.3 18.7c-25-25-65.5-25-90.5 0zm-47.4 168l-144 144c-6.2 6.2-16.4 6.2-22.6 0s-6.2-16.4 0-22.6l144-144c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6z"
></path>
</svg>
</button>
</div>
<div id="Add" class="deng1" style="display: none;">
<h1>注册</h1>
<h1></h1>
<div class="group">
<input id="3" required="" type="text" class="input">
<span class="highlight"></span>
<span class="bar"></span>
<label>用户名</label>
</div>
<h1></h1>
<div class="group">
<input id="4" required="" type="text" class="input">
<span class="highlight"></span>
<span class="bar"></span>
<label>密码</label>
</div>
<h1></h1>
<button type = "button" class="button-name" onclick="add()">注册</button>
<!-- <button type = "button" class="button-name" onclick="add()">注册</button> -->
<h1>已有账号?点击登录!</h1>
<button class="Btn" onclick="bb()">
登录
<svg viewBox="0 0 512 512" class="svg">
<path
d="M410.3 231l11.3-11.3-33.9-33.9-62.1-62.1L291.7 89.8l-11.3 11.3-22.6 22.6L58.6 322.9c-10.4 10.4-18 23.3-22.2 37.4L1 480.7c-2.5 8.4-.2 17.5 6.1 23.7s15.3 8.5 23.7 6.1l120.3-35.4c14.1-4.2 27-11.8 37.4-22.2L387.7 253.7 410.3 231zM160 399.4l-9.1 22.7c-4 3.1-8.5 5.4-13.3 6.9L59.4 452l23-78.1c1.4-4.9 3.8-9.4 6.9-13.3l22.7-9.1v32c0 8.8 7.2 16 16 16h32zM362.7 18.7L348.3 33.2 325.7 55.8 314.3 67.1l33.9 33.9 62.1 62.1 33.9 33.9 11.3-11.3 22.6-22.6 14.5-14.5c25-25 25-65.5 0-90.5L453.3 18.7c-25-25-65.5-25-90.5 0zm-47.4 168l-144 144c-6.2 6.2-16.4 6.2-22.6 0s-6.2-16.4 0-22.6l144-144c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6z"
></path>
</svg>
</button>
</div>
<!-- <button id = "3" type = "button" class="button-name" onclick="load()">登录</button>
<button id = "4" type = "button" class="button-name" onclick="add()">注册</button> -->
</body>
<script>
function dd(){
document.getElementById("Load").style.display='none';
document.getElementById("Add").style.display='flex';
document.getElementById('H1').innerHTML='注册您的账号';
}
function bb(){
document.getElementById("Load").style.display='flex';
document.getElementById("Add").style.display='none';
document.getElementById('H1').innerHTML='请登录您的账号';
}
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;
var loadd = 0;
for (i=0;i<data.length;i++){
console.log(data[i])
if (name == data[i].用户名 && mima == data[i].密码){
aai=1;
const zhano=confirm("登录成功!!!");
loadd = 1;
if (zhano){
console.log(aai);
window.location.href = "../Backend-services/frame.html";
}
break;
}
}
if (loadd == 0){
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("请完整输入用户名和密码!!!");
}
}
function add(){
const name = document.getElementById("1").value;
const mima = document.getElementById("2").value;
console.log({name,mima});
if (name == "" || mima == ""){
alert("请输入完整的用户名和密码!!!");
}
else{
const zhanghao=confirm("确认密码:" + name + "\n" +"确认密码:" + mima);
if (zhanghao){
const requestBody = {"wenti":0,"用户名":String(name),"密码":String(mima)};
fetch('http://localhost:3000', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // 设置请求头为JSON
},
body: JSON.stringify(requestBody) // 将请求体转换为JSON字符串
})
.then(response =>
response.json())
.then(data => {
console.log(data);
}) // 打印服务器返回的数据
.catch(error => console.error('Error:', error)); // 捕获并打印错误信息
}
}
}
</script>
</html>
Loading…
Cancel
Save