zhitong.yu
2024-10-11 4f58a93c95ff123d51adcb8fa2e521333e8ab022
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2024/4/22
  Time: 9:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>更改密码</title>
    <style>
        .form {
            background-color: #fff;
            display: block;
            padding: 1rem;
            max-width: 350px;
            border-radius: 0.5rem;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
 
        .form-title {
            font-size: 1.25rem;
            line-height: 1.75rem;
            font-weight: 600;
            text-align: center;
            color: #000;
        }
 
        .input-container {
            position: relative;
        }
 
        .input-container input, .form button {
            outline: none;
            border: 1px solid #e5e7eb;
            margin: 8px 0;
        }
 
        .input-container input {
            background-color: #fff;
            padding: 1rem;
            padding-right: 3rem;
            font-size: 0.875rem;
            line-height: 1.25rem;
            width: 300px;
            border-radius: 0.5rem;
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        }
 
        .submit {
            display: block;
            padding-top: 0.75rem;
            padding-bottom: 0.75rem;
            padding-left: 1.25rem;
            padding-right: 1.25rem;
            background-color: #4F46E5;
            color: #ffffff;
            font-size: 0.875rem;
            line-height: 1.25rem;
            font-weight: 500;
            width: 100%;
            border-radius: 0.5rem;
            text-transform: uppercase;
        }
 
        .signup-link {
            color: #6B7280;
            font-size: 0.875rem;
            line-height: 1.25rem;
            text-align: center;
        }
 
        .signup-link a {
            text-decoration: underline;
        }
    </style>
</head>
<body>
<div style="width: 100%;text-align: center;text-align: center;margin: auto;height: 100%">
   <form class="form" action="javascript:;" style="margin-left: 38.5%;margin-top:15%">
        <p class="form-title">请填写完整信息进行验证</p>
        <div class="input-container" id="yz1">
            <input type="text" id="phone" placeholder="请输入手机号">
            <span>
          </span>
        </div>
        <div class="input-container" id="yz2" style="">
            <input type="password" id="yzm" style="width: 45%;float: left;margin-left: 7%" placeholder="请输入验证码">
            <button id="yzm1" style="cursor:pointer;width: 34%;height: 5.7%;margin-top: 2.5%;border-radius: 5px" onclick="HqYzm()">获取短信验证码</button>
        </div>
       <div class="input-container" id="yz5" style="display: none">
           <input type="text" id="pssword" placeholder="请输入新密码">
           <span>
          </span>
       </div>
        <button id="yz3" style="cursor:pointer;" type="submit" onclick="Sub()" class="submit">
            下一步
        </button>
       <button id="yz4" style="display: none;cursor:pointer;" type="submit" onclick="Geng()" class="submit">
           提交
       </button>
        <p class="signup-link">
                在此处根据手机号更改登录密码!
        </p>
    </form>
</div>
</body>
<script src="HouTai/Js/jquery-3.5.1.js"></script>
<script src="/hxzkuwb/JS/layui.js"></script>
<script src="/hxzkuwb/JS/layer.js"></script>
<script src="/hxzkuwb/HouTai/Js/notify.js"></script>
<script src="/hxzkuwb/HouTai/Js/notify_stand.js"></script>
<script>
    var pdyzm;
    var sjh;
    function HqYzm() {
        var phone = $("#phone").val();
        if (phone == "" || phone == null) {
            layer.msg('请先输入手机号后在获取验证码')
        } else {
            var data = "phone=" + phone
            $.get("/hxzkuwb/findPhoneUser", data, function (data) {
                if (data == "" || data.length == 0) {
                    layer.msg('当前手机号不存在,请重新输入后在获取')
                } else {
                    //发送验证码
                    var yzm = generateRandomCode();
                    var yzmpd = "";
                    pdyzm = yzm;
                    var data = "phone=" + phone + "&randomNumber=" + yzm;
                    $.ajax({
                        url: "/hxzkuwb/sms",
                        data: data,
                        async: false,
                        success: function (data) {
                            // 处理返回的数据
                            yzms = data;
 
                        }
                    });
                    startCountdown(60)
                    var notify=layui.notify;
                    notify.success('获取成功')
                }
            })
        }
    }
    function Geng(){
        var password = $("#pssword").val();
        var phone = sjh;
        var pattern = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/;
        if (!pattern.test(password)){
            flag = false;
            layer.msg("密码设置必须包含数字和字母并且不能小于8位")
        }else{
            var data = "phone="+phone+"&password="+password;
            $.post("/hxzkuwb/upPassword",data,function (data){
                if (data == 1){
                    var notify=layui.notify;
                    notify.success("提交成功!即将跳转到登录页面.....")
                    setTimeout(function (){
                        location.href="./index.jsp"
                    },2500)
                }else{
                    alert("提交失败,请联系管理员!")
                }
            })
        }
 
    }
    function Sub(){
        var phone =$("#phone").val();
        var yzm =$("#yzm").val();
        var notify=layui.notify;
        if (phone == "" || phone.length <11 && phone.length >12){
            notify.warning("请输入完整的11位手机号");
            return false;
        }
        if (yzm == ""){
            notify.warning('请输入验证码')
            return false;
        }
        if (yzm != pdyzm){
            notify.warning('当前输入的验证码不正确,请重新获取')
            return false;
        }
        sjh = phone
        $("#yz4").fadeIn(1000);
        $("#yz5").fadeIn(1000);
        $("#yz1").hide();
        $("#yz2").hide();
        $("#yz3").hide();
 
    }
 
        function startCountdown(seconds) {
            var btn = document.getElementById('yzm1');
            btn.disabled = true;
            var count = seconds;
            btn.textContent = count + ' 秒后重新获取';
            var timer = setInterval(function() {
                count--;
                if (count <= 0) {
                    clearInterval(timer);
                    btn.textContent = '获取验证码';
                    btn.disabled = false;
                } else {
                    btn.textContent = count + ' 秒后重新获取';
                }
            }, 1000);
        }
 
    function generateRandomCode() {
        var code = "";
        var possible = "0123456789"; // 可选的字符集合
 
        for (var i = 0; i < 4; i++) {
            // 从字符集合中随机选择一个字符,并添加到验证码中
            code += possible.charAt(Math.floor(Math.random() * possible.length));
        }
 
        return code;
    }
</script>
</html>