完成操作记录相关功能
This commit is contained in:
parent
ba5d4f0bde
commit
db607aa35a
48
api/record.js
Normal file
48
api/record.js
Normal file
@ -0,0 +1,48 @@
|
||||
import request from '../utils/request'
|
||||
|
||||
// record 记录模块
|
||||
|
||||
// 获取事件记录列表
|
||||
export function getEventRecordListRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/lockEventList',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取操作记录列表
|
||||
export function getRecordListRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/list',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 清空操作记录
|
||||
export function clearRecordRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/clear',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询最后一条记录时间
|
||||
export function getLastRecordTimeRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/getLastRecordTime',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 锁记录上传
|
||||
export function uploadRecordRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/fromLock',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
21
pages.json
21
pages.json
@ -302,6 +302,27 @@
|
||||
"navigationBarTitleText": "授权管理员",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/recordList/recordList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "操作记录",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/recordDetail/recordDetail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "操作记录详情",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/typeRecordList/typeRecordList",
|
||||
"style": {
|
||||
"navigationBarTitleText": "操作记录",
|
||||
"disableScroll": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
@ -25,7 +25,10 @@
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.sendDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="showModal = true">删除</view>
|
||||
</view>
|
||||
<up-modal
|
||||
@ -70,6 +73,17 @@
|
||||
}
|
||||
})
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.keyName,
|
||||
key: 'keyId',
|
||||
id: info.value.keyId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const confirmModal = async () => {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
|
||||
@ -55,6 +55,7 @@
|
||||
endDate: params.value.endDate,
|
||||
faceName: params.value.faceName,
|
||||
faceNumber: String(data.faceNumber),
|
||||
faceUserNo: String(data.faceNumber),
|
||||
faceType: params.value.faceType,
|
||||
addType: 1,
|
||||
fingerRight: params.value.isAdmin,
|
||||
|
||||
@ -59,6 +59,7 @@
|
||||
endDate: params.endDate,
|
||||
fingerprintName: params.fingerprintName,
|
||||
fingerprintNumber: String(data.fingerprintNumber),
|
||||
fingerprintUserNo: String(data.fingerprintNumber),
|
||||
fingerprintType: params.fingerprintType,
|
||||
addType: 1,
|
||||
fingerRight: params.isAdmin,
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
endDate: params.endDate,
|
||||
palmVeinName: params.palmVeinName,
|
||||
palmVeinNumber: String(data.palmVeinNumber),
|
||||
palmVeinUserNo: String(data.palmVeinNumber),
|
||||
palmVeinType: params.palmVeinType,
|
||||
addType: 1,
|
||||
palmVeinRight: params.isAdmin,
|
||||
|
||||
@ -39,7 +39,10 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,11 +53,13 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
@ -65,6 +70,17 @@
|
||||
}
|
||||
})
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.cardName,
|
||||
key: 'cardId',
|
||||
id: info.value.cardId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
eventChannel.emit('delete', {})
|
||||
}
|
||||
|
||||
@ -39,7 +39,10 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,21 +53,33 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
console.log(info.value)
|
||||
}
|
||||
})
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.faceName,
|
||||
key: 'faceId',
|
||||
id: info.value.faceId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
eventChannel.emit('delete', {})
|
||||
}
|
||||
|
||||
@ -39,7 +39,10 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,6 +53,9 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
@ -58,6 +64,17 @@
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.fingerprintName,
|
||||
key: 'fingerprintId',
|
||||
id: info.value.fingerprintId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
|
||||
@ -45,6 +45,10 @@
|
||||
<view class="item-title">发送时间</view>
|
||||
<view class="item-content">{{ timeFormat(currentKeyInfo.sendDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deleteKey">删除</view>
|
||||
<up-modal
|
||||
:show="showModal"
|
||||
@ -88,7 +92,17 @@
|
||||
'getKeyList',
|
||||
'convertWeekDaysToChineseString'
|
||||
]),
|
||||
...mapActions(useBasicStore, ['backAndToast']),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'routeJump']),
|
||||
async toRecordList() {
|
||||
this.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: this.currentKeyInfo.keyName,
|
||||
key: 'keyId',
|
||||
id: this.currentKeyInfo.keyId
|
||||
}
|
||||
})
|
||||
},
|
||||
cancelModal() {
|
||||
this.showModal = false
|
||||
this.checked = false
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
<image class="menu-main-image" src="/static/images/icon_admin_black.png"></image>
|
||||
<view>授权管理员</view>
|
||||
</view>
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'keyList' })">
|
||||
<view class="menu-main-view" @click="routeJump({ name: 'recordList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_record.png"></image>
|
||||
<view>操作记录</view>
|
||||
</view>
|
||||
@ -196,7 +196,8 @@
|
||||
...mapActions(useBluetoothStore, [
|
||||
'openDoor',
|
||||
'updateServerTimestamp',
|
||||
'closeBluetoothConnection'
|
||||
'closeBluetoothConnection',
|
||||
'syncRecord'
|
||||
]),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
|
||||
closePopup() {
|
||||
@ -285,7 +286,12 @@
|
||||
openTime: parseInt(new Date().getTime() / 1000, 10) + this.time,
|
||||
onlineToken: this.onlineToken
|
||||
})
|
||||
this.closeBluetoothConnection()
|
||||
this.syncRecord({
|
||||
keyId: this.currentLockInfo.toString(),
|
||||
uid: this.userInfo.uid.toString()
|
||||
}).then(() => {
|
||||
this.closeBluetoothConnection()
|
||||
})
|
||||
if (type === 'open') {
|
||||
uni.reportEvent('open_door', {
|
||||
result: code,
|
||||
|
||||
@ -39,7 +39,10 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,11 +53,13 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
@ -65,6 +70,17 @@
|
||||
}
|
||||
})
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.palmVeinName,
|
||||
key: 'palmVeinId',
|
||||
id: info.value.palmVeinId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
eventChannel.emit('delete', {})
|
||||
}
|
||||
|
||||
@ -33,6 +33,10 @@
|
||||
timeFormat(currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -59,7 +63,17 @@
|
||||
timeFormat,
|
||||
...mapActions(useBluetoothStore, ['setLockPassword', 'closeBluetoothConnection']),
|
||||
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType', 'routeJump']),
|
||||
async toRecordList() {
|
||||
this.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: this.currentPasswordInfo.keyboardPwdName,
|
||||
key: 'keyboardPwdId',
|
||||
id: this.currentPasswordInfo.keyboardPwdId
|
||||
}
|
||||
})
|
||||
},
|
||||
async deletePassword() {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
|
||||
32
pages/recordDetail/recordDetail.vue
Normal file
32
pages/recordDetail/recordDetail.vue
Normal file
@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<view>
|
||||
<view v-if="info"
|
||||
><view class="font-bold text-base mx-3 py-3">
|
||||
操作时间:{{ timeFormat(info.operateDate, 'yyyy-mm-dd h:M') }}{{
|
||||
}}</view>
|
||||
<view class="bg-white shadow-sm mx-3 p-3 rounded-xl font-bold text-lg">{{
|
||||
info.recordDetailStr
|
||||
}}</view></view
|
||||
>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { ref } from 'vue'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
onLoad(options => {
|
||||
if (options.info) {
|
||||
info.value = JSON.parse(options.info)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
448
pages/recordList/recordList.vue
Normal file
448
pages/recordList/recordList.vue
Normal file
@ -0,0 +1,448 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="flex items-center h-[60px] mx-3 font-bold">
|
||||
<view>日期:</view>
|
||||
<view class="bg-[rgba(0,0,0,0.5)] rounded-full px-2 py-1.5 mr-5">
|
||||
<picker :value="timeText" mode="date" @change="changeDate">
|
||||
<up-icon
|
||||
:label="timeText"
|
||||
color="#ffffff"
|
||||
label-color="#ffffff"
|
||||
labelPos="left"
|
||||
name="arrow-down-fill"
|
||||
size="32rpx"
|
||||
space="16rpx"
|
||||
></up-icon>
|
||||
</picker>
|
||||
</view>
|
||||
<view>事件:</view>
|
||||
<view class="bg-[rgba(0,0,0,0.5)] rounded-full px-2 py-1.5 mr-1">
|
||||
<picker
|
||||
:value="index"
|
||||
mode="selector"
|
||||
:range="range"
|
||||
range-key="name"
|
||||
@change="changeEvent"
|
||||
>
|
||||
<up-icon
|
||||
:label="range[index].name"
|
||||
color="#ffffff"
|
||||
label-color="#ffffff"
|
||||
labelPos="left"
|
||||
name="arrow-down-fill"
|
||||
size="32rpx"
|
||||
space="16rpx"
|
||||
></up-icon>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
scroll-y="true"
|
||||
:style="{ height: `calc(${deviceInfo.screenHeight - deviceInfo.safeArea.top - 60}px)` }"
|
||||
lower-threshold="100"
|
||||
@refresherrefresh="refresherList"
|
||||
:refresher-enabled="true"
|
||||
@scrolltolower="nextPage"
|
||||
:refresher-triggered="refresherTriggered"
|
||||
>
|
||||
<view style="padding: 0 0 calc(env(safe-area-inset-bottom) + 250rpx) 0">
|
||||
<view v-if="list.length === 0 && requestFinished">
|
||||
<image
|
||||
class="empty-list"
|
||||
src="/static/images/background_empty_list.png"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="empty-list-text">暂无数据</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<div class="flex flex-col relative pl-5 text-base">
|
||||
<div
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
class="relative flex items-start pb-10 last:pb-0"
|
||||
@click="toDetail(item)"
|
||||
>
|
||||
<div class="w-16 h-16 bg-#eeeeee rounded-full absolute left-0 top-2"></div>
|
||||
<div
|
||||
v-if="index !== list.length - 1"
|
||||
class="absolute left-4 top-16 w-8 h-full bg-#eeeeee"
|
||||
></div>
|
||||
<div class="ml-5">
|
||||
<div class="font-bold pb-3">{{ item.recordStr }}</div>
|
||||
<view v-if="item.videoUrl !== ''" @click.stop="playFullScreen(index)">
|
||||
<video
|
||||
:id="`video${index}`"
|
||||
class="w-300 h-225"
|
||||
object-fit="cover"
|
||||
:src="item.videoUrl"
|
||||
></video>
|
||||
</view>
|
||||
<image
|
||||
class="w-300 h-225"
|
||||
v-else-if="item.imagesUrl"
|
||||
:src="item.imagesUrl"
|
||||
mode="aspectFill"
|
||||
@click.stop="previewImage(item.imagesUrl)"
|
||||
></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="button">
|
||||
<view class="button-reset" @click="reset">清空记录</view>
|
||||
<view class="button-create" @click="syncRecord">同步记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { clearRecordRequest, getEventRecordListRequest } from '@/api/record'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const list = ref([])
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 50
|
||||
const total = ref(0)
|
||||
const lockId = ref(null)
|
||||
const startDate = ref(0)
|
||||
const endDate = ref(0)
|
||||
|
||||
const range = ref([
|
||||
{ name: '全部事件', lockEventType: 0 },
|
||||
{ name: '开锁事件', lockEventType: 10 },
|
||||
{ name: '异常事件', lockEventType: 20 },
|
||||
{ name: '门铃事件', lockEventType: 30 },
|
||||
{ name: '视频事件', lockEventType: 40 }
|
||||
])
|
||||
|
||||
const timeText = ref('今天')
|
||||
const index = ref(0)
|
||||
|
||||
const deviceInfo = ref(null)
|
||||
const requestFinished = ref(false)
|
||||
const refresherTriggered = ref(false)
|
||||
|
||||
const playFullScreen = index => {
|
||||
const videoContext = uni.createVideoContext(`video${index}`)
|
||||
videoContext.requestFullScreen({ direction: 0 })
|
||||
}
|
||||
|
||||
const previewImage = url => {
|
||||
uni.previewImage({
|
||||
urls: [url]
|
||||
})
|
||||
}
|
||||
|
||||
const changeDate = async value => {
|
||||
if (value.detail.value === timeFormat(new Date(), 'yyyy-mm-dd')) {
|
||||
timeText.value = '今天'
|
||||
} else {
|
||||
timeText.value = value.detail.value
|
||||
}
|
||||
startDate.value = new Date(value.detail.value).setHours(0, 0, 0, 0)
|
||||
endDate.value = startDate.value + 24 * 60 * 60 * 1000 - 1
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeEvent = async value => {
|
||||
index.value = Number(value.detail.value)
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
lockId.value = $bluetooth.currentLockInfo.lockId
|
||||
startDate.value = new Date().setHours(0, 0, 0, 0)
|
||||
endDate.value = startDate.value + 24 * 60 * 60 * 1000 - 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
requestFinished.value = true
|
||||
uni.hideLoading()
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const reset = async () => {
|
||||
uni.showModal({
|
||||
title: '是否要删除操作记录?',
|
||||
content: '被删除的记录不能恢复',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
await deleteData()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deleteData = async () => {
|
||||
uni.showLoading({
|
||||
title: '删除中'
|
||||
})
|
||||
|
||||
const { code: requestCode, message } = await clearRecordRequest({
|
||||
lockId: lockId.value
|
||||
})
|
||||
if (requestCode === 0) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: `删除成功`,
|
||||
icon: 'none'
|
||||
})
|
||||
pageNo.value = 1
|
||||
await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const refresherList = async () => {
|
||||
refresherTriggered.value = true
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
refresherTriggered.value = false
|
||||
}
|
||||
|
||||
const nextPage = async () => {
|
||||
if (total.value <= pageNo.value * pageSize) {
|
||||
return
|
||||
}
|
||||
const page = pageNo.value + 1
|
||||
const params = {
|
||||
pageNo: page
|
||||
}
|
||||
const { code, message } = await getList(params)
|
||||
if (code === 0) {
|
||||
pageNo.value = page
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const getList = async params => {
|
||||
const { code, data, message } = await getEventRecordListRequest({
|
||||
...params,
|
||||
pageNo: params.pageNo,
|
||||
lockId: lockId.value,
|
||||
startDate: startDate.value,
|
||||
endDate: endDate.value,
|
||||
lockEventType: range.value[index.value].lockEventType,
|
||||
pageSize
|
||||
})
|
||||
if (code === 0) {
|
||||
total.value = data.total
|
||||
if (params.pageNo === 1) {
|
||||
list.value = data.list
|
||||
} else {
|
||||
list.value = list.value.concat(data.list)
|
||||
}
|
||||
return { code }
|
||||
}
|
||||
return { code, message }
|
||||
}
|
||||
|
||||
const syncRecord = async () => {
|
||||
uni.showLoading({
|
||||
title: '同步中'
|
||||
})
|
||||
const { code, message } = await $bluetooth.syncRecord({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '同步成功',
|
||||
icon: 'none'
|
||||
})
|
||||
pageNo.value = 1
|
||||
await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toDetail = item => {
|
||||
$basic.routeJump({
|
||||
name: 'recordDetail',
|
||||
params: {
|
||||
info: JSON.stringify({
|
||||
operateDate: item.operateDate,
|
||||
recordDetailStr: item.recordDetailStr
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search {
|
||||
padding: 32rpx;
|
||||
width: 686rpx !important;
|
||||
}
|
||||
|
||||
.button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 20rpx);
|
||||
font-weight: bold;
|
||||
|
||||
.button-reset {
|
||||
margin-left: 50rpx;
|
||||
width: 300rpx;
|
||||
height: 88rpx;
|
||||
background-color: #df282d;
|
||||
color: white;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
|
||||
.button-create {
|
||||
margin-left: 50rpx;
|
||||
width: 300rpx;
|
||||
height: 88rpx;
|
||||
background-color: #63b8af;
|
||||
color: white;
|
||||
text-align: center;
|
||||
line-height: 88rpx;
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #ffffff;
|
||||
height: 120rpx;
|
||||
width: 750rpx;
|
||||
|
||||
.item-left {
|
||||
margin-left: 32rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
margin-right: 32rpx;
|
||||
margin-left: 32rpx;
|
||||
width: 574rpx;
|
||||
|
||||
.item-right-top {
|
||||
max-width: 400rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.item-right-bottom {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
height: 2rpx;
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
.empty-list {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
margin: 300rpx auto 20rpx 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.empty-list-text {
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-left: auto;
|
||||
font-size: 26rpx;
|
||||
color: #df282d;
|
||||
}
|
||||
</style>
|
||||
@ -39,7 +39,10 @@
|
||||
<view class="item-title">添加时间</view>
|
||||
<view class="item-content">{{ timeFormat(info.createDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -50,11 +53,13 @@
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const info = ref(null)
|
||||
|
||||
@ -65,6 +70,17 @@
|
||||
}
|
||||
})
|
||||
|
||||
const toRecordList = async () => {
|
||||
$basic.routeJump({
|
||||
name: 'typeRecordList',
|
||||
params: {
|
||||
name: info.value.remoteName,
|
||||
key: 'remoteId',
|
||||
id: info.value.remoteId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePassword = async () => {
|
||||
eventChannel.emit('delete', {})
|
||||
}
|
||||
|
||||
272
pages/typeRecordList/typeRecordList.vue
Normal file
272
pages/typeRecordList/typeRecordList.vue
Normal file
@ -0,0 +1,272 @@
|
||||
<template>
|
||||
<view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
scroll-y="true"
|
||||
:style="{ height: `${deviceInfo.screenHeight - deviceInfo.safeArea.top}px` }"
|
||||
lower-threshold="100"
|
||||
@refresherrefresh="refresherList"
|
||||
:refresher-enabled="true"
|
||||
@scrolltolower="nextPage"
|
||||
:refresher-triggered="refresherTriggered"
|
||||
>
|
||||
<view style="padding: 0 0 calc(env(safe-area-inset-bottom) + 250rpx) 0">
|
||||
<view v-if="list.length === 0 && requestFinished">
|
||||
<image
|
||||
class="empty-list"
|
||||
src="/static/images/background_empty_list.png"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="empty-list-text">暂无数据</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<div
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
class="border-b-#eeeeee border-b-2 border-b-solid"
|
||||
@click="toDetail(item)"
|
||||
>
|
||||
<view class="mx-3 text-lg flex items-center h-100 font-bold">
|
||||
<up-icon name="clock"></up-icon>
|
||||
<div class="mx-3">{{ timeFormat(item.operateDate, 'yyyy-mm-dd h:M') }}</div>
|
||||
<div>{{ item.recordTypeName }}</div>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view
|
||||
class="w-120 h-120 text-center font-bold text-20 justify-center fixed bottom-[calc(env(safe-area-inset-bottom)+50rpx)] right-32 rounded-50% color-white bg-#5eb6aa"
|
||||
@click="syncRecord"
|
||||
>
|
||||
<image
|
||||
class="w-48 h-48 m-a mt-2.5"
|
||||
mode="aspectFill"
|
||||
src="/static/images/icon_sync.png"
|
||||
></image>
|
||||
<view>同步记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { getRecordListRequest } from '@/api/record'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const list = ref([])
|
||||
const pageNo = ref(1)
|
||||
const pageSize = 50
|
||||
const total = ref(0)
|
||||
const lockId = ref(null)
|
||||
const key = ref('')
|
||||
const id = ref('')
|
||||
|
||||
const deviceInfo = ref(null)
|
||||
const requestFinished = ref(false)
|
||||
const refresherTriggered = ref(false)
|
||||
|
||||
onLoad(async options => {
|
||||
uni.setNavigationBarTitle({
|
||||
title: options.name
|
||||
})
|
||||
key.value = options.key
|
||||
id.value = Number(options.id)
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
lockId.value = $bluetooth.currentLockInfo.lockId
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
requestFinished.value = true
|
||||
uni.hideLoading()
|
||||
if (code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const refresherList = async () => {
|
||||
refresherTriggered.value = true
|
||||
pageNo.value = 1
|
||||
const { code, message } = await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
refresherTriggered.value = false
|
||||
}
|
||||
|
||||
const nextPage = async () => {
|
||||
if (total.value <= pageNo.value * pageSize) {
|
||||
return
|
||||
}
|
||||
const page = pageNo.value + 1
|
||||
const params = {
|
||||
pageNo: page
|
||||
}
|
||||
const { code, message } = await getList(params)
|
||||
if (code === 0) {
|
||||
pageNo.value = page
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const getList = async params => {
|
||||
const { code, data, message } = await getRecordListRequest({
|
||||
...params,
|
||||
pageNo: params.pageNo,
|
||||
lockId: lockId.value,
|
||||
[key.value]: id.value,
|
||||
pageSize
|
||||
})
|
||||
if (code === 0) {
|
||||
total.value = data.total
|
||||
if (params.pageNo === 1) {
|
||||
list.value = data.list
|
||||
} else {
|
||||
list.value = list.value.concat(data.list)
|
||||
}
|
||||
return { code }
|
||||
}
|
||||
return { code, message }
|
||||
}
|
||||
|
||||
const syncRecord = async () => {
|
||||
uni.showLoading({
|
||||
title: '同步中'
|
||||
})
|
||||
const { code, message } = await $bluetooth.syncRecord({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '同步成功',
|
||||
icon: 'none'
|
||||
})
|
||||
pageNo.value = 1
|
||||
await getList({
|
||||
pageNo: pageNo.value
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toDetail = item => {
|
||||
$basic.routeJump({
|
||||
name: 'recordDetail',
|
||||
params: {
|
||||
info: JSON.stringify({
|
||||
operateDate: item.operateDate,
|
||||
recordDetailStr: item.recordDetailStr
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search {
|
||||
padding: 32rpx;
|
||||
width: 686rpx !important;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #ffffff;
|
||||
height: 120rpx;
|
||||
width: 750rpx;
|
||||
|
||||
.item-left {
|
||||
margin-left: 32rpx;
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
margin-right: 32rpx;
|
||||
margin-left: 32rpx;
|
||||
width: 574rpx;
|
||||
|
||||
.item-right-top {
|
||||
max-width: 400rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
padding-bottom: 6rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.item-right-bottom {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 100%;
|
||||
height: 2rpx;
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
.empty-list {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
margin: 300rpx auto 20rpx 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.empty-list-text {
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin-left: auto;
|
||||
font-size: 26rpx;
|
||||
color: #df282d;
|
||||
}
|
||||
</style>
|
||||
BIN
static/images/icon_sync.png
Normal file
BIN
static/images/icon_sync.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 923 B |
BIN
static/images/img.png
Normal file
BIN
static/images/img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@ -226,6 +226,21 @@ const pages = [
|
||||
name: 'adminList',
|
||||
path: '/pages/adminList/adminList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'recordList',
|
||||
path: '/pages/recordList/recordList',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'recordDetail',
|
||||
path: '/pages/recordDetail/recordDetail',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'typeRecordList',
|
||||
path: '/pages/typeRecordList/typeRecordList',
|
||||
tabBar: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import { reportOpenDoorRequest } from '@/api/lockRecords'
|
||||
import { updateTimezoneOffsetRequest } from '@/api/user'
|
||||
import log from '@/utils/log'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getLastRecordTimeRequest, uploadRecordRequest } from '@/api/record'
|
||||
|
||||
// 定时器
|
||||
let timer
|
||||
@ -81,7 +82,9 @@ const subCmdIds = {
|
||||
// 注册掌纹确认
|
||||
registerPalmVeinConfirm: 43,
|
||||
// 注册掌纹取消
|
||||
registerPalmVeinCancel: 44
|
||||
registerPalmVeinCancel: 44,
|
||||
// 同步操作记录
|
||||
syncRecord: 41
|
||||
}
|
||||
|
||||
export const useBluetoothStore = defineStore('ble', {
|
||||
@ -264,7 +267,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
})
|
||||
},
|
||||
// 解析特征值
|
||||
parsingCharacteristicValue(binaryData) {
|
||||
async parsingCharacteristicValue(binaryData) {
|
||||
const $user = useUserStore()
|
||||
const that = this
|
||||
// 0x20 明文 0x22 SM4(事先约定密钥) 0x23 SM4(设备指定密钥)
|
||||
@ -375,7 +378,6 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
break
|
||||
case cmdIds.expandCmd:
|
||||
const subCmdId = decrypted[3]
|
||||
// eslint-disable-next-line default-case
|
||||
switch (subCmdId) {
|
||||
case subCmdIds.resetLockPassword:
|
||||
that.updateCurrentLockInfo({
|
||||
@ -473,6 +475,37 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
process: decrypted[6]
|
||||
})
|
||||
break
|
||||
case subCmdIds.syncRecord:
|
||||
if (decrypted[2] === 0 && decrypted[6] > 0) {
|
||||
const records = []
|
||||
const count = decrypted[6] || 0
|
||||
for (let i = 0; i < count; i++) {
|
||||
let password = decrypted.slice(14 + 17 * i, 14 + 17 * i + 10)
|
||||
if (password.every(item => item === 0)) {
|
||||
password = null
|
||||
} else {
|
||||
password = this.uint8ArrayToString(password)
|
||||
}
|
||||
const record = {
|
||||
type: decrypted[7 + 17 * i],
|
||||
user: decrypted[8 + 17 * i] * 256 + decrypted[9 + 17 * i],
|
||||
date: this.arrayToTimestamp(decrypted.slice(10 + 17 * i, 14 + 17 * i)) * 1000,
|
||||
success: 1,
|
||||
password
|
||||
}
|
||||
records.push(record)
|
||||
}
|
||||
const { code, message } = await uploadRecordRequest({
|
||||
records,
|
||||
lockId: this.currentLockInfo.lockId
|
||||
})
|
||||
characteristicValueCallback({ code, data: { count }, message })
|
||||
} else {
|
||||
characteristicValueCallback({ code: decrypted[2] })
|
||||
}
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
break
|
||||
case cmdIds.openDoor:
|
||||
@ -2454,6 +2487,127 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
await this.writeBLECharacteristicValue(packageArray)
|
||||
|
||||
return this.getWriteResult(this.registerAuthenticationCancel, data)
|
||||
},
|
||||
// 获取操作记录
|
||||
async syncRecord(params) {
|
||||
const { uid, keyId } = params
|
||||
|
||||
const { code, data, message } = await this.syncSingleRecord({
|
||||
uid,
|
||||
keyId
|
||||
})
|
||||
|
||||
if (code === 0) {
|
||||
if (data?.count === 10) {
|
||||
return await this.syncSingleRecord({
|
||||
uid,
|
||||
keyId
|
||||
})
|
||||
}
|
||||
return { code, data, message }
|
||||
}
|
||||
return { code, data, message }
|
||||
},
|
||||
// 获取单次操作记录
|
||||
async syncSingleRecord(data) {
|
||||
// 确认蓝牙状态正常
|
||||
if (this.bluetoothStatus !== 0) {
|
||||
console.log('写入未执行', this.bluetoothStatus)
|
||||
this.getBluetoothStatus()
|
||||
return {
|
||||
code: -1
|
||||
}
|
||||
}
|
||||
|
||||
// 确认设备连接正常
|
||||
if (!this.currentLockInfo.connected) {
|
||||
const searchResult = await this.searchAndConnectDevice()
|
||||
if (searchResult.code !== 0) {
|
||||
return searchResult
|
||||
}
|
||||
this.updateCurrentLockInfo({
|
||||
...this.currentLockInfo,
|
||||
deviceId: searchResult.data.deviceId
|
||||
})
|
||||
console.log('设备ID:', this.currentLockInfo.deviceId)
|
||||
const result = await this.connectBluetoothDevice()
|
||||
console.log('连接结果', result)
|
||||
if (!result) {
|
||||
return {
|
||||
code: -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否已添加为用户
|
||||
const checkResult = await this.checkLockUser()
|
||||
if (!checkResult) {
|
||||
return {
|
||||
code: -1
|
||||
}
|
||||
}
|
||||
|
||||
const { keyId, uid } = data
|
||||
|
||||
const logsCount = 10
|
||||
|
||||
const timeResult = await getLastRecordTimeRequest({
|
||||
lockId: this.currentLockInfo.lockId
|
||||
})
|
||||
|
||||
if (timeResult.code !== 0) {
|
||||
return timeResult
|
||||
}
|
||||
|
||||
const operateDate = Math.ceil(timeResult.data.operateDate / 1000)
|
||||
const currentDate = Math.ceil(timeResult.data.currentDate / 1000)
|
||||
|
||||
const length = 2 + 1 + 1 + 40 + 20 + 2 + 4 + 4 + 1 + 16
|
||||
const headArray = this.createPackageHeader(3, length)
|
||||
|
||||
const contentArray = new Uint8Array(length)
|
||||
contentArray[0] = cmdIds.expandCmd / 256
|
||||
contentArray[1] = cmdIds.expandCmd % 256
|
||||
|
||||
// 子命令
|
||||
contentArray[2] = subCmdIds.syncRecord
|
||||
|
||||
contentArray[3] = length - 3
|
||||
|
||||
for (let i = 0; i < keyId.length; i++) {
|
||||
contentArray[i + 4] = keyId.charCodeAt(i)
|
||||
}
|
||||
|
||||
for (let i = 0; i < uid.length; i++) {
|
||||
contentArray[i + 44] = uid.charCodeAt(i)
|
||||
}
|
||||
|
||||
contentArray[64] = logsCount / 256
|
||||
contentArray[65] = logsCount % 256
|
||||
|
||||
contentArray.set(this.timestampToArray(operateDate), 66)
|
||||
contentArray.set(this.timestampToArray(currentDate), 70)
|
||||
|
||||
contentArray[74] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
uid + keyId,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.bluetooth.publicKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, 75)
|
||||
|
||||
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.bluetooth.privateKey, {
|
||||
mode: 'ecb',
|
||||
output: 'array'
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
|
||||
await this.writeBLECharacteristicValue(packageArray)
|
||||
|
||||
return this.getWriteResult(this.syncSingleRecord, data)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user