首页 > 其他分享 >12.14

12.14

时间:2023-12-18 13:16:09浏览次数:31  
标签:username const alert 12.14 error document data

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <style>
        button {
            display: block;
            margin-top: 10px;
            padding: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .centered-form {
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }

        .bordered-form {
            border: 2px solid #000; /* 边框样式 */
            padding: 20px; /* 可选的内边距 */
            background-color: #f0f0f0; /* 可选的背景颜色 */
        }
    </style>
</head>
<body>
<div class="centered-form">
    <div class="bordered-form">
        <h1>用户登录</h1>
        <form id="login">
            <label for="username">用户名:</label><input type="text" id="username">
            <br>
            <label for="password">密码:</label><input type="password" id="password">
            <br>
            <div class="centered-buttons">
                <button type="submit" style="display: block; margin: 0 auto;">登录</button>
                <br>
                <button id="register" type="button" style="display: block; margin: 0 auto;">注册</button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    const register = document.getElementById("register");
    register.addEventListener("click", function () {
        window.location.href = "http://localhost:8080/CUSTOMER/register.html";
    });
    document.getElementById("login").addEventListener("submit", function (event) {
        event.preventDefault();
        const username = document.getElementById("username").value;
        const password = document.getElementById("password").value;
        const url = `user/getByUser?username=${username}&password=${password}`;
        fetch(url, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            }
        })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    console.log(data);
                    if (data.data.position === '系统管理员') {
                        window.location.href = "ROOT/root.html?username=" + encodeURIComponent(username);
                    } else if (data.data.position === '顾客') {
                        window.location.href = "CUSTOMER/customer.html?username=" + encodeURIComponent(username);
                    } else if (data.data.position === '房产经纪') {
                        window.location.href = "AGENT/agent.html?username=" + encodeURIComponent(username);
                    }
                    alert("登陆成功");
                } else {
                    alert("登录失败");
                    console.log(data);
                }
            })
            .catch(error => {
                alert("密码或账号错误");
                console.error(error);
            });
    });
</script>
</html>

selectID.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查找个人信息</title>
    <style>
        .form {
            width: 600px;
            margin: 0 auto;
            /*border: 1px solid red;*/
        }

        .form table {
            margin: 0 auto;
        }

        .form table tr td {
            width: 100px;
            height: 30px;
            border: 1px solid #000;
            text-align: center;
        }

        button {
            display: block;
            margin-top: 10px;
            padding: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .centered-form {
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }

        .bordered-form {
            border: 2px solid #000; /* 边框样式 */
            padding: 150px; /* 可选的内边距 */
            background-color: #f0f0f0; /* 可选的背景颜色 */
        }
    </style>
</head>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log(username);
    const requestUrl = `http://localhost:8080/user/selectUsers/${username}`;
    fetch(requestUrl, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json'
        },
    })
        .then(res => res.json())
        .then(data => {
            if (data.msg === 'success') {
                if (data.data.position === "房产经纪") {
                    select1(username);
                } else if (data.data.position === "顾客") {
                    select2(username);
                }
            } else {
                alert("添加失败  " + data.msg);
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<body>
<div class="centered-form">
    <!--    增加边框-->
    <div class="bordered-form">
        <!--        调整边框大小-->
        <div class="form">
            <div id="container">

            </div>
        </div>
    </div>
</div>
</body>
<script>
    function select1(id) {
        const requestUrl = `http://localhost:8080/user/select1/${id}`;
        fetch(requestUrl, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    generateTable1(data.data);
                } else {
                    alert("添加失败  " + data.msg);
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }

    function select2(id) {
        const requestUrl = `http://localhost:8080/user/select2/${id}`;
        fetch(requestUrl, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    generateTable2(data.data);
                } else {
                    alert("添加失败  " + data.msg);
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>
    function generateTable2(data) {
        const tableContainer = document.getElementById("container");
// 清空 tableContainer 中的所有子节点
        while (tableContainer.hasChildNodes()) {
            tableContainer.removeChild(tableContainer.firstChild);
        }
        const table = document.createElement("table");
        const tableBody = document.createElement("tbody");
        let row = document.createElement("tr");
        row.innerHTML = '<td>ID</td><td>姓名</td><td>性别</td><td>身份证号</td><td>手机号</td><td>家庭住址</td><td>审核状态</td>';
        tableBody.appendChild(row);
// 查询方式是按姓名查询或多条查询
        row = document.createElement("tr");
        row.innerHTML = `<td>${data.id}</td><td>${data.name}</td><td>${data.sex}</td><td>${data.idNumber}</td><td>${data.phone}</td><td>${data.position}</td><td>${data.state}</td>`;
        tableBody.appendChild(row);
        table.appendChild(tableBody);
        tableContainer.appendChild(table);
    }
    function generateTable1(data) {
        const tableContainer = document.getElementById("container");
// 清空 tableContainer 中的所有子节点
        while (tableContainer.hasChildNodes()) {
            tableContainer.removeChild(tableContainer.firstChild);
        }
        const table = document.createElement("table");
        const tableBody = document.createElement("tbody");
        let row = document.createElement("tr");
        row.innerHTML = '<td>ID</td><td>姓名</td><td>手机号</td><td>家庭住址</td>';
        tableBody.appendChild(row);
// 查询方式是按姓名查询或多条查询
        row = document.createElement("tr");
        row.innerHTML = `<td>${data.agentID}</td><td>${data.agentName}</td><td>${data.phone}</td><td>${data.agentAddress}</td>`;
        tableBody.appendChild(row);
        table.appendChild(tableBody);
        tableContainer.appendChild(table);
    }
</script>
</html>

updatePassword.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <style>
        button {
            display: block;
            margin-top: 10px;
            padding: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        .centered-form {
            text-align: center;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }

        .bordered-form {
            border: 2px solid #000; /* 边框样式 */
            padding: 20px; /* 可选的内边距 */
            background-color: #f0f0f0; /* 可选的背景颜色 */
        }
    </style>
</head>
<body>
<h1 style="text-align: center">修改密码</h1>
<div class="centered-form">
    <div class="bordered-form">

        <label for="old">旧密码</label>
        <input type="text" id="old" required>
        <br>
        <label for="new1">新密码</label>
        <input type="text" id="new1" required>
        <br>
        <label for="new2">确认新密码</label>
        <input type="text" id="new2" required>
        <div id="match"></div>
        <br>
        <button id="update" style="display: block; margin: 0 auto;">更改密码</button>
    </div>
</div>
</body>
<script>
    const newPassword1 = document.getElementById("new1");
    const newPassword2 = document.getElementById("new2");
    const passwordMatchMessage = document.getElementById("match");

    function checkPasswordMatch() {
        const password1 = newPassword1.value;
        const password2 = newPassword2.value;

        if (password1 === password2) {
            passwordMatchMessage.textContent = "两次密码一致";
            passwordMatchMessage.style.color = "green";
        } else {
            passwordMatchMessage.textContent = "两次密码不一致";
            passwordMatchMessage.style.color = "red";
        }
    }

    newPassword1.addEventListener("input", checkPasswordMatch);
    newPassword2.addEventListener("input", checkPasswordMatch);
</script>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log("用户名为:" + username);
    document.getElementById('update').addEventListener('click', function () {
        const requestUrl = `http://localhost:8080/user/selectUsers/${username}`;
        fetch(requestUrl, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    console.log(data);
                    deal(data.data);
                } else {
                    alert("此结果不存在");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    })
</script>
<script>
    function deal(data) {
        const old = document.getElementById('old').value;
        const new1 = document.getElementById('new1').value;
        const new2 = document.getElementById('new2').value;
        const password = data.password;
        console.log("密码为   " + password);
        if (old !== password) {
            alert("您输入的旧密码有误");
        } else if (old !== password && new1 !== new2) {
            alert("输入的两次密码不一致");
        } else if (old === password && new1 === new2) {
            const requestUrl = `http://localhost:8080/user/updatePassword/${username}/${new1}`;
            fetch(requestUrl, {
                method: 'PUT',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
                .then(response => response.json())
                .then(data => {
                    if (data.msg === 'success') {
                        alert("修改成功,请您重新登陆");
                        window.location.href = "http://localhost:8080/index.html";
                    } else {
                        alert("修改失败");
                    }
                })
                .catch(error => {
                    alert("请求失败,请重试");
                    console.error(error);
                });
        }
    }
</script>
</html>

 

标签:username,const,alert,12.14,error,document,data
From: https://www.cnblogs.com/zzqq1314/p/17910947.html

相关文章

  • 【2023潇湘夜雨】WIN11_Pro_23H2.22631.2861软件选装纯净版12.14
    【系统简介】=============================================================1.本次更新母盘来自WIN11_Pro_23H2.22631.2861。2.增加部分优化方案,手工精简部分较多。3.OS版本号为22631.2861。精简系统只是为部分用户安装,个别要求高的去MSDN下。4.集成《DrvCeo-2.15.0.5》网卡版、......
  • 12.14日记
    FlinkJobManager架构原理的核心是JobMaster和ResourceManager,其中JobMaster负责任务的调度和监控,ResourceManager负责集群资源的管理。JobMaster和ResourceManager之间通过RPC通信进行交互。JobMaster主要负责以下几个方面:   任务管理JobMaster负责接收用户提交的任务,并将任......
  • 12.14每日总结
    今天完成建民的课堂测试和.NET考试 软件需求与分析课堂测试十——综合案例分析(5分) 根据下列案例需求描述,回答相关问题:有一个对外营业的会议中心,有各种不同规格的会议室,为用户提供以下服务:1,用户可以按照会议人数,会议时间预订会议室。可以只预订1次,也可预订定期召开的会议......
  • 每日总结12.14
    根据下列案例需求描述,回答相关问题:有一个对外营业的会议中心,有各种不同规格的会议室,为用户提供以下服务:1、用户可以按照会议人数、会议时间预订会议室。可以只预订1次,也可预订定期召开的会议。2、开会前允许用户修改会议时间、人数,重新选择会议室,甚至取消预订的会议。3、......
  • 2023.12.14
    importtorchimporttorch.nnasnnimporttorch.optimasoptimfromtorchvisionimportdatasets,transformsclassModulatedAttLayer(nn.Module):#(Unchangedcode)classSimpleCNN(nn.Module):def__init__(self):super(SimpleCNN,self).__i......
  • 闲话12.14
    今天晚上写题写累了,闲话可能比较水。上午接着颓,上课也颓废。K8一句话说的很对啊,就是提前来这体验大学生活了,上午上课颓废,下午晚上自习颓废,赢麻了。上午的树上问题没啥听懂的,感觉昨天的ds都放今天了是为啥。写起来也挺难受的。过几天好像就是沈老师来讲课了。下午普通的写题......
  • 2023.12.14
    7-1数据结构作业#include<iostream>#include<vector>usingnamespacestd;intmain(){intn,p;scanf("%d%d",&n,&p);vector<int>a(p,-1);//初始化数组,全为-1while(n--){intx;cin>>......
  • Solution Set 2023.12.14
    CF698FCoprimePermutation考虑\(p_i=0\)的情况下怎么做,首先排列\(p_i=i\)一定符合条件,考虑在此基础上生成其他符合要求的排列,考虑什么情况下\(p_i\)和\(p_j\)可以互换,发现其可以互换当且仅当对于所有\(x\neqi\)且\(x\neqj\),均有\(\left[\gcd\left(i,x\rig......
  • 百度网盘(百度云)SVIP超级会员共享账号每日更新(2023.12.14)
    一、百度网盘SVIP超级会员共享账号可能很多人不懂这个共享账号是什么意思,小编在这里给大家做一下解答。我们多知道百度网盘很大的用处就是类似U盘,不同的人把文件上传到百度网盘,别人可以直接下载,避免了U盘的物理载体,直接在网上就实现文件传输。百度网盘SVIP会员可以让自己百度账......
  • 【笔记】2023.12.14 树上问题
    笔记2023.12.14:树上问题[Ynoi2004]rpmtdq支配对:\(i_1\leqi_2\leqj_2\leqj_1,dist(i_1,j_1)\geqdist(i_2,j_2)\)时,称\((i_1,j_1)\)被\((i_2,j_2)\)支配,前者就无用了,选到区间只要包含\((i_1,j_1)\)就一定包含\((i_2,j_2)\)。点分治到\(rt\)时,记\(d_x=dis......