当前位置:网站首页>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
边栏推荐
- Redis core technology and practice 1 - start with building a simple key value database simplekv
- 在渤海期货办理开户安全吗。
- On the forced conversion of C language pointer
- Pit encountered using camera x_ When onpause, the camera is not released, resulting in a black screen when it comes back
- MySQL practical skills
- Codeforces Round #783 (Div. 2) D题解
- OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
- js 计算时间差
- SQL常用的命令
- [advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
猜你喜欢

Audio signal processing and coding - 2.5.3 the discrete cosine transform

2022.04.23 (lc_763_divided into letter interval)

浅谈c语言指针的强制转换

An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary

An idea of rendering pipeline based on FBO

mysql通过binlog恢复或回滚数据

网络协议之:sctp流控制传输协议

The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics

Matlab 2019 installation of deep learning toolbox model for googlenet network

OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
随机推荐
MySQL practical skills
SSDB基础2
mysql通过binlog恢复或回滚数据
Strange problems in FrameLayout view hierarchy
Openlayers 5.0 two centering methods
[报告] Microsoft :Application of deep learning methods in speech enhancement
Class loading process of JVM
SSDB foundation 2
Summary of several relationships of UML class diagram
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
The fifth bullet of MySQL learning -- detailed explanation of transaction and its operation characteristics
js获取本机ip地址
JS controls the file type and size when uploading files
腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
JS calculation time difference
UML类图几种关系的总结
Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
SSDB基础
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
