From 896fc7959c7e3dacae3cd1dc223c15e5c5ddc42d Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Mon, 11 Mar 2024 15:19:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=8F=E8=BF=B0:=E8=BF=9C=E7=A8=8B=E9=97=A8?= =?UTF-8?q?=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/api/meeting/equipment.js | 21 +++++ .../meeting/accessControl/accessControl.js | 87 ++++++++++++++++--- .../meeting/accessControl/accessControl.json | 9 +- .../meeting/accessControl/accessControl.wxml | 35 ++++---- .../meeting/accessControl/accessControl.wxss | 25 ++++-- 5 files changed, 139 insertions(+), 38 deletions(-) create mode 100644 miniprogram/api/meeting/equipment.js diff --git a/miniprogram/api/meeting/equipment.js b/miniprogram/api/meeting/equipment.js new file mode 100644 index 0000000..b727cd1 --- /dev/null +++ b/miniprogram/api/meeting/equipment.js @@ -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 + }); +} \ No newline at end of file diff --git a/miniprogram/pages/meeting/accessControl/accessControl.js b/miniprogram/pages/meeting/accessControl/accessControl.js index 0916f84..388f7af 100644 --- a/miniprogram/pages/meeting/accessControl/accessControl.js +++ b/miniprogram/pages/meeting/accessControl/accessControl.js @@ -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" }) diff --git a/miniprogram/pages/meeting/accessControl/accessControl.json b/miniprogram/pages/meeting/accessControl/accessControl.json index 83d0798..4c43518 100644 --- a/miniprogram/pages/meeting/accessControl/accessControl.json +++ b/miniprogram/pages/meeting/accessControl/accessControl.json @@ -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" + } } \ No newline at end of file diff --git a/miniprogram/pages/meeting/accessControl/accessControl.wxml b/miniprogram/pages/meeting/accessControl/accessControl.wxml index 0dda9dc..43db89b 100644 --- a/miniprogram/pages/meeting/accessControl/accessControl.wxml +++ b/miniprogram/pages/meeting/accessControl/accessControl.wxml @@ -1,23 +1,25 @@ - + + + + + 设备 + + - - - - - 西大门 - 在线 - - - - - + + + {{item.equipmentName}} + {{item.equipmentStatus}} + + + - 开门记录 - 更多 + 开门记录 + 更多 @@ -31,4 +33,7 @@ - \ No newline at end of file + + + + \ No newline at end of file diff --git a/miniprogram/pages/meeting/accessControl/accessControl.wxss b/miniprogram/pages/meeting/accessControl/accessControl.wxss index 619c4a9..a9b249f 100644 --- a/miniprogram/pages/meeting/accessControl/accessControl.wxss +++ b/miniprogram/pages/meeting/accessControl/accessControl.wxss @@ -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; } @@ -128,4 +135,4 @@ font-size: 26rpx; word-break: break-all; line-height: 1; -} +} \ No newline at end of file