web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

vue年会大转盘抽奖活动代码

163 ℃
     

Vue移动端抽奖组件,用于大转盘滚动抽奖场景,可配置奖品、图片、转盘样式等。下面web建站小编给大家简单介绍一下具体实现代码!

vue组件安装

import { createApp } from "vue";
// vue
import { Turntable } from "@nutui/nutui-bingo";
// taro
import { Turntable } from "@nutui/nutui-bingo-taro";

const app = createApp();
app.use(Turntable);

vue基础用法

<template>
  <nutbig-turntable
    class="turntable"
    ref="turntable"
    :width="luckWidth"
    :height="luckheight"
    :prize-list="prizeList"
    :turns-number="turnsNumber"
    :turns-time="turnsTime"
    :prize-index="prizeIndex"
    :style-opt="styleOpt"
    :pointer-style="pointerStyle"
    @start-turns="startTurns"
    @end-turns="endTurns"
  >
  </nutbig-turntable>
</template>
<script>
  import { Toast } from "@nutui/nutui";
  import { ref, reactive } from "vue";
  export default {
    setup() {
      const turntable = ref(null);
      // 转盘大小
      const luckWidth = ref("450px");
      const luckheight = ref("450px");
      // 转盘指针图片样式
      const pointerStyle = {
        width: "80px",
        height: "80px",
        backgroundImage:'url("背景图片")',
        backgroundSize: "contain",
        backgroundRepeat: "no-repeat",
      };
      // 转盘上要展示的奖品数据
      const prizeList = ref([
        {
          id: "xiaomi",
          prizeName: "小米手机",
          prizeImg: "小米手机图片.jpg",
        },
        {
          id: "huawei",
          prizeColor: "rgb(251, 219, 216)",
          prizeName: "华为手机",
          prizeImg: "华为手机图片.jpg",
        },
        {
          id: "apple",
          prizeName: "apple watch",
          prizeImg: "apple watch.jpg",
        },
        {
          id: "shubiao",
          prizeColor: "rgba(246, 142, 46, 0.5)",
          prizeName: "鼠标",
          prizeImg: "鼠标.jpg",
        },
        {
          id: "jianpan",
          prizeName: "键盘.jpg",
          prizeImg:
            "",
        },
        {
          id: "thanks",
          prizeName: "谢谢参与",
          prizeImg: "谢谢参与.jpg",
        },
      ]);
      // 转动圈数
      const turnsNumber = ref(5);
      // 转动需要持续的时间(秒)
      const turnsTime = ref(5);
      // 转盘样式的选项
      const styleOpt = reactive({
        // 转盘中每一块扇形的背景色,根据奖品的index来取每一块的对应颜色
        prizeBgColors: [
          "rgb(255, 231, 149)",
          "rgb(255, 247, 223)",
          "rgb(255, 231, 149)",
          "rgb(255, 247, 223)",
          "rgb(255, 231, 149)",
          "rgb(255, 247, 223)",
        ],
        // 每一个扇形的外边框颜色
        borderColor: "#ff9800",
      });
      // 中奖的奖品的index(此数据可根据后台返回的值重新赋值)
      const prizeIndex = ref(-1);
      // 剩余抽奖次数
      const num = ref(5);
      const startTurns = () => {
        const index = Math.floor(Math.random() * prizeList.value.length);
        prizeIndex.value = index;
        turntable.value.rotateTurn();
      };
      const endTurns = () => {
        console.log("中奖了");
      };
      return {
        turntable,
        luckWidth,
        luckheight,
        pointerStyle,
        prizeList,
        turnsNumber,
        turnsTime,
        styleOpt,
        prizeIndex,
        num,
        startTurns,
        endTurns,
      };
    },
  };
</script>

vue模拟娃娃机抽奖活动代码

vue红包摇一摇抽奖活动代码

vue商城红包雨抽奖活动代码

vue年会砸金蛋抽奖活动代码

vue年会刮刮卡抽奖活动代码

标签: vue大转盘, 年会抽奖, 抽奖活动

上面是“vue年会大转盘抽奖活动代码”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_14315.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计2006个字,预计阅读时长14分钟
生活小工具,收录了80多款小工具
上一篇: WordPress用自定义代码实现更高级的分页功能
下一篇: 车牌号输入HTML模板下载
x 打工人ai神器