write sth. upfront
Through the use of visual programming to implement the lottery function of WeChat applets, we will take you to a preliminary understanding of the power of iVX.
Article Catalog
- write sth. upfront
- iVX Development
- Lucky Draw Function Implementation
iVX Development
- Basic Introduction
iVX
It is a "zero-code" visual programming language, with a convenient online integrated development environment , do not need to download the development environment , you can open the browser to edit the project anytime and anywhere .
ivx public number: ivx_cn
iVX official website: /
- Advantages of low-code platforms
- Fast learning: programmers get up to speed quickly in a week, newbies reduce their learning time by two years.
- Rapid development: more than 5 times more efficient development thanks to drag and drop and configuration.
- Fast running: front-end and back-end using the most advanced framework, selected fusion cloud computing company core products.
- Rapid Maintenance: Efficiency is increased several times, and the product can still be quickly maintained after core developers leave.
![]()
Lucky Draw Function Implementation
Implementation methodology
1. The odds of drawing a prize are controlled by random number generation. If the random number is within the START and STOP intervals for a particular prize, it means that the prize has been drawn.
2. Practice of the nine-pointed grid
Nine objects are created by looping through the loop, and their current serial numbers are as follows.
0 1 2
3 4 5
6 7 8
The one with serial number 4 is the lucky draw button, while the other eight are arranged clockwise and correspond to the prizes one by one, with the following correspondence
Serial No. 0: Prize 0
Serial No. 1: Awards1
Serial No. 2: Prize 2
Serial No. 5: Prize 3
Serial No. 8: Awards 4
Serial No. 7: Prize 5
Serial No. 6: Awards 6
Serial No. 3: Awards 7
Save this correspondence in a one-dimensional array
For loop is bound to a one-dimensional array, through the current data 1 to the list of prizes to find the corresponding prize name, and then set a variable, the variable modulo 8 operation, when the remainder and the current data 1 is equal to the current rotation to the prize on behalf of the nine-gallon grid, and then through the trigger each time to the variable plus 1 to achieve the effect of rotation.
For every 8 turns of the grid, 4 turns, the trigger will be triggered 40 times. In addition to clicking the button has been obtained when the final results of the lottery, with 40 plus the return of the awards serial number and then subtract 1 is the total number of triggers triggered, when the trigger ends will be exactly stopped in the actual draw on the prize.
3. Realization of the carrousel draw
The difference between the carousel draw and the nine-grid is only that the trigger is triggered by changing the state to change the rotation angle of the carousel, here there are 8 prizes, then each prize occupies a sector angle of 45 °. We set the trigger interval to 0.2s, each trigger rotates 45° and the length of the transformation is the same as the trigger interval.
Similar to the Nine Lattice Draw, we spin the wheel 4 full rotations of 1440°, or 24 triggers, and then add the number of prizes returned minus 1 for the final total number of triggers, which stops when the wheel stops at the actual prize drawn.