当前位置:网站首页>基于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
边栏推荐
猜你喜欢
Neuron and neural network
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)
STM32 learning record 0007 - new project (based on register version)
Choreographer full resolution
Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
CentOS mysql多实例部署
JS 烧脑面试题大赏
Wechat applet
The latest development of fed digital currency
Quartus Prime硬件实验开发(DE2-115板)实验二功能可调综合计时器设计
随机推荐
金蝶云星空API调用实践
微信小程序进行蓝牙初始化、搜索附近蓝牙设备及连接指定蓝牙(一)
接口文档yaml
smart-doc + torna生成接口文档
【报名】TF54:工程师成长地图与卓越研发组织打造
专题测试05·二重积分【李艳芳全程班】
pthread_self()为何重复了
Autumn recruitment in 2021, salary ranking No
PATH环境变量
STM32学习记录0007——新建工程(基于寄存器版)
[code analysis (1)] communication efficient learning of deep networks from decentralized data
AtomicIntegerArray源码分析与感悟
1256: bouquet for algenon
mysql新表,自增id长达20位,原因竟是......
Spark入门基本操作
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
Postman reference summary
Chapter 15 new technologies of software engineering
【项目】小帽外卖(八)
Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]