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()
|
const app = getApp()
|
||||||
|
|
||||||
|
import Notify from '@vant/weapp/notify/notify';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getEquipmentByUserIdRq,
|
||||||
|
openDoorRq
|
||||||
|
} from "../../../api/meeting/equipment.js"
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -7,29 +15,88 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
IMG_NAME: app.IMG_NAME,
|
IMG_NAME: app.IMG_NAME,
|
||||||
activeNames: [0],
|
activeNames: [0],
|
||||||
|
userDetail: {},
|
||||||
|
equipmentDataList: [],
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
let title = options.name;
|
let _this = this;
|
||||||
if (!title) {
|
let userDetail = wx.getStorageSync('user')
|
||||||
title = '远程门禁';
|
_this.setData({
|
||||||
}
|
userDetail,
|
||||||
|
...options,
|
||||||
|
})
|
||||||
// 页面初始化 options为页面跳转所带来的参数
|
// 页面初始化 options为页面跳转所带来的参数
|
||||||
wx.setNavigationBarTitle({
|
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({
|
openDoor(e) {
|
||||||
activeNames: event.detail,
|
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({
|
wx.navigateTo({
|
||||||
url: "/pages/meeting/accessControl/accessControlRecord/accessControlRecord"
|
url: "/pages/meeting/accessControl/accessControlRecord/accessControlRecord"
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {
|
"usingComponents": {
|
||||||
"van-collapse": "@vant/weapp/collapse/index",
|
"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">
|
<view class="controlView">
|
||||||
<van-collapse value="{{ activeNames }}" bind:change="onChange">
|
<view class="controlItem" wx:for="{{equipmentDataList}}">
|
||||||
<van-collapse-item title="{{idx+'标题'}}" name="{{idx}}" wx:for="{{2}}" wx:for-index="idx">
|
<view class="msg">
|
||||||
<view class="controlItem" wx:for="{{3}}">
|
<view class="title">{{item.equipmentName}}</view>
|
||||||
<view class="msg">
|
<view class="status {{item.statusClass}}">{{item.equipmentStatus}}</view>
|
||||||
<view class="title">西大门</view>
|
</view>
|
||||||
<view class="status">在线</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>
|
||||||
<image class="openCloseImg" src="{{IMG_NAME + '/profile/static/meeting/accessControl/openClose.png'}}" mode="aspectFill" />
|
|
||||||
</view>
|
|
||||||
</van-collapse-item>
|
|
||||||
</van-collapse>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<view class="itemTitleView">
|
<view class="itemTitleView">
|
||||||
<view class="title">开门记录</view>
|
<view class="leftLineTitle">开门记录</view>
|
||||||
<view class="more" bind:tap="jumpRecord">更多</view>
|
<view class="more" bind:tap="jumpOpenDoorRecord">更多</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 开门记录 -->
|
<!-- 开门记录 -->
|
||||||
@ -31,4 +33,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 消息通知 -->
|
||||||
|
<van-notify id="van-notify" />
|
@ -1,11 +1,7 @@
|
|||||||
.container {
|
.containerView.public {
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
background: #fcfcfc;
|
background: #fcfcfc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.van-collapse-item__content {
|
.van-collapse-item__content {
|
||||||
background-color: #f7f7f7 !important;
|
background-color: #f7f7f7 !important;
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
@ -40,7 +36,7 @@
|
|||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controlView .controlItem .msg .status::after {
|
.controlView .controlItem .msg .status.online::after {
|
||||||
display: block;
|
display: block;
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -53,6 +49,18 @@
|
|||||||
border-radius: 10rpx;
|
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 {
|
.controlView .controlItem .openCloseImg {
|
||||||
width: 69rpx;
|
width: 69rpx;
|
||||||
@ -60,7 +68,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.itemTitleView {
|
.itemTitleView {
|
||||||
border-left: 8rpx solid #2A6FFF;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -91,7 +98,7 @@
|
|||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.recordView .recordItem:nth-child(2n){
|
.recordView .recordItem:nth-child(2n) {
|
||||||
background: #f9fafc;
|
background: #f9fafc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,4 +135,4 @@
|
|||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user