diff --git a/miniprogram/api/meeting/equipment.js b/miniprogram/api/meeting/equipment.js index 3831ea7..870961f 100644 --- a/miniprogram/api/meeting/equipment.js +++ b/miniprogram/api/meeting/equipment.js @@ -27,4 +27,56 @@ export function getOpenDoorRecordRq(data) { method: "post", data }); -} \ No newline at end of file +} + + + +// 获取所有房间 +export function getAllRoomInfoRq() { + return request({ + url: `/api/wisdom/getAllRoomInfo`, + method: "post", + }); +} + +// 根据房间获取对应设备列表 +export function getAllDeviceInfoByRoomIdRq(id) { + return request({ + url: `/api/wisdom/getAllDeviceInfoByRoomId?id=${id}`, + method: "get", + }); +} + + +// 根据房间获取对应情景列表 +export function getAllPanelInfoByRoomIdRq(id) { + return request({ + url: `/api/wisdom/getAllPanelInfoByRoomId?id=${id}`, + method: "get", + }); +} + + +// 根据设备id调用对接接口 +//{ +// "deviceId": 15, +// "actionArg": true, +// "bir": 74, +// "colourTemperature": 31, +// "coverType": "test_1f24337e3bf8" +// } +export function callApiByDeviceIdRq(data) { + return request({ + url: `/api/wisdom/callApiByDeviceId`, + method: "post", + data + }); +} + +// 查询设备详情 +export function getDeviceInfoRq(id) { + return request({ + url: `/api/wisdom/getDeviceInfo?id=${id}`, + method: "get", + }); +} diff --git a/miniprogram/app.js b/miniprogram/app.js index db7160e..ab933b9 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -6,13 +6,13 @@ App({ parkId : '26', // 园区id parkName : '长阳智会云控', // 园区名称 // 本地测试 - // DOMAIN_NAME_PREFIX: 'http://192.168.0.11', - // DOMAIN_NAME: 'http://192.168.0.11:9227', //接口域名 - // IMG_NAME: 'http://192.168.0.11:9227', + DOMAIN_NAME_PREFIX: 'http://192.168.0.30', + DOMAIN_NAME: 'http://192.168.0.30:9227', //接口域名 + IMG_NAME: 'http://192.168.0.30:9227', // 生产 - DOMAIN_NAME_PREFIX: 'https://www.chuangzhikj.com', - DOMAIN_NAME: 'https://www.chuangzhikj.com/saas-ics', //接口域名 - IMG_NAME: 'https://www.chuangzhikj.com/saas-ics', + // DOMAIN_NAME_PREFIX: 'https://www.chuangzhikj.com', + // DOMAIN_NAME: 'https://www.chuangzhikj.com/saas-ics', //接口域名 + // IMG_NAME: 'https://www.chuangzhikj.com/saas-ics', globals: { refreshMyPages: false, homedata: {}, diff --git a/miniprogram/pages/smartDevice/region/region.js b/miniprogram/pages/smartDevice/region/region.js index 02bb7c1..b99b79f 100644 --- a/miniprogram/pages/smartDevice/region/region.js +++ b/miniprogram/pages/smartDevice/region/region.js @@ -8,8 +8,8 @@ import { } from "../../../utils/util.js" import { - cancelOrderRq -} from "../../../api/meeting/meetingRoom.js" + getAllRoomInfoRq +} from "../../../api/meeting/equipment.js" Page({ @@ -18,6 +18,7 @@ Page({ */ data: { IMG_NAME: app.IMG_NAME, + roomList : [] }, /** @@ -28,13 +29,27 @@ Page({ _this.setData({ userData: wx.getStorageSync('user'), }) - + + _this.getData() + }, + + getData() { + let _this = this + getAllRoomInfoRq().then(res => { + console.log('getAllRoomInfoRq', res); + _this.setData({ + roomList : res.rows + }) + }) }, // 跳转房间 - jumpRoom(){ + jumpRoom(e) { + console.log('jumpRoom' , e); + let id = e.currentTarget.dataset.obj.id + let roomName = e.currentTarget.dataset.obj.meetingName wx.navigateTo({ - url: '/pages/smartDevice/room/room', + url: `/pages/smartDevice/room/room?roomId=${id}&roomName=${roomName}`, }) }, @@ -50,7 +65,7 @@ Page({ */ onShow() { let _this = this; - + }, /** @@ -87,6 +102,6 @@ Page({ * 用户点击右上角分享 */ onShareAppMessage(e) { - + } }) \ No newline at end of file diff --git a/miniprogram/pages/smartDevice/region/region.wxml b/miniprogram/pages/smartDevice/region/region.wxml index 542760f..ad9a936 100644 --- a/miniprogram/pages/smartDevice/region/region.wxml +++ b/miniprogram/pages/smartDevice/region/region.wxml @@ -1,10 +1,10 @@ - - 会议室 - - 设备数:10 - 场景数:3 + + {{item.meetingName}} + + 设备数:{{item.deviceNum}} + 场景数:{{item.panelNum}} diff --git a/miniprogram/pages/smartDevice/region/region.wxss b/miniprogram/pages/smartDevice/region/region.wxss index ec2eef6..b674b5d 100644 --- a/miniprogram/pages/smartDevice/region/region.wxss +++ b/miniprogram/pages/smartDevice/region/region.wxss @@ -14,7 +14,7 @@ border-radius: 10rpx; position: relative; width: 330rpx; - height: 260rpx; + height: 280rpx; margin-top: 24rpx; background: white; diff --git a/miniprogram/pages/smartDevice/room/room.js b/miniprogram/pages/smartDevice/room/room.js index 91c0bf2..3ce9255 100644 --- a/miniprogram/pages/smartDevice/room/room.js +++ b/miniprogram/pages/smartDevice/room/room.js @@ -1,5 +1,12 @@ const app = getApp() +import { + getAllDeviceInfoByRoomIdRq, + getAllPanelInfoByRoomIdRq, + callApiByDeviceIdRq, + getDeviceInfoRq +} from "../../../api/meeting/equipment.js" + Page({ /** @@ -7,37 +14,23 @@ Page({ */ data: { IMG_NAME: app.IMG_NAME, + roomId: null, + roomName: '', + lockDoor: null, sceneList: [{ name: '茶歇模式', - url: 'chaxie1.png', - selectUrl: 'chaxie0.png', + url: app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + 'chaxie1.png', + selectUrl: app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + 'chaxie0.png', isSelect: false }, { name: '开门模式', - url: 'kaimen1.png', - selectUrl: 'kaimen0.png', + url: app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + 'kaimen1.png', + selectUrl: app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + 'kaimen0.png', isSelect: false }, - { - name: '开门模式', - url: 'kaimen1.png', - selectUrl: 'kaimen0.png', - isSelect: false - }, - { - name: '开门模式', - url: 'kaimen1.png', - selectUrl: 'kaimen0.png', - isSelect: false - }, - { - name: '开门模式', - url: 'kaimen1.png', - selectUrl: 'kaimen0.png', - isSelect: false - } - ] + ], + equipmentList: [], // 设备列表 }, /** @@ -45,21 +38,121 @@ Page({ */ onLoad(options) { let _this = this + _this.setData({ + ...options + }) - _this.initScene() + // 查询所有设备列表 + _this.queryDeviceList() + // 查询情景列表 + _this.queryScene() }, - initScene() { + // 查询情景列表 + queryScene() { let _this = this - let sceneList = _this.data.sceneList.map(item => { - item.url = app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + item.url - item.selectUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/scene/' + item.selectUrl - return item + getAllPanelInfoByRoomIdRq(_this.data.roomId).then(res => { + console.log('getAllPanelInfoByRoomIdRq', res); + let sceneList = res.data.map(item => { + item.isSelect = false + item.img = app.IMG_NAME + item.img + item.imgOpen = app.IMG_NAME + item.imgOpen + return item + }) + _this.setData({ + sceneList + }) }) - _this.setData({ - sceneList + }, + + // 查询所有设备列表 + queryDeviceList() { + let _this = this + getAllDeviceInfoByRoomIdRq(_this.data.roomId).then(res => { + console.log('getAllDeviceInfoByRoomIdRq', res); + let equipmentList = res.data.map(item => _this.formatDevice(item)) + equipmentList = equipmentList.filter(item => item.type != '门锁') + let lockDoor = res.data.find(item => item.type == '门锁') + _this.setData({ + lockDoor, + equipmentList + }) + // 查询设备详情 + _this.queryDeviceInfo() }) }, + // 格式化设备数据 + formatDevice(item) { + if (item.type == '灯条') { + item.status = false + item.lampCloseUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'lamp-close.png' + item.lampOpenUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'lamp-open.png' + item.switchCloseUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'switch-close.png' + item.switchOpenUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'switch-open.png' + } + if (item.type == '雾化玻璃') { + item.status = false + item.glassImgUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/glass/glass-close.png' + item.glassImgActivityUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/glass/glass-open.png' + item.glassSwitchImgUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/glass/switch-close.png' + item.glassSwitchImgActivityUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/glass/switch-open.png' + } + if (item.type == '窗帘') { + item.subtype = 'curtain' + item.status = 'close_cover' + item.equipmentCurtainCurtainTopImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/curtainTop.png' + item.equipmentCurtainWindowImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/window.png' + item.equipmentCurtainCordFabricImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/cordFabric.png' + item.curtainSwitchOpenImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/switch-open.png' + item.curtainSwitchCloseImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/switch-close.png' + item.curtainStopImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/curtain/stop-black.png' + } + if (item.type == '插座') { + item.status = false + item.socketImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/socket/socket.png' + item.socketSwitchCloseImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/socket/switch-close.png' + item.socketSwitchOpenImg = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/socket/switch-open.png' + } + if (item.type == '调光灯') { + item.status = false + item.lampCloseUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'lamp-close.png' + item.lampOpenUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'lamp-open.png' + item.switchCloseUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'switch-close.png' + item.switchOpenUrl = app.IMG_NAME + '/profile/static/shanghai_changyang/device/equipment/lamp/' + 'switch-open.png' + } + return item + }, + + // 查询设备详情 + queryDeviceInfo() { + let _this = this + let equipmentList = _this.data.equipmentList + for (let i = 0; i < equipmentList.length; i++) { + let equipmentData = equipmentList[i]; + if (equipmentData.type == '窗帘' || equipmentData.type == '门锁') { + continue + } + // + getDeviceInfoRq(equipmentData.id).then(res => { + console.log('getDeviceInfoRq', equipmentData.type, res); + if (equipmentData.type == '灯条') { + equipmentData.status = res.on + } + if (equipmentData.type == '雾化玻璃') { + equipmentData.status = res.on + } + if (equipmentData.type == '插座') { + equipmentData.status = res.on + } + if (equipmentData.type == '调光灯') { + equipmentData.status = res.on + } + _this.setData({ + equipmentList + }) + }) + } + }, // 选择情景 selectScene(e) { @@ -68,7 +161,7 @@ Page({ let obj = e.currentTarget.dataset.obj let sceneList = _this.data.sceneList sceneList = sceneList.map(item => { - if (item.name == obj.name) { + if (item.id == obj.id) { item.isSelect = !item.isSelect } else { item.isSelect = false @@ -80,6 +173,109 @@ Page({ }) }, + + // 灯控 + lampCall(e) { + console.log('lampCall', e); + let _this = this + let id = e.currentTarget.dataset.obj.id + let equipmentList = _this.data.equipmentList + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = !equipmentData.status + _this.setData({ + equipmentList + }) + // 调用设备接口 + _this.callApiByDevice({ + "deviceId": equipmentData.id, + "actionArg": equipmentData.status, + }) + }, + + + // 窗帘 + curtainSwitch(e) { + console.log('curtainSwitch', e); + let _this = this + let id = e.currentTarget.dataset.obj.id + let status = e.currentTarget.dataset.status + let equipmentList = _this.data.equipmentList + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = status + _this.setData({ + equipmentList + }) + + // 调用设备接口 + _this.callApiByDevice({ + "deviceId": equipmentData.id, + "coverType": equipmentData.status, + }) + }, + + // 雾化玻璃 + glassSwitch(e) { + console.log('glassSwitch', e); + let _this = this + let id = e.currentTarget.dataset.obj.id + let equipmentList = _this.data.equipmentList + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = !equipmentData.status + _this.setData({ + equipmentList + }) + + // 调用设备接口 + _this.callApiByDevice({ + "deviceId": equipmentData.id, + "actionArg": equipmentData.status, + }) + }, + + // 调光灯 + dimmingSwitch(e) { + console.log('dimmingSwitch', e); + let _this = this + let id = e.currentTarget.dataset.obj.id + let equipmentList = _this.data.equipmentList + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = !equipmentData.status + _this.setData({ + equipmentList + }) + + // 调用设备接口 + _this.callApiByDevice({ + "deviceId": equipmentData.id, + "actionArg": equipmentData.status, + }) + }, + + // 插座开关 + socketSwitch(e) { + console.log('socketSwitch', e); + let _this = this + let id = e.currentTarget.dataset.obj.id + let equipmentList = _this.data.equipmentList + let equipmentData = equipmentList.find(item => item.id == id) + equipmentData.status = !equipmentData.status + _this.setData({ + equipmentList + }) + // 调用设备接口 + _this.callApiByDevice({ + "deviceId": equipmentData.id, + "actionArg": equipmentData.status, + }) + }, + + // 调用设备接口 + callApiByDevice(data) { + callApiByDeviceIdRq(data).then(res => { + console.log('callApiByDeviceIdRq', res); + }) + }, + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/miniprogram/pages/smartDevice/room/room.wxml b/miniprogram/pages/smartDevice/room/room.wxml index 46e0ca1..11d21cd 100644 --- a/miniprogram/pages/smartDevice/room/room.wxml +++ b/miniprogram/pages/smartDevice/room/room.wxml @@ -4,14 +4,24 @@ - 大会议室 + {{roomName}} + 门锁 + + + + + + 点击开门 + + + 情景模式 - - 会议模式 + + {{item.panelName}} @@ -19,8 +29,53 @@ 设备列表 - + + {{item.equipmentName}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/smartDevice/room/room.wxss b/miniprogram/pages/smartDevice/room/room.wxss index 22c2590..c8ad8d7 100644 --- a/miniprogram/pages/smartDevice/room/room.wxss +++ b/miniprogram/pages/smartDevice/room/room.wxss @@ -36,6 +36,47 @@ margin-top: 60rpx; } +.lockView { + display: flex; + justify-content: flex-start; + align-items: center; + + margin-top: 30rpx; +} + +.lockView .lockImg { + width: 188rpx; + height: 134rpx; +} + +.lockView .lockSwitchView { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + + width: 180rpx; + height: 180rpx; + background: white; + border-radius: 10rpx; + box-shadow: rgba(204, 204, 204, 0.6) 0px 2px 2px 0px; + transition: 0.1s all; +} + +.lockView .lockSwitchView:active { + opacity: 0.4; +} + +.lockView .lockSwitchView .switchImg { + width: 60rpx; + height: 60rpx; +} + +.lockView .lockSwitchView .label { + margin-top: 20rpx; + font-size: 24rpx; +} + .sceneView { display: flex; justify-content: flex-start; @@ -93,16 +134,220 @@ .equipmentList { display: flex; flex-wrap: wrap; - justify-content: space-evenly; + justify-content: space-between; align-items: center; + padding: 0 30rpx; } -.equipmentList .equipmentItem { +.equipmentItem { box-shadow: rgba(214, 214, 214, 0.5) 0px 1px 0px 0px, rgb(238, 238, 238) 0px 1px 2px 0px; border-radius: 10rpx; position: relative; width: 330rpx; - height: 260rpx; + height: 340rpx; margin-top: 24rpx; background: white; +} + +.equipmentItem .equipmentTitle { + position: absolute; + left: 31rpx; + top: 24rpx; + + width: 160rpx; + font-size: 18rpx; + color: #314773; + + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.equipmentItem .equipmentContent { + width: 100%; + height: 100%; +} + +/* 灯控 */ +.equipmentContent .equipmentLampImg { + position: absolute; + z-index: 1; + top: 0; + left: 50%; + transform: translateX(-50%); + width: 248rpx; + height: 287rpx; +} + +.equipmentContent .equipmentSwitchImg { + position: absolute; + z-index: 2; + bottom: 20rpx; + left: 50%; + transform: translateX(-50%); + width: 88rpx; + height: 88rpx; +} + +/* 窗帘 */ +.equipmentContent .equipmentCurtainView { + position: absolute; + z-index: 1; + top: 60rpx; + left: 50%; + transform: translateX(-50%); + width: 200rpx; + height: 180rpx; +} + + +.equipmentContent .equipmentCurtainCurtainTopImg { + position: absolute; + z-index: 10; + top: 0; + left: 0; + + width: 200rpx; + height: 20rpx; +} + +.equipmentContent .equipmentCurtainWindowImg { + position: absolute; + z-index: 5; + top: 16rpx; + left: 50%; + transform: translateX(-50%); + + width: 200rpx; + height: 158rpx; +} + +.equipmentContent .equipmentCurtainCordFabricView { + position: absolute; + z-index: 5; + top: 16rpx; + + width: 113rpx; + height: 181rpx; + overflow: hidden; +} + +.equipmentContent .equipmentCurtainCordFabricImg { + position: absolute; + top: 0; + width: 100%; + height: 100%; + transition: 1s all; +} + +.equipmentContent .equipmentCurtainCordFabricImg.opacity { + opacity: 0.6; +} + + +.equipmentContent .equipmentCurtainCordFabricView.left { + left: 8rpx; +} + +.equipmentContent .equipmentCurtainCordFabricView.left .equipmentCurtainCordFabricImg.open { + right: 100%; +} + +.equipmentContent .equipmentCurtainCordFabricView.left .equipmentCurtainCordFabricImg.close { + right: 0; +} + +.equipmentContent .equipmentCurtainCordFabricView.left .equipmentCurtainCordFabricImg.stop { + right: 50%; +} + +.equipmentContent .equipmentCurtainCordFabricView.right { + right: 8rpx; +} + +.equipmentContent .equipmentCurtainCordFabricView.right .equipmentCurtainCordFabricImg.open { + left: 100%; +} + +.equipmentContent .equipmentCurtainCordFabricView.right .equipmentCurtainCordFabricImg.close { + left: 0; +} + +.equipmentContent .equipmentCurtainCordFabricView.right .equipmentCurtainCordFabricImg.stop { + left: 50%; +} + +.equipmentContent .curtainSwitchOpenImg { + position: absolute; + z-index: 1; + left: 30rpx; + bottom: 30rpx; + + width: 41rpx; + height: 35rpx; +} + +.equipmentContent .curtainSwitchCloseImg { + position: absolute; + z-index: 1; + right: 30rpx; + bottom: 30rpx; + + width: 41rpx; + height: 35rpx; +} + +.equipmentContent .curtainStopImg { + position: absolute; + z-index: 1; + bottom: 22rpx; + left: 50%; + transform: translateX(-50%); + width: 51rpx; + height: 51rpx; +} + + +/* 雾化玻璃 */ +.equipmentContent .glassImg { + position: absolute; + z-index: 1; + top: 77rpx; + left: 50%; + transform: translateX(-50%); + width: 200rpx; + height: 140rpx; + transition: 1s all; +} + +.equipmentContent .glassSwitchImg { + position: absolute; + z-index: 1; + bottom: 22rpx; + left: 50%; + transform: translateX(-50%); + width: 104rpx; + height: 48rpx; +} + +/* 插座 */ +.equipmentContent .socketImg { + position: absolute; + z-index: 1; + top: 77rpx; + left: 50%; + transform: translateX(-50%); + width: 150rpx; + height: 149rpx; + transition: 1s all; +} + +.equipmentContent .socketSwitchImg { + position: absolute; + z-index: 1; + bottom: 28rpx; + left: 50%; + transform: translateX(-50%); + width: 104rpx; + height: 48rpx; } \ No newline at end of file