基于JS+Vue.js实现抽奖大转盘

Hello,大家好,我是CodingSir,一枚十多年的程序员,同时也是一名在读研究生,关注我,且看一个平凡的程序员如何在自我成长,CodingSir只为各位小伙伴提供编程相关干货知识,希望在自我蜕变的路上,我们一起努力,努力什么时候开始都不晚,我,从现在开始做起!

一、前言

最近的一个项目因为目前新增用户和日活用户不断下滑,所以结合情况需要加一个抽奖大转盘,所以本篇就把前端实现抽奖大转盘的代码分享出来,本次大转盘主要是使用js+vue.js实现的,希望可以给你带来一丝灵感。

二、抽奖大转盘实现步骤

2.1 需求原型

要求实现一个抽奖大转盘的功能

2.2 编码实现

主要分为3块实现,分别是:1.页面标签绘制 2.页面标签样式设置 3.页面交互,主要是结合js+vue.js实现抽奖的动作交互行为

页面绘制:

<div id="app">
<!--    标题-->
    <h1 style="color: white;text-align: center;margin: 50px">CodingSir-抽奖大转盘</h1>
<!--    抽奖部分-->
    <div class="container-out">
        <div class="container-in">
            <div class="content-out" v-for="(box,index) in list"
                 :style="{left:box.left+'px',top:box.top+'px','background-color':index==indexSelect?colorSelect:colorDefault}">
                <img class="pond-name-img" :src="box.image_url" alt="">
                <div class="pond-name">{
  {box.name}}</div>
            </div>
        </div>
        <div class="start-btn" v-on:click="startBtn">
            <img src="../imgs/pond-button.png" style="height:80px;width:100%;" alt="">
            <img src="../imgs/pond-cj.png" :style="{'top':btntop+'px'}"
                 style="position:absolute;left:5px;height:68px;width:89px;top:0;" alt="">
        </div>
        <div class="circle" v-for="(item,index) in circleList"
             :style="{'top':item.topCircle+'px','left':item.leftCircle+'px','background-color':index%2==0?colorFirst:colorSecond}">
        </div>
    </div>
<!-- 抽奖结果展示-->
    <div class="prize" v-show="prize==1">
        <div class="prize-box">
            <img class="prize-img" src="../imgs/pond-success.png" alt="">
            <div class="prize-msg">
        
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值