jQuery九宫格抽奖活动代码

  [复制链接]
查看2164 | 回复3 | 2019-6-30 14:35:31 | 显示全部楼层 |阅读模式
案例截图:
360截图17411029489481.png

部分源码
  1. <script type="text/javascript">
  2. var lottery = {
  3.         index: -1,    //当前转动到哪个位置,起点位置
  4.         count: 0,     //总共有多少个位置
  5.         timer: 0,     //setTimeout的ID,用clearTimeout清除
  6.         speed: 20,    //初始转动速度
  7.         times: 0,     //转动次数
  8.         cycle: 50,    //转动基本次数:即至少需要转动多少次再进入抽奖环节
  9.         prize: -1,    //中奖位置
  10.         init: function(id) {
  11.                 if ($('#' + id).find('.lottery-unit').length > 0) {
  12.                         $lottery = $('#' + id);
  13.                         $units = $lottery.find('.lottery-unit');
  14.                         this.obj = $lottery;
  15.                         this.count = $units.length;
  16.                         $lottery.find('.lottery-unit.lottery-unit-' + this.index).addClass('active');
  17.                 };
  18.         },
  19.         roll: function() {
  20.                 var index = this.index;
  21.                 var count = this.count;
  22.                 var lottery = this.obj;
  23.                 $(lottery).find('.lottery-unit.lottery-unit-' + index).removeClass('active');
  24.                 index += 1;
  25.                 if (index > count - 1) {
  26.                         index = 0;
  27.                 };
  28.                 $(lottery).find('.lottery-unit.lottery-unit-' + index).addClass('active');
  29.                 this.index = index;
  30.                 return false;
  31.         },
  32.         stop: function(index) {
  33.                 this.prize = index;
  34.                 return false;
  35.         }
  36. };
  37. </script>
复制代码


百度网盘地址:
链接:https://pan.baidu.com/s/1lCIQjy4U5TIIVST5NEbBvg
提取码:349e
回复

使用道具 举报

Legolas | 2020-2-4 07:54:52 | 显示全部楼层
强烈支持楼主ing……学习先,谢谢了
回复

使用道具 举报

what164 | 2020-2-8 18:20:15 | 显示全部楼层

强烈支持楼主ing……
回复

使用道具 举报

what164 | 2020-2-8 18:22:12 | 显示全部楼层

强烈支持楼主ing……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则