|
//中奖记录
function lotteryrecord() {
var t = "",
e = json_ajax("/shop/index.php?act=lottery&url=get_isOklotteryList",t,"GET",!0);
if (e) {
var r = e.length;
if (r > 0) {
for (var o = "",
i = 0; r > i; i++) o += "<li><span> 恭喜" + e[i].member_mobile + " 获得 奖品 【<a>" + e[i].title + "】</a>,快去试手气吧 !</li>";
$("#lotteryrecord").html(o)
} else {
var o = "<li><span>大奖等着你,快去试手气 !</span></li>";
$("#lotteryrecord").html(o)
}
}
jQuery(".brand-main02-right-box01-wrap").slide({
mainCell: ".brand-main02-right-box01 ul",
autoPage: !0,
effect: "top",
autoPlay: !0,
vis: 6
})
}
//如果中奖获取中奖详细信息
function lotterygrand() {
}
function startLottery() {
lotteryrecord();
if ($("#nolottery").hide(), $("#winlottery").hide(), lottery.init("lottery"), !click) {
lottery.speed = 100;
var t = $("#user_id").val();
if ("0" == t) userLogin();
else {
var e = "",
r = json_ajax("/shop/index.php?act=lottery&url=ajax_get_mylottery",e,"POST",!0);
//alert(r.data.prize_name);
if (r && r.result) switch (r.result) {
case "0":
userLogin();
break;
case "1":
//本期活动已经关闭!
$("#close").show();
break;
case "2":
//您的积分暂时不足,赚足积分再来玩吧!
$("#jifen").show();
break;
case "3":
//本期活动结束
$("#jieshu").show();
break;
case "4":
//今天摇奖次数已经用完,明天再来吧!
$("#cishu").show();
break;
case "7":
//异常
break;
case "6":
//您的手机号码没有绑定!
$("#shenhe").show();
break;
case "5":
$("#lottery").attr("state", r.data.state),
$("#lottery").attr("prize_site", r.data.prize_site),
$("#lottery").attr("prize_name", r.data.prize_name),
$("#lottery").attr("prize_type", r.data.prize_type),
$("#lottery").attr("copywriter", r.data.copywriter),
$("#lottery").attr("prize_point", r.data.prize_point),
$("#lottery").attr("user_points", r.data.user_points),
roll(),
click = !0
} else alert("网络异常,请检测网络线路!")
}
}
}
function userLogin() {
// login_dialog();
alert('请先登录');
}
function prize_show(t) {
var e = $("#lottery").attr("copywriter");
if ("0" == t) {
var r = $("#lottery").attr("prize_point");
$("#wincopywriter").html(e),
$("#winpoint").html(r + "积分"),
$("#winlottery").fadeIn(1500),
lotterygrand()
} else {
var o = $("#lottery").attr("prize_name");
$("#winpoint").html(o),
$("#wincopywriter").html("<a href='#'>填写收货地址</a>"),
$("#winlottery").fadeIn(1500),
lotteryrecord()
}
}
function roll() {
lottery.times += 1,
lottery.roll();//转动过程调用的是lottery的roll方法,这里是第一次调用初始化
var t = $("#lottery").attr("prize_site");
if (lottery.times > lottery.cycle + 10 && lottery.index == t) {
var e = $("#lottery").attr("state"),
r = $("#lottery").attr("copywriter");
if ("0" == e) $("#nocopywriter").html(r),
$("#nolottery").fadeIn(1500);
else {
var o = $("#lottery").attr("prize_type");
prize_show(o)
}
var i = $("#lottery").attr("user_points");
$("#lotteryPoint").html(i),
$("#no_users_point").html(i),
$("#win_users_point").html(i),
clearTimeout(lottery.timer),
lottery.prize = 0,
lottery.times = 0,
click = !1
} else {
if (lottery.times < lottery.cycle) lottery.speed -= 10;
else if (lottery.times == lottery.cycle) {
var l = Math.random() * lottery.count | 0;
lottery.prize = l
} else lottery.speed += lottery.times > lottery.cycle + 10 && (0 == lottery.prize && 7 == lottery.index || lottery.prize == lottery.index + 1) ? 110 : 20;
lottery.speed < 40 && (lottery.speed = 35),
lottery.timer = setTimeout(roll, lottery.speed);//循环调用
}
return ! 1
}
var lottery = {
index: -1,//当前转动到哪个位置,起点位置
count: 9, //总共有多少个位置
timer: 0, //setTimeout的ID,用clearTimeout清除
speed: 20,//初始转动速度
times: 0, //转动次数
cycle: 50,//转动基本次数:即至少需要转动多少次再进入抽奖环节
prize: 0, //中奖位置
init: function(t) {
$("#" + t).find(".lottery-unit").length > 0 && ($lottery = $("#" + t), $units = $lottery.find(".lottery-unit"), this.obj = $lottery, this.count = $units.length, $lottery.find(".lottery-unit-" + this.index).addClass("active"))
},
roll: function() {
var t = this.index,
e = this.count,
r = this.obj;
return $(r).find(".lottery-unit-" + t).removeClass("active"),
t += 1,
t > e - 1 && (t = 0),
$(r).find(".lottery-unit-" + t).addClass("active"),
this.index = t,
!1
},
stop: function(t) {
return this.prize = t,
!1
}
},
click = !1;
window.onload = function() {
lotterygrand();
lotteryrecord();
lottery.init("lottery");
};
|