微信小程序?qū)崿F(xiàn)轉(zhuǎn)盤抽獎(jiǎng)
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)轉(zhuǎn)盤抽獎(jiǎng)的具體代碼,供大家參考,具體內(nèi)容如下
效果圖如下所示
.wxml
<view class="index"> <view class="xian"></view> <view class="xian"></view> <view class="xian"></view> <view class="detail">一等獎(jiǎng)</view> <view class="detail">二等獎(jiǎng)</view> <view class="detail">三等獎(jiǎng)</view> <view class="detail">四等獎(jiǎng)</view> <view class="detail">五等獎(jiǎng)</view> <view class="detail">六等獎(jiǎng)</view> <span bindtap="zhuanin" style="transform:rotate({{trasn}}deg);"></span> </view>
.wxss
.index{ width: 300px; margin: 50rpx calc((100% - 300px) / 2); border:1px solid #ffcccc; border-radius: 50%; height: 300px; position: relative; overflow: hidden; font-size: 26rpx; } .xian{ width:300px; height:1px; background:#d6d6d6; position:absolute; top:150px; left:0; } .index>.xian:nth-child(2){ transform:rotateZ(60deg) } .index>.xian:nth-child(3){ transform:rotateZ(120deg) } .detail{ position: absolute; } .index>.detail:nth-child(4){ top:25px;left:132px; } .index>.detail:nth-child(5){ top:90px;left:225px; } .index>.detail:nth-child(6){ top:190px;left:225px; } .index>.detail:nth-child(7){ top:250px;left:132px; } .index>.detail:nth-child(8){ top:190px;left:40px; } .index>.detail:nth-child(9){ top:90px;left:40px; } .index>span{ width: 30px; height: 30px; background-color: #ffcccc; border-radius: 50%; position: absolute; left: 135px; top:135px; } .index>span::after{ content: ' '; width:0; height:0; border-right:6px solid transparent; border-left:6px solid transparent; border-bottom:26px solid #ffcccc; z-index: 10; position: absolute; left: 8.5px; top: -24px; }
.js
Page({ data: { random:'', trasn:0, }, zhuanin:function(e){ let that = this let num = 0 that.setData({ random:Math.floor(Math.random() * 360), trasn:0, }) let a = setInterval(function () { that.setData({ trasn:that.data.trasn+5 }) if(360 <= that.data.trasn){ that.data.trasn = 0 num = num + 1 } if(num == 3){ that.currinl() clearInterval(a) } },5) }, currinl:function(e){ let that = this let name = '' if(that.data.random == 30 || that.data.random == 90 || that.data.random == 150 || that.data.random == 210 || that.data.random == 330){ that.setData({ random:that.data.random + 1 }) } if(that.data.random < 30 || 330 < that.data.random){ name = '一等獎(jiǎng)' }else if(that.data.random > 30 && that.data.random < 90){ name = '二等獎(jiǎng)' }else if(that.data.random > 90 && that.data.random < 150){ name = '三等獎(jiǎng)' }else if(that.data.random > 150 && that.data.random < 210){ name = '四等獎(jiǎng)' }else if(that.data.random > 210 && that.data.random < 270){ name = "五等獎(jiǎng)" }else{ name = "六等獎(jiǎng)" } let b = setInterval(function () { that.setData({ trasn:that.data.trasn+2 }) if(that.data.random <= that.data.trasn){ wx.showToast({ title: name, icon: 'none', duration: 2000 }) clearInterval(b) } },10) }, })
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 微信小程序開發(fā)之大轉(zhuǎn)盤 仿天貓超市抽獎(jiǎng)實(shí)例
- 微信小程序?qū)崿F(xiàn)簡(jiǎn)單九宮格抽獎(jiǎng)
- 微信小程序?qū)崿F(xiàn)走馬燈式抽獎(jiǎng)
- 微信小程序抽獎(jiǎng)組件的使用步驟
- 微信小程序?qū)崿F(xiàn)翻牌抽獎(jiǎng)動(dòng)畫
- 微信小程序 扭蛋抽獎(jiǎng)機(jī)css3動(dòng)畫實(shí)現(xiàn)詳解
- 微信小程序?qū)崿F(xiàn)九宮格抽獎(jiǎng)
- 微信小程序?qū)崿F(xiàn)多宮格抽獎(jiǎng)活動(dòng)
- 微信小程序 搖一搖抽獎(jiǎng)簡(jiǎn)單實(shí)例實(shí)現(xiàn)代碼
- 微信小程序轉(zhuǎn)盤抽獎(jiǎng)的實(shí)現(xiàn)方法
相關(guān)文章
在table中插入多行,能使用與insertAdjacentHTML相似的功能嗎?
在table中插入多行,能使用與insertAdjacentHTML相似的功能嗎?...2006-12-12JS實(shí)現(xiàn)根據(jù)文件字節(jié)數(shù)返回文件大小的方法
這篇文章主要介紹了JS實(shí)現(xiàn)根據(jù)文件字節(jié)數(shù)返回文件大小的方法,涉及javascript數(shù)值計(jì)算與字符串操作相關(guān)技巧,需要的朋友可以參考下2016-08-08JS DOMReady事件的六種實(shí)現(xiàn)方法總結(jié)
下面小編就為大家?guī)?lái)一篇JS DOMReady事件的六種實(shí)現(xiàn)方法總結(jié)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-11-11js實(shí)現(xiàn)點(diǎn)擊按鈕復(fù)制文本功能
這篇文章主要為大家詳細(xì)介紹了原生js實(shí)現(xiàn)點(diǎn)擊按鈕復(fù)制文本的相關(guān)代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-04-04使用JavaScript 編寫簡(jiǎn)單計(jì)算器
這篇文章主要介紹了使用JavaScript 編寫簡(jiǎn)單計(jì)算器,需要的朋友可以參考下2014-11-11ES6?關(guān)鍵字?let?和?ES5?及關(guān)鍵字?var?的區(qū)別解析
var可以穿透控制語(yǔ)句、條件語(yǔ)句這樣的作用域,導(dǎo)致變量沖突經(jīng)常發(fā)生,這篇文章主要介紹了ES6?關(guān)鍵字?let?和?ES5?及關(guān)鍵字?var?的區(qū)別,需要的朋友可以參考下2022-09-09