当前位置:网站首页>基于ibeacons签到系统
基于ibeacons签到系统
2022-04-23 14:02:00 【1029179954】
基于ibeacons签到系统
具体功能:
老师:发起签到,结束签到和查看签到人数
学生:进行签到
硬件:ibeacons一个
软件:
整体分为2部分,通过不同的账号登录,区分人员身份,这个主要利用的是全局的变量。在app.js设置具体的变量
globalData: {
userInfo: null,
tag:1,//tag代表签到状态 1未发起签到 2是发起签到
count:0//count代表签到的人数 默认为0
}
老师部分的代码
(1)wxml
<view class="scan">
<view class="time-section">
<view class="time">
<view class="hourminuts">
<text>{
{hours}}:{
{minutes}}</text>
</view>
<view class="seconds">
<text>{
{seconds}}</text>
</view>
</view>
<view class="date">
<text>{
{month}}月{
{day}}日 {
{week}}</text>
</view>
</view>
<view class="footer">
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock">发起签到</button>
<button class="to-clock" hover-class="hover-to-clock" bindtap="todistance">结束签到</button>
<button class="to-clock" hover-class="hover-to-clock" bindtap="todistance1">签到人数</button>
</view>
<view class="date">
<text>{
{count4}}</text>
</view>
</view>
(2)js代码
发起签到
//发起签到
toClock(){
//tag==2发起签到
app.globalData.tag=2
console.log(app.globalData.tag)
wx.showToast({
title: '发起签到成功',
icon: 'loading',
duration: 2000
})
// var that = this
// that.timing()
},
结束签到
todistance(){
//tag==1结束签到
app.globalData.tag=1
console.log(app.globalData.tag)
wx.showToast({
title: '结束签到成功',
icon: 'loading',
duration: 2000
})
// var that = this
// clearTimeout(that.con)
},
查看签到人数
//查看签单人数
todistance1(){
var count2=app.globalData.count
var count3="签到总人数:"+count2
var that=this
that.setData({
count4:count3
})
},
学生部分代码
(1)wxml
<view class="scan">
<view class="time-section">
<view class="time">
<view class="hourminuts">
<text>{
{hours}}:{
{minutes}}</text>
</view>
<view class="seconds">
<text>{
{seconds}}</text>
</view>
</view>
<view class="date">
<text>{
{month}}月{
{day}}日 {
{week}}</text>
</view>
</view>
<view class="footer">
<button class="to-clock" hover-class="hover-to-clock" bindtap="toClock">签到</button>
</view>
<view class="date">
<text>{
{diatance}}</text>
</view>
</view>
(2)js代码
这部分代码涉及搜索ibeacons,连接ibeacons,连接成功则签到就成功,人数获取全局的变量+1就可以,代码如下:
//发现ibeacons
wx.startBeaconDiscovery({
//设置ibeacons的参数
uuids: ['E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'],
//连接成功
success: function () {
console.log("开始扫描设备")
//监听iBeacon设备的更新事件
wx.onBeaconUpdate(function (res) {
if (res && res.beacons && res.beacons.length > 0) {
console.log("设备的uuid是:"+res.beacons[0].uuid)
console.log("距离ibeacons的距离是:"+res.beacons[0].accuracy)
var distance=res.beacons[0].accuracy
//距离在3米
if(distance<3){
wx.showToast({
title: '签到成功',
icon: 'loading',
duration: 2000
})
//签到成功 人数+1
app.globalData.count=app.globalData.count+1
console.log("签到人数"+app.globalData.count)
}else{
wx.showToast({
title: '努力搜索中',
icon: 'loading',
duration: 2000
})
}
}
})
},
fail:function(){
wx.showToast({
title: '没进入设备范围',
icon: 'fail',
duration: 500
})
}
}),
实现效果和整个案例微信公众号搜索:小白XBIT即可获取
版权声明
本文为[1029179954]所创,转载请带上原文链接,感谢
https://blog.csdn.net/baidu_38978508/article/details/115831050
边栏推荐
- 1256: bouquet for algenon
- [code analysis (2)] communication efficient learning of deep networks from decentralized data
- Jiannanchun understood the word game
- PySide2
- JS force deduction brush question 102 Sequence traversal of binary tree
- 微信小程序基于udp协议与esp8266进行通信
- [code analysis (6)] communication efficient learning of deep networks from decentralized data
- JS 力扣刷题 103. 二叉树的锯齿形层序遍历
- 接口文档yaml
- Logging模块
猜你喜欢
Express②(路由)
服务器中挖矿病毒了,屮
Express middleware ③ (custom Middleware)
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
低频量化之明日涨停预测
联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
scikit-learn构建模型的万能模板
Basic knowledge learning record
Postman reference summary
Lin Lin, product manager of Lenovo: network failure of local network operator in Tianjin. The background server of Zui system can't work normally for the time being
随机推荐
About note 1
读了一篇博客,重新理解闭包整理一下
Basic knowledge learning record
Neuron and neural network
接口文档yaml
L2-024 tribe (25 points)
Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
腾讯根据ip解析地址
程序编译调试学习记录
JS 力扣刷题 102. 二叉树的层序遍历
生成随机高质量符合高斯分布的随机数
Analysis and understanding of atomicintegerarray source code
CentOS mysql多实例部署
Logging模块
Postman reference summary
村上春树 --《当我谈跑步时,我谈些什么》句子摘录
MySQL 修改主数据库
Express ② (routing)
【项目】小帽外卖(八)
crontab定时任务输出产生大量邮件耗尽文件系统inode问题处理