/**
* Created by tagguo on 2015/7/25.
*/
//页面加载后执行
/* 发送手机*/
/* 游戏规则*/
window.times = 0;
window.queryp = 0;
$(".All-pages").css({ "height": $(window).height() + 'px' });
//弹出游戏规则
$(function () {
$('.game').click(function () {
$('.theme-popover-game').fadeIn(100);
$('.theme-game').slideDown(200);
})
$('.btnrule').click(function () {
$('.theme-popover-game').fadeOut(100);
$('.theme-game').slideUp(200);
})
//打开查询验证
$('.inquireopen').click(function () {
$('.theme-popover-inquire').fadeIn(100);
$('.theme-inquire').slideDown(200);
})
$('.theme-poptit-inquire .close-inquire').click(function () { //查询关闭按钮
$('.theme-popover-inquire').fadeOut(100);
$('.theme-inquire').slideUp(200);
})
$('.gameprizeguanbi').click(function () {
$('.theme-popover-gameprize').fadeOut(100); //奖品关闭
$('.theme-gameprize').slideUp(200);
})
});
//开始转盘旋转
$(function () {
$(".prize").hide();
if ($(window).width() > 640) {
$(".All-pages").css({ "height": $(window).height() + 'px' });
}
if ($(window).width() > 640) {
$(".one").hide();
}
/*if($(window).width()<800){
$(".All-pages").css("background", "url(../images/c3background.jpg");
}*/
$(".cursor-box").removeAttr('style'); //失去转动
var num = 10;
var deg = 36 * num * 2; //旋转的角度
window.onload = function time() {
$(".cursor-box").css({
"transform-origin": "center center",
"transition": "all 3s cubic-bezier(0, 0, 0,0.0)",
"transform": "rotate(" + deg + "deg)" //旋转的角度,360为1圈
});
setTimeout(time, 10000); //time是指本身,延时递归调用自己,100为间隔调用时间,单位毫秒
}
//CSS3小灯排列
var lamp_html = '';
for (var i = 0; i < 36; i++) {
lamp_html += "
";
}
$(".turntable-box .lamp-list").prepend(lamp_html);
$(".turntable-box .lamp-list li").each(function (index) {
var deg = index * 10;
$(this).css({
"transform-origin": "bottom center", //变形原点transform-origin:x y;
"transform": "rotate(" + deg + "deg)" //旋转transform:rotate(0deg);
});
});
})
//抽奖过程
$(function () {
//中奖提示
var text_tip = ["ipad mini", "榨汁机", "电压力锅", "保鲜碗3件套装", "纯棉毛巾礼盒", "1000元大礼包", "500元大礼包", "100元大礼包", "感谢参与", "iphone 6 plus"];
//抽奖旋转
$('.cursor-box').click(function () {
if (window.times == 0) {
$('.theme-popover-mask').fadeIn(100);
$('.theme-popover').slideDown(200);
} else {
var phone = document.getElementById("phoneCode1").value; //"18824172109"; "15202054934"
var shopName = document.getElementById('shopSelect').value; //"芬尼广州番禺体验店";
$.ajax({
type: "POST",
url: "/tools/phnix_ajax.ashx?action=phnix_draw", //提交的页面/方法名
data: { 'phone': phone, 'shopName': shopName },
success: function (data) {
var drawresult = eval('(' + data + ')');
if (drawresult && drawresult.errCode == 0) {
if (drawresult.isPrized) {
for (var i = 1; i <= text_tip.length; i++) {
if (text_tip[i - 1] == drawresult.prizeName) {
zhuanpan(i, drawresult.prizeName);
break;
}
}
} else {
zhuanpan(9, "感谢参与");
}
} else if (drawresult.errCode == -1) {
alert(drawresult.errMsg);
} else if (drawresult.errCode == 1) {
alert(drawresult.errMsg);
} else {
alert(drawresult.errMsg);
}
},
error: function (err) {
alert('错误' + err.toString());
}
});
}
})
//获奖滚动转盘
var bRotate = false;
var rotateFn = function (awards, angles, prizeName) {
$('.prizetupian').fadeOut(6000); //隐藏广告
bRotate = !bRotate;
$('.b1').stopRotate();
$('.b1').rotate({
angle: 0,
animateTo: angles + 3600,
duration: 6000,
callback: function () {
$(".PCprize").html(prizeName);
$(".phone-prize").html(prizeName);
bRotate = !bRotate;
}
})
};
function zhuanpan(index, prizeName) {
$(".cursor-box").unbind();
//$(".cursor-box").removeAttr('style'); //指针失去移除事件
//公布奖品
setTimeout(function () {
if ($(window).width() > 700) { //Pc淡入
$(".prize").fadeIn(800);
}
if ($(window).width() < 680) { //移动弹框
$('.theme-popover-gameprize').fadeIn(100);
$('.theme-gameprize').slideDown(200);
}
}, 6000);
switch (index) {
case 0:
//rotateFn(0, 360, 'iphone 6 plus');
rotateFn(0, 360, prizeName);
break;
case 1:
//rotateFn(1, 36, 'ipad mini');
rotateFn(1, 36, prizeName);
break;
case 2:
//rotateFn(2, 72, '榨汁机 ');
rotateFn(2, 72, prizeName);
break;
case 3:
//rotateFn(3, 108, '电压力锅');
rotateFn(3, 108, prizeName);
break;
case 4:
//rotateFn(4, 144, '保鲜碗3件套装');
rotateFn(4, 144, prizeName);
break;
case 5:
//rotateFn(5, 180, '纯棉毛巾礼盒');
rotateFn(5, 180, prizeName);
break;
case 6:
//rotateFn(6, 216, '1000元大礼包');
rotateFn(6, 216, prizeName);
break;
case 7:
//rotateFn(7, 252, '500元大礼包');
rotateFn(7, 252, prizeName);
break;
case 8:
//rotateFn(8, 288, '100元大礼包');
rotateFn(8, 288, prizeName);
break;
case 9:
//rotateFn(9, 324, '感谢参与');
rotateFn(9, 324, prizeName);
break;
}
}
$('.theme-poptit .close').click(function () { //关闭 验证获取抽奖资格
$('.theme-popover-mask').fadeOut(100);
$('.theme-popover').slideUp(200);
})
// $("[type=submit]").click(function () { //手机验证获取抽奖资格
// window.times += 1;
// $('.theme-popover-mask').fadeOut(100);
// $('.theme-popover').slideUp(200);
// });
});
//滚动显示
$(function () {
var $this = $(".the-right-huadong");
var scrollTimer;
$this.hover(function () {
clearInterval(scrollTimer);
}, function () {
scrollTimer = setInterval(function () {
scrollNews($this);
}, 1000);
}).trigger("mouseout");
});
function scrollNews(obj) {
var $self = obj.find("ul:first");
var lineHeight = $self.find("li:first").height();
$self.animate({ "top": -lineHeight + "px" }, 1000, function () {
$self.css({ "top": "0px" }).find("li:first").appendTo($self);
});
}