当前位置:网站首页>Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy
2022-04-23 19:19:00 【"Technology makes customers"】
background
Who's cooking today , Who does the dishes , Who buys vegetables … ah ,Boss Say draw lots , So here's the picture
This has the problem of cheating ( Remember the characteristics of the stick , Who first? , Who smokes later... Wait ) So there's this little lottery program ( Of course, I control the applet alone , Whether I want to cheat depends on my mood )
brief introduction
Sweep code experience
Data services , Storage
This project uses wechat cloud development , Cloud database declares a lottery chouqianList Assemble ( Cloud development provides developers with complete native cloud support and wechat service support , Weakening back end and O & M concepts , There's no need to set up a server , Use the... Provided by the platform API Develop core business , Fast online and iterative )
Preparation before operation
(1) Sign up for wechat applet , obtain appid, Replace this item project.config.json Inside appid
(2) Open the cloud development of small programs
Concrete realization
home page
The home page has the theme of drawing lots from top to bottom , Lottery options , Initiate a draw , Often draw lots , The main function of this page is to initiate the drawing of lots , Save the contents of the lottery in the database .
Wechat audit tips
To solve this problem, add content to call this method ( Applet content security api, Cloud development can call )
isCheckMsg: function (msg) {
return new Promise(function (n, s) {
wx.cloud.callFunction({
name: 'msg',
data: ({
text: msg
})
}).then(res => {
if (res.result.errCode === 87014) {
// Failed to pass
n(false)
} else {
// (" adopt ")
n(true)
}
});
});
},
Random draw
// Recursive random return of lottery items
edchouqian() {
let that = this;
return new Promise(function (n, s) {
const db = wx.cloud.database()
// Query all of the current user's chouqianList
db.collection('chouqianList').where({
_id: that.data.drawlotsId
}).get({
success: res => {
that.setData({
detail: res.data[0].detail,
});
let nullDetail = res.data[0].detail.filter(item => item.openid == "");// Find out the options without drawing lots
let arrIndex = Math.floor((Math.random() * nullDetail.length));// Choose one option at random from options that don't have lots
let objindex = nullDetail[arrIndex].index;
n(objindex)
},
fail: err => {
wx.showToast({
icon: 'none',
title: ' Query record failed '
})
console.error('[ database ] [ Query log ] Failure :', err);
s(err);
}
})
});
},
Lottery page
The drawing tab has the function of drawing lots , Show the draw results , The main functions of this page , Query from the database whether the lot has been drawn , Lots have been drawn to show the results of the draw , Random allocation of lots without drawing lots ( Or show that the number of lots has been used up ).
For the problem of repeated lottery, use function anti shake or throttling
Draw results page
Draw results page , Show all the people who drew the lot and the results ( The results are obtained from the database according to the results of the drawing table id Inquire about )
That's it Source code address
Conclusion :
Because the hair time is relatively short , page 、 The function needs to be improved slowly , The released features also have some areas to be improved , Welcome the same like-minded coders to give more advice and exchange .ヾ(*╹◡╹)ノ~
Front end learning bosses 493671066, Many beauties . Old driver, get in the car , It's too late to explain .
Author correlation Vue article
be based on Vue2.0 Realize the authority control of background system
vue2.0- be based on elementui Skin peeler ( Custom theme )
VUE2.0 Add, delete, change, check, attach, edit, add model( bounced ) Component sharing
Reward Heartfelt thanks
版权声明
本文为["Technology makes customers"]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210559121039.html
边栏推荐
- SQL server requires to query the information of all employees with surname 'Wang'
- Redis core technology and practice 1 - start with building a simple key value database simplekv
- Regular expressions for judging positive integers
- Oracle configuration st_ geometry
- Parsing headless jsonarray arrays
- ArcMap publishing slicing service
- 2022.04.23 (the best time for lc_714_to buy and sell stocks, including handling charges)
- The flyer realizes page Jump through routing routes
- Steps to build a deep learning environment GPU
- Using 8266 as serial port debugging tool
猜你喜欢
mysql通过binlog恢复或回滚数据
Installation, use and problem summary of binlog2sql tool
An idea of rendering pipeline based on FBO
FTP, SSH Remote Access and control
Network protocol: SCTP flow control transmission protocol
ArcMap connecting ArcGIS Server
SQL常用的命令
redis优化系列(三)解决主从配置后的常见问题
Audio signal processing and coding - 2.5.3 the discrete cosine transform
FTP、ssh远程访问及控制
随机推荐
该买什么设备,Keysight 给你挑好了
Oracle configuration st_ geometry
js 计算时间差
js获取本机ip地址
ArcGIS JS API dojoconfig configuration
Codeforces Round #783 (Div. 2) D题解
Common processing of point cloud dataset
Transaction processing of SQL Server database
Pit encountered using camera x_ When onpause, the camera is not released, resulting in a black screen when it comes back
Customize the non slidable viewpage and how to use it
JVM的类加载过程
Using 8266 as serial port debugging tool
Xlslib use
2022.04.23(LC_763_划分字母区间)
在渤海期货办理开户安全吗。
为何PostgreSQL即将超越SQL Server?
Intuitive understanding of the essence of two-dimensional rotation
An idea of rendering pipeline based on FBO
redis优化系列(三)解决主从配置后的常见问题
PostgreSQL