mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 14:19:38 +08:00
描述:远程门禁
This commit is contained in:
parent
b48ba728bf
commit
896fc7959c
21
miniprogram/api/meeting/equipment.js
Normal file
21
miniprogram/api/meeting/equipment.js
Normal 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
|
||||
});
|
||||
}
|
@ -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"
|
||||
})
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-collapse": "@vant/weapp/collapse/index",
|
||||
"van-collapse-item": "@vant/weapp/collapse-item/index"
|
||||
"van-collapse-item": "@vant/weapp/collapse-item/index",
|
||||
"van-notify": "@vant/weapp/notify/index"
|
||||
}
|
||||
}
|
@ -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="controlItem" wx:for="{{equipmentDataList}}">
|
||||
<view class="msg">
|
||||
<view class="title">西大门</view>
|
||||
<view class="status">在线</view>
|
||||
<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" />
|
||||
<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>
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
</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" />
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user