描述:远程门禁

This commit is contained in:
SelfRidicule 2024-03-11 15:19:54 +08:00
parent b48ba728bf
commit 896fc7959c
5 changed files with 139 additions and 38 deletions

View File

@ -0,0 +1,21 @@
import {
request
} from '../selfRequest';
// 根据用户id查询对应的设备
export function getEquipmentByUserIdRq(id) {
return request({
url: '/api/equipment/getEquipmentByUserId/' + id,
method: "get",
});
}
// 开门
export function openDoorRq(data) {
return request({
url: '/api/equipment/openDoor',
method: "post",
data
});
}

View File

@ -1,4 +1,12 @@
const app = getApp()
import Notify from '@vant/weapp/notify/notify';
import {
getEquipmentByUserIdRq,
openDoorRq
} from "../../../api/meeting/equipment.js"
Page({
/**
@ -7,29 +15,88 @@ Page({
data: {
IMG_NAME: app.IMG_NAME,
activeNames: [0],
userDetail: {},
equipmentDataList: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let title = options.name;
if (!title) {
title = '远程门禁';
}
let _this = this;
let userDetail = wx.getStorageSync('user')
_this.setData({
userDetail,
...options,
})
// 页面初始化 options为页面跳转所带来的参数
wx.setNavigationBarTitle({
title
title: '远程门禁'
})
// 获取设备数据
_this.getEquipmentData();
},
// 获取设备数据
getEquipmentData() {
let _this = this;
getEquipmentByUserIdRq(_this.data.userDetail.id).then(res => {
console.log('getEquipmentData', res);
let equipmentDataList = res.data
equipmentDataList = equipmentDataList.map(item => {
let statusClass = "offline";
// equipmentStatus
if (item.equipmentStatus == '在线') {
statusClass = "online";
} else if (item.equipmentStatus == '离线') {
statusClass = "offline";
}
item.statusClass = statusClass;
return item
})
_this.setData({
equipmentDataList
})
})
},
onChange(event) {
this.setData({
activeNames: event.detail,
});
// 开门
openDoor(e) {
console.log('openDoor', e);
let _this = this;
let userId = _this.data.userDetail.id;
let deviceId = e.currentTarget.dataset.deviceid
let roomId = e.currentTarget.dataset.roomid
let status = e.currentTarget.dataset.status
if (!status == '在线') {
Notify({
type: 'danger',
message: '设备不在线!'
});
return;
}
openDoorRq({
roomId,
deviceId,
userId
}).then(res => {
console.log('openDoor', res);
if (res.code == 0) {
Notify({
type: 'success',
message: res.msg
});
} else {
Notify({
type: 'danger',
message: res.msg
});
}
})
},
jumpRecord() {
// 跳转-开门记录
jumpOpenDoorRecord() {
wx.navigateTo({
url: "/pages/meeting/accessControl/accessControlRecord/accessControlRecord"
})

View File

@ -1,6 +1,7 @@
{
"usingComponents": {
"van-collapse": "@vant/weapp/collapse/index",
"van-collapse-item": "@vant/weapp/collapse-item/index"
}
"usingComponents": {
"van-collapse": "@vant/weapp/collapse/index",
"van-collapse-item": "@vant/weapp/collapse-item/index",
"van-notify": "@vant/weapp/notify/index"
}
}

View File

@ -1,23 +1,25 @@
<view class="container">
<view class="containerView public">
<!-- 标题 -->
<view class="itemTitleView">
<view class="leftLineTitle">设备</view>
</view>
<!-- 门禁控制列表 -->
<view class="controlView">
<van-collapse value="{{ activeNames }}" bind:change="onChange">
<van-collapse-item title="{{idx+'标题'}}" name="{{idx}}" wx:for="{{2}}" wx:for-index="idx">
<view class="controlItem" wx:for="{{3}}">
<view class="msg">
<view class="title">西大门</view>
<view class="status">在线</view>
</view>
<image class="openCloseImg" src="{{IMG_NAME + '/profile/static/meeting/accessControl/openClose.png'}}" mode="aspectFill" />
</view>
</van-collapse-item>
</van-collapse>
<view class="controlItem" wx:for="{{equipmentDataList}}">
<view class="msg">
<view class="title">{{item.equipmentName}}</view>
<view class="status {{item.statusClass}}">{{item.equipmentStatus}}</view>
</view>
<image class="openCloseImg" src="{{IMG_NAME + '/profile/static/meeting/accessControl/openClose.png'}}" mode="aspectFill" data-deviceid="{{item.equipmentId}}" data-status="{{item.equipmentStatus}}" data-roomid="{{item.roomId}}" bind:tap="openDoor" />
</view>
</view>
<!-- 标题 -->
<view class="itemTitleView">
<view class="title">开门记录</view>
<view class="more" bind:tap="jumpRecord">更多</view>
<view class="leftLineTitle">开门记录</view>
<view class="more" bind:tap="jumpOpenDoorRecord">更多</view>
</view>
<!-- 开门记录 -->
@ -32,3 +34,6 @@
</view>
</view>
<!-- 消息通知 -->
<van-notify id="van-notify" />

View File

@ -1,11 +1,7 @@
.container {
width: 100vw;
height: 100vh;
overflow-y: auto;
.containerView.public {
background: #fcfcfc;
}
.van-collapse-item__content {
background-color: #f7f7f7 !important;
padding: 0 !important;
@ -40,7 +36,7 @@
font-size: 24rpx;
}
.controlView .controlItem .msg .status::after {
.controlView .controlItem .msg .status.online::after {
display: block;
content: '';
position: absolute;
@ -53,6 +49,18 @@
border-radius: 10rpx;
}
.controlView .controlItem .msg .status.offline::after {
display: block;
content: '';
position: absolute;
margin-right: 10rpx;
right: 100%;
top: 10rpx;
width: 16rpx;
height: 16rpx;
background: gray;
border-radius: 10rpx;
}
.controlView .controlItem .openCloseImg {
width: 69rpx;
@ -60,7 +68,6 @@
}
.itemTitleView {
border-left: 8rpx solid #2A6FFF;
display: flex;
justify-content: space-between;
align-items: center;
@ -91,7 +98,7 @@
background: #ffffff;
}
.recordView .recordItem:nth-child(2n){
.recordView .recordItem:nth-child(2n) {
background: #f9fafc;
}