diff --git a/api/room.js b/api/room.js new file mode 100644 index 0000000..2670416 --- /dev/null +++ b/api/room.js @@ -0,0 +1,12 @@ +import request from '../utils/request' + +// room 房间模块 + +// 更新锁电量 +export function updateElectricQuantityRequest(data) { + return request({ + url: '/room/uploadElectricQuantity', + method: 'POST', + data + }) +} diff --git a/config/env.js b/config/env.js index c012285..5f1fca5 100644 --- a/config/env.js +++ b/config/env.js @@ -23,4 +23,4 @@ const PROD = { } // 更换环境的时候 切换导出就行 -export default PRE +export default DEV diff --git a/pages/lockDetail/lockDetail.vue b/pages/lockDetail/lockDetail.vue index 357fe78..65c3c2d 100644 --- a/pages/lockDetail/lockDetail.vue +++ b/pages/lockDetail/lockDetail.vue @@ -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 }) }, diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 144368f..7632b2a 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -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,