添加开关门电量上报

This commit is contained in:
范鹏 2024-08-30 15:56:04 +08:00
parent f40d0477d9
commit 8581513b09
4 changed files with 40 additions and 2 deletions

12
api/room.js Normal file
View File

@ -0,0 +1,12 @@
import request from '../utils/request'
// room 房间模块
// 更新锁电量
export function updateElectricQuantityRequest(data) {
return request({
url: '/room/uploadElectricQuantity',
method: 'POST',
data
})
}

View File

@ -23,4 +23,4 @@ const PROD = {
}
// 更换环境的时候 切换导出就行
export default PRE
export default DEV

View File

@ -89,9 +89,11 @@ export default {
...mapActions(useBasicStore, ['routeJump']),
powerTip() {
const that = this
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
console.log('更新时间', that.currentLockInfo.electricQuantityDate, time)
uni.showModal({
title: '锁电量更新时间',
content: `${timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')}`,
content: time,
showCancel: false
})
},

View File

@ -7,6 +7,7 @@ import { sm4 } from 'sm-crypto'
import { md5 } from 'js-md5'
import { getServerDatetime } from '@/api/check'
import { getUserNoListRequest, updateLockUserNoRequest } from '@/api/key'
import { updateElectricQuantityRequest } from '@/api/room'
// 定时器
let timer
@ -325,6 +326,29 @@ export const useBluetoothStore = defineStore('ble', {
break
}
break
case cmdIds.openDoor:
that.updateCurrentLockInfo({
...that.currentLockInfo,
token: decrypted.slice(2,6)
})
console.log('开门', decrypted[6], that.currentLockInfo.token)
characteristicValueCallback({
code: decrypted[6]
})
if(decrypted[6] === 0) {
updateElectricQuantityRequest({
lockId: that.currentLockInfo.lockId,
electricQuantity: decrypted[7],
electricQuantityStandby: decrypted[9]
}).then(res => {
if(res.code === 0) {
that.updateCurrentLockInfo({
...that.currentLockInfo,
electricQuantityDate: res.data.electricQuantityDate
})
}
})
}
default:
that.updateCurrentLockInfo({
...that.currentLockInfo,