-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday06_GetAnswer_2.html
205 lines (175 loc) · 6.83 KB
/
day06_GetAnswer_2.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/new_code_windows.css">
<link rel="stylesheet" type="text/css" href="css/new_nav.css">
<link rel="stylesheet" type="text/css" href="css/day_5_index.css">
<link rel="stylesheet" type="text/css" href="css/go_to_PC.css">
<script async defer data-website-id="0a453f1f-f1bc-4f69-9772-6a1e6cfea828" src="https://stat.buctsnc.cn/umami.js"></script>
<title>Day 6</title>
</head>
<script src="js/jquery.js"></script>
<script src="js/randomShowForDay05.js"></script>
<body>
<header class="navigate" style="display: none">
<div class="buct_logo"> <img src="img/buctlogo.png" alt="" class="nav_logo"></div>
<div class="snc_logo"> <img src="img/snclogo.png" alt="" class="nav_logo"></div>
</header>
<div class="code_submit_window" style="display:none;">
<div class="window_submit_title">
<div class="window_close"></div>
<div class="window_min"></div>
<div class="window_max"></div>
</div>
<div class="window_submit_main">
<form method="post" class="new_submit_form">
<table>
<tr>
<td>用户名:</td>
<td><input id="nickname" name="nickname" type="text" placeholder="注册过用户名" autocomplete="off" class="day05_input"></td>
<td>没有注册?<a href="register.html">注册</a></td>
</tr>
<tr>
<td>电话号码:</td>
<td><input id="contact" name="contact" type="text" placeholder="注册过的电话号码" autocomplete="off" class="day05_input"></td>
<td></td>
</tr>
<tr>
<td>获得的答案:</td>
<td><input id="answer_q6_2" name="answer_q6_2" type="text" placeholder="Day 6答案" autocomplete="off" class="day05_input"></td>
<td>没有找到?<a href="#" id="back_to_phone">返回</a> </td>
</tr>
</table>
<div class="window_submit_btn">
<button class="submit_btn" type="reset" onclick="">重新输入</button>
<button class="submit_btn" type="button" onclick="submits()">提交答案</button>
</div>
</form>
</div>
</div>
<div id="goToPC" style="display: none; font-size: 14px;">
<div class="go_to_PC_content">
<img src="img/goToPC.png" alt="" class="go_to_PC_img">
<p style="background: none">在PC端访问</p>
<p style="background: none">体验效果更佳</p>
</div>
</div>
<div id="goToWeChat" style="display: none; font-size: 14px;">
<div class="go_to_PC_content">
<img src="img/goToPhone.png" alt="" class="go_to_PC_img">
<p style="background: none">请回到微信推送中</p>
<p style="background: none">寻找有关线索</p>
</div>
</div>
</body>
<script>
function checkDevice() {
let usrAgentInfo = navigator.userAgent;
let Agents = ['Android', 'iPhone', 'Windows Phone', 'iPad'];
let flag = true;
for (let i = 0; i < Agents.length; i++) {
if (usrAgentInfo.indexOf(Agents[i]) > 0) {
flag = false;
break;
}
}
return flag;
}
let submit = false;
function checkSubmit() {
if(!submit) {
// 表单提交后设置标志位
submit = true;
return true;
}
// 表单已经提交,不允许再次提交
console.log("请不要重复提交表单!");
return false;
}
function isLegalName (str) {
let re = /^[0-9a-zA-Z]*$/;
if (!re.test(str) || str.indexOf(" ") != -1) {
return false;
} else {
return true;
}
}
function isLegalTel(str) {
let re = /^[0-9|+]*$/;
if (!re.test(str) || str.indexOf(" ") != -1) {
return false;
} else {
return true;
}
}
function check(nickname, contact, answer_q6_2) {
if(nickname.length < 1 || contact.length < 10 || answer_q6_2.length < 1){
return false;
}
return true;
}
function submits() {
if (!checkSubmit()) {
alert("请勿重复提交!");
} else {
let nickname = document.getElementById("nickname")
let contact = document.getElementById("contact")
let answer_q6_2 = document.getElementById("answer_q6_2")
if(check(nickname.value, contact.value, answer_q6_2.value) && isLegalName(nickname.value) && isLegalTel(contact.value)){
$.ajax({
url:"https://sncdeveloper.cn:8000/argProject/day06",
method:"post",
async:"false",
data:{"nickname":nickname.value,"contact":contact.value,"answer_q6":answer_q6_2.value},
dataType:"json",
contentType:"application/x-www-form-urlencoded",
success(result){
nickname.value = ""
contact.value = ""
answer_q6_2.value = ""
window.alert(result.msg)
// if(result.data.solveStatus==1){
//
// }
submit = false
},
error(msg){
console.log("error"+msg)
window.alert("活动太火爆了,请稍后再试")
submit = false
}
})
}else{
if (!isLegalName(nickname.value))
alert("用户名只能由数字和字母组成!");
else
alert("联系方式格式有误或答案为空,请重新输入")
submit = false
}
}
}
window.onload = function () {
if (!checkDevice()) {
$('#goToPC').fadeIn()
setTimeout(function () {
$('#goToPC').fadeOut();
}, 1000)
}
$('.navigate').fadeIn(500);
$('.code_submit_window').fadeIn(700);
}
var backToPhone = document.getElementById('back_to_phone');
backToPhone.addEventListener('click', function() {
$('#goToWeChat').fadeIn();
setTimeout(function() {
$('#goToWeChat').fadeOut();
}, 1000)
})
$(document).keyup(function(e){
if (13 == e.keyCode || 108 == e.keyCode){
submits();
}
});
</script>
</html>