$(function () { //右侧菜单 $(window).scroll(function (e) { var wh = $(window).scrollTop(); if (wh > 500) { $('.sidebar').fadeIn(); } else { $('.sidebar').fadeOut(); } }); //报名按钮 $("#baoming,.baoming").click(function() { var h = $(".zt_form").offset().top - 200; $('body,html').animate({ scrollTop: h }, 500); return false; }); var other = ""; // 自定义radio $(".old").click( function () { $(this).addClass("active"); $('.new').removeClass("active"); other = "老房"; }); $(".new").click( function () { $(this).addClass("active"); $('.old').removeClass("active"); other = "新房"; }); //表单提交 $(".postbtn").click(function() { // 防止重复提交 if ($(this).hasClass("submitting")) { return false; } $(this).addClass("submitting"); var data = {}; var el = $(this).parent().parent(); data.type = 1; data.province_id = $.trim(el.find("select[name=province_id]").val()); data.city_id = $.trim(el.find("select[name=city_id]").val()); data.name = $.trim(el.find("input[name=name]").val()); data.mobile = $.trim(el.find("input[name=mobile]").val()); data.size = $.trim(el.find("input[name=size]").val()); // data.building_id = $.trim(el.find("input[name=building_id]").val()); data.remark = $.trim(el.find("input[name=remark]").val()); data.url = window.location.href; data.channel = $.cookie('channel'); // 添加CSRF令牌 //data._token = $("meta[name='csrf-token']").attr("content") || $.cookie('_token'); if(data.remark == "广州公司汇金展厅PC专题") { data.province_id = "440000"; data.city_id = "440100"; data.other = el.find("select").val(); } if(data.remark == "常州公司20周年庆PC专题") { data.province_id = "320000"; data.city_id = "320400"; } // 严格的姓名验证(只允许中文、英文和点号) if (!/^[\u4e00-\u9fa5a-zA-Z·]{2,20}$/.test(data.name)) { layer.msg("请输入正确的姓名,2-20个字符"); el.find("input[name=name]").focus(); $(this).removeClass("submitting"); return false; } if (data.mobile == "") { layer.msg("请输入您的手机号!"); el.find("input[name=mobile]").focus(); $(this).removeClass("submitting"); return false; } else if (!/^1[3-9]\d{9}$/.test(data.mobile)) { layer.msg("请输入正确的手机号!"); el.find("input[name=mobile]").focus(); $(this).removeClass("submitting"); return false; } if (el.find('input[name=province_id]').length > 0) { layer.msg("请选择省/市!"); $(this).removeClass("submitting"); return false; } if (el.find('input[name=city_id]').length > 0) { layer.msg("请选择城市!"); $(this).removeClass("submitting"); return false; } $.ajax({ type: "POST", url: "/index/order/submit?t==" + Math.random(), data: data, dataType: "json", beforeSend: function() { layer.load(); }, success: function(result) { layer.closeAll(); if (result.code > 0) { layer.msg("预约成功,客服稍候会与您联系",{icon: 1,time: 2000,shade: 0.3},function(){ window._agl && window._agl.push(['track', ['success', {t: 3}]]); el[0].reset(); $(this).removeClass("submitting"); $(".pop").hide(); $(".popup-alert").hide() }); } else { layer.msg(result.msg); } } }); return false; }); //数字滚动 var istrue = true; function numSroll(wrapTop) { $(window).scroll(function() { if ($(window).scrollTop() >= wrapTop - 700 && istrue) { $('.timer').each(count); istrue = false; } }); } var num = $("#brandnum").attr("data-to"); //目标数字 if (window.location.pathname == "/activity/kmh2026") { var to_num = 4530 - (TimeDown("2026-03-15") * 113); } else { var to_num = 6000 - (TimeDown("2025-07-21") * 107); } $("#brandnum").attr("data-to", to_num); //设置预约人数 if ($(".yuyue_num").length > 0) { var wrapTop = $(".yuyue_num").offset().top; numSroll(wrapTop); } //倒计时,endDateStr为活动结束时间 function TimeDown(endDateStr) { //结束时间 var endDate = new Date(endDateStr); //当前时间 var nowDate = new Date(); //相差的总秒数 var totalSeconds = parseInt((endDate - nowDate) / 1000); //天数 var days = Math.floor(totalSeconds / (60 * 60 * 24)); //取模(余数) var modulo = totalSeconds % (60 * 60 * 24); //小时数 var hours = Math.floor(modulo / (60 * 60)); modulo = modulo % (60 * 60); //分钟 var minutes = Math.floor(modulo / 60); //秒 var seconds = modulo % 60; //输出到页面 //document.getElementById(id).innerHTML = "还剩:" + days + "天" + hours + "小时" + minutes + "分钟" + seconds + "秒"; //延迟一秒执行自己 /*setTimeout(function () { TimeDown(id, endDateStr); }, 1000)*/ return days; } //昨天的时间 var day1 = new Date(); day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000); var s1 = day1.getFullYear() + "-" + (day1.getMonth() + 1) + "-" + day1.getDate(); //获取当天日期 var day2 = new Date(); day2.setTime(day2.getTime()); //var s2 = day2.getFullYear()+"-" + (day2.getMonth()+1) + "-" + day2.getDate(); //m = (day2.getDate() > 10) ? day2.getDate() : "0"+day2.getDate(); d = day2.getDate(); var s2 = (day2.getMonth() + 1) + "月" + d + "日"; //ali.find("span").text(s2); var person = [ "广州李女士138****3698", "上海陈先生139****9854", "佛山王小姐158****5641", "深圳李先生136****8542", "武汉高小姐134****2569", "江门陈小姐135****8868", "长沙吴先生159****9985", "岳阳雷小姐186****6514", "广州常先生157****6564", "深圳小祝180****3392", "佛山欧女士151****3639", "岳阳陈女士138****8556", "上海张先生139****6903", "南京柳小姐137****5770", "成都梁女士136****3306", "惠州赵先生133****2595", "南昌陈先生132****2350", "济南钱小姐134****4987", "汕头王先生188****6089", "常州孙女士138****8989", "广州韩小姐137****4334", ]; //从数组中随机获取指定个数的元素 function getRandomArrayElements(arr, count) { var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index; while (i-- > min) { index = Math.floor((i + 1) * Math.random()); temp = shuffled[index]; shuffled[index] = shuffled[i]; shuffled[i] = temp; } return shuffled.slice(min); } var personOn = getRandomArrayElements(person, 4); var html = ""; for (var k = 0, length = personOn.length; k < length; k++) { html += '
'; } if ($(".zt_form .customerS").length) { $(".zt_form .swiper-wrapper").html(html); var customer = new Swiper('.customerS', { autoplay: true, direction: 'vertical', loop: true, observer:true, observeParents:true, slidesPerView: 'auto', }) } }); //判断是否为移动端访问 function is_mobile() { var mobileAgent = new Array( "iphone", "ipod", "ipad", "android", "windows ce", "mobile", "midp", "rv:1.2.3.4", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire" ); var userAgent = navigator.userAgent.toLowerCase(); var isMobile = false; for (var i = 0; i < mobileAgent.length; i++) { if (userAgent.indexOf(mobileAgent[i]) != -1) { isMobile = true; break; } } return isMobile; }