consumer-coupon/js/script.js

151 lines
4.3 KiB
JavaScript
Raw Normal View History

2022-09-02 15:59:41 +00:00
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 //选取需求数字
}
2022-09-11 07:08:25 +00:00
$('.turntable').css({transition: 'all 3s'});
2022-09-02 15:59:41 +00:00
$('.turntable').css({transform: 'rotate('+needNum+'deg)'});
}
2022-09-11 07:32:21 +00:00
// 打开弹窗
2022-09-02 15:59:41 +00:00
setTimeout(function(){
$('.pull-bg').addClass('show');
$('.result-tips').addClass('show');
},3000)
});
2022-09-12 05:52:42 +00:00
2022-09-02 15:59:41 +00:00
// 关闭弹窗
$('.tips-btn').click(function(){
2022-09-11 07:48:48 +00:00
turntableFlag = true;
2022-09-11 07:32:21 +00:00
// 关闭弹窗
$('.pull-bg').removeClass('show');
$('.result-tips').removeClass('show');
// 归零
$('.turntable').css({transition: 'all 0s'});
$('.turntable').css({transform: 'rotate(0)'});
2022-09-02 15:59:41 +00:00
});
}
2022-09-12 05:52:42 +00:00
// 打开导航弹窗
2022-09-02 15:59:41 +00:00
if($('.navigation-btn').length){
// 打开弹窗
$('.navigation-btn').click(function(){
2022-09-12 05:52:42 +00:00
$('.pull-bg').addClass('show');
$('.navigation-box').addClass('show');
2022-09-03 10:14:57 +00:00
});
}
2022-09-12 05:52:42 +00:00
// 开始导航
if($('.navigation-box').length){
// 腾讯地图
$('.tx-navigation').click(function(){ // (lng,lat)
window.open('https://apis.map.qq.com/uri/v1/marker?marker=coord:30.763954,104.098515;addr:万圣家园B区;&referer=webtest')
});
// 百度地图
$('.bd-navigation').click(function(){ // (lng,lat)
window.open('http://api.map.baidu.com/marker?location=30.763954,104.098515&title=万圣家园B区&output=html')
});
// 高德地图
$('.gd-navigation').click(function(){ // (lat,lng)
window.open('https://uri.amap.com/marker?position=104.098515,30.763954&name=万圣家园B区')
});
}
// 关闭导航弹窗
if($('.pull-bg-navigation').length){
$('.pull-bg-navigation').click(function(){
$('.pull-bg').removeClass('show');
$('.navigation-box').removeClass('show');
2022-09-02 15:59:41 +00:00
});
}
// 使用卡券
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');
});
}
2022-09-03 10:14:57 +00:00
// 复制完整券码
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();
}
  }
});
}
2022-09-02 15:59:41 +00:00
})