window.onload = function() {
window.addEventListener('scroll', function() {
var scrollBarTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; // 滚动条离页面顶端的距离
var targetTop = document.getElementsByClassName('successCase')[0].offsetTop // 目标元素离页面顶端的距离
//console.log(scrollBarTop)
// 如果目标元素离页面顶端的距离小于视窗高度+滚动条离页面顶端的距离
// 则表示已滚动到目标元素位置
if(targetTop < scrollBarTop ) {
$('.customer-btn').show()
}else{
$('.customer-btn').hide();
}
})
}
$(function() {
//返回顶部
$("#back-top").click(function() {
_czc.push(["_trackEvent",'获取减税方案','点击']);
var a = $('.send-form').offset().top
$('body,html').animate({
scrollTop: a-160
}, 1000);
return false;
});
//电话咨询
$("#callPhone").click(function() {
_czc.push(["_trackEvent",'电话咨询','点击']);
});
//联系客服
$("#kefu").click(function() {
is_weixin()?
layer.open({
title: [
'保存图片或者长按二维码识别添加微信好友',
'background-color: #2E7BDA; color:#fff;'
],
content: "微信号:A0rainA0"
}):
layer.open({
title: [
'保存图片,在微信识别二维码添加好友',
'background-color: #2E7BDA; color:#fff;'
],
content: "微信号:A0rainA0"
});
});
//表单提交
$('#sendForm').submit(function() {
event.preventDefault();//防止默认事件行为
var contactName = $('#contactName').val()
var contactPhone = $('#contactPhone').val()
if(!contactName){
layer.open({
content: '请填写联系人姓名',
style: 'width:auto; height:auto; font-size:0.32rem; background-color:#494949; color:#fff;',
shade: false,
time: 1
});
}else if(!contactPhone){
layer.open({
content: '请填写手机号码',
style: 'width:auto; height:auto; font-size:0.32rem; background-color:#494949; color:#fff;',
shade: false,
time: 1
});
}else{
_czc.push(["_trackEvent",'马上获取减税方案','点击']);
$.ajax({
type: 'POST',
url: window.location.protocol + '//www.wodeshebao.com/sbw/ent/sign',
data: $("#sendForm").serialize(),
dataType: 'json',
success: function(resp) {
if (resp.code == 200) {
window.location.replace("suc.html")
} else {
layer.open({
content: resp.msg,
style: 'width:auto; height:auto; font-size:0.32rem; background-color:#494949; color:#fff;',
shade: false,
time: 3
});
}
}
});
}
})
});
// isweixin
function is_weixin(){
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
//console.log("微信")
return true;
} else {
//console.log("其他浏览器")
return false;
}
}