当前位置:网站首页>基于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
边栏推荐
- MySQL 修改主数据库
- JS 力扣刷题 102. 二叉树的层序遍历
- STM32 learning record 0007 - new project (based on register version)
- Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
- Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
- 对List集合进行分页
- 关于pthread多线程一些好文章
- VsCode-Go
- Function executes only the once function for the first time
- Oracle alarm log alert Chinese trace and trace files
猜你喜欢
随机推荐
快捷键(多行)
json反序列化匿名数组/对象
linux安装mysql后修改密码
About note 1
MySQL 修改主数据库
JS force deduction brush question 102 Sequence traversal of binary tree
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
Universal template for scikit learn model construction
Atcoder beginer contest 248c dice sum (generating function)
Android篇:2019初中级Android开发社招面试解答(中
Spark入门基本操作
leetcode--977. Squares of a Sorted Array
Function executes only the once function for the first time
Business case | how to promote the activity of sports and health app users? It is enough to do these points well
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
FDFS start
freeCodeCamp----time_ Calculator exercise
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
nodejs通过require读取本地json文件出现Unexpected token / in JSON at position
The art of automation