以下為風信建站項目開發(fā)中所使用的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周年慶砸金蛋 活動期間每次刷新頁面都會出現(xiàn) 直到砸過
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);
}
}
}
}