php 抽奖

       最近做一个抽奖的功能,一开始毫无头绪,不知道随机这个概念,后来找了一堆资料,才慢慢知道这个原理

1、ps圆盘及箭头用于抽奖frontend展示

2、找jquery插件用于旋转箭头,jqueryRotate和jquery.easing,前者就是让图像旋转功能,后者就是让图像运动的效果

3、php端判断是否中奖,用了一个比较简单的方法

            $a =array_fill(0,$lottery['first_prize'], 1);
            $b = array_fill(0,$lottery['second_prize'], 2);
            $c = array_fill(0,$lottery['third_prize'], 3);
            $d = array_fill(0,$lottery['four_prize'], 4);
            $e = array_fill(0,$lottery['five_prize'], 5);
            $arr = array_merge($a, $b, $c, $d, $e);

            $total=count($arr);
            $luck = $arr[mt_rand(0,$total)];

            这样就能控制随机的中奖

4、前端箭头控制

      $(this).rotate({ 

                  duration: 3000, //转动时间 

                  angle: 0, //起始角度 

                  animateTo: 1440 + radio, //结束的角度 

                   easing: $.easing.easeOutSine, //定义运动的效果,需要引用jquery.easing.min.js的文件 

                   callback: function() { // 回调函数 

                            $("#message_box").text(message); 

                            $("#message_reward").modal('show'); 

                   } 

        });      






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值