以下为风信建站项目开发中所使用的JQuery用户提交登记信息进行验证的代码片段,分享给大家使用。
//弹出大鸡蛋
function showZnq2() {
$("#znq2").remove();
var showZnqHtml = "<div id='znq_cont'>" +
"<div id='smash_egg' onclick='smashEgg()'><img id='hammer' src='/images/wx_active/znq2/cz.png' /></div>" +
"</div>";
var $vexContent = vex.open({
content: showZnqHtml,
contentCSS: {'background-color': 'transparent', 'width': '890px', 'height': '660px'},
closeClassName: "znq_close"
});
$vexContent.find('.close').on('click', function() {
if ($vexContent.data().vex) {
vex.close($vexContent.data().vex.id);
} else {
vex.close();
}
});
}
//点击砸蛋蛋
function smashEgg() {
//$("#smash_egg").addClass("egg_open");
//$(".hammer").css({"top":_this.position().top-55,"left":_this.position().left+185});
var _this = $("#hammer");
$("#hammer").animate({
"top":_this.position().top+325,
"left":_this.position().left-225,
}, 100,function(){
$("#smash_egg").addClass("egg_open");
}
);
}
function closeShowEgg() {
$("#znq2").remove();
}
window.smashEgg = smashEgg;
window.showZnq2 = showZnq2;
window.closeShowEgg = closeShowEgg;
//2周年庆砸金蛋 活动期间每次刷新页面都会出现 直到砸过
var mydate = new Date();
var tday = mydate.getFullYear()+"-"+(mydate.getMonth()+1)+"-"+mydate.getDate();
var znq_layer_day = "2017-10-21";
var znq_jd_start_day = "2017-10-19";
var znq_jd_end_day = "2017-10-25";
if(tday >= znq_jd_start_day && tday <= znq_jd_end_day){
if(!window.ismobile){//pc
if($.cookie('znq2_layer_ck')!=1 && tday==znq_layer_day){//会显示弹窗-不显示金蛋
}else{
if($.cookie('znq2_ck')!=1
&& (typeof(window.second_year_view)=="undefined" || !window.second_year_view)
&& (typeof(window.pc_index_view)=="undefined" || !window.pc_index_view)
){//cookie只访问一次
setTimeout(function() {
$.cookie('znq2_ck', 1);
var znq_class = Math.floor(Math.random()*4+1);
var znq2_html = "<div id='znq2' class='znq2_fix_"+znq_class+"'><div class='znq_egg_close' onclick='closeShowEgg()'></div><img onclick='showZnq2()' src='/images/wx_active/znq2/fixed.png' /></div>";
$body.append(znq2_html);
}, 1000);
}
}
}else{//手机
if(typeof(window.is_wx_znq2)=="undefined" || !window.is_wx_znq2){
if($.cookie('znq2_mobile_ck')!=1){//cookie只访问一次
setTimeout(function() {
$.cookie('znq2_mobile_ck', 1);
var $znq2_mobile = vex.open({
content: "<img style='margin-top:30px;' src='/images/wx_active/znq2/mobile_oe2.png' />",
contentCSS: {'background-color': 'transparent', 'left':0, 'right':0, 'margin': '0 auto', 'padding':0, 'top':'100px'},
overlayCSS: {'background': 'rgba(0, 0, 0, 0.7)'},
css: {'z-index': 99999}
});
$znq2_mobile.find('.close').on('click', function() {
if ($znq2_mobile.data().vex) {
vex.close($znq2_mobile.data().vex.id);
} else {
vex.close();
}
});
}, 1000);
}
}
}
}