135 lines
3.9 KiB
JavaScript
135 lines
3.9 KiB
JavaScript
jQuery(function($){
|
||
// 轮播
|
||
if($('.banner-swiper').length){
|
||
var bannerSwiper = new Swiper('.banner-swiper', {
|
||
loop:true,//开启循环播放
|
||
autoplay: {//开启自动播放
|
||
delay:3000,
|
||
disableOnInteraction: false,//触摸后不会停止自动滚动
|
||
pauseOnMouseEnter: true,//鼠标置于swiper时暂停自动切换,鼠标离开时恢复自动切换。
|
||
}
|
||
})
|
||
}
|
||
|
||
// 抽奖
|
||
var turntableFlag = true;
|
||
if($('.pointer').length){
|
||
// 开始抽奖
|
||
$('.pointer').click(function(){
|
||
if(turntableFlag){
|
||
turntableFlag = false;
|
||
var ran = Math.ceil(Math.random()*100); //外层100以内的随机整数
|
||
if(ran<=55){ //通过概率判断选取数字
|
||
var needNum= 360*4-120; //选取需求数字
|
||
}else if(55<ran<=75){
|
||
var needNum= 360*4-60; //选取需求数字
|
||
}else if(75<ran<=85){
|
||
var needNum= 360*4-180; //选取需求数字
|
||
}else if(85<ran<=93){
|
||
var needNum= 360*4-240; //选取需求数字
|
||
}else if(93<ran<=98){
|
||
var needNum= 360*4-300; //选取需求数字
|
||
}else if(98<ran<=100){
|
||
var needNum= 360*4 //选取需求数字
|
||
}
|
||
$('.turntable').css({transition: 'all 3s'});
|
||
$('.turntable').css({transform: 'rotate('+needNum+'deg)'});
|
||
}
|
||
// 打开弹窗
|
||
setTimeout(function(){
|
||
$('.pull-bg').addClass('show');
|
||
$('.result-tips').addClass('show');
|
||
},3000)
|
||
});
|
||
// 关闭弹窗
|
||
$('.tips-btn').click(function(){
|
||
turntableFlag = true;
|
||
// 关闭弹窗
|
||
$('.pull-bg').removeClass('show');
|
||
$('.result-tips').removeClass('show');
|
||
// 归零
|
||
$('.turntable').css({transition: 'all 0s'});
|
||
$('.turntable').css({transform: 'rotate(0)'});
|
||
});
|
||
}
|
||
|
||
// 立即导航
|
||
if($('.navigation-btn').length){
|
||
// 打开弹窗
|
||
$('.navigation-btn').click(function(){
|
||
// 百度地图(纬度,经度)
|
||
window.open('http://api.map.baidu.com/marker?location=30.763954,104.098515&title=万圣家园B区&content=居民小区&output=html')
|
||
});
|
||
}
|
||
|
||
// 详情页导航
|
||
if($('.addr-item-btn').length){
|
||
// 打开弹窗
|
||
$('.addr-item-btn').click(function(){
|
||
// 百度地图(纬度,经度)
|
||
window.open('http://api.map.baidu.com/marker?location=30.763954,104.098515&title=万圣家园B区&content=居民小区&output=html')
|
||
});
|
||
}
|
||
|
||
// 使用卡券
|
||
if($('.card-btn').length){
|
||
// 打开弹窗
|
||
$('.card-btn').click(function(){
|
||
$('.pull-bg').addClass('show');
|
||
$('.card-window').addClass('show');
|
||
});
|
||
// 关闭弹窗
|
||
$('.pull-bg').click(function(){
|
||
$(this).removeClass('show');
|
||
$('.card-window').removeClass('show');
|
||
});
|
||
}
|
||
|
||
// 复制完整券码
|
||
if($('.copy-btn').length){
|
||
$('.copy-btn').click(function() {
|
||
var copyText = $(this).find('em').text(); //获取对象
|
||
var oInput = document.createElement('input');//创建一个input标签
|
||
oInput.value = copyText;//设置value属性
|
||
document.body.appendChild(oInput);//挂载到body下面
|
||
oInput.select(); // 选择对象
|
||
document.execCommand("Copy"); // 执行浏览器复制命令
|
||
oInput.className = 'oInput';
|
||
oInput.style.display='none';
|
||
$('.pull-bg').addClass('show');
|
||
$('.copy-tips').addClass('show');
|
||
setTimeout(function(){
|
||
$('.pull-bg').removeClass('show');
|
||
$('.copy-tips').removeClass('show');
|
||
},1000)
|
||
})
|
||
}
|
||
|
||
// 定义state
|
||
var state = true;
|
||
|
||
// 查询数据
|
||
function getData(){
|
||
setTimeout(function(){
|
||
state = true;
|
||
},1000)
|
||
}
|
||
|
||
// 触底
|
||
if($('.business-body').length){
|
||
$(window).scroll(function () {
|
||
var scrollTop = $(window).scrollTop();
|
||
var windowHeight = $(window).height();
|
||
var scrollHeight = $(document).height()-50;
|
||
console.log(scrollTop + windowHeight,scrollHeight);
|
||
if (scrollTop + windowHeight > scrollHeight) {
|
||
if(state){
|
||
//此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
|
||
console.log("到底了,发起请求");
|
||
state = false;
|
||
getData();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}) |