Mini Program to Implement Sieve Lottery

Mini Program to Implement Sieve Lottery

This article example shares the specific code of the mini program to implement the sieve lottery for your reference. The specific content is as follows

Rendering

<!--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({
 
  /**
   * Initial data of the page */
  data: {
    activeTrue:"active1",
    rotateX:0,
    rotateY:0,
    rotateZ:0,
  },
 
  /**
   * Life cycle function--listen for page loading*/
  onLoad: function (options) {
    
  },
  gamePlay:function(){
    let _that = this;
    this.setData({
      activeTrue:"active2",
      rotateX:0,
      rotateY:0,
      rotateZ:0,
    })
    clearInterval(dingshiqi3)
    let _possible = [
      { 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 },
     ]
    // Prepare to draw a random number 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);
  },
  /**
   * Life cycle function - listen for the completion of the initial rendering of the page*/
  onReady: function () {
 
  },
 
  /**
   * Life cycle function--monitor page display*/
  onShow: function () {
 
  },
 
  /**
   * Life cycle function--listen for page hiding*/
  onHide: function () {
 
  },
 
  /**
   * Life cycle function--monitor page uninstallation*/
  onUnload: function () {
 
  },
 
  /**
   * Page related event processing function - listen to user pull-down action */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * The function that handles the bottoming event on the page*/
  onReachBottom: function () {
 
  },
 
  /**
   * User clicks on the upper right corner to share*/
  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);
}

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • WeChat applet realizes the effect of shaking the sieve

<<:  How to check the hard disk size and mount the hard disk in Linux

>>:  MySQL data migration using MySQLdump command

Recommend

Implementation of multi-port mapping of nginx reverse proxy

Code Explanation 1.1 http:www.baidu.test.com defa...

js to realize automatic lock screen function

1. Usage scenarios There is such a requirement, s...

Native js drag and drop function to create a slider example code

Drag and drop is a common function in the front e...

Several ways to add timestamps in MySQL tables

Scenario: The data in a table needs to be synchro...

JavaScript realizes the generation and verification of random codes

The generation and verification of random codes i...

MySQL sorting feature details

Table of contents 1. Problem scenario 2. Cause An...

Use Python to connect to MySQL database using the pymysql module

Install pymysql pip install pymysql 2|0Using pymy...

Docker data volume container creation and usage analysis

A data volume container is a container specifical...

MySQL InnoDB row_id boundary overflow verification method steps

background I talked to my classmates about a boun...

Vue implements a movable floating button

This article example shares the specific code of ...

Summary of common MySQL table design errors

Table of contents Mistake 1: Too many columns of ...

HTML CSS3 does not stretch the image display effect

1. Use the transform attribute to display the ima...

Summary of MySQL view principles and usage examples

This article summarizes the principles and usage ...