当前位置:网站首页>Check in system based on ibeacons

Check in system based on ibeacons

2022-04-23 14:04:00 one billion twenty-nine million one hundred and seventy-nine th

be based on ibeacons Sign in system
Specific function :
teacher : Initiate sign in , End check-in and check the number of check-in people
Student : Check in
Hardware :ibeacons One
Software :
The whole is divided into 2 part , Log in with different accounts , Identify people , This mainly uses global variables . stay app.js Set specific variables

globalData: {
    userInfo: null,
    tag:1,//tag Sign in status represents   1 Sign in not initiated    2 Is to initiate check-in 
    count:0//count The number of people signed in by the representative    The default is 0
  }

The code of the teacher part
(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}} month {
   {day}} Japan   {
   {week}}</text>
        </view>
        
    </view>
    <view class="footer">
        <button class="to-clock" hover-class="hover-to-clock" bindtap="toClock"> Initiate sign in </button>
        <button class="to-clock" hover-class="hover-to-clock" bindtap="todistance"> End sign in </button>
        <button class="to-clock" hover-class="hover-to-clock" bindtap="todistance1"> Attendance </button>
    </view>

     <view class="date">
            <text>{
   {count4}}</text>
        </view>
</view>

(2)js Code
Initiate sign in

// Initiate sign in 
toClock(){
  //tag==2 Initiate sign in 
  app.globalData.tag=2
  console.log(app.globalData.tag)
  wx.showToast({
    title: ' Check in initiated successfully ',
    icon: 'loading',
    duration: 2000
}) 
  // var that = this
  // that.timing()
  },

End sign in

  todistance(){
    //tag==1 End sign in 
    app.globalData.tag=1
    console.log(app.globalData.tag) 
    wx.showToast({
      title: ' Check in ended successfully ',
      icon: 'loading',
      duration: 2000
  }) 
    // var that = this
    // clearTimeout(that.con)  
  },

Check in number

// View the number of signers 
  todistance1(){
    var count2=app.globalData.count
    var count3=" Total attendance :"+count2
    var that=this
    that.setData({
      count4:count3
    })
  },

Student part code
(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}} month {
   {day}} Japan   {
   {week}}</text>
        </view>
        
    </view>
    <view class="footer">
        <button class="to-clock" hover-class="hover-to-clock" bindtap="toClock"> Sign in </button>
    </view>

     <view class="date">
            <text>{
   {diatance}}</text>
        </view>
</view>

(2)js Code
This part of the code involves searching ibeacons, Connect ibeacons, If the connection is successful, the check-in is successful , Get global variables +1 Can , The code is as follows :

  // Find out ibeacons
    wx.startBeaconDiscovery({
      // Set up ibeacons Parameters of 
      uuids: ['E2C56DB5-DFFB-48D2-B060-D0F5A71096E0'],
      // Successful connection 
      success: function () {
        console.log(" Start scanning devices ")
        // monitor iBeacon Update event of the device 
        wx.onBeaconUpdate(function (res) {
          if (res && res.beacons && res.beacons.length > 0) {
             console.log(" The equipment uuid yes :"+res.beacons[0].uuid)
             console.log(" distance ibeacons The distance is :"+res.beacons[0].accuracy)
            var distance=res.beacons[0].accuracy
            // The distance is 3 rice 
            if(distance<3){
              wx.showToast({
                title: ' Sign in successfully ',
                icon: 'loading',
                duration: 2000
            })   
            // Sign in successfully    The number of +1
              app.globalData.count=app.globalData.count+1
              console.log(" Attendance "+app.globalData.count)
            }else{
              wx.showToast({
                title: ' Trying to search ',
                icon: 'loading',
                duration: 2000
            })        
            }
          }
        })
      },
      fail:function(){
        wx.showToast({
          title: ' Not in the range of equipment ',
          icon: 'fail',
          duration: 500
        })
      }
    }),

WeChat's official account search results and the whole case search : The small white XBIT Can get
 Insert picture description here

版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401298243.html