forked from panxinwu/cj-message
-
Notifications
You must be signed in to change notification settings - Fork 1
/
youhui.html
executable file
·107 lines (106 loc) · 2.26 KB
/
youhui.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
<meta charset="UTF-8">
<title>添加</title>
<style>
.wrap {
width: 300px;
margin: 0 auto;
}
.wrap input {
display: block;
width: 300px;
height: 34px;
line-height: 34px;
margin-bottom: 10px;
}
.title {
text-align: center;
}
.submit {
width: 250px;
height: 40px;
display: block;
background: #00f;
color: #fff;
font-weight: bold;
text-decoration: none;
line-height: 40px;
text-align: center;
margin: 0 auto;
}
.unvalid {
background: #ccc;
}
</style>
</head>
<body>
<div class="wrap">
<p class="title">录入优惠信息</p>
<input name="userid" id="userid" placeholder="学号">
<input id="pwd" placeholder="添加密码" type="password">
<a href="javascript:;" class="submit" id="sub">提交</a>
</div>
<script src="./js/md5.js"></script>
<script>
var ourpass = '9f23bb4ae0b5fdfe357c031c1270eb39';
if(localStorage.ourpass) {
pwd.value = localStorage.ourpass;
}
var url = "youhui.php";
var xhr = new XMLHttpRequest ();
xhr.onreadystatechange = function () {
if(xhr.readyState == 4){
if (xhr.status >= 200 && xhr.status < 400){
var data;
try{
data = JSON.parse(xhr.response);
}catch (e) {
data = xhr.response;
}
success(data);
}
}
}
function success(data) {
console.log(data);
if(data.error != 0){
alert(data.data);
}
if (data.error == 203){
alert('出现错误!这个问题非常严重,请联系范明非解决');
}
sub.className="submit";
if (data.error==0)
alert('添加成功!');
}
function submit() {
if(hex_md5(pwd.value) != ourpass){
alert('添加密码错误');
return;
}
var xh = userid.value;
if(!xh){
alert('请填写内容!');
return;
}
sub.className="submit unvalid";
var post = "?xh=" + xh;
xhr.open("post",url+post);
xhr.send();
localStorage.ourpass = pwd.value;
}
sub.onclick=function(){
if(sub.classList.contains('unvalid')) retrun;
submit();
}
window.onkeydown = function (e) {
if(e.keyCode == 13){
submit();
}
}
</script>
</body>
</html>