|
@@ -9,6 +9,7 @@
|
|
|
<script src="js/jquery.min.js"></script>
|
|
|
<link rel="stylesheet" href="css/lottery.css" type="text/css" />
|
|
|
<script type="text/javascript">
|
|
|
+ var id = 3;
|
|
|
var current = 0;
|
|
|
var last = 0;
|
|
|
var threshold = 0;
|
|
@@ -21,6 +22,13 @@
|
|
|
setPosition();
|
|
|
});
|
|
|
|
|
|
+ //在这里查看是否有id
|
|
|
+ if(id == null){
|
|
|
+ alert("请先登录");
|
|
|
+ window.location.href = "index.html";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//获取
|
|
|
$.post("../prize/luckDrawList", {}, function(resp) {
|
|
|
if (resp.code == 'error') {
|
|
@@ -35,14 +43,12 @@
|
|
|
//点击抽奖
|
|
|
$(".button").click(function () {
|
|
|
if(enable == true){
|
|
|
-
|
|
|
- //获取
|
|
|
- $.post("../prize/luckDraw", {userId: 6}, function(resp) {
|
|
|
+// 获取抽奖结果
|
|
|
+ $.post("../prize/luckDraw", {userId: id}, function(resp) {
|
|
|
if (resp.code == 'error') {
|
|
|
- console.log(resp.code);
|
|
|
alert(resp.msg);
|
|
|
}else{
|
|
|
- //进入不可点击状态
|
|
|
+ //进入不可点击状态
|
|
|
enable = false;
|
|
|
//设置初始速度
|
|
|
speed = 60;
|
|
@@ -51,14 +57,19 @@
|
|
|
threshold = 4;
|
|
|
}else if(resp.data.prizeLevel == 0){
|
|
|
threshold = 6;
|
|
|
+ $(".result_success_logo").attr("src", "images/result_oil_60_2.png")
|
|
|
}else if(resp.data.prizeLevel == 1){
|
|
|
- threshold = 7;
|
|
|
+ threshold = 7;
|
|
|
+ $(".result_success_logo").attr("src", "images/result_oil5_2.png")
|
|
|
}else if(resp.data.prizeLevel == 2){
|
|
|
- threshold = 2;
|
|
|
+ threshold = 2;
|
|
|
+ $(".result_success_logo").attr("src", "images/result_oil10_2.png")
|
|
|
}else if(resp.data.prizeLevel == 3){
|
|
|
- threshold = 5;
|
|
|
+ threshold = 5;
|
|
|
+ $(".result_success_logo").attr("src", "images/result_soap2.png")
|
|
|
}else if(resp.data.prizeLevel == 4){
|
|
|
- threshold = 0;
|
|
|
+ threshold = 0;
|
|
|
+ $(".result_success_logo").attr("src", "images/result_book2.png")
|
|
|
}else{
|
|
|
threshold = 4;
|
|
|
}
|
|
@@ -71,7 +82,28 @@
|
|
|
});
|
|
|
//谢谢惠顾后点击的按钮
|
|
|
$(".result_failed_button").click(function () {
|
|
|
- alert("点击了再玩一次");
|
|
|
+ window.location.href = "index.html";
|
|
|
+ });
|
|
|
+ //领取奖品按钮
|
|
|
+ $(".result_success_button").click(function () {
|
|
|
+ var name = $(".result_success_name").val();
|
|
|
+ var phone = $(".result_success_phone").val();
|
|
|
+ if(name == "" || phone == ""){
|
|
|
+ alert("请填写完整信息");
|
|
|
+ }else{
|
|
|
+ $.post("../prize/luckDrawAddInfo", {
|
|
|
+ id: id,
|
|
|
+ phone: phone,
|
|
|
+ username: name
|
|
|
+ }, function(resp) {
|
|
|
+ if (resp.code == 'error') {
|
|
|
+ console.log(resp.code);
|
|
|
+ }else{
|
|
|
+ alert("填写成功");
|
|
|
+ window.location.href = "index.html";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
});
|
|
@@ -107,7 +139,11 @@
|
|
|
setTimeout(function(){next()}, speed);
|
|
|
}else{
|
|
|
setTimeout(function(){
|
|
|
- alert("抽奖完毕,抽到了" + threshold + "号");
|
|
|
+ if(threshold == 4){
|
|
|
+ failed();
|
|
|
+ }else{
|
|
|
+ success();
|
|
|
+ }
|
|
|
enable = true;
|
|
|
}, 1500);
|
|
|
}
|
|
@@ -130,14 +166,38 @@
|
|
|
$(".failed").show();
|
|
|
$(".result_failed_button").show();
|
|
|
}
|
|
|
+
|
|
|
+ //判断微信分享
|
|
|
+ document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
|
|
|
+ //发送给好友
|
|
|
+ WeixinJSBridge.on('menu:share:appmessage', function(argv){
|
|
|
+ $.post("../prize/luckDrawAddShare", {uid: id}, function(resp) {
|
|
|
+ if (resp.code == 'error') {
|
|
|
+ console.log(resp.code);
|
|
|
+ }else{
|
|
|
+ alert("分享成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //分享到朋友圈
|
|
|
+ WeixinJSBridge.on('menu:share:timeline', function(argv){
|
|
|
+ $.post("../prize/luckDrawAddShare", {uid: id}, function(resp) {
|
|
|
+ if (resp.code == 'error') {
|
|
|
+ console.log(resp.code);
|
|
|
+ }else{
|
|
|
+ alert("分享成功");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }, false);
|
|
|
</script>
|
|
|
</head>
|
|
|
|
|
|
-<body>
|
|
|
+<body style="width: 100%">
|
|
|
<img class="background" src="images/lottery_background.png">
|
|
|
<img class="pool" src="images/lottery_pool.png">
|
|
|
<div class="container">
|
|
|
- <img class="item item0 active" src="images/reward_book.png">
|
|
|
+ <img class="item item0" src="images/reward_book.png">
|
|
|
<img class="item item1" src="images/reward_soap.png">
|
|
|
<img class="item item2" src="images/reward_oil10.png">
|
|
|
<img class="item item7" src="images/reward_oil5.png">
|
|
@@ -191,7 +251,7 @@
|
|
|
<div class="mask" style="display: none;"></div>
|
|
|
<img class="result success" src="images/result_success.png" style="display: none;">
|
|
|
<p class="result_success_title" style="display: none;">输入个人信息进行领奖</p>
|
|
|
- <img class="result_success_logo" src="images/reward_oil10_2.png" style="display: none;">
|
|
|
+ <img class="result_success_logo" style="display: none;">
|
|
|
<input class="result_success_name" type="text" placeholder="姓名" style="display: none;">
|
|
|
<input class="result_success_phone" type="text" placeholder="手机号" style="display: none;">
|
|
|
<img class="result_success_button" src="images/result_success_button.png" style="display: none;">
|
|
@@ -199,5 +259,4 @@
|
|
|
<img class="result failed" src="images/result_failed.png" style="display: none;">
|
|
|
<img class="result_failed_button" src="images/result_failed_button.png" style="display: none;">
|
|
|
</body>
|
|
|
-
|
|
|
</html>
|