Merge branch 'fanpeng' into 'develop'

Fanpeng

See merge request StarlockTeam/wx-starlock!17
This commit is contained in:
范鹏 2025-02-11 07:49:00 +00:00
commit bc9e2c2bbf
74 changed files with 5506 additions and 25 deletions

48
api/face.js Normal file
View File

@ -0,0 +1,48 @@
import request from '../utils/request'
// face 人脸模块
// 获取人脸列表
export function getFaceList(data) {
return request({
url: '/face/list',
method: 'POST',
data
})
}
// 删除人脸
export function deleteFaceRequest(data) {
return request({
url: '/face/delete',
method: 'POST',
data
})
}
// 清空人脸
export function clearFaceRequest(data) {
return request({
url: '/face/clear',
method: 'POST',
data
})
}
// 检查人脸名称是否重复
export function checkFaceNameRequest(data) {
return request({
url: '/face/checkFaceName',
method: 'POST',
data
})
}
// 添加人脸
export function addFaceRequest(data) {
return request({
url: '/face/add',
method: 'POST',
data
})
}

48
api/palmVein.js Normal file
View File

@ -0,0 +1,48 @@
import request from '../utils/request'
// palmVein 掌纹模块
// 获取掌纹列表
export function getPalmVeinList(data) {
return request({
url: '/palmVein/list',
method: 'POST',
data
})
}
// 删除掌纹
export function deletePalmVeinRequest(data) {
return request({
url: '/palmVein/delete',
method: 'POST',
data
})
}
// 清空掌纹
export function clearPalmVeinRequest(data) {
return request({
url: '/palmVein/clear',
method: 'POST',
data
})
}
// 检查掌纹名称是否重复
export function checkPalmVeinNameRequest(data) {
return request({
url: '/palmVein/checkPalmVeinName',
method: 'POST',
data
})
}
// 添加掌纹
export function addPalmVeinRequest(data) {
return request({
url: '/palmVein/add',
method: 'POST',
data
})
}

48
api/record.js Normal file
View 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
})
}

48
api/remote.js Normal file
View File

@ -0,0 +1,48 @@
import request from '../utils/request'
// remote 远程模块
// 获取远程列表
export function getRemoteList(data) {
return request({
url: '/remote/list',
method: 'POST',
data
})
}
// 删除远程
export function deleteRemoteRequest(data) {
return request({
url: '/remote/delete',
method: 'POST',
data
})
}
// 清空远程
export function clearRemoteRequest(data) {
return request({
url: '/remote/clear',
method: 'POST',
data
})
}
// 检查远程名称是否重复
export function checkRemoteNameRequest(data) {
return request({
url: '/remote/checkRemoteName',
method: 'POST',
data
})
}
// 添加远程
export function addRemoteRequest(data) {
return request({
url: '/remote/add',
method: 'POST',
data
})
}

View File

@ -1,7 +1,16 @@
<template>
<view class="bg-white">
<view class="name">
<view class="name-text">{{ title }}</view>
<view class="flex items-center">
<view class="name-text mr-1">{{ title }}</view>
<up-icon
v-if="tip"
name="question-circle-fill"
color="#555555"
size="38"
@click="tipDialog"
></up-icon>
</view>
<switch :checked="checked" class="mr-4 transform-scale-90" @change="change" color="#002ce5" />
</view>
<view class="px-3 text-sm whitespace-pre-line pb-2" v-if="placeholder">{{ placeholder }}</view>
@ -16,16 +25,26 @@
const props = defineProps({
title: String,
placeholder: String,
value: Boolean
value: Boolean,
tip: String
})
onMounted(() => {
checked.value = props.value
})
const emits = defineEmits(['change'])
const change = e => {
console.log(111, e)
// this.$emit('changeInput', e.detail.value)
emits('change', e)
}
const tipDialog = () => {
uni.showModal({
title: '提示',
content: props.tip,
showCancel: false
})
}
</script>

View File

@ -197,6 +197,132 @@
"navigationBarTitleText": "添加指纹",
"disableScroll": true
}
},
{
"path": "pages/faceList/faceList",
"style": {
"navigationBarTitleText": "人脸",
"disableScroll": true
}
},
{
"path": "pages/createFace/createFace",
"style": {
"navigationBarTitleText": "添加人脸",
"disableScroll": true
}
},
{
"path": "pages/faceDetail/faceDetail",
"style": {
"navigationBarTitleText": "人脸详情",
"disableScroll": true
}
},
{
"path": "pages/bindFace/bindFace",
"style": {
"navigationBarTitleText": "添加人脸",
"disableScroll": true
}
},
{
"path": "pages/remoteList/remoteList",
"style": {
"navigationBarTitleText": "遥控",
"disableScroll": true
}
},
{
"path": "pages/createRemote/createRemote",
"style": {
"navigationBarTitleText": "添加遥控",
"disableScroll": true
}
},
{
"path": "pages/remoteDetail/remoteDetail",
"style": {
"navigationBarTitleText": "遥控详情",
"disableScroll": true
}
},
{
"path": "pages/bindRemote/bindRemote",
"style": {
"navigationBarTitleText": "添加遥控",
"disableScroll": true
}
},
{
"path": "pages/palmVeinList/palmVeinList",
"style": {
"navigationBarTitleText": "掌静脉",
"disableScroll": true
}
},
{
"path": "pages/createPalmVein/createPalmVein",
"style": {
"navigationBarTitleText": "添加掌静脉",
"disableScroll": true
}
},
{
"path": "pages/palmVeinDetail/palmVeinDetail",
"style": {
"navigationBarTitleText": "掌静脉详情",
"disableScroll": true
}
},
{
"path": "pages/bindPalmVein/bindPalmVein",
"style": {
"navigationBarTitleText": "添加掌静脉",
"disableScroll": true
}
},
{
"path": "pages/createAdmin/createAdmin",
"style": {
"navigationBarTitleText": "创建授权管理员",
"disableScroll": true
}
},
{
"path": "pages/adminDetail/adminDetail",
"style": {
"navigationBarTitleText": "授权管理员详情",
"disableScroll": true
}
},
{
"path": "pages/adminList/adminList",
"style": {
"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": {

View File

@ -0,0 +1,157 @@
<template>
<view>
<view v-if="info">
<view class="item">
<view class="item-title">姓名</view>
<view class="item-content">{{ info.keyName }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">有效期</view>
<view v-if="info.keyType === 1">永久</view>
<view v-else>
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
</view>
<view class="item" style="margin-top: 20rpx">
<view class="item-title">接受者</view>
<view class="item-content">{{ info.username }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">添加者</view>
<view class="item-content">{{ info.senderUsername }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<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
:show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio">
<view style="display: flex; align-items: center">
<radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view>
</view>
</up-modal>
</view>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { timeFormat } from 'uview-plus'
import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $basic = useBasicStore()
const info = ref(null)
const showModal = ref(false)
const checked = ref(false)
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.keyName,
key: 'keyId',
id: info.value.keyId
}
})
}
const confirmModal = async () => {
uni.showLoading({
title: '删除中',
mask: true
})
const { code } = await deleteKeyRequest({
keyId: info.value.keyId,
includeUnderlings: checked.value ? 1 : 0
})
showModal.value = false
if (code === 0) {
eventChannel.emit('refresherList', {})
uni.hideLoading()
$basic.backAndToast('删除成功')
} else {
uni.hideLoading()
uni.showToast({
title: 'message',
icon: 'none'
})
}
}
const cancelModal = () => {
showModal.value = false
checked.value = false
}
const changeRadio = () => {
checked.value = !checked.value
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.item-title {
width: 350rpx;
}
.item {
padding: 24rpx 32rpx;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 32rpx;
font-weight: 500;
}
.tips {
padding: 24rpx 32rpx;
font-size: 24rpx;
color: #999999;
}
.button {
margin: 32rpx;
width: 686rpx;
height: 88rpx;
background-color: #df282d;
color: white;
text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,399 @@
<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 class="search">
<up-search
shape="square"
:searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></up-search>
</view>
<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>
<up-swipe-action>
<up-swipe-action-item
ref="swipeItem"
:options="options"
v-for="item in list"
:key="item.keyboardPwdId"
:threshold="50"
@click="deleteItem(item)"
>
<view class="item" @click="toDetail(item)">
<image
class="item-left rounded-50%"
:src="item.headUrl === '' ? '/static/images/icon_user.png' : item.headUrl"
mode="aspectFill"
></image>
<view class="item-right">
<view style="display: flex; align-items: center">
<view class="item-right-top">{{ item.keyName }}</view>
<view class="status">
{{ $lock.getKeyStatus(item.keyStatus) }}
</view>
</view>
<view class="item-right-bottom">{{ item.timeText }}</view>
</view>
</view>
<view class="line"></view>
</up-swipe-action-item>
</up-swipe-action>
</view>
</view>
</scroll-view>
<view class="button">
<view class="button-create" @click="toCreate">添加授权管理员</view>
</view>
<up-modal
:show="showModal"
title="是否删除授权管理员钥匙?"
:showCancelButton="true"
width="600rpx"
@cancel="cancelModal"
@confirm="confirmModal"
>
<view class="slot-content" @click="changeRadio">
<view style="display: flex; align-items: center">
<radio :checked="checked"></radio>
<view>同时删除其发送的所有钥匙钥匙删除后不能恢复</view>
</view>
</view>
</up-modal>
</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 { deleteKeyRequest, getKeyListRequest } from '@/api/key'
import { useLockStore } from '@/stores/lock'
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $lock = useLockStore()
const swipeItem = ref(null)
const searchStr = ref('')
const list = ref([])
const pageNo = ref(1)
const pageSize = 50
const total = ref(0)
const lockId = ref(null)
const deviceInfo = ref(null)
const requestFinished = ref(false)
const refresherTriggered = ref(false)
const options = ref([
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
])
const showModal = ref(false)
const checked = ref(false)
const deleteData = ref(null)
onMounted(async () => {
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 confirmModal = async () => {
uni.showLoading({
title: '删除中',
mask: true
})
const { code } = await deleteKeyRequest({
keyId: deleteData.value.keyId,
includeUnderlings: checked.value ? 1 : 0
})
showModal.value = false
if (code === 0) {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
uni.hideLoading()
uni.showToast({
title: '删除成功',
icon: 'none'
})
} else {
uni.hideLoading()
uni.showToast({
title: 'message',
icon: 'none'
})
}
}
const cancelModal = () => {
showModal.value = false
checked.value = false
}
const changeRadio = () => {
checked.value = !checked.value
}
const deleteItem = async data => {
const index = list.value.findIndex(item => item.keyboardPwdId === data.keyboardPwdId)
swipeItem.value[index].closeHandler()
showModal.value = true
deleteData.value = data
}
const refresherList = async () => {
refresherTriggered.value = true
pageNo.value = 1
const { code, message } = await getList({
pageNo: pageNo.value,
searchStr: searchStr.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 = {
searchStr: searchStr.value,
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 getKeyListRequest({
...params,
lockId: lockId.value,
keyRight: 1,
endDate: '0',
startDate: '0',
keyStatus: [110401, 110402, 110412, 110405, 110403],
pageSize
})
if (code === 0) {
total.value = data.total
for (let i = 0; i < data.list.length; i++) {
if (data.list[i].keyType === 1) {
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].keyType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM')
}
}
if (params.pageNo === 1) {
list.value = data.list
} else {
list.value = list.value.concat(data.list)
}
return { code }
}
return { code, message }
}
const changeSearch = async data => {
pageNo.value = 1
const { code, message } = await getList({
searchStr: data,
pageNo: pageNo.value
})
if (code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const toCreate = () => {
$basic.routeJump({
name: 'createAdmin',
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
const toDetail = item => {
$basic.routeJump({
name: 'adminDetail',
params: {
info: JSON.stringify(item)
},
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</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-create {
margin-left: 32rpx;
width: 686rpx;
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>

View File

@ -67,6 +67,28 @@
} else {
$basic.backAndToast(message)
}
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
uni.showToast({
title: '管理员已满',
icon: 'none'
})
} else if (data.status === 0xfd) {
uni.showToast({
title: '用户已满',
icon: 'none'
})
} else if (data.status === 0xfc) {
uni.showToast({
title: '卡片已满',
icon: 'none'
})
} else if (data.status === 0xfb) {
uni.showToast({
title: '卡片已存在',
icon: 'none'
})
}
})
}

133
pages/bindFace/bindFace.vue Normal file
View File

@ -0,0 +1,133 @@
<template>
<view>
<view class="flex justify-center flex-col pt-10 text-align-center text-base">
<image
v-if="showProcess"
src="/static/images/icon_add_face_1.png"
mode="widthFix"
class="mx-[100rpx] w-550 mt-5 rounded-2xl"
></image>
<image
v-else
src="/static/images/icon_add_face_2.png"
mode="widthFix"
class="mx-[100rpx] w-550 mt-5 rounded-2xl"
></image>
<view class="my-10 text-align-left mx-3">
<view>请单人正对门锁距离一个成年人手臂长度</view><view>(约0.6)</view
><view>保持脸部无遮挡漏出五官</view>
</view>
<view v-if="showProcess" class="mt-5 font-bold"> 正在录入中 </view>
<view v-else> <view class="button mt-5" @click="ready">准备好了开始添加</view> </view>
</view>
</view>
</template>
<script setup>
import { ref, onUnmounted, getCurrentInstance } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { addFaceRequest } from '@/api/face'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
const $user = useUserStore()
const bindFlag = ref(false)
const showProcess = ref(false)
const params = ref(null)
onLoad(async options => {
if (options.info) {
params.value = JSON.parse(options.info)
uni.$on('registerFaceConfirm', async data => {
if (data.status === 0) {
bindFlag.value = true
const { code, message } = await addFaceRequest({
lockId: $bluetooth.currentLockInfo.lockId,
startDate: params.value.startDate,
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,
isCoerced: params.value.isForce === 1 ? 2 : 1
})
if (code === 0) {
eventChannel.emit('refresherList', {})
$basic.backAndToast('添加成功', 2)
} else {
$basic.backAndToast(message)
}
}
})
uni.$on('registerFaceProcess', data => {
if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
uni.showToast({
title: '管理员已满',
icon: 'none'
})
} else if (data.status === 0xfd) {
uni.showToast({
title: '用户已满',
icon: 'none'
})
} else if (data.status === 0xfc) {
uni.showToast({
title: '人脸已满',
icon: 'none'
})
} else if (data.status === 0xfb) {
uni.showToast({
title: '人脸已存在',
icon: 'none'
})
}
})
}
})
const ready = async () => {
showProcess.value = true
const { code } = await $bluetooth.registerAuthentication(params.value)
if (code !== 0) {
$basic.backAndToast('操作失败,请重试')
}
}
onUnmounted(() => {
uni.$off('registerFaceConfirm')
if (!bindFlag.value) {
$bluetooth.registerAuthenticationCancel({
type: 'face',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString()
})
}
})
</script>
<style scoped lang="scss">
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
</style>

View File

@ -4,7 +4,7 @@
<view>
{{ text }}
</view>
<view v-if="showProcess" class="mt-5 font-bold">({{ process }}/5)</view>
<view v-if="showProcess" class="mt-5 font-bold">({{ process }}/{{ maxProcess }})</view>
<image
:src="`/static/images/icon_fingerprint_${process}.png`"
mode="widthFix"
@ -33,16 +33,18 @@
const bindFlag = ref(false)
const showProcess = ref(false)
const process = ref(0)
const maxProcess = ref(0)
const text = ref('尝试连接设备…')
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
const { code } = await $bluetooth.registerAuthentication(params)
const { code, data } = await $bluetooth.registerAuthentication(params)
if (code === 0) {
text.value = '请将您的手指按下'
maxProcess.value = data.maxProcess
showProcess.value = true
} else {
$basic.backAndToast('操作失败,请重试')
@ -57,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,
@ -73,6 +76,28 @@
uni.$on('registerFingerprintProcess', data => {
if (data.status === 0) {
process.value = data.process
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
uni.showToast({
title: '管理员已满',
icon: 'none'
})
} else if (data.status === 0xfd) {
uni.showToast({
title: '用户已满',
icon: 'none'
})
} else if (data.status === 0xfc) {
uni.showToast({
title: '指纹已满',
icon: 'none'
})
} else if (data.status === 0xfb) {
uni.showToast({
title: '指纹已存在',
icon: 'none'
})
}
})
}

View File

@ -0,0 +1,106 @@
<template>
<view>
<view class="flex justify-center flex-col pt-20">
<image
src="/static/images/icon_add_palm_vein.png"
mode="aspectFill"
class="mx-[125rpx] w-500 h-500"
></image>
<view
class="text-base rounded-xl mt-15 bg-#5eb4ac mx-[32rpx] w-686 h-80 text-align-center line-height-[80rpx] text-white shadow-sm"
>{{ text }}</view
>
</view>
</view>
</template>
<script setup>
import { ref, onUnmounted, getCurrentInstance } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { addPalmVeinRequest } from '@/api/palmVein'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
const $user = useUserStore()
const bindFlag = ref(false)
const text = ref('尝试连接设备…')
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
const { code } = await $bluetooth.registerAuthentication(params)
if (code === 0) {
text.value = '已连接到锁,请自然张开手掌,掌心对准摄像头'
} else {
$basic.backAndToast('操作失败,请重试')
}
uni.$on('registerPalmVeinConfirm', async data => {
if (data.status === 0) {
bindFlag.value = true
const { code, message } = await addPalmVeinRequest({
lockId: $bluetooth.currentLockInfo.lockId,
startDate: params.startDate,
endDate: params.endDate,
palmVeinName: params.palmVeinName,
palmVeinNumber: String(data.palmVeinNumber),
palmVeinUserNo: String(data.palmVeinNumber),
palmVeinType: params.palmVeinType,
addType: 1,
palmVeinRight: params.isAdmin,
isCoerced: params.isForce === 1 ? 2 : 1
})
if (code === 0) {
eventChannel.emit('refresherList', {})
$basic.backAndToast('绑卡成功', 2)
} else {
$basic.backAndToast(message)
}
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
uni.showToast({
title: '管理员已满',
icon: 'none'
})
} else if (data.status === 0xfd) {
uni.showToast({
title: '用户已满',
icon: 'none'
})
} else if (data.status === 0xfc) {
uni.showToast({
title: '掌静脉已满',
icon: 'none'
})
} else if (data.status === 0xfb) {
uni.showToast({
title: '掌静脉已存在',
icon: 'none'
})
}
})
}
})
onUnmounted(async () => {
uni.$off('registerPalmVeinConfirm')
if (!bindFlag.value) {
await $bluetooth.registerAuthenticationCancel({
type: 'palmVein',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString()
})
}
$bluetooth.closeBluetoothConnection()
})
</script>

View File

@ -0,0 +1,114 @@
<template>
<view>
<view class="flex justify-center flex-col pt-20">
<image
src="/static/images/icon_add_remote.png"
mode="aspectFill"
class="mx-[200rpx] w-350 h-350"
></image>
<view class="mt-5">
<up-loading-icon size="70rpx" text="" :vertical="true" textSize="32rpx"></up-loading-icon>
</view>
<view
class="text-base rounded-xl mt-15 bg-black mx-[75rpx] w-600 h-80 text-align-center line-height-[80rpx] text-white shadow-sm"
>{{ text }}</view
>
</view>
</view>
</template>
<script setup>
import { ref, onUnmounted, getCurrentInstance } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { addRemoteRequest } from '@/api/remote'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
const $user = useUserStore()
const bindFlag = ref(false)
const text = ref('尝试连接设备…')
onLoad(async options => {
if (options.info) {
const params = JSON.parse(options.info)
const { code } = await $bluetooth.registerAuthentication(params)
if (code === 0) {
text.value = '已连接到锁,请按遥控'
} else {
$basic.backAndToast('操作失败,请重试')
}
uni.$on('registerRemoteConfirm', async data => {
if (data.status === 0) {
bindFlag.value = true
const { code, message } = await addRemoteRequest({
lockId: $bluetooth.currentLockInfo.lockId,
startDate: params.startDate,
endDate: params.endDate,
remoteName: params.remoteName,
remoteNumber: String(data.remoteNumber),
remoteType: params.remoteType,
addType: 1,
remoteRight: params.isAdmin,
isCoerced: params.isForce === 1 ? 2 : 1
})
if (code === 0) {
eventChannel.emit('refresherList', {})
$basic.backAndToast('添加成功', 2)
} else {
$basic.backAndToast(message)
}
} else if (data.status === 0xff) {
$basic.backAndToast('添加失败,请重试')
} else if (data.status === 0xfe) {
uni.showToast({
title: '管理员已满',
icon: 'none'
})
} else if (data.status === 0xfd) {
uni.showToast({
title: '用户已满',
icon: 'none'
})
} else if (data.status === 0xfc) {
uni.showToast({
title: '遥控已满',
icon: 'none'
})
} else if (data.status === 0xfb) {
uni.showToast({
title: '遥控已存在',
icon: 'none'
})
}
})
}
})
onUnmounted(async () => {
uni.$off('registerRemoteConfirm')
if (!bindFlag.value) {
await $bluetooth.registerAuthenticationCancel({
type: 'remote',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString()
})
}
$bluetooth.closeBluetoothConnection()
})
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>

View File

@ -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', {})
}

View File

@ -0,0 +1,342 @@
<template>
<view>
<view class="tabs">
<up-tabs
:list="tabs"
lineWidth="40rpx"
lineHeight="5rpx"
:current="currentIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs>
</view>
<swiper
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currentIndex"
@change="changeSwiper"
>
<swiper-item>
<LockInput
:value="permanentAccount"
title="接收者"
placeholder="请输入手机号或者邮箱"
@change-input="changeAccount('permanent', $event)"
></LockInput>
<LockInput
:value="permanentName"
title="姓名"
placeholder="请输入"
@change-input="changeName('permanent', $event)"
></LockInput>
<view class="mt-3">
<LockSwitch
:value="permanentManageSelf"
title="仅管理自己创建的用户"
:tip="tip"
@change="changeAdmin('permanent', $event)"
></LockSwitch>
</view>
<view class="button mt-5" @click="create('permanent')">发送</view>
</swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput
:value="temporaryAccount"
title="接收者"
placeholder="请输入手机号或者邮箱"
@change-input="changeAccount('permanent', $event)"
></LockInput>
<LockInput
:value="temporaryName"
title="姓名"
placeholder="请输入"
@change-input="changeName('permanent', $event)"
></LockInput>
<view class="mt-3">
<LockDatetimePicker
title="生效时间"
:value="temporaryStartTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryStartTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockDatetimePicker
title="失效时间"
:value="temporaryEndTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryEndTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockSwitch
:value="temporaryManageSelf"
title="仅管理自己创建的用户"
:tip="tip"
@change="changeAdmin('permanent', $event)"
></LockSwitch>
</view>
<view class="button mt-5" @click="create('temporary')">发送</view>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import test from 'uview-plus/libs/function/test'
import { useBasicStore } from '@/stores/basic'
import { createKeyRequest } from '@/api/key'
import { useBluetoothStore } from '@/stores/bluetooth'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const tabs = [
{
name: '永久'
},
{
name: '限时'
}
]
const permanentAccount = ref('')
const permanentName = ref('')
const permanentManageSelf = ref(false)
const temporaryAccount = ref('')
const temporaryName = ref('')
const temporaryStartTime = ref(Number(new Date()))
const temporaryEndTime = ref(Number(new Date()))
const temporaryManageSelf = ref(false)
const minDate = ref(Number(new Date()))
const maxDate = ref(Number(4133951940000))
const currentIndex = ref(0)
const deviceInfo = ref(null)
const tip = '授权管理员只能查看和管理自己下发的钥匙、密码等权限'
const pending = ref(false)
onLoad(async () => {
deviceInfo.value = await $basic.getDeviceInfo()
temporaryStartTime.value = setTime()
temporaryEndTime.value = setTime()
minDate.value = Number(getNextFullHour())
maxDate.value = Number(getFutureTimestamp())
})
const getNextFullHour = () => {
const now = new Date()
const currentHour = now.getHours()
now.setHours(currentHour)
now.setMinutes(0)
now.setSeconds(0)
now.setMilliseconds(0)
return now
}
const getFutureTimestamp = () => {
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = currentDate.getMonth()
const day = currentDate.getDate()
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
return futureDate.getTime()
}
const setTime = () => {
const now = new Date()
now.setMinutes(0, 0, 0)
return now.getTime()
}
const create = async (type, createUser = false) => {
if (
(type === 'temporary' && temporaryAccount.value === '') ||
(type === 'permanent' && permanentAccount.value === '')
) {
uni.showToast({
title: '请输入接收者账号',
icon: 'none'
})
return
}
if (
(type === 'temporary' &&
!(test.email(temporaryAccount.value) || test.mobile(temporaryAccount.value))) ||
(type === 'permanent' &&
!(test.email(permanentAccount.value) || test.mobile(permanentAccount.value)))
) {
uni.showToast({
title: '请输入格式正确的手机号或邮箱',
icon: 'none'
})
return
}
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
uni.showToast({
title: '失效时间要大于生效时间',
icon: 'none'
})
return
}
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
if (pending.value) {
return
}
pending.value = true
let params = {
faceAuthentication: '2',
isRemoteUnlock: '2',
lockId: $bluetooth.currentLockInfo.lockId,
keyRight: '1',
remarks: '',
countryCode: '86',
createUser: '0'
}
if (createUser) {
params.createUser = '1'
params.usernameType = test.mobile(temporaryAccount.value) ? '1' : '2'
}
if (type === 'temporary') {
params.keyNameForAdmin = temporaryName.value
params.endDate = temporaryEndTime.value.toString()
params.keyType = '2'
params.receiverUsername = temporaryAccount.value
params.startDate = temporaryStartTime.value.toString()
params.isOnlyManageSelf = temporaryManageSelf.value ? 1 : 0
} else {
params.keyNameForAdmin = permanentName.value
params.startDate = new Date().getTime().toString()
params.endDate = '0'
params.keyType = '1'
params.receiverUsername = permanentAccount.value
params.isOnlyManageSelf = permanentManageSelf.value ? 1 : 0
}
const { code, message } = await createKeyRequest(params)
if (code === 0) {
eventChannel.emit('refresherList', {})
$basic.backAndToast('添加成功')
} else if (code === 425) {
pending.value = false
uni.showModal({
title: '提示',
content: `是否发送电子钥匙给未注册账号\n${params.receiverUsername}`,
success: async res => {
if (res.confirm) {
await create(type, true)
}
}
})
} else {
uni.showToast({
title: message,
icon: 'none'
})
}
pending.value = false
}
const changeName = (type, event) => {
if (type === 'permanent') {
permanentName.value = event
} else {
temporaryName.value = event
}
}
const changeDate = (type, event) => {
if (type === 'temporaryStartTime') {
temporaryStartTime.value = event
} else {
temporaryEndTime.value = event
}
}
const changeAdmin = (type, event) => {
if (type === 'permanent') {
permanentManageSelf.value = event.detail.value
} else {
temporaryManageSelf.value = event.detail.value
}
}
const changeAccount = (type, event) => {
if (type === 'permanent') {
permanentAccount.value = event
} else {
temporaryAccount.value = event
}
}
const clickTab = data => {
currentIndex.value = data.index
}
const changeSwiper = e => {
currentIndex.value = e.detail.current
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.tabs {
display: flex;
justify-content: center;
}
.text {
margin-top: 40rpx;
margin-bottom: 50rpx;
color: #262626;
font-size: 26rpx;
padding: 0 32rpx;
}
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,307 @@
<template>
<view>
<view class="tabs">
<up-tabs
:list="tabs"
lineWidth="40rpx"
lineHeight="5rpx"
:current="currentIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs>
</view>
<swiper
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currentIndex"
@change="changeSwiper"
>
<swiper-item>
<LockInput
:value="permanentName"
title="姓名"
placeholder="请输入"
@change-input="changeName('permanent', $event)"
></LockInput>
<view class="mt-3">
<LockSwitch
:value="permanentAdmin"
title="是否为管理员"
@change="changeAdmin('permanent', $event)"
></LockSwitch>
</view>
<view class="button mt-5" @click="create('permanent')">下一步</view>
</swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput
:value="temporaryName"
title="姓名"
placeholder="请输入"
@change-input="changeName('temporary', $event)"
></LockInput>
<view class="mt-3">
<LockDatetimePicker
title="生效时间"
:value="temporaryStartTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryStartTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockDatetimePicker
title="失效时间"
:value="temporaryEndTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryEndTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockSwitch
:value="temporaryAdmin"
title="是否为管理员"
@change="changeAdmin('temporary', $event)"
></LockSwitch>
</view>
<view class="button mt-5" @click="create('temporary')">下一步</view>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useBluetoothStore } from '@/stores/bluetooth'
import { checkFaceNameRequest } from '@/api/face'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const tabs = [
{
name: '永久'
},
{
name: '限时'
}
]
const permanentName = ref('')
const permanentAdmin = ref(false)
const temporaryName = ref('')
const temporaryStartTime = ref(Number(new Date()))
const temporaryEndTime = ref(Number(new Date()))
const temporaryAdmin = ref(false)
const minDate = ref(Number(new Date()))
const maxDate = ref(Number(4133951940000))
const currentIndex = ref(0)
const deviceInfo = ref(null)
onLoad(async () => {
deviceInfo.value = await $basic.getDeviceInfo()
temporaryStartTime.value = setTime()
temporaryEndTime.value = setTime()
minDate.value = Number(getNextFullHour())
maxDate.value = Number(getFutureTimestamp())
})
const getNextFullHour = () => {
const now = new Date()
const currentHour = now.getHours()
now.setHours(currentHour)
now.setMinutes(0)
now.setSeconds(0)
now.setMilliseconds(0)
return now
}
const getFutureTimestamp = () => {
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = currentDate.getMonth()
const day = currentDate.getDate()
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
return futureDate.getTime()
}
const setTime = () => {
const now = new Date()
now.setMinutes(0, 0, 0)
return now.getTime()
}
const create = async type => {
if (
(type === 'temporary' && temporaryName.value === '') ||
(type === 'permanent' && permanentName.value === '')
) {
uni.showToast({
title: '名称不能为空',
icon: 'none'
})
return
}
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
uni.showToast({
title: '失效时间要大于生效时间',
icon: 'none'
})
return
}
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
let params = {
type: 'face',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: 0,
operate: 0,
userCountLimit: 0xffff
}
if (type === 'permanent') {
params = {
...params,
faceName: permanentName.value,
isAdmin: permanentAdmin.value ? 1 : 0,
weekDays: [],
isRound: 0,
startDate: 0,
faceType: 1,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
}
} else {
params = {
...params,
faceName: temporaryName.value,
isAdmin: temporaryAdmin.value ? 1 : 0,
weekDays: [],
faceType: 2,
isRound: 0,
startDate: temporaryStartTime.value,
endDate: temporaryEndTime.value,
startTime: '00:00',
endTime: '00:00'
}
}
const { code, message } = await checkFaceNameRequest({
lockId: $bluetooth.currentLockInfo.lockId,
faceName: params.faceName
})
if (code === 0) {
$basic.routeJump({
name: 'bindFace',
params: {
info: JSON.stringify(params)
},
events: {
refresherList() {
eventChannel.emit('refresherList', {})
}
}
})
} else {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const changeName = (type, event) => {
if (type === 'permanent') {
permanentName.value = event
} else {
temporaryName.value = event
}
}
const changeDate = (type, event) => {
if (type === 'temporaryStartTime') {
temporaryStartTime.value = event
} else {
temporaryEndTime.value = event
}
}
const changeAdmin = (type, event) => {
if (type === 'permanent') {
permanentAdmin.value = event.detail.value
} else {
temporaryAdmin.value = event.detail.value
}
}
const clickTab = data => {
currentIndex.value = data.index
}
const changeSwiper = e => {
currentIndex.value = e.detail.current
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.tabs {
display: flex;
justify-content: center;
}
.text {
margin-top: 40rpx;
margin-bottom: 50rpx;
color: #262626;
font-size: 26rpx;
padding: 0 32rpx;
}
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
</style>

View File

@ -39,7 +39,7 @@
<view class="mt-3 mb-3">
<LockSwitch
:value="permanentCoerced"
title="胁迫"
title="胁迫指纹"
@change="changeCoerced('permanent', $event)"
:placeholder="placeholder"
></LockSwitch>
@ -83,7 +83,7 @@
<view class="mt-3 mb-3">
<LockSwitch
:value="temporaryCoerced"
title="胁迫"
title="胁迫指纹"
@change="changeCoerced('temporary', $event)"
:placeholder="placeholder"
></LockSwitch>

View File

@ -0,0 +1,337 @@
<template>
<view>
<view class="tabs">
<up-tabs
:list="tabs"
lineWidth="40rpx"
lineHeight="5rpx"
:current="currentIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs>
</view>
<swiper
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currentIndex"
@change="changeSwiper"
>
<swiper-item>
<LockInput
:value="permanentName"
title="姓名"
placeholder="请输入"
@change-input="changeName('permanent', $event)"
></LockInput>
<view class="mt-3">
<LockSwitch
:value="permanentAdmin"
title="是否为管理员"
@change="changeAdmin('permanent', $event)"
></LockSwitch>
</view>
<view class="mt-3 mb-3">
<LockSwitch
:value="permanentCoerced"
title="胁迫掌静脉"
@change="changeCoerced('permanent', $event)"
:placeholder="placeholder"
></LockSwitch>
</view>
<view class="button" @click="create('permanent')">下一步</view>
</swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput
:value="temporaryName"
title="姓名"
placeholder="请输入"
@change-input="changeName('temporary', $event)"
></LockInput>
<view class="mt-3">
<LockDatetimePicker
title="生效时间"
:value="temporaryStartTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryStartTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockDatetimePicker
title="失效时间"
:value="temporaryEndTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryEndTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockSwitch
:value="temporaryAdmin"
title="是否为管理员"
@change="changeAdmin('temporary', $event)"
></LockSwitch>
</view>
<view class="mt-3 mb-3">
<LockSwitch
:value="temporaryCoerced"
title="胁迫掌静脉"
@change="changeCoerced('temporary', $event)"
:placeholder="placeholder"
></LockSwitch>
</view>
<view class="button" @click="create('temporary')">下一步</view>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useBluetoothStore } from '@/stores/bluetooth'
import { checkPalmVeinNameRequest } from '@/api/palmVein'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const tabs = [
{
name: '永久'
},
{
name: '限时'
}
]
const permanentName = ref('')
const permanentAdmin = ref(false)
const permanentCoerced = ref(false)
const temporaryName = ref('')
const temporaryStartTime = ref(Number(new Date()))
const temporaryEndTime = ref(Number(new Date()))
const temporaryAdmin = ref(false)
const temporaryCoerced = ref(false)
const minDate = ref(Number(new Date()))
const maxDate = ref(Number(4133951940000))
const currentIndex = ref(0)
const deviceInfo = ref(null)
const placeholder =
'当被胁迫要求强行开锁时,使用胁迫掌静脉会触发报警,报警信息会推送给管理员,该功能需要锁联网。\n请不要将胁迫掌静脉用于日常开锁'
onLoad(async () => {
deviceInfo.value = await $basic.getDeviceInfo()
temporaryStartTime.value = setTime()
temporaryEndTime.value = setTime()
minDate.value = Number(getNextFullHour())
maxDate.value = Number(getFutureTimestamp())
})
const getNextFullHour = () => {
const now = new Date()
const currentHour = now.getHours()
now.setHours(currentHour)
now.setMinutes(0)
now.setSeconds(0)
now.setMilliseconds(0)
return now
}
const getFutureTimestamp = () => {
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = currentDate.getMonth()
const day = currentDate.getDate()
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
return futureDate.getTime()
}
const setTime = () => {
const now = new Date()
now.setMinutes(0, 0, 0)
return now.getTime()
}
const create = async type => {
if (
(type === 'temporary' && temporaryName.value === '') ||
(type === 'permanent' && permanentName.value === '')
) {
uni.showToast({
title: '名称不能为空',
icon: 'none'
})
return
}
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
uni.showToast({
title: '失效时间要大于生效时间',
icon: 'none'
})
return
}
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
let params = {
type: 'palmVein',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: 0,
operate: 0,
userCountLimit: 0xffff
}
if (type === 'permanent') {
params = {
...params,
palmVeinName: permanentName.value,
isAdmin: permanentAdmin.value ? 1 : 0,
isForce: permanentCoerced.value ? 1 : 0,
weekDays: [],
isRound: 0,
startDate: 0,
palmVeinType: 1,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
}
} else {
params = {
...params,
palmVeinName: temporaryName.value,
isAdmin: temporaryAdmin.value ? 1 : 0,
isForce: temporaryCoerced.value ? 1 : 0,
weekDays: [],
palmVeinType: 2,
isRound: 0,
startDate: temporaryStartTime.value,
endDate: temporaryEndTime.value,
startTime: '00:00',
endTime: '00:00'
}
}
const { code, message } = await checkPalmVeinNameRequest({
lockId: $bluetooth.currentLockInfo.lockId,
palmVeinName: params.palmVeinName
})
if (code === 0) {
$basic.routeJump({
name: 'bindPalmVein',
params: {
info: JSON.stringify(params)
},
events: {
refresherList() {
eventChannel.emit('refresherList', {})
}
}
})
} else {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const changeName = (type, event) => {
if (type === 'permanent') {
permanentName.value = event
} else {
temporaryName.value = event
}
}
const changeDate = (type, event) => {
if (type === 'temporaryStartTime') {
temporaryStartTime.value = event
} else {
temporaryEndTime.value = event
}
}
const changeAdmin = (type, event) => {
if (type === 'permanent') {
permanentAdmin.value = event.detail.value
} else {
temporaryAdmin.value = event.detail.value
}
}
const changeCoerced = (type, event) => {
if (type === 'permanent') {
permanentCoerced.value = event.detail.value
} else {
temporaryCoerced.value = event.detail.value
}
}
const clickTab = data => {
currentIndex.value = data.index
}
const changeSwiper = e => {
currentIndex.value = e.detail.current
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.tabs {
display: flex;
justify-content: center;
}
.text {
margin-top: 40rpx;
margin-bottom: 50rpx;
color: #262626;
font-size: 26rpx;
padding: 0 32rpx;
}
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,281 @@
<template>
<view>
<view class="tabs">
<up-tabs
:list="tabs"
lineWidth="40rpx"
lineHeight="5rpx"
:current="currentIndex"
lineColor="#63b8af"
@click="clickTab"
:inactiveStyle="{ color: '#a3a3a3', fontSize: '32rpx', fontWeight: 'bold' }"
:activeStyle="{ color: '#63b8af', fontSize: '32rpx', fontWeight: 'bold' }"
>
</up-tabs>
</view>
<swiper
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top - 44 + 'px' }"
v-if="deviceInfo"
:list="tabs"
:autoplay="false"
:circular="true"
:current="currentIndex"
@change="changeSwiper"
>
<swiper-item>
<LockInput
:value="permanentName"
title="姓名"
placeholder="请输入"
@change-input="changeName('permanent', $event)"
></LockInput>
<view class="button mt-5" @click="create('permanent')">下一步</view>
</swiper-item>
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
<LockInput
:value="temporaryName"
title="姓名"
placeholder="请输入"
@change-input="changeName('temporary', $event)"
></LockInput>
<view class="mt-3">
<LockDatetimePicker
title="生效时间"
:value="temporaryStartTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryStartTime', $event)"
></LockDatetimePicker>
</view>
<view class="mt-3">
<LockDatetimePicker
title="失效时间"
:value="temporaryEndTime"
:minDate="minDate"
:maxDate="maxDate"
type="datehour"
@change-time="changeDate('temporaryEndTime', $event)"
></LockDatetimePicker>
</view>
<view class="button mt-5" @click="create('temporary')">下一步</view>
</swiper-item>
</swiper>
</view>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useBasicStore } from '@/stores/basic'
import { useUserStore } from '@/stores/user'
import { useBluetoothStore } from '@/stores/bluetooth'
import { checkRemoteNameRequest } from '@/api/remote'
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const tabs = [
{
name: '永久'
},
{
name: '限时'
}
]
const permanentName = ref('')
const temporaryName = ref('')
const temporaryStartTime = ref(Number(new Date()))
const temporaryEndTime = ref(Number(new Date()))
const minDate = ref(Number(new Date()))
const maxDate = ref(Number(4133951940000))
const currentIndex = ref(0)
const deviceInfo = ref(null)
onLoad(async () => {
deviceInfo.value = await $basic.getDeviceInfo()
temporaryStartTime.value = setTime()
temporaryEndTime.value = setTime()
minDate.value = Number(getNextFullHour())
maxDate.value = Number(getFutureTimestamp())
})
const getNextFullHour = () => {
const now = new Date()
const currentHour = now.getHours()
now.setHours(currentHour)
now.setMinutes(0)
now.setSeconds(0)
now.setMilliseconds(0)
return now
}
const getFutureTimestamp = () => {
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = currentDate.getMonth()
const day = currentDate.getDate()
const futureDate = new Date(year + 3, month, day, 23, 0, 0)
return futureDate.getTime()
}
const setTime = () => {
const now = new Date()
now.setMinutes(0, 0, 0)
return now.getTime()
}
const create = async type => {
if (
(type === 'temporary' && temporaryName.value === '') ||
(type === 'permanent' && permanentName.value === '')
) {
uni.showToast({
title: '名称不能为空',
icon: 'none'
})
return
}
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
uni.showToast({
title: '失效时间要大于生效时间',
icon: 'none'
})
return
}
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
let params = {
type: 'remote',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: 0,
operate: 0,
userCountLimit: 0xffff
}
if (type === 'permanent') {
params = {
...params,
remoteName: permanentName.value,
weekDays: [],
isRound: 0,
startDate: 0,
remoteType: 1,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
}
} else {
params = {
...params,
remoteName: temporaryName.value,
weekDays: [],
remoteType: 2,
isRound: 0,
startDate: temporaryStartTime.value,
endDate: temporaryEndTime.value,
startTime: '00:00',
endTime: '00:00'
}
}
const { code, message } = await checkRemoteNameRequest({
lockId: $bluetooth.currentLockInfo.lockId,
remoteName: params.remoteName
})
if (code === 0) {
$basic.routeJump({
name: 'bindRemote',
params: {
info: JSON.stringify(params)
},
events: {
refresherList() {
eventChannel.emit('refresherList', {})
}
}
})
} else {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const changeName = (type, event) => {
if (type === 'permanent') {
permanentName.value = event
} else {
temporaryName.value = event
}
}
const changeDate = (type, event) => {
if (type === 'temporaryStartTime') {
temporaryStartTime.value = event
} else {
temporaryEndTime.value = event
}
}
const clickTab = data => {
currentIndex.value = data.index
}
const changeSwiper = e => {
currentIndex.value = e.detail.current
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.tabs {
display: flex;
justify-content: center;
}
.text {
margin-top: 40rpx;
margin-bottom: 50rpx;
color: #262626;
font-size: 26rpx;
padding: 0 32rpx;
}
.button {
border-radius: 64rpx;
width: 686rpx;
margin-left: 32rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
background-color: #63b8af;
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,126 @@
<template>
<view>
<view v-if="info">
<view class="item">
<view class="item-title">人脸号</view>
<view class="item-content">{{ info.faceNumber }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">姓名</view>
<view class="item-content">{{ info.faceName }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">有效期</view>
<view v-if="info.faceType === 1">永久</view>
<view v-else-if="info.faceType === 2">
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
<view v-else>
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4">
<view class="item-title">有效日</view>
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.faceType === 4">
<view class="item-title">有效时间</view>
<view class="item-content">
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
</view>
</view>
<view class="item" style="margin-top: 20rpx">
<view class="item-title">添加者</view>
<view class="item-content">{{ info.senderUsername }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<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>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
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)
}
})
const toRecordList = async () => {
$basic.routeJump({
name: 'typeRecordList',
params: {
name: info.value.faceName,
key: 'faceId',
id: info.value.faceId
}
})
}
const deletePassword = async () => {
eventChannel.emit('delete', {})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.item-title {
width: 350rpx;
}
.item {
padding: 24rpx 32rpx;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 32rpx;
font-weight: 500;
}
.tips {
padding: 24rpx 32rpx;
font-size: 24rpx;
color: #999999;
}
.button {
margin: 32rpx;
width: 686rpx;
height: 88rpx;
background-color: #df282d;
color: white;
text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
font-weight: bold;
}
</style>

464
pages/faceList/faceList.vue Normal file
View File

@ -0,0 +1,464 @@
<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 class="search">
<up-search
shape="square"
:searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></up-search>
</view>
<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>
<up-swipe-action>
<up-swipe-action-item
ref="swipeItem"
:options="options"
v-for="item in list"
:key="item.keyboardPwdId"
:threshold="50"
@click="deleteItem(item)"
>
<view class="item" @click="toDetail(item)">
<image
class="item-left"
src="/static/images/icon_face_white.png"
mode="aspectFill"
></image>
<view class="item-right">
<view style="display: flex; align-items: center">
<view class="item-right-top">{{ item.faceName }}</view>
<view class="status">
{{ item.statusText }}
</view>
</view>
<view class="item-right-bottom">{{ item.timeText }}</view>
</view>
</view>
<view class="line"></view>
</up-swipe-action-item>
</up-swipe-action>
</view>
</view>
</scroll-view>
<view class="button">
<view class="button-reset" @click="reset">重置人脸</view>
<view class="button-create" @click="toCreate">添加人脸</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 { useUserStore } from '@/stores/user'
import { clearFaceRequest, deleteFaceRequest, getFaceList } from '@/api/face'
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const swipeItem = ref(null)
const searchStr = ref('')
const list = ref([])
const pageNo = ref(1)
const pageSize = 50
const total = ref(0)
const lockId = ref(null)
const deviceInfo = ref(null)
const requestFinished = ref(false)
const refresherTriggered = ref(false)
const options = ref([
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
])
onMounted(async () => {
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 reset = async () => {
uni.showModal({
title: '提示',
content: '重置后,该锁的人脸都将被删除哦,确认要重置吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
operate: 3
})
}
}
})
}
const deleteData = async info => {
uni.showLoading({
title: `${info.operate === 2 ? '删除' : '重置'}`
})
const { code } = await $bluetooth.registerAuthentication({
type: 'face',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: Number(info.faceNumber) || 0,
operate: info.operate,
isAdmin: 0,
isForce: 0,
userCountLimit: 0,
weekDays: [],
isRound: 0,
startDate: 0,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
})
$bluetooth.closeBluetoothConnection()
if (code === 0) {
let params = {
lockId: $bluetooth.currentLockInfo.lockId,
deleteType: 1,
type: 1
}
if (info.operate === 2) {
params = {
...params,
faceId: info.faceId,
type: 0
}
}
const { code: requestCode, message } =
info.operate === 3 ? await clearFaceRequest(params) : await deleteFaceRequest(params)
if (requestCode === 0) {
if (info.back) {
$basic.backAndToast(`删除成功`)
}
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}成功`,
icon: 'none'
})
pageNo.value = 1
await getList({
pageNo: pageNo.value
})
} else {
uni.hideLoading()
uni.showToast({
title: message,
icon: 'none'
})
}
} else if (code === -1) {
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}失败,请保持在锁附近`,
icon: 'none'
})
}
}
const deleteItem = async data => {
const index = list.value.findIndex(item => item.keyboardPwdId === data.keyboardPwdId)
swipeItem.value[index].closeHandler()
uni.showModal({
title: '提示',
content: '确定要删除吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
...data,
operate: 2
})
}
}
})
}
const refresherList = async () => {
refresherTriggered.value = true
pageNo.value = 1
const { code, message } = await getList({
pageNo: pageNo.value,
searchStr: searchStr.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 = {
searchStr: searchStr.value,
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 {
data: { timestamp }
} = await $bluetooth.updateServerTimestamp()
const { code, data, message } = await getFaceList({
...params,
lockId: lockId.value,
pageSize
})
if (code === 0) {
total.value = data.total
for (let i = 0; i < data.list.length; i++) {
if (data.list[i].faceStatus === 1 && data.list[i].startDate > timestamp) {
data.list[i].statusText = '未生效'
} else if (data.list[i].faceStatus === 2) {
data.list[i].statusText = '已失效'
}
if (data.list[i].faceType === 1) {
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].faceType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM') +
' 限时'
} else {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd') +
' 循环'
}
}
if (params.pageNo === 1) {
list.value = data.list
} else {
list.value = list.value.concat(data.list)
}
return { code }
}
return { code, message }
}
const changeSearch = async data => {
pageNo.value = 1
const { code, message } = await getList({
searchStr: data,
pageNo: pageNo.value
})
if (code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const toCreate = () => {
$basic.routeJump({
name: 'createFace',
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
const toDetail = item => {
$basic.routeJump({
name: 'faceDetail',
params: {
info: JSON.stringify(item)
},
events: {
delete() {
deleteItem({ ...item, back: true })
}
}
})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</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>

View File

@ -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)

View File

@ -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

View File

@ -84,11 +84,44 @@
<image class="menu-main-image" src="/static/images/icon_fingerprint.png"></image>
<view>指纹</view>
</view>
<view class="menu-main-view" @click="routeJump({ name: 'keyList' })">
<view
v-if="
currentLockInfo.lockFeature.bluetoothRemoteControl || currentLockInfo.keyRight === 1
"
class="menu-main-view"
@click="routeJump({ name: 'remoteList' })"
>
<image class="menu-main-image" src="/static/images/icon_remote.png"></image>
<view>遥控</view>
</view>
<view
v-if="currentLockInfo.lockFeature.d3Face || currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'faceList' })"
>
<image
class="menu-main-image transform-scale-125"
src="/static/images/icon_face.png"
></image>
<view>人脸</view>
</view>
<view
v-if="currentLockInfo.lockFeature.palmVein || currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'palmVeinList' })"
>
<image class="menu-main-image" src="/static/images/icon_palm_vein.png"></image>
<view>掌静脉</view>
</view>
<view
v-if="currentLockInfo.userType === 110301"
class="menu-main-view"
@click="routeJump({ name: 'adminList' })"
>
<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>
@ -163,7 +196,8 @@
...mapActions(useBluetoothStore, [
'openDoor',
'updateServerTimestamp',
'closeBluetoothConnection'
'closeBluetoothConnection',
'syncRecord'
]),
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
closePopup() {
@ -252,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,

View File

@ -0,0 +1,127 @@
<template>
<view>
<view v-if="info">
<view class="item">
<view class="item-title">掌静脉号</view>
<view class="item-content">{{ info.palmVeinNumber }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">姓名</view>
<view class="item-content">{{ info.palmVeinName }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">有效期</view>
<view v-if="info.palmVeinType === 1">永久</view>
<view v-else-if="info.palmVeinType === 2">
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
<view v-else>
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.palmVeinType === 4">
<view class="item-title">有效日</view>
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.palmVeinType === 4">
<view class="item-title">有效时间</view>
<view class="item-content">
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
</view>
</view>
<view class="item" style="margin-top: 20rpx">
<view class="item-title">添加者</view>
<view class="item-content">{{ info.senderUsername }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<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>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
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.palmVeinName,
key: 'palmVeinId',
id: info.value.palmVeinId
}
})
}
const deletePassword = async () => {
eventChannel.emit('delete', {})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.item-title {
width: 350rpx;
}
.item {
padding: 24rpx 32rpx;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 32rpx;
font-weight: 500;
}
.tips {
padding: 24rpx 32rpx;
font-size: 24rpx;
color: #999999;
}
.button {
margin: 32rpx;
width: 686rpx;
height: 88rpx;
background-color: #df282d;
color: white;
text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,468 @@
<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 class="search">
<up-search
shape="square"
:searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></up-search>
</view>
<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>
<up-swipe-action>
<up-swipe-action-item
ref="swipeItem"
:options="options"
v-for="item in list"
:key="item.keyboardPwdId"
:threshold="50"
@click="deleteItem(item)"
>
<view class="item" @click="toDetail(item)">
<view class="item-left rounded-50% bg-#2863f6 flex items-center justify-center">
<image
class="w-50 h-50"
src="/static/images/icon_palm_vein_white.png"
mode="aspectFill"
></image>
</view>
<view class="item-right">
<view style="display: flex; align-items: center">
<view class="item-right-top">{{ item.palmVeinName }}</view>
<view class="status">
{{ item.statusText }}
</view>
</view>
<view class="item-right-bottom">{{ item.timeText }}</view>
</view>
</view>
<view class="line"></view>
</up-swipe-action-item>
</up-swipe-action>
</view>
</view>
</scroll-view>
<view class="button">
<view class="button-reset" @click="reset">重置掌静脉</view>
<view class="button-create" @click="toCreate">添加掌静脉</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 { useUserStore } from '@/stores/user'
import { clearPalmVeinRequest, deletePalmVeinRequest, getPalmVeinList } from '@/api/palmVein'
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const swipeItem = ref(null)
const searchStr = ref('')
const list = ref([])
const pageNo = ref(1)
const pageSize = 50
const total = ref(0)
const lockId = ref(null)
const deviceInfo = ref(null)
const requestFinished = ref(false)
const refresherTriggered = ref(false)
const options = ref([
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
])
onMounted(async () => {
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 reset = async () => {
uni.showModal({
title: '提示',
content: '重置后,该锁的掌静脉都将被删除哦,确认要重置吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
operate: 3
})
}
}
})
}
const deleteData = async info => {
uni.showLoading({
title: `${info.operate === 2 ? '删除' : '重置'}`
})
const { code } = await $bluetooth.registerAuthentication({
type: 'palmVein',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: Number(info.palmVeinNumber) || 0,
operate: info.operate,
isAdmin: 0,
isForce: 0,
userCountLimit: 0,
weekDays: [],
isRound: 0,
startDate: 0,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
})
$bluetooth.closeBluetoothConnection()
if (code === 0) {
let params = {
lockId: $bluetooth.currentLockInfo.lockId,
deleteType: 1,
type: 1
}
if (info.operate === 2) {
params = {
...params,
palmVeinId: info.palmVeinId,
type: 0
}
}
const { code: requestCode, message } =
info.operate === 3
? await clearPalmVeinRequest(params)
: await deletePalmVeinRequest(params)
if (requestCode === 0) {
if (info.back) {
$basic.backAndToast(`删除成功`)
}
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}成功`,
icon: 'none'
})
pageNo.value = 1
await getList({
pageNo: pageNo.value
})
} else {
uni.hideLoading()
uni.showToast({
title: message,
icon: 'none'
})
}
} else if (code === -1) {
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}失败,请保持在锁附近`,
icon: 'none'
})
}
}
const deleteItem = async data => {
const index = list.value.findIndex(item => item.keyboardPwdId === data.keyboardPwdId)
swipeItem.value[index].closeHandler()
uni.showModal({
title: '提示',
content: '确定要删除吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
...data,
operate: 2
})
}
}
})
}
const refresherList = async () => {
refresherTriggered.value = true
pageNo.value = 1
const { code, message } = await getList({
pageNo: pageNo.value,
searchStr: searchStr.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 = {
searchStr: searchStr.value,
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 {
data: { timestamp }
} = await $bluetooth.updateServerTimestamp()
const { code, data, message } = await getPalmVeinList({
...params,
lockId: lockId.value,
pageSize
})
if (code === 0) {
total.value = data.total
for (let i = 0; i < data.list.length; i++) {
if (data.list[i].palmVeinStatus === 1 && data.list[i].startDate > timestamp) {
data.list[i].statusText = '未生效'
} else if (data.list[i].palmVeinStatus === 2) {
data.list[i].statusText = '已失效'
}
if (data.list[i].palmVeinType === 1) {
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].palmVeinType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM') +
' 限时'
} else {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd') +
' 循环'
}
}
if (params.pageNo === 1) {
list.value = data.list
} else {
list.value = list.value.concat(data.list)
}
return { code }
}
return { code, message }
}
const changeSearch = async data => {
pageNo.value = 1
const { code, message } = await getList({
searchStr: data,
pageNo: pageNo.value
})
if (code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const toCreate = () => {
$basic.routeJump({
name: 'createPalmVein',
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
const toDetail = item => {
$basic.routeJump({
name: 'palmVeinDetail',
params: {
info: JSON.stringify(item)
},
events: {
delete() {
deleteItem({ ...item, back: true })
}
}
})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</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>

View File

@ -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) {

View 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>

View 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>

View File

@ -0,0 +1,127 @@
<template>
<view>
<view v-if="info">
<view class="item">
<view class="item-title">遥控号</view>
<view class="item-content">{{ info.remoteNumber }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">姓名</view>
<view class="item-content">{{ info.remoteName }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">有效期</view>
<view v-if="info.remoteType === 1">永久</view>
<view v-else-if="info.remoteType === 2">
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd h:M') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd h:M') }}</view>
</view>
<view v-else>
<view class="item-content">{{ timeFormat(info.startDate, 'yyyy-mm-dd') }}</view>
<view class="item-content">{{ timeFormat(info.endDate, 'yyyy-mm-dd') }}</view>
</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4">
<view class="item-title">有效日</view>
<view class="item-content">{{ $lock.convertWeekDaysToChineseString(info.weekDay) }}</view>
</view>
<view class="item" style="margin-top: 2rpx" v-if="info.remoteType === 4">
<view class="item-title">有效时间</view>
<view class="item-content">
{{ timeFormat(info.startDate, 'h:M') }} - {{ timeFormat(info.endDate, 'h:M') }}
</view>
</view>
<view class="item" style="margin-top: 20rpx">
<view class="item-title">添加者</view>
<view class="item-content">{{ info.senderUsername }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<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>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
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.remoteName,
key: 'remoteId',
id: info.value.remoteId
}
})
}
const deletePassword = async () => {
eventChannel.emit('delete', {})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</style>
<style lang="scss" scoped>
.item-title {
width: 350rpx;
}
.item {
padding: 24rpx 32rpx;
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 32rpx;
font-weight: 500;
}
.tips {
padding: 24rpx 32rpx;
font-size: 24rpx;
color: #999999;
}
.button {
margin: 32rpx;
width: 686rpx;
height: 88rpx;
background-color: #df282d;
color: white;
text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,466 @@
<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 class="search">
<up-search
shape="square"
:searchIconSize="48"
:inputStyle="{ fontSize: '32rpx' }"
:height="80"
placeholder="搜索"
:clearabled="false"
@change="changeSearch"
v-model="searchStr"
bgColor="#ffffff"
:showAction="false"
maxlength="50"
></up-search>
</view>
<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>
<up-swipe-action>
<up-swipe-action-item
ref="swipeItem"
:options="options"
v-for="item in list"
:key="item.keyboardPwdId"
:threshold="50"
@click="deleteItem(item)"
>
<view class="item" @click="toDetail(item)">
<view class="item-left rounded-50% bg-#2863f6 flex items-center justify-center">
<image
class="w-80 h-80"
src="/static/images/icon_remote_white.png"
mode="aspectFill"
></image>
</view>
<view class="item-right">
<view style="display: flex; align-items: center">
<view class="item-right-top">{{ item.remoteName }}</view>
<view class="status">
{{ item.statusText }}
</view>
</view>
<view class="item-right-bottom">{{ item.timeText }}</view>
</view>
</view>
<view class="line"></view>
</up-swipe-action-item>
</up-swipe-action>
</view>
</view>
</scroll-view>
<view class="button">
<view class="button-reset" @click="reset">重置遥控</view>
<view class="button-create" @click="toCreate">添加遥控</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 { useUserStore } from '@/stores/user'
import { clearRemoteRequest, deleteRemoteRequest, getRemoteList } from '@/api/remote'
const $basic = useBasicStore()
const $bluetooth = useBluetoothStore()
const $user = useUserStore()
const swipeItem = ref(null)
const searchStr = ref('')
const list = ref([])
const pageNo = ref(1)
const pageSize = 50
const total = ref(0)
const lockId = ref(null)
const deviceInfo = ref(null)
const requestFinished = ref(false)
const refresherTriggered = ref(false)
const options = ref([
{
text: '删除',
style: {
backgroundColor: '#f56c6c'
}
}
])
onMounted(async () => {
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 reset = async () => {
uni.showModal({
title: '提示',
content: '重置后,该锁的遥控都将被删除哦,确认要重置吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
operate: 3
})
}
}
})
}
const deleteData = async info => {
uni.showLoading({
title: `${info.operate === 2 ? '删除' : '重置'}`
})
const { code } = await $bluetooth.registerAuthentication({
type: 'remote',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: Number(info.remoteNumber) || 0,
operate: info.operate,
isAdmin: 0,
isForce: 0,
userCountLimit: 0,
weekDays: [],
isRound: 0,
startDate: 0,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
})
$bluetooth.closeBluetoothConnection()
if (code === 0) {
let params = {
lockId: $bluetooth.currentLockInfo.lockId,
deleteType: 1,
type: 1
}
if (info.operate === 2) {
params = {
...params,
remoteId: info.remoteId,
type: 0
}
}
const { code: requestCode, message } =
info.operate === 3 ? await clearRemoteRequest(params) : await deleteRemoteRequest(params)
if (requestCode === 0) {
if (info.back) {
$basic.backAndToast(`删除成功`)
}
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}成功`,
icon: 'none'
})
pageNo.value = 1
await getList({
pageNo: pageNo.value
})
} else {
uni.hideLoading()
uni.showToast({
title: message,
icon: 'none'
})
}
} else if (code === -1) {
uni.hideLoading()
uni.showToast({
title: `${info.operate === 2 ? '删除' : '重置'}失败,请保持在锁附近`,
icon: 'none'
})
}
}
const deleteItem = async data => {
const index = list.value.findIndex(item => item.keyboardPwdId === data.keyboardPwdId)
swipeItem.value[index].closeHandler()
uni.showModal({
title: '提示',
content: '确定要删除吗?',
async success(res) {
if (res.confirm) {
const netWork = await $basic.getNetworkType()
if (!netWork) {
return
}
await deleteData({
...data,
operate: 2
})
}
}
})
}
const refresherList = async () => {
refresherTriggered.value = true
pageNo.value = 1
const { code, message } = await getList({
pageNo: pageNo.value,
searchStr: searchStr.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 = {
searchStr: searchStr.value,
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 {
data: { timestamp }
} = await $bluetooth.updateServerTimestamp()
const { code, data, message } = await getRemoteList({
...params,
lockId: lockId.value,
pageSize
})
if (code === 0) {
total.value = data.total
for (let i = 0; i < data.list.length; i++) {
if (data.list[i].remoteStatus === 1 && data.list[i].startDate > timestamp) {
data.list[i].statusText = '未生效'
} else if (data.list[i].remoteStatus === 2) {
data.list[i].statusText = '已失效'
}
if (data.list[i].remoteType === 1) {
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].remoteType === 2) {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd hh:MM') +
' 限时'
} else {
data.list[i].timeText =
timeFormat(data.list[i].startDate, 'yyyy-mm-dd') +
' - ' +
timeFormat(data.list[i].endDate, 'yyyy-mm-dd') +
' 循环'
}
}
if (params.pageNo === 1) {
list.value = data.list
} else {
list.value = list.value.concat(data.list)
}
return { code }
}
return { code, message }
}
const changeSearch = async data => {
pageNo.value = 1
const { code, message } = await getList({
searchStr: data,
pageNo: pageNo.value
})
if (code !== 0) {
uni.showToast({
title: message,
icon: 'none'
})
}
}
const toCreate = () => {
$basic.routeJump({
name: 'createRemote',
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
const toDetail = item => {
$basic.routeJump({
name: 'remoteDetail',
params: {
info: JSON.stringify(item)
},
events: {
delete() {
deleteItem({ ...item, back: true })
}
}
})
}
</script>
<style lang="scss">
page {
background-color: $uni-bg-color-grey;
}
</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>

View 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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 880 B

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
static/images/icon_add_face_1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
static/images/icon_add_face_2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 B

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/images/icon_face.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

BIN
static/images/icon_face_white.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 929 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -151,6 +151,96 @@ const pages = [
name: 'bindFingerprint',
path: '/pages/bindFingerprint/bindFingerprint',
tabBar: false
},
{
name: 'faceList',
path: '/pages/faceList/faceList',
tabBar: false
},
{
name: 'createFace',
path: '/pages/createFace/createFace',
tabBar: false
},
{
name: 'faceDetail',
path: '/pages/faceDetail/faceDetail',
tabBar: false
},
{
name: 'bindFace',
path: '/pages/bindFace/bindFace',
tabBar: false
},
{
name: 'remoteList',
path: '/pages/remoteList/remoteList',
tabBar: false
},
{
name: 'createRemote',
path: '/pages/createRemote/createRemote',
tabBar: false
},
{
name: 'remoteDetail',
path: '/pages/remoteDetail/remoteDetail',
tabBar: false
},
{
name: 'bindRemote',
path: '/pages/bindRemote/bindRemote',
tabBar: false
},
{
name: 'palmVeinList',
path: '/pages/palmVeinList/palmVeinList',
tabBar: false
},
{
name: 'createPalmVein',
path: '/pages/createPalmVein/createPalmVein',
tabBar: false
},
{
name: 'palmVeinDetail',
path: '/pages/palmVeinDetail/palmVeinDetail',
tabBar: false
},
{
name: 'bindPalmVein',
path: '/pages/bindPalmVein/bindPalmVein',
tabBar: false
},
{
name: 'createAdmin',
path: '/pages/createAdmin/createAdmin',
tabBar: false
},
{
name: 'adminDetail',
path: '/pages/adminDetail/adminDetail',
tabBar: false
},
{
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
}
]

View File

@ -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
@ -68,12 +69,22 @@ const subCmdIds = {
registerFaceConfirm: 82,
// 注册人脸取消
registerFaceCancel: 86,
// 注册人脸过程
registerFaceProcess: 83,
// 注册遥控
registerRemote: 26,
// 注册遥控确认
registerRemoteConfirm: 27,
// 注册遥控取消
registerRemoteCancel: 28
registerRemoteCancel: 28,
// 注册掌纹
registerPalmVein: 42,
// 注册掌纹确认
registerPalmVeinConfirm: 43,
// 注册掌纹取消
registerPalmVeinCancel: 44,
// 同步操作记录
syncRecord: 41
}
export const useBluetoothStore = defineStore('ble', {
@ -256,7 +267,7 @@ export const useBluetoothStore = defineStore('ble', {
})
},
// 解析特征值
parsingCharacteristicValue(binaryData) {
async parsingCharacteristicValue(binaryData) {
const $user = useUserStore()
const that = this
// 0x20 明文 0x22 SM4事先约定密钥 0x23 SM4设备指定密钥
@ -367,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({
@ -397,9 +407,8 @@ export const useBluetoothStore = defineStore('ble', {
})
break
case subCmdIds.registerCard:
case subCmdIds.registerFingerprint:
case subCmdIds.registerFace:
case subCmdIds.registerRemote:
case subCmdIds.registerPalmVein:
that.updateCurrentLockInfo({
...that.currentLockInfo,
token: decrypted.slice(5, 9)
@ -407,8 +416,20 @@ export const useBluetoothStore = defineStore('ble', {
characteristicValueCallback({
code: decrypted[2],
data: {
status: decrypted[9],
no: decrypted[10] * 256 + decrypted[11]
status: decrypted[9]
}
})
break
case subCmdIds.registerFingerprint:
case subCmdIds.registerFace:
that.updateCurrentLockInfo({
...that.currentLockInfo,
token: decrypted.slice(5, 9)
})
characteristicValueCallback({
code: decrypted[2],
data: {
maxProcess: decrypted[11]
}
})
break
@ -424,12 +445,67 @@ export const useBluetoothStore = defineStore('ble', {
fingerprintNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerFaceConfirm:
uni.$emit('registerFaceConfirm', {
status: decrypted[5],
faceNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerRemoteConfirm:
uni.$emit('registerRemoteConfirm', {
status: decrypted[5],
remoteNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerPalmVeinConfirm:
uni.$emit('registerPalmVeinConfirm', {
status: decrypted[5],
palmVeinNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerFingerprintProcess:
uni.$emit('registerFingerprintProcess', {
status: decrypted[5],
process: decrypted[6]
})
break
case subCmdIds.registerFaceProcess:
uni.$emit('registerFaceProcess', {
status: decrypted[5],
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:
@ -2292,8 +2368,10 @@ export const useBluetoothStore = defineStore('ble', {
contentArray[2] = subCmdIds.registerFingerprint
} else if (type === 'face') {
contentArray[2] = subCmdIds.registerFace
} else {
} else if (type === 'remote') {
contentArray[2] = subCmdIds.registerRemote
} else if (type === 'palmVein') {
contentArray[2] = subCmdIds.registerPalmVein
}
contentArray[3] = length - 3
@ -2371,8 +2449,10 @@ export const useBluetoothStore = defineStore('ble', {
contentArray[2] = subCmdIds.registerFingerprintCancel
} else if (type === 'face') {
contentArray[2] = subCmdIds.registerFaceCancel
} else {
} else if (type === 'remote') {
contentArray[2] = subCmdIds.registerRemoteCancel
} else if (type === 'palmVein') {
contentArray[2] = subCmdIds.registerPalmVeinCancel
}
contentArray[3] = length - 3
@ -2407,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)
}
}
})