consumer-coupon/js/script.js

100 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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({transform: 'rotate('+needNum+'deg)'});
}
setTimeout(function(){
$('.pull-bg').addClass('show');
$('.result-tips').addClass('show');
},3000)
});
// 关闭弹窗
$('.tips-btn').click(function(){
// 刷新当前页面
location.reload(true);
});
}
// 立即导航
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)
})
}
})