diff --git a/app.js b/app.js index 3758242..c45bd45 100644 --- a/app.js +++ b/app.js @@ -44,6 +44,7 @@ App({ HotelId:-1, CreateTime:null, HotelCode:null, + CreatDate:null, }, toast:function(type,title,success,time){ if(type==1){ diff --git a/app.json b/app.json index 5553764..461b1a2 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,11 @@ "pages/basics/MakingRounds/process/process", "pages/basics/MakingRoundsAbnormal/MakingRoundsAbnormal", "pages/basics/HostUpgrade/HostUpgrade", - "pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol" + "pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol", + "pages/test/test", + "pages/basics/FacialDeviceBinding/FacialDeviceBinding", + "pages/basics/progress/progress", + "pages/basics/progress/RoomTypeControlLog/RoomTypeControlLog" ], "window": { "backgroundTextStyle": "light", diff --git a/colorui/main.wxss b/colorui/main.wxss index fef3f65..46fb8f1 100644 --- a/colorui/main.wxss +++ b/colorui/main.wxss @@ -1398,6 +1398,14 @@ button.icon.lg { justify-content: space-between; align-items: center } +.cu-list.menu>.cu-itemzn { + position: relative; + padding: 0 10rpx; + min-height: 100rpx; + background-color: var(--white); + justify-content: space-between; + align-items: center +} .cu-list.menu>.cu-item:last-child:after { border: none diff --git a/lib/RequestingCenter.js b/lib/RequestingCenter.js index 182a590..18332ee 100644 --- a/lib/RequestingCenter.js +++ b/lib/RequestingCenter.js @@ -191,6 +191,16 @@ export async function GetRoomTypeNode(params){ url: BoonliveUrl + 'GetDeviceInfo', data: params || {} }) +} +//获取房型下的设备 +export async function GetRoomAddressStatus(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: "", + url: BoonliveUrl + 'GetRoomAddressStatus', + data: params || {} + }) } export async function WebChatUpgrade(params){ @@ -257,4 +267,58 @@ export async function SetRCUCurtain(params){ data: params || {} }) } -SetRCUCurtain \ No newline at end of file + +//查询设备列表 +export async function QueryDeviceList(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: null, + url: BoonliveUrl + 'QueryDeviceList', + data: params || {} + }) +} + +//设置RCU服务 +export async function SetRCUService(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: null, + url: BoonliveUrl + 'SetRCUService', + data: params || {} + }) +} + +//写入房间设备访问日志 +export async function WriteRoomVisitLog(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: "上传查房记录中", + url: BoonliveUrl + 'WriteRoomVisitLog', + data: params || {} + }) +} + +//查询房间设备访问日志 +export async function QueryRoomVisitLog(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: "查询设备访问日志中", + url: BoonliveUrl + 'QueryRoomVisitLog', + data: params || {} + }) +} + +//修改房间设备访问日志 +export async function UpdateRoomVisitLog(params){ + params.token = gettoken(); + console.log(params) + return await reqeust1({ + title: "更新故障记录中", + url: BoonliveUrl + 'UpdateRoomVisitLog', + data: params || {} + }) +} \ No newline at end of file diff --git a/lib/request1.js b/lib/request1.js index 36011f0..2fee24f 100644 --- a/lib/request1.js +++ b/lib/request1.js @@ -2,29 +2,34 @@ let show = 0; export default async function reqeust(params) { show++; - return new Promise((resolve, reject) => { - + // 判断是否需要显示loading弹窗 + const needLoading = params.title !== undefined && params.title !== null && params.title !== ''; + + if (needLoading) { wx.showLoading({ title: params.title, - mask:true - }) - wx.request({ + mask: true + }); + } + + return new Promise((resolve, reject) => { + wx.request({ header: { - contentType: 'application/x-www-form-urlencoded', // 填入服务名称 - }, + contentType: 'application/x-www-form-urlencoded', // 填入服务名称 + }, url: params.url, method: params.method || 'post', data: params.data || {}, success: res => { - resolve(res.data) + resolve(res.data) }, fail: err => { reject(err) }, complete:()=>{ show--; - if(show==0){ - wx.hideLoading() + if (needLoading && show === 0) { + wx.hideLoading(); } } }) diff --git a/pages/NewHome/NewHome.js b/pages/NewHome/NewHome.js index a6c3bc0..232aad4 100644 --- a/pages/NewHome/NewHome.js +++ b/pages/NewHome/NewHome.js @@ -25,13 +25,7 @@ Page({ name: 'HostUpgrade', color: 'purple', icon: 'font' - }, - { - title: '主机绑定 ', - name: 'HostBinding', - color: 'mauve', - icon: 'icon' - }, + }, { title: '人脸机绑定', name: 'FacialDeviceBinding', diff --git a/pages/basics/FacialDeviceBinding/FacialDeviceBinding.js b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.js new file mode 100644 index 0000000..24c0a37 --- /dev/null +++ b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.js @@ -0,0 +1,629 @@ +// pages/FacialDeviceBinding/FacialDeviceBinding.js +// 人脸设备绑定页面逻辑 +const app = getApp() +// 导入请求中心 +import { + GetHostsInfo, + GetFaceSN, + GetFaceCode, + CheckFaceSNAutho, + CheckFaceSN, + OpenDoorTest + } from '../../../lib/RequestingCenter'; + +Page({ + data: { + autho:null, + RoomIndex: 0, // 当前选中房间索引 + Hotelinfo: null, // 酒店信息 + HostsData: null, // 原始设备数据 + HostsDataFilters: [], // 过滤后的设备数据 + onlineFaceDevices: 0, // 在线人脸设备数量 + inputValue: "", // 搜索输入值 + scrollHeight: 0, // 滚动区域高度 + toView: '', // 滚动位置 + modal: '', // 弹窗状态 + selHosts: null, // 当前选中的房间 + faceSNCode: '', // 人脸设备SN输入 + bdHosts: [], // 已绑定的主机列表 + Help: false, // 帮助状态 + islogs: false, // 操作记录状态 + showinfo: 0, // 显示信息类型 + faceAddress: '', // 人脸设备地址 + input: 0, // 输入类型 + ISLoopDebugging: 0, // 回路调试状态 + message: [], // 弹窗信息 + }, + + + /** + * 页面的初始数据 + */ + + onLoad:async function(options) { + + if (!options.HotelId || app.globalData.autho == null) { + app.toast(2, "无酒店信息~") + return; + } + + this.setData({ + autho: app.globalData.autho , + HotelId:options.HotelId + }) + try { + this.data.autho.forEach((element, index) => { + element.Hotels.forEach((elements, indexs) => { + if (elements.HotelId == options.HotelId) { + this.setData({ + Hotelinfo: elements + }) + throw new Error(); + } + }) + }); + } catch (error) { + console.log("已经找到,无需循环~") + } + // 计算滚动区域高度 + this.calcScrollHeight(); + // 获取人脸设备数据 + this.GetHostsInfo(); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + // 页面显示时重新获取数据 + this.GetHostsInfo(); + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + this.GetHostsInfo(); + wx.stopPullDownRefresh(); + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + + // 返回上一页 + back: function () { + wx.navigateBack({ + delta: 1 + }); + }, + + // 计算滚动区域高度 + calcScrollHeight: function () { + +// 1. 拿到屏幕可用高度(px) +const sys = wx.getSystemInfoSync(); +const screenHeight = sys.windowHeight; // px + +// 2. 拿到 scroll-view 的 top(px) +wx.createSelectorQuery() + .in(this) + .select('#myScroll') + .boundingClientRect(rect => { + if (rect) { + const topPx = rect.top; // px + const bottomPx = 10 / 2; // 10rpx → 5px(2倍屏) + const heightPx = screenHeight - topPx - bottomPx; + + // 3. 转 rpx 并写入 + this.setData({ + scrollHeight: heightPx * 2 // px→rpx + }); + } + }) + .exec(); + + + + }, + + // 获取人脸设备数据 + GetHostsInfo: function () { + const that = this; + // 显示加载提示 + wx.showLoading({ + title: '加载中...', + }); + + // 调用获取主机信息接口 + GetHostsInfo({ + HotelID: that.data.HotelId + }).then(res => { + // 隐藏加载提示 + wx.hideLoading(); + + if (res.Status == 200) { + // 处理数据 + const HostsData = res.Data; + const HostsDataFilters = HostsData; + + // 统计在线人脸设备数量 + let onlineFaceDevices = 0; + for (let i = 0; i < HostsDataFilters.length; i++) { + if (HostsDataFilters[i].FaceStatus) { + onlineFaceDevices++; + } + } + + // 更新数据 + that.setData({ + HostsData: HostsData, + HostsDataFilters: HostsDataFilters, + onlineFaceDevices: onlineFaceDevices, + RoomIndex: 0 + }); + + // 获取位置信息 + that.GetLOC(); + } else { + wx.showToast({ + title: '获取数据失败', + icon: 'none' + }); + } + }).catch(err => { + wx.hideLoading(); + wx.showToast({ + title: '网络异常', + icon: 'none' + }); + console.error('获取主机信息失败:', err); + }); + }, + + // 获取位置信息 + GetLOC: function () { + const that = this; + // 调用微信获取位置接口 + wx.getFuzzyLocation({ + type: 'wgs84', + success(res) { + const latitude = res.latitude; + const longitude = res.longitude; + const address = `${latitude},${longitude}`; + that.setData({ + faceAddress: address + }); + }, + fail(err) { + console.error('获取位置信息失败:', err); + // 位置信息获取失败不影响主流程 + } + }); + }, + + // 搜索输入 + inputSearchForHotels: function (e) { + this.setData({ + inputValue: e.detail.value + }); + }, + + // 搜索房间 + SearchForHotels: function () { + const that = this; + const inputValue = that.data.inputValue; + const HostsData = that.data.HostsData; + + if (inputValue === '') { + // 搜索条件为空,显示所有数据 + that.setData({ + HostsDataFilters: HostsData + }); + return; + } + + // 根据房号搜索 + const filters = HostsData.filter(item => { + return item.RoomNumber.indexOf(inputValue) !== -1; + }); + + that.setData({ + HostsDataFilters: filters + }); + }, + + // 刷新房间数据 + RefreshTheRoom: function () { + this.GetHostsInfo(); + }, + + // 跳转到人脸设备详情或直接扫码绑定 + goFaceDetail: function (e) { + const index = e.currentTarget.id.split('-')[1]; + const HostsDataFilters = this.data.HostsDataFilters; + const selHosts = HostsDataFilters[index]; + selHosts.index = index; + + this.setData({ + RoomIndex: index, + selHosts: selHosts + }); + + // 判断条件:离线且未绑定 + if (!selHosts.FaceStatus && (!selHosts.FaceSN || selHosts.FaceSN === '')) { + + // 直接调用摄像头扫码绑定 + this.GetFaceCode(); + } else { + // 设置消息数据 + this.setData({ + message: [selHosts.FaceSN, selHosts.RoomNumber], + // 显示设备详情 + modal: -1 + }); + } + }, + + // 关闭弹窗 + GetHide: function () { + this.setData({ + modal: '' + }); + }, + + // 反馈错误 + ErrorInfo: function () { + wx.showToast({ + title: '反馈功能开发中', + icon: 'none' + }); + }, + + // 人脸设备解绑 + JbSn: function (params) { + let jbjd = null; + let faceSN = null; + let that = this; + let index = -1; + + // 检查是否从SN已绑定弹窗点击解绑按钮 + if (typeof params.currentTarget.dataset['index'] != 'undefined') { + faceSN = this.data.faceSNCode; + index = params.currentTarget.dataset['index']; + // 解绑的房间 + jbjd = this.data.bdHosts[index]; + } else { + jbjd = this.data.selHosts; + faceSN = this.data.selHosts.FaceSN; + } + + wx.showModal({ + title: '解绑确认', + content: `确定要解除${jbjd.RoomNumber}房间的人脸设备绑定吗?`, + success(res) { + if (res.confirm) { + // 调用解绑接口 + GetFaceSN({ + faceSN: faceSN, + roomID: jbjd.Id, + roomNumber: jbjd.RoomNumber, + faceAddress: that.data.faceAddress, + HotelID: jbjd.HotelID, + isjb: true + }).then(res => { + if (res.Status == 200) { + wx.showToast({ + title: '解绑成功', + icon: 'success' + }); + + // 如果是从SN已绑定弹窗解绑,需要更新bdHosts数据 + if (index > -1) { + let databdHosts = that.data.bdHosts; + databdHosts.splice(index, 1); + that.setData({ + bdHosts: databdHosts + }); + + // 如果bdHosts为空,继续执行绑定 + if (databdHosts.length <= 0) { + that.GetFaceSNend(); + } + } + + // 重新获取数据 + that.GetHostsInfo(); + // 关闭弹窗 + that.GetHide(); + } else { + wx.showToast({ + title: '解绑失败', + icon: 'none' + }); + } + }).catch(err => { + wx.showToast({ + title: '网络异常', + icon: 'none' + }); + console.error('解绑失败:', err); + }); + } + } + }); + }, + + // 扫码绑定人脸设备 + GetFaceCode: function () { + const that = this; + + // 检查权限 + if (!that.CheckFaceSNAutho()) { + wx.showToast({ + title: '您没有权限绑定人脸设备', + icon: 'none' + }); + return; + } + + // 调用微信扫码接口 + wx.scanCode({ + success: (res) => { + const code = res.result; + that.setData({ + faceSNCode: code + }); + debugger + that.GetFaceSNOK(); + }, + fail: (err) => { + console.error('扫码失败:', err); + wx.showToast({ + title: '扫码失败', + icon: 'none' + }); + } + }); + }, + + // 手动输入人脸设备SN + ShowInputsn: function () { + // 检查权限 + if (!this.CheckFaceSNAutho()) { + wx.showToast({ + title: '您没有权限绑定人脸设备', + icon: 'none' + }); + return; + } + + this.setData({ + modal: 'showBindConfirm' + }); + }, + + + GetFaceSNOK:function(){ + let that = this; + if (!this.CheckFaceMAC(that.data.faceSNCode)) { + this.setData({ + modal: 520 + }) + return; + }; + if (that.data.selHosts.FaceSN == that.data.faceSNCode) { + app.toast(2, "条码一致,无需更改~") + return; + } + this.CheckFaceMACWL() + }, + CheckFaceMACWL(){ + let that = this; + CheckFaceSN({faceSN:this.data.faceSNCode}).then( + res => { + if (res.Status == 200) { + if(res.Data<=0){ + that.setData({ + modal:-521, + }) + }else{ + let remove = []; + let bdHosts = res.Data; + try { + //记录已经分配酒店但是未分配房间 且酒店是当前酒店 那就判断为没有绑定 + that.data.autho.forEach((element, index) => { + element.Hotels.forEach((elements, indexs) => { + for (let index = 0; index < bdHosts.length; index++) { + if (elements.HotelId == bdHosts[index].HotelID) { + if(bdHosts[index].HotelID == that.data.Hotelinfo.HotelId && bdHosts[index].Id==0){ + remove.push(index); + } + elements.Auth.forEach (Auth=>{ + if(Auth.AuthorityId == 21 && Auth.AuthotypeId == 3){ + //有权限 + bdHosts[index].qx = 0; + } + }) + } + } + }) + }); + } catch (error) { + console.log(error) + } + remove.forEach (x=>{ + bdHosts.splice(x, 1); + }) + let modalval = -200; + if(bdHosts.length<=0){ + modalval = -521; + } + that.setData({ + modal:modalval, + bdHosts:bdHosts + }) + // app.toast(2, "已经被绑定") + } + }else{ + app.toast(2, "网络繁忙") + } + }, + err => { + console.log(err) + app.toast(2, "网络繁忙") + }).catch(err => { + console.log(err) + app.toast(2, "网络繁忙") + }); + }, + CheckFaceMAC:function(vlues){ + return true; + console.log(vlues.length != 16) + return vlues.length == 16; + }, + // 完成人脸设备绑定 + GetFaceSNend: function () { + const that = this; + const selHosts = that.data.selHosts; + const faceSNCode = that.data.faceSNCode; + + // 显示加载提示 + wx.showLoading({ + title: '绑定中...', + }); + + // 调用绑定接口 + GetFaceSN({ + faceSN: faceSNCode, + roomID: selHosts.Id, + roomNumber: selHosts.RoomNumber, + faceAddress: that.data.faceAddress, + HotelID: selHosts.HotelID, + isjb: false + }).then(res => { + // 隐藏加载提示 + wx.hideLoading(); + + if (res.Status == 200) { + wx.showToast({ + title: '绑定成功', + icon: 'success' + }); + // 重新获取数据 + that.GetHostsInfo(); + // 关闭弹窗 + that.GetHide(); + } else if (res.Status == 400) { + // 设备已被绑定 + that.setData({ + bdHosts: res.Data, + code: faceSNCode, + modal: -200 + }); + } else { + wx.showToast({ + title: '绑定失败', + icon: 'none' + }); + } + }).catch(err => { + // 隐藏加载提示 + wx.hideLoading(); + + wx.showToast({ + title: '网络异常', + icon: 'none' + }); + console.error('绑定失败:', err); + }); + }, + + // 检查人脸设备绑定权限 + CheckFaceSNAutho: function () { + let res = false; + this.data.Hotelinfo.Auth.forEach(x => { + if (x.AuthorityId == 21 && x.AuthotypeId == 3) { + res = true; + } + }); + return res; + }, + + // 设置操作 + testinfo: function (e) { + var jbjd = this.data.selHosts; + wx.navigateTo({ + url: '/pages/test/test?Hotelinfo=' + e.currentTarget.id + '&RoomID=' + jbjd.Id + '&faceadd=' + this.data.faceAddress + }); + }, + + // 开门操作 + OpenDoor: function (e) { + const sn = e.currentTarget.id.split('_'); + OpenDoorTest({faceSN:sn[2],isjb:true}).then( + res=>{ + if (res.Status == 200) { + wx.showToast({ + title: res.Message, + icon: 'none' + }) + }else{ + wx.showToast({ + title: res.Message, + icon: 'none' + }) + } + },rej=>{ + wx.showToast({ + title: "网络繁忙", + icon: 'none' + }) + } + ); + }, + + // 切换显示信息 + GetshowinfoClick: function (e) { + const index = e.currentTarget.dataset.index; + this.setData({ + showinfo: index + }); + }, + + // 切换显示信息(刷新) + GetshowinfoClick1: function () { + this.GetHostsInfo(); + }, +}) \ No newline at end of file diff --git a/pages/basics/FacialDeviceBinding/FacialDeviceBinding.json b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.json new file mode 100644 index 0000000..75a629e --- /dev/null +++ b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.json @@ -0,0 +1,6 @@ +{ + "navigationBarTitleText": "人脸设备绑定", + "usingComponents": { + "cu-custom": "/colorui/components/cu-custom" + } +} \ No newline at end of file diff --git a/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxml b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxml new file mode 100644 index 0000000..f836003 --- /dev/null +++ b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxml @@ -0,0 +1,144 @@ + + 返回 + {{Hotelinfo.HotelName}}({{Hotelinfo.Code}}) + + + + + +房号:{{HostsDataFilters[RoomIndex].RoomNumber}} + + + 人脸设备在线: + {{onlineFaceDevices}}/ + {{HostsDataFilters.length}} + + + + + + + + + + + + + + + + + + + + + + + + + {{item.RoomNumber}} + {{item.FaceSN || '未绑定'}} + + + + + + + + + + {{selHosts.RoomNumber}}已经绑定人脸机 + + + + + + + 酒店:{{Hotelinfo.HotelName}} + 房间:{{message[1]}} + 人脸机SN:{{message[0]}} + 房间已经绑定人脸机,点击继续将执行扫描绑定;点击取消,将不会执行任何操作~ + + + + + + + 设置 + 开门 + + + + + + + + + + + + + + + + + 绑定人脸设备 + + + + + + 酒店:{{Hotelinfo.HotelName}} + 房间:{{selHosts.RoomNumber}} + 人脸设备SN: + + + + 确定为该房间绑定人脸设备SN,点击继续将执行绑定操作;点击取消,将不会执行任何操作~ + + + 取消 + 继续 + + + + + + + + + {{code}}已经被绑定 + + + + + + + + + +酒店:{{item.HotelName}} +房间:{{item.RoomNumber}} + + + + + + + + SN:{{faceSNCode}} + SN已经被其他房间绑定,点击解绑将取消原有绑定,执行新的绑定;点击取消,将不会执行任何操作~ + + + + 取消 + + 继续 + + + + + + diff --git a/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxss b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxss new file mode 100644 index 0000000..33628d0 --- /dev/null +++ b/pages/basics/FacialDeviceBinding/FacialDeviceBinding.wxss @@ -0,0 +1,364 @@ +/* pages/FacialDeviceBinding/FacialDeviceBinding.wxss */ +/* 人脸设备绑定页面样式 */ + +/* 滚动区域样式 */ +#scroll { + height: 100%; +} + +/* 房间列表样式 */ +.nav-list1 { + display: flex; + flex-wrap: wrap; + padding: 0 10rpx; +} + +/* 房间项样式 */ +.nav-li4 { + width: 31.33%; + margin: 1%; + padding: 15rpx; + border-radius: 8rpx; + text-align: center; + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); + transition: all 0.3s; +} + +.nav-li4:active { + transform: scale(0.95); +} + +/* 在线状态样式 */ +.bg-green { + background-color: #4CD964; + color: white; +} + +/* 青色在线状态样式 */ +.bg-cyan { + background-color: #00BCD4; + color: white; +} + +/* 离线状态样式 */ +.bg-gray { + background-color: #E5E5EA; + color: #8E8E93; +} + +/* 搜索框样式 */ +.cu-btn1 { + position: relative; + border: 0rpx; + display: inline-flex; + align-items: center; + justify-content: center; + box-sizing: border-box; + padding: 0 5rpx; + font-size: 26rpx; + height: 64rpx; + line-height: 1; + text-align: center; + text-decoration: none; + overflow: visible; + margin-left: initial; + transform: translate(0rpx, 0rpx); + margin-right: initial; +} + +/* 按钮样式 */ +.margin-left { + margin-left: 10rpx; +} + +/* 顶部操作栏样式 */ +.cu-bar1 { + display: flex; + align-items: center; + justify-content: space-between; +} + +/* 弹性换行样式 */ +.flex-wrap { + display: flex; +} + +/* 固体样式 */ +.solids { + display: block; +} + +/* 顶部信息栏样式 */ +.text-xl { + font-size: 36rpx; + font-weight: bold; +} + +.text-blue { + color: #007AFF; +} + +.text-black { + color: #000000; +} + +/* 弹窗样式 */ +.cu-modal { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + z-index: 999; + display: flex; + align-items: center; + justify-content: center; + opacity: 0; + transition: opacity 0.3s; +} + +.cu-modal.show { + opacity: 1; +} + +.cu-dialog { + background: white; + border-radius: 10rpx; + width: 80%; + max-width: 500rpx; + overflow: hidden; + transform: scale(0.8); + transition: transform 0.3s; +} + +.cu-modal.show .cu-dialog { + transform: scale(1); +} + +.cu-bar { + display: flex; + align-items: center; + justify-content: space-between; + padding: 20rpx; + border-bottom: 1px solid #E5E5EA; +} + +.cu-bar .content { + font-size: 36rpx; + font-weight: bold; +} +.cu-bar.bg-gradual-blue .action { + color: white; +} +.cu-bar.bg-gradual-blue .action text { + color: white; +} +.cu-bar .action { + color: #007AFF; + font-size: 32rpx; +} + +/* 内容区样式 */ +.padding-lg { + padding: 30rpx; +} + +.flex { + display: flex; +} + +.flex-wrap { + flex-wrap: wrap; +} + +.basis-sm { + width: 30%; + text-align: right; + padding-right: 20rpx; +} + +.basis-lg { + width: 70%; + text-align: left; +} + +.text-red { + color: #FF3B30; +} + +.text-green { + color: #4CD964; +} + +/* 输入框样式 */ +input { + border: 1px solid #E5E5EA; + border-radius: 5rpx; + padding: 15rpx; + width: 100%; + font-size: 32rpx; + box-sizing: border-box; +} + +/* 底部按钮栏样式 */ +.cu-bar.bg-white { + border-top: 1px solid #E5E5EA; + border-bottom: none; +} + +.cu-bar .action { + padding: 10rpx 20rpx; +} + +.solid-left { + border-left: 1px solid #E5E5EA; +} + +/* 酒店信息样式 */ +.text-df { + font-size: 28rpx; +} + +/* 设备信息样式 */ +.text-sm { + font-size: 24rpx; +} + +/* 分隔线样式 */ +.ControlLine { + height: 2rpx; + background-color: #E5E5EA; + margin: 20rpx 0; +} + +/* 轻量级文本样式 */ +.light { + opacity: 0.7; +} + +/* 禁用状态样式 */ +button:disabled { + opacity: 0.5; +} + +/* 加载提示样式 */ +.loading { + display: flex; + justify-content: center; + align-items: center; + padding: 50rpx; +} + +.loading text { + margin-left: 10rpx; + font-size: 32rpx; + color: #8E8E93; +} + +/* 空数据提示样式 */ +.empty { + text-align: center; + padding: 100rpx; + color: #8E8E93; + font-size: 32rpx; +} + +/* 帮助区域样式 */ +.cu-card { + margin: 20rpx; + background: white; + border-radius: 10rpx; + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); +} + +.cu-item { + padding: 30rpx; +} + +.title { + font-size: 36rpx; + font-weight: bold; + margin-bottom: 20rpx; +} + +.content { + font-size: 32rpx; + line-height: 1.6; +} + +.desc { + margin-bottom: 20rpx; +} + +.text-content { + font-size: 30rpx; + line-height: 1.8; +} + +/* 酒店信息样式 */ +.hotel-info { + padding: 20rpx; + background: white; + border-bottom: 1px solid #E5E5EA; +} + +.hotel-name { + font-size: 36rpx; + font-weight: bold; + color: #000000; +} + +.hotel-code { + font-size: 30rpx; + color: #8E8E93; + margin-top: 10rpx; +} + +/* 状态统计样式 */ +.status-stats { + display: flex; + justify-content: space-around; + padding: 20rpx; + background: white; + border-bottom: 1px solid #E5E5EA; +} + +.stat-item { + text-align: center; +} + +.stat-label { + font-size: 30rpx; + color: #8E8E93; +} + +.stat-value { + font-size: 40rpx; + font-weight: bold; + color: #007AFF; +} + +/* 操作按钮样式 */ +.operation-buttons { + display: flex; + justify-content: space-around; + padding: 20rpx; + background: white; + border-bottom: 1px solid #E5E5EA; +} + +.operation-button { + flex: 1; + margin: 0 10rpx; + padding: 20rpx; + background: #007AFF; + color: white; + border-radius: 50rpx; + text-align: center; + font-size: 32rpx; +} + +.operation-button:active { + opacity: 0.8; +} \ No newline at end of file diff --git a/pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol.wxml b/pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol.wxml index ad0291f..7567b3b 100644 --- a/pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol.wxml +++ b/pages/basics/HostUpgrade/EquipmentCaontrol/EquipmentCaontrol.wxml @@ -88,8 +88,7 @@ - - + diff --git a/pages/basics/MakingRounds/MakingRounds.js b/pages/basics/MakingRounds/MakingRounds.js index 2c57958..a975c1f 100644 --- a/pages/basics/MakingRounds/MakingRounds.js +++ b/pages/basics/MakingRounds/MakingRounds.js @@ -16,6 +16,7 @@ import { SetRCULight, SetRCUAir, SetRCUCurtain, + GetRoomAddressStatus } from '../../../lib/RequestingCenter.js' Page({ @@ -79,7 +80,8 @@ Page({ onlineNumber=onlineNumber+1 } } - + + app.globalData.CreatDate =res.Data[0].CreateTime that.setData({ onlineNumber:onlineNumber, HostsData: res.Data, @@ -103,9 +105,6 @@ Page({ app.toast(2, "网络繁忙") }); - - - }, /** @@ -194,11 +193,19 @@ Page({ }) }, goProcess(e) { + let indexstr = e.currentTarget.id.replace("msg-","") + let index= Number(indexstr) const { room, hotel, status } = e.currentTarget.dataset; - + this.setData({ + RoomIndex:index + } ) + //debugger + let HostsDataFilters= this.data.HostsDataFilters + console.log(HostsDataFilters[index].RoomNumber) + let RoomTypeID=HostsDataFilters[index].RoomTypeID if (status !== 1) return; // 不为1时不跳转 wx.navigateTo({ - url: `/pages/basics/MakingRounds/process/process?RoomNumber=${room}&HotelName=${hotel}&HotelId=${this.data.Hotelinfo.HotelId }` + url: `/pages/basics/MakingRounds/process/process?RoomNumber=${room}&RoomTypeID=${RoomTypeID}&HotelName=${hotel}&HotelId=${this.data.Hotelinfo.HotelId }` }); }, RefreshTheRoom:async function(e){ @@ -209,14 +216,17 @@ Page({ if (res.Status == 200) { let onlineNumber=0 + for (let index = 0; index < res.Data.length; index++) { const element = res.Data[index]; if (element.Status===1) { + onlineNumber=onlineNumber+1 } } - + that.setData({ + RoomIndex:RoomIndex, onlineNumber:onlineNumber, HostsData: res.Data, HostsDataFilters: res.Data, diff --git a/pages/basics/MakingRounds/process/process.js b/pages/basics/MakingRounds/process/process.js index c8be377..ddb6da5 100644 --- a/pages/basics/MakingRounds/process/process.js +++ b/pages/basics/MakingRounds/process/process.js @@ -1,4 +1,10 @@ -// pages/basics/MakingRounds/process/process.js +const app = getApp() +import { + GetRoomAddressStatus, + QueryDeviceList, + WriteRoomVisitLog, + SetRCUService +} from '../../../../lib/RequestingCenter.js' Page({ /** @@ -7,23 +13,7 @@ Page({ data: { RoomNumber:"", HotelName:"", - deviceList:[ - {id:1, name:'取电面板通讯', status:'在线',note:'在线',isnote:"0"}, - {id:2, name:'温控面板通讯', status:'在线',note:'在线',isnote:0}, - {id:3, name:'红外转发通讯', status:'离线',note:'在线',isnote:0}, - {id:4, name:'485窗帘电机通讯',status:'在线',note:'在线',isnote:0}, - {id:5, name:'门口传感器测试', status:'显示',note:'在线',isnote:0}, - {id:6, name:'卫生间传感器测试',status:'显示',note:'在线',isnote:0}, - {id:7, name:'淋浴间传感器测试',status:'不显示',note:'在线',isnote:0}, - {id:8, name:'床尾传感器测试', status:'不显示',note:'在线',isnote:0}, - {id:9, name:'镜前传感器测试', status:'不显示',note:'在线',isnote:0}, - {id:10,name:'休闲区传感器测试',status:'不显示',note:'在线',isnote:0}, - {id:11,name:'客厅传感器测试', status:'不显示',note:'在线',isnote:0}, - {id:12,name:'厅卫传感器测试', status:'不显示',note:'在线',isnote:0}, - {id:13,name:'浴缸传感器测试', status:'不显示',note:'在线',isnote:0}, - {id:14,name:'门磁测试', status:'不显示',note:'在线',isnote:0}, - {id:15,name:'干接点窗帘测试', status:'正常',note:'在线',isnote:0} // 最后一条你自行改状态 - ], + deviceList:[], deviceListindex:0, inputValue:"", toView:"", @@ -32,15 +22,22 @@ Page({ note:"", noteok:"", errorsNumber:0, - HotelId:"" + HotelId:"", + RoomTypeID:"", + showErrorReasonInput: false, // 控制异常原因输入框显示/隐藏 + errorReason: "", // 异常原因内容 }, + + // 定时器ID + timer5s: null, + timer1min: null, /** * 生命周期函数--监听页面加载 */ - onLoad(options) { + onLoad:async function(options) { - if (!options.RoomNumber || !options.HotelName ||!options.HotelId) { + if (!options.RoomNumber || !options.HotelName ||!options.HotelId ||!options.RoomTypeID) { app.toast(2, "无酒店信息~") return; } @@ -48,15 +45,95 @@ Page({ this.setData ({ RoomNumber:options.RoomNumber, HotelName:options.HotelName, - HotelId:options.HotelId + HotelId:options.HotelId, + RoomTypeID:options.RoomTypeID }) + console.log(app.globalData.HotelCode) + + // let HotelId =parseInt(app.globalData.HotelCode); + // await GetRoomAddressStatus({ + // Code: HotelId, + // RoomNum:options.RoomNumber + // }).then(res => { + + // if (res.Status == 200) { + + + + // } else { + // app.toast(2, res.Message || "网络繁忙") + // } + // }, err => { + // console.log(err) + // app.toast(2, "网络繁忙") + // }).catch(err => { + // console.log(err) + // app.toast(2, "网络繁忙") + // }); + }, /** * 生命周期函数--监听页面初次渲染完成 */ - onReady() { + onReady:async function() { + //debugger this.calcScrollHeight(); + + // 页面加载完毕时调用QueryDeviceList获取设备列表 + await this.getDeviceList(); + }, + + /** + * 获取设备列表 + */ + getDeviceList:async function() { + try { + const res = await QueryDeviceList({ + HotelID: app.globalData.HotelCode, + RoomTypeID: this.data.RoomTypeID + }); + + if (res.Status == 1) { + console.log('设备列表获取成功:', res.Data); + // 更新设备列表数据 + let deviceList = []; + for (let index = 0; index < res.Data.length; index++) { + const element = res.Data[index]; + // 检查是否已存在相同名称的设备 + const isExist = deviceList.some(item => item.name === element.DevName); + if (!isExist) { + deviceList.push({ + id: deviceList.length + 1, + name: element.DevName, + status: "在线", + note: element.Process, + isnote: 0, + Addrlist: [element.DevAddr] + }); + } else { + // 如果设备已存在,将新地址添加到Addrlist中 + const existingDevice = deviceList.find(item => item.name === element.DevName); + if (existingDevice) { + // 检查Addrlist中是否已存在该地址,避免重复添加 + if (!existingDevice.Addrlist.includes(element.DevAddr)) { + existingDevice.Addrlist.push(element.DevAddr); + } + } + } + } + this.setData({ + deviceList: deviceList + }); + + } else { + console.log('设备列表获取失败:', res.Message); + app.toast(2, res.Message || "获取设备列表失败"); + } + } catch (error) { + console.log('获取设备列表出错:', error); + app.toast(2, "获取设备列表失败"); + } }, calcScrollHeight() { // 1. 拿到屏幕可用高度(px) @@ -66,7 +143,7 @@ Page({ // 2. 拿到 scroll-view 的 top(px) wx.createSelectorQuery() .in(this) - .select('#myScroll') + .select('#NmyScroll') .boundingClientRect(rect => { if (rect) { const topPx = rect.top; // px @@ -85,21 +162,172 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + // 启动定时器 + this.startTimers(); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { - + // 停止定时器 + this.stopTimers(); }, /** * 生命周期函数--监听页面卸载 */ onUnload() { + // 停止定时器 + this.stopTimers(); + }, + /** + * 启动定时器 + */ + startTimers() { + // 先调用一次SetRCUService + this.callSetRCUService(); + // 再调用一次GetRoomAddressStatus + this.callGetRoomAddressStatus(); + + // 设置5秒定时器,查询设备离在线状态 + this.timer5s = setInterval(() => { + this.callGetRoomAddressStatus(); + }, 5000); + + // 设置1分钟定时器,启动设备巡检 + this.timer1min = setInterval(() => { + this.callSetRCUService(); + }, 60000); + }, + + /** + * 停止定时器 + */ + stopTimers() { + if (this.timer5s) { + clearInterval(this.timer5s); + this.timer5s = null; + } + if (this.timer1min) { + clearInterval(this.timer1min); + this.timer1min = null; + } + }, + + /** + * 调用SetRCUService接口 + */ + async callSetRCUService() { + // 解析.NET风格的日期格式 "/Date(1473004800000)/" + let dotNetDate = app.globalData.CreatDate + let timestamp, pageCreateTime + try { + timestamp = parseInt(dotNetDate.match(/\d+/)[0]) + pageCreateTime = new Date(timestamp) + } catch (error) { + console.error('日期解析错误:', error) + // 如果解析失败,使用当前日期作为备选 + pageCreateTime = new Date() + } + let year = pageCreateTime.getFullYear() + let month = (pageCreateTime.getMonth() + 1).toString().padStart(2, '0') + let day = pageCreateTime.getDate().toString().padStart(2, '0') + let CreateTime = `${year}-${month}-${day}` + + try { + + const params = { + code: app.globalData.HotelCode, + creatDate:CreateTime, + roomNumber: this.data.RoomNumber, + modalAddress:"004000029", + status: "1" + }; + const res = await SetRCUService(params); + console.log('SetRCUService调用成功:', res); + } catch (error) { + console.error('SetRCUService调用失败:', error); + } + }, + + /** + * 调用GetRoomAddressStatus接口 + */ + async callGetRoomAddressStatus() { + //debugger + try { + const params = { + Code: parseInt(app.globalData.HotelCode), + RoomNum: this.data.RoomNumber + }; + const res = await GetRoomAddressStatus(params); + //console.log('GetRoomAddressStatus调用成功:', res); + + // 更新设备状态 + if (res.Status === 1 && res.Data) { + this.updateDeviceStatus(res.Data); + } + } catch (error) { + console.error('GetRoomAddressStatus调用失败:', error); + } + }, + + /** + * 更新设备状态 + */ + updateDeviceStatus(data) { + let deviceList = this.data.deviceList; + + // 检测data和deviceList是否有数据,若无数据则退出函数 + if (!data || !deviceList || deviceList.length === 0) return; + + // 先将所有设备标记为在线 + deviceList = deviceList.map(device => ({ + ...device, + status: '在线' + })); + + // 遍历设备异常数据集合data + for (const exceptionAddr in data) { + if (data.hasOwnProperty(exceptionAddr)) { + // 取异常地址的前6个字符 + const exceptionAddrPrefix = exceptionAddr.toString().substring(0, 6); + + // 遍历设备列表 + for (let index = 0; index < deviceList.length; index++) { + const device = deviceList[index]; + let isMatched = false; + + // 遍历设备的地址集合 + for (let addrIndex = 0; addrIndex < device.Addrlist.length; addrIndex++) { + const deviceAddr = device.Addrlist[addrIndex]; + // 取设备地址的前6个字符 + const deviceAddrPrefix = deviceAddr.toString().substring(0, 6); + + // 比较地址前缀 + if (deviceAddrPrefix === exceptionAddrPrefix) { + // 地址匹配,将设备标记为离线 + deviceList[index].status = '离线'; + isMatched = true; + break; // 退出当前设备的地址循环 + } + } + + if (isMatched) { + continue; // 匹配成功,遍历下一个设备 + } + } + } + } + + // 更新设备列表 + this.setData({ + deviceList: deviceList + }); + + console.log('设备状态更新完成:', deviceList); }, /** @@ -131,29 +359,52 @@ Page({ DialogModal1(e){ let deviceList = this.data.deviceList let deviceListindex=this.data.deviceListindex - deviceList[deviceListindex].equipmentstatus=e.currentTarget.dataset.id + const status = e.currentTarget.dataset.id - this.setData({ - modalName: null, - deviceList:deviceList - }) - console.log(this.data.deviceList) - }, - DialogModal2(e){ - let deviceList = this.data.deviceList - let deviceListindex=this.data.deviceListindex - if (e.currentTarget.dataset.id==="hideModal_1") { - deviceList[deviceListindex].isnote=1 - }else{ - deviceList[deviceListindex].isnote=0 + // 如果选择异常,显示异常原因弹窗 + if (status === 'hideModal_0') { + // 先设置设备状态为异常 + deviceList[deviceListindex].equipmentstatus = status + + // 重新计算异常数量 + const errorsNumber = deviceList.filter(device => device.equipmentstatus === 'hideModal_0').length; + + this.setData({ + errorReason: deviceList[deviceListindex].errorReason || "", // 显示已有的异常原因 + modalName: "DialogModal4", + deviceList: deviceList, + errorsNumber: errorsNumber + }) + } else { + // 选择正常,直接保存状态并关闭弹窗 + deviceList[deviceListindex].equipmentstatus = status + // 清除异常原因 + deviceList[deviceListindex].errorReason = undefined + + // 重新计算异常数量 + const errorsNumber = deviceList.filter(device => device.equipmentstatus === 'hideModal_0').length; + + this.setData({ + modalName: null, + deviceList: deviceList, + errorsNumber: errorsNumber + }) } - - - this.setData({ - deviceList:deviceList + console.log(this.data.deviceList) + }, + DialogModal2(e){ + this.setData({ + modalName: "DialogModal3" }) console.log(this.data.deviceList) }, + + DialogModal3(e){ + this.setData({ + modalName:"" + }) + }, + inputSearchForHotels(e){ this.setData({ note: e.detail.value @@ -171,12 +422,106 @@ Page({ let deviceListindex=this.data.deviceListindex let note=this.data.note let noteok=e.currentTarget.dataset.id - deviceList[deviceListindex].isnote= 0 if (noteok==="ok") { deviceList[deviceListindex].note= note } - this.setData({ - deviceList:deviceList + this.setData({ + deviceList:deviceList, + modalName: "DialogModal1" }) }, + // 处理异常原因输入 + inputErrorReason(e){ + this.setData({ + errorReason: e.detail.value + }) + }, + // 确认异常原因弹窗 + confirmErrorReasonModal(){ + let deviceList = this.data.deviceList + let deviceListindex=this.data.deviceListindex + + // 保存异常原因到设备节点 + deviceList[deviceListindex].errorReason = this.data.errorReason + + this.setData({ + deviceList: deviceList, + modalName: null, // 退出所有弹窗 + errorReason: "" + }) + + console.log("异常原因已保存:", deviceList[deviceListindex]) + }, + // 取消异常原因弹窗 + cancelErrorReasonModal(){ + let deviceList = this.data.deviceList + let deviceListindex=this.data.deviceListindex + + // 如果还没有保存过异常原因,将设备状态改回未检测 + if (!deviceList[deviceListindex].errorReason) { + deviceList[deviceListindex].equipmentstatus = undefined + + // 重新计算异常数量 + const errorsNumber = deviceList.filter(device => device.equipmentstatus === 'hideModal_0').length; + + this.setData({ + deviceList: deviceList, + errorsNumber: errorsNumber + }) + } + + this.setData({ + modalName: "DialogModal1", // 返回之前的弹窗 + errorReason: "" + }) + }, + /** + * 上传查房状态 + */ + async uploadWardRoundStatus() { + const deviceList = this.data.deviceList + // 检查所有设备是否已设置equipmentstatus状态 + const allSet = deviceList.every(device => device.equipmentstatus !== undefined && device.equipmentstatus !== null) + if (!allSet) { + app.toast(2, "请先完成所有设备的状态检测") + return + } + + try { + // 构造请求参数 + const params = { + HotelID: this.data.HotelId, + RoomNumber: this.data.RoomNumber, + EquipmentList: deviceList.map(device => ({ + EquipmentStatus: device.equipmentstatus === 'hideModal_1' ? '正常' : device.equipmentstatus === 'hideModal_0' ? '故障' : '', + FaultDescription: device.errorReason || '', + DevName: device.name, + EquipmentStatusType: device.equipmentstatus === 'hideModal_1' ? '1' : device.equipmentstatus === 'hideModal_0' ? '2' : '', + EquipmentOnlineStatus: device.status === '在线' ? '1' : '2' + })) + } + + // 调用接口上传数据 + const res = await WriteRoomVisitLog(params) + + // 处理返回结果 + if (res.Status === 1) { + app.toast(1, res.Message || "上传成功") + console.log("上传成功", res) + } else { + app.toast(2, res.Message || "上传失败") + console.log("上传失败", res) + } + } catch (error) { + app.toast(2, "上传失败,请检查网络连接") + console.error("上传出错", error) + } + }, + /** + * 刷新设备列表 + */ + refreshDeviceList() { + // 调用getDeviceList函数刷新设备列表 + this.getDeviceList() + }, }) \ No newline at end of file diff --git a/pages/basics/MakingRounds/process/process.wxml b/pages/basics/MakingRounds/process/process.wxml index 844212d..35cccd5 100644 --- a/pages/basics/MakingRounds/process/process.wxml +++ b/pages/basics/MakingRounds/process/process.wxml @@ -4,24 +4,24 @@ ({{HotelName}})_{{RoomNumber}} - + 异常数量: - 1 + {{errorsNumber}} /{{deviceList.length}} - 查看查房记录 - 上传查房状态 + 查看查房记录 + 上传查房状态 + 刷新设备 - - + 设备名称 - 状态 - 设备检测 + 状态 + 设备检测 - + @@ -29,14 +29,12 @@ {{item.name}} - - - {{item.status}} - + + {{item.status}} - + @@ -59,25 +57,51 @@ - - - + + + + + - - 检测流程: - -