首页 > 其他分享 >12.15

12.15

时间:2023-12-18 13:14:34浏览次数:29  
标签:username console getElementById 12.15 error document data

AGENT/agent.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;
        }
    </style>
</head>
<body>
<h1 style="text-align: center">房产经纪人系统</h1>
<div class="form">
    <table border="1px" cellspacing="0" width="600px">
        <tr>
            <th>编号</th>
            <th>功能</th>
        </tr>
        <tr>
            <td>1</td>
            <td>
                <button id="select">查看个人信息</button>
            </td>
        </tr>
        <tr>
            <td>2</td>
            <td>
                <button id="select2">浏览房产信息</button>
            </td>
        </tr>
        <tr>
            <td>3</td>
            <td>
                <button id="add">增加房产经纪人</button>
            </td>
        </tr>
        <tr>
            <td>4</td>
            <td>
                <button id="update">修改信息</button>
            </td>
        </tr>
        <tr>
            <td>5</td>
            <td>
                <button id="select1">查询信息</button>
            </td>
        </tr>
        <tr>
            <td>6</td>
            <td>
                <button id="reset">重置密码</button>
            </td>
        </tr>
    </table>
</div>
</body>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log(username);
    document.getElementById("select").addEventListener("click", function () {
        window.location.href = "../selectID.html?username=" + username;
    });
    document.getElementById('select2').addEventListener('click', function () {
        window.location.href = "../CUSTOMER/select2.html";
    });
    document.getElementById("add").addEventListener("click", function () {
        window.location.href = "addAgent.html";
    });
    document.getElementById('update').addEventListener('click', function () {
        window.location.href = "update.html";
    });
    document.getElementById("select1").addEventListener("click", function () {
        window.location.href = "select.html";
    });
    document.getElementById("reset").addEventListener("click", function () {
        window.location.href = "../updatePassword.html?username=" + username;
    });
</script>
</html>

CUSTOMER/customer.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;
        }
    </style>
</head>
<body>
<h1 style="text-align: center">顾客系统</h1>
<div class="form">
    <table border="1px" cellspacing="0" width="600px">
        <tr>
            <th>编号</th>
            <th>功能</th>
        </tr>
        <tr>
            <td>1</td>
            <td>
                <button id="select">查看个人信息</button>
            </td>
        </tr>
        <tr>
            <td>2</td>
            <td>
                <button id="select2">浏览房产信息</button>
            </td>
        </tr>
        <tr>
            <td>4</td>
            <td>
                <button id="update">修改信息</button>
            </td>
        </tr>
        <tr>
            <td>5</td>
            <td>
                <button id="select1">查询信息</button>
            </td>
        </tr>
        <tr>
            <td>6</td>
            <td>
                <button id="reset">重置密码</button>
            </td>
        </tr>
    </table>
</div>
</body>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log(username);
    document.getElementById("select").addEventListener("click", function () {
        window.location.href = "../selectID.html?username=" + username;
    });
    document.getElementById("select2").addEventListener("click", function () {
        window.location.href = "select2.html?username=" + username;
    });
    document.getElementById('update').addEventListener('click', function () {
        window.location.href = "update.html";
    });
    document.getElementById("select1").addEventListener("click", function () {
        window.location.href = "select.html";
    });
    document.getElementById("reset").addEventListener("click", function () {
        window.location.href = "../updatePassword.html?username=" + username;
    });
</script>
</html>

CUSTOMER/register.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="register">

            <label for="id">顾客ID:</label><input type="text" id="id">
            <br>
            <label for="StuName">姓名:</label><input type="text" id="StuName">
            <br>
            <label>性别:</label>
            <div id="sex">
                <label><input type="radio" name="sex" value="男"> 男</label>
                <label><input type="radio" name="sex" value="女"> 女</label>
            </div>
            <label for="Phone">手机号:</label><input type="text" id="Phone">
            <br>
            <label for="IdNumber">身份证号:</label><input type="text" id="IdNumber">
            <br>
            <label for="Position">住址:</label>
            <input type="text" id="Position"
                   pattern="[\u4e00-\u9fa5]{2,4}(?:省|自治区|市)?[\u4e00-\u9fa5]{2,4}(?:市|自治州)?[\u4e00-\u9fa5]{2,4}(?:区|县|市|旗)?[\u4e00-\u9fa5]{2,20}(?:街道|镇)?[\u4e00-\u9fa5]{2,20}(?:小区)?[\u4e00-\u9fa5\d]{1,10}(?:号楼)?[\u4e00-\u9fa5\d]{1,10}(?:单元)?[\u4e00-\u9fa5\d]{1,10}(?:门牌)?">
            <span>家庭住址(地址格式:XX省XX市XX区(县)XX街道XX小区XX号楼XX单元XXX门牌)</span>
            <div class="centered-buttons">
                <button type="submit" style="display: block; margin: 0 auto;">注册</button>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    document.getElementById('register').addEventListener('submit', function (event) {
        event.preventDefault();
        const id = document.getElementById('id');
        const StuName = document.getElementById('StuName');
        const sex = document.querySelectorAll('input[name="sex"]');
        let s;
        sex.forEach(radio => {
            if (radio.checked) {
                s = radio.value;
                alert(s);
            }
        });
        const Phone = document.getElementById('Phone');
        const IdNumber = document.getElementById('IdNumber');
        const Position = document.getElementById('Position');
        console.log(id.value + StuName.value + s + Phone.value + " " + IdNumber.value + " " + Position.value);
        const requestUrl = 'http://localhost:8080/user/add';
        fetch(requestUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(
                {
                    id: id.value,
                    name: StuName.value,
                    sex: s,
                    phone: Phone.value,
                    idNumber: IdNumber.value,
                    position: Position.value,
                    state: 0
                })
        })
            .then(res => res.json())
            .then(data => {
                if (data.msg === 'success') {
                    alert("添加成功,请等待审核");
                    console.log(data);
                } else {
                    alert("添加失败  " + data.msg);
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    })
</script>
</html>

CUSTOMER/select2.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浏览房产信息</title>
    <style>
        .reSet {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 20px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
        }

        .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: 20px; /* 可选的内边距 */
            background-color: #f0f0f0; /* 可选的背景颜色 */
        }
    </style>
</head>
<body>
<div class="centered-form">
    <div class="bordered-form">
        <div class="form">
            <div id="container">

            </div>
        </div>
    </div>
</div>
</body>
<script>
    var urlParams = new URLSearchParams(window.location.search);
    var username = urlParams.get('username');
    console.log(username);
    const url = `http://localhost:8080/user/selectUsers/${username}`;
    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 === '系统管理员') {
                    deal1();
                } else if (data.data.position === '顾客') {
                    deal2("在售");
                } else if (data.data.position === '房产经纪') {
                    deal3(username);
                }
                alert("登陆成功");
            } else {
                alert("登录失败");
                console.log(data);
            }
        })
        .catch(error => {
            alert("请求失败");
            console.error(error);
        });
</script>
<script>
    function deal1() {
        const requestUrl = `http://localhost:8080/user/selectHouse`;
        fetch(requestUrl,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    console.log(data);
                    generateTable(data.data);
                } else {
                    alert("房产不存在");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }

    function deal2(type) {
        const requestUrl = `http://localhost:8080/user/selectHouse2/${type}`;
        fetch(requestUrl,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    console.log(data);
                    generateTable(data.data);
                } else {
                    alert("房产不存在");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }

    function deal3(username) {
        const requestUrl = `http://localhost:8080/user/selectHouse3/${username}`;
        fetch(requestUrl,
            {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json'
                },
            })
            .then(response => response.json())
            .then(data => {
                if (data.msg === 'success') {
                    console.log(data);
                    generateTable(data.data);
                } else {
                    alert("房产不存在");
                }
            })
            .catch(error => {
                alert("请求失败,请重试");
                console.error(error);
            });
    }
</script>
<script>
    const requestUrl = `http://localhost:8080/user/selectHouse`;
    fetch(requestUrl,
        {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json'
            },
        })
        .then(response => response.json())
        .then(data => {
            if (data.msg === 'success') {
                console.log(data);
                generateTable(data.data);
            } else {
                alert("房产不存在");
            }
        })
        .catch(error => {
            alert("请求失败,请重试");
            console.error(error);
        });
</script>
<script>
    function generateTable(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>编号</td><td>户型</td><td>地址</td><td>年份</td><td>建造面积</td><td>销售报价</td><td>销售状态</td><td>房产经纪人ID</td><td>顾客ID</td>';
        tableBody.appendChild(row);
        // 查询方式是按姓名查询或多条查询
        for (let i = 0; i < data.length; i++) {
            row = document.createElement("tr");
            row.innerHTML = `<td>${data[i].id}</td>${data[i].type}<td>${data[i].position}</td><td>${data[i].year}</td><td>${data[i].area}</td><td>${data[i].much}</td><td>${data[i].state}</td><td>${data[i].agentID}</td><td>${data[i].userID}</td>`;
            tableBody.appendChild(row);
            table.appendChild(tableBody);
            tableContainer.appendChild(table);
        }
    }
</script>
</html>

 

标签:username,console,getElementById,12.15,error,document,data
From: https://www.cnblogs.com/zzqq1314/p/17910950.html

相关文章

  • 【2023潇湘夜雨】WIN10_Pro_22H2.19045.3803软件选装纯净版12.15
    【系统简介】=============================================================1.本次更新母盘来自WIN10_Pro_22H2.19045.3803。2.增加部分优化方案,手工精简部分较多。3.OS版本号为19045.3803。精简系统只是为部分用户安装,个别要求高的去MSDN下。4.集成《DrvCeo-2.15.0.5》网卡版、......
  • 12.15每日总结(阅读笔记8)
    《人月神话》这本书是软件工程类的一本经典著作。阅读这本书的第一感受就是感觉这本书不像是一种和学习相关的书,更像是用很多形象的比喻,阐述项目管理当中的一些问题,让读者能够很轻松,明白的去阅读。一般在大学学习计算机行业的时候,都会学习一门叫做软件工程的课程,老师也会跟我们讲......
  • 2023.12.15
    分布式文件系统的特点如下:hdfs的主从结构: hdfs的分块存储:  hdfs的副本机制:为了保证数据安全,把数据放到其他机器上 hadoop文件系统操作:hadoopfs  这个Hadoop配置了默认访问为hdfs文件系统。hdfs常用shell命令:   本地文件系统即客户端所在机器,假如你在n......
  • 12.15日记
    log4j.rootLogger=info,consolePrint,errorFile,logFile log4j.appender.consolePrint.Encoding=UTF-8log4j.appender.consolePrint=org.apache.log4j.ConsoleAppenderlog4j.appender.consolePrint.Target=System.outlog4j.appender.consolePrint.layout=org.apache.l......
  • 2023.12.15——每日总结
    学习所花时间(包括上课):9h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习;我了解到的知识点:1.c#明日计划:学习......
  • 12.15
    最后20分钟写个闲话今天没啥,调一道题调了一晚上......
  • 闲话12.15
    今天打了一场模拟赛,垫底了。T1找了两个小时的性质,没找到性质,寄。也没一点暴力分,有了性质基本就是100pts了,矩阵加速比较裸。T2T3已经没时间看了,就摆了,打了15pts就跑了。最终得分15pts,rk70多吧。越来越拉了呢。下午花了一个半小时改T4,有半个小时都是因为没开ll在调......
  • 12.15 闲话
    今天特别水基本没有学术昨天忘更闲话了学校奇怪规定,本地的可以回家但是外地不行幸好我是秦皇岛的不然就能回去了,哦哦原来我家长来了我又能走了推歌世末歌者蝉时雨化成淡墨渲染暮色渗透着勾勒出足迹与车辙欢笑声与漂浮的水汽饱和隔着窗同城市一并模糊了拨弄着旧吉......
  • 12.15每日总结
    分布式文件系统的特点如下:hdfs的主从结构: hdfs的分块存储:  hdfs的副本机制:为了保证数据安全,把数据放到其他机器上 hadoop文件系统操作:hadoopfs  这个Hadoop配置了默认访问为hdfs文件系统。hdfs常用shell命令:   本地文件系统即客户端所在机器,假如你在n......
  • 12.15---python文件读取
    withopen('pi_digits.txt')asfile:contents=file.read()print(contents.strip())要想访问文件内容需要先打开它才能访问,函数open()接受一个参数:要打开文件的名称。在当前执行文件的目录中查找文件名。代码中,open('E:/python/文件和异常/pi_digits.txt')返回一个表示......