Commit d78a521c by doszhang

dos

parent ff42db25
...@@ -66,6 +66,8 @@ let answerArr = []; ...@@ -66,6 +66,8 @@ let answerArr = [];
let watchedQuestion = [1]; let watchedQuestion = [1];
//结果 //结果
let resultType = 8; let resultType = 8;
//提交信息按钮防抖
let submit = true;
//记录初始状态下fontsize //记录初始状态下fontsize
const fontSize = parseFloat($('html').css('fontSize')); const fontSize = parseFloat($('html').css('fontSize'));
...@@ -146,33 +148,42 @@ $(document).ready(function () { ...@@ -146,33 +148,42 @@ $(document).ready(function () {
}); });
function submit() { function submit() {
const name = $('input[name=name]').val(); if (submit) {
const tel = $('input[name=tel]').val(); submit = false;
const name = $('input[name=name]').val();
if (name.match(/^\s*$/)) { const tel = $('input[name=tel]').val();
$('#notification_area').remove();
my_notify('请填写姓名'); if (name.match(/^\s*$/)) {
return false; $('#notification_area').remove();
} else if (!tel.match(/^1\d{10}$/)) { my_notify('请填写姓名');
$('#notification_area').remove(); return false;
my_notify('电话填写有误'); } else if (!tel.match(/^1\d{10}$/)) {
return false; $('#notification_area').remove();
} my_notify('电话填写有误');
return false;
$.ajax({
url: '/index/commit',
type: 'POST',
data: {
name: name,
tel: tel
},
success: function () {
$('.prize-page').hide();
$('.poster-page').show();
$('input[name=name]').val('');
$('input[name=tel]').val('');
} }
})
$.ajax({
url: '/index/commit',
type: 'POST',
data: {
name: name,
tel: tel
},
success: function () {
$('#notification_area').remove();
my_notify('提交成功', 1500);
setTimeout(function () {
$('.prize-page').hide();
$('.poster-page').show();
$('input[name=name]').val('');
$('input[name=tel]').val('');
submit = true;
}, 1500);
}
})
}
} }
function tryprize() { function tryprize() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment