小程序?qū)崿F(xiàn)篩子抽獎(jiǎng)
本文實(shí)例為大家分享了小程序?qū)崿F(xiàn)篩子抽獎(jiǎng)的具體代碼,供大家參考,具體內(nèi)容如下
效果圖

<!--pages/shaizi/index.wxml-->
<view class="container">
<view class="shaizi_box {{activeTrue}}" style="transform: rotateX({{rotateX}}deg) rotateY({{rotateY}}deg) rotateZ({{rotateZ}}deg);">
<view class="shaizi">1</view>
<view class="shaizi">2</view>
<view class="shaizi">3</view>
<view class="shaizi">4</view>
<view class="shaizi">5</view>
<view class="shaizi">6</view>
</view>
<text class="view"></text>
<button bindtap="gamePlay">PLAY</button>
</view>
// pages/shaizi/index.js
var dingshiqi1 = 0;
var dingshiqi2 = 0;
var dingshiqi3 = 0;
Page({
/**
* 頁(yè)面的初始數(shù)據(jù)
*/
data: {
activeTrue:"active1",
rotateX:0,
rotateY:0,
rotateZ:0,
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面加載
*/
onLoad: function (options) {
},
gamePlay:function(){
let _that = this;
this.setData({
activeTrue:"active2",
rotateX:0,
rotateY:0,
rotateZ:0,
})
clearInterval(dingshiqi3)
let _posible = [
{ value: 1, x: 0, y: 0 },
{ value: 6, x: 180, y: 0 },
{ value: 3, x: 0, y: -90 },
{ value: 4, x: 0, y: 90 },
{ value: 5, x: -90, y: 0 },
{ value: 2, x: 90, y: 0 },
]
// 準(zhǔn)備抽取的隨機(jī)數(shù)
let _random = Math.floor(Math.random() * 6);
dingshiqi1 = setTimeout(() => {
_that.setData({
rotateX:360,
rotateY:250,
rotateZ:0,
})
}, 0);
dingshiqi2 = setTimeout(() => {
_that.setData({
rotateX:_posible[_random].x,
rotateY:_posible[_random].y,
})
dingshiqi3 = setTimeout(() => {
_that.setData({
activeTrue:"active1",
})
}, 4500);
}, 800);
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面顯示
*/
onShow: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面隱藏
*/
onHide: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁(yè)面卸載
*/
onUnload: function () {
},
/**
* 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作
*/
onPullDownRefresh: function () {
},
/**
* 頁(yè)面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function () {
},
/**
* 用戶點(diǎn)擊右上角分享
*/
onShareAppMessage: function () {
}
})
/* pages/shaizi/index.wxss */
@keyframes rotate {
to {
transform: rotateX(360deg) rotateY(250deg);
}
}
@keyframes shaiziCss{
20%{
transform: rotateX(20deg);
}
60%{
transform: rotateX(20deg) rotateY(200deg);
}
100%{
transform: rotateX(100deg) rotateY(1000deg) rotateZ(-100deg);
}
}
.shaizi_box {
width: 200rpx;
height: 200rpx;
margin: 200rpx auto;
position: relative;
transform-style: preserve-3d;
animation-duration: 3s;
animation-timing-function: linear;
transition: all 1s;
}
.shaizi_box.active1{
animation: rotate 5s linear 0s infinite alternate !important;
}
.shaizi_box.active2{
animation: shaiziCss 2s !important;
}
.shaizi_box .shaizi {
width: 200rpx;
height: 200rpx;
display: flex;
position: absolute;
left: 0;
top: 0;
border: 1px solid #000;
background: rgb(253, 250, 250);
border-radius: 20rpx;
font-size: 100rpx;
color: red;
text-align: center;
}
.shaizi:nth-child(1) {
justify-content: center;
align-items: center;
transform: translateZ(100rpx);
}
.shaizi:nth-child(2) {
justify-content: space-around;
align-items: center;
transform: rotateX(-90deg) translateZ(100rpx);
}
.shaizi:nth-child(3) {
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
transform: rotateY(90deg) translateZ(100rpx);
}
.shaizi:nth-child(4) {
flex-wrap: wrap;
justify-content: center;
align-items: center;
transform: rotateY(-90deg) translateZ(100rpx);
}
.shaizi:nth-child(5) {
flex-wrap: wrap;
justify-content: center;
align-items: center;
transform: rotateX(90deg) translateZ(100rpx);
}
.shaizi:nth-child(6) {
flex-wrap: wrap;
justify-content: center;
align-items: center;
transform: rotateX(-180deg) translateZ(100rpx);
}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS中函數(shù)科里化的背景與應(yīng)用實(shí)例教程
在數(shù)學(xué)和計(jì)算機(jī)科學(xué)中,柯里化是一種將使用多個(gè)參數(shù)的一個(gè)函數(shù)轉(zhuǎn)換成一系列使用一個(gè)參數(shù)的函數(shù)的技術(shù),下面這篇文章主要給大家介紹了JS中函數(shù)科里化的背景與應(yīng)用實(shí)例的相關(guān)資料,需要的朋友可以參考下2022-06-06
JavaScript設(shè)計(jì)模式--簡(jiǎn)單工廠模式實(shí)例分析【XHR工廠案例】
這篇文章主要介紹了JavaScript設(shè)計(jì)模式--簡(jiǎn)單工廠模式,結(jié)合實(shí)例形式分析了JavaScript設(shè)計(jì)模式中簡(jiǎn)單工廠模式原理與XHR工廠應(yīng)用案例,需要的朋友可以參考下2020-05-05
高性能JavaScript模板引擎實(shí)現(xiàn)原理詳解
這篇文章主要介紹了JavaScript模板引擎實(shí)現(xiàn)原理詳解,本文著重講解artTemplate模板的實(shí)現(xiàn)原理,它采用預(yù)編譯方式讓性能有了質(zhì)的飛躍,是其它知名模板引擎的25、32 倍,需要的朋友可以參考下2015-02-02
JavaScript實(shí)現(xiàn)簡(jiǎn)易計(jì)算器功能的兩種方法
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)簡(jiǎn)易計(jì)算器功能的兩種方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-07-07
JavaScript設(shè)計(jì)模式之抽象工廠模式介紹
這篇文章主要介紹了JavaScript設(shè)計(jì)模式之抽象工廠模式介紹,抽象工廠模式就是對(duì)功能類單獨(dú)創(chuàng)建工廠類,這樣就不必修改之前的代碼,又?jǐn)U展了功能,需要的朋友可以參考下2014-12-12
Three.js實(shí)現(xiàn)臉書元宇宙3D動(dòng)態(tài)Logo效果
本文主要講述通過 Three.js + Blender 技術(shù)棧,實(shí)現(xiàn) Meta 公司炫酷的 3D 動(dòng)態(tài) Logo,內(nèi)容包括基礎(chǔ)模型圓環(huán)、環(huán)面扭結(jié)、管道及模型生成、模型加載、添加動(dòng)畫、添加點(diǎn)擊事件、更換材質(zhì)等2021-11-11
關(guān)于JavaScript使用export和import的兩個(gè)報(bào)錯(cuò)解決
說來慚愧es6寫了這么久,連最基本的export和import都沒搞明白,下面這篇文章主要給大家介紹了關(guān)于JavaScript使用export和import的兩個(gè)報(bào)錯(cuò)的解決方法,需要的朋友可以參考下2022-07-07
javascript回車完美實(shí)現(xiàn)tab切換功能
這篇文章主要介紹了javascript通過回車實(shí)現(xiàn)tab切換功能,需要的朋友可以參考下2014-03-03

