完成指纹相关功能

This commit is contained in:
范鹏 2025-02-09 14:38:52 +08:00
parent fffecaa021
commit 6bd95a7d5d
19 changed files with 1134 additions and 34 deletions

39
api/fingerprint.js Normal file
View File

@ -0,0 +1,39 @@
import request from '../utils/request'
// fingerprint 指纹模块
// 获取指纹列表
export function getFingerprintList(data) {
return request({
url: '/fingerprint/list',
method: 'POST',
data
})
}
// 删除指纹
export function deleteFingerprintRequest(data) {
return request({
url: '/fingerprint/delete',
method: 'POST',
data
})
}
// 检查指纹名称是否重复
export function checkFingerprintNameRequest(data) {
return request({
url: '/fingerprint/checkFingerprintName',
method: 'POST',
data
})
}
// 添加指纹
export function addFingerprintRequest(data) {
return request({
url: '/fingerprint/add',
method: 'POST',
data
})
}

View File

@ -190,6 +190,13 @@
"navigationBarTitleText": "指纹详情",
"disableScroll": true
}
},
{
"path": "pages/bindFingerprint/bindFingerprint",
"style": {
"navigationBarTitleText": "添加指纹",
"disableScroll": true
}
}
],
"globalStyle": {

View File

@ -6,8 +6,11 @@
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-20 bg-black mx-[75rpx] w-600 h-80 text-align-center line-height-[80rpx] text-white shadow-sm"
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>
@ -36,7 +39,7 @@
onLoad(async options => {
if (options.card) {
const params = JSON.parse(options.card)
const { code } = await $bluetooth.registerCard(params)
const { code } = await $bluetooth.registerAuthentication(params)
if (code === 0) {
text.value = '已连接到锁,请将卡靠近锁的读卡区'
@ -69,14 +72,16 @@
}
})
onUnmounted(() => {
onUnmounted(async () => {
uni.$off('registerCardConfirm')
if (!bindFlag.value) {
$bluetooth.registerCardCancel({
await $bluetooth.registerAuthenticationCancel({
type: 'card',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString()
})
}
$bluetooth.closeBluetoothConnection()
})
</script>

View File

@ -0,0 +1,91 @@
<template>
<view>
<view class="flex justify-center flex-col pt-10 text-align-center text-base">
<view>
{{ text }}
</view>
<view v-if="showProcess" class="mt-5 font-bold">({{ process }}/5)</view>
<image
:src="`/static/images/icon_fingerprint_${process}.png`"
mode="widthFix"
class="mx-[250rpx] w-250 mt-5"
></image>
<view class="mt-10">根据提示抬起手指后再进行下一次指纹采集</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 { addFingerprintRequest } from '@/api/fingerprint'
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 process = ref(0)
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 = '请将您的手指按下'
showProcess.value = true
} else {
$basic.backAndToast('操作失败,请重试')
}
uni.$on('registerFingerprintConfirm', async data => {
if (data.status === 0) {
bindFlag.value = true
const { code, message } = await addFingerprintRequest({
lockId: $bluetooth.currentLockInfo.lockId,
startDate: params.startDate,
endDate: params.endDate,
fingerprintName: params.fingerprintName,
fingerprintNumber: String(data.fingerprintNumber),
fingerprintType: params.fingerprintType,
addType: 1,
fingerRight: params.isAdmin,
isCoerced: params.isForce === 1 ? 2 : 1
})
if (code === 0) {
eventChannel.emit('refresherList', {})
$basic.backAndToast('添加成功', 2)
} else {
$basic.backAndToast(message)
}
}
})
uni.$on('registerFingerprintProcess', data => {
if (data.status === 0) {
process.value = data.process
}
})
}
})
onUnmounted(() => {
uni.$off('registerFingerprintConfirm')
if (!bindFlag.value) {
$bluetooth.registerAuthenticationCancel({
type: 'fingerprint',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString()
})
}
})
</script>

View File

@ -149,10 +149,11 @@
title: `${info.operate === 2 ? '删除' : '重置'}`
})
const { code } = await $bluetooth.registerCard({
const { code } = await $bluetooth.registerAuthentication({
type: 'card',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
cardNo: Number(info.cardNumber) || 0,
no: Number(info.cardNumber) || 0,
operate: info.operate,
isAdmin: 0,
isForce: 0,

View File

@ -199,9 +199,10 @@
}
let params = {
type: 'card',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
cardNo: 0,
no: 0,
operate: 0,
userCountLimit: 0xffff
}

View File

@ -1,7 +1,337 @@
<template>
<view> </view>
<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 lang="ts"></script>
<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 { checkFingerprintNameRequest } from '@/api/fingerprint'
<style scoped lang="scss"></style>
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: 'fingerprint',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: 0,
operate: 0,
userCountLimit: 0xffff
}
if (type === 'permanent') {
params = {
...params,
fingerprintName: permanentName.value,
isAdmin: permanentAdmin.value ? 1 : 0,
isForce: permanentCoerced.value ? 1 : 0,
weekDays: [],
isRound: 0,
startDate: 0,
fingerprintType: 1,
endDate: 0,
startTime: '00:00',
endTime: '00:00'
}
} else {
params = {
...params,
fingerprintName: temporaryName.value,
isAdmin: temporaryAdmin.value ? 1 : 0,
isForce: temporaryCoerced.value ? 1 : 0,
weekDays: [],
fingerprintType: 2,
isRound: 0,
startDate: temporaryStartTime.value,
endDate: temporaryEndTime.value,
startTime: '00:00',
endTime: '00:00'
}
}
const { code, message } = await checkFingerprintNameRequest({
lockId: $bluetooth.currentLockInfo.lockId,
fingerprintName: params.fingerprintName
})
if (code === 0) {
$basic.routeJump({
name: 'bindFingerprint',
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

@ -1,7 +1,111 @@
<template>
<view> </view>
<view>
<view v-if="info">
<view class="item">
<view class="item-title">指纹号</view>
<view class="item-content">{{ info.fingerprintNumber }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">姓名</view>
<view class="item-content">{{ info.fingerprintName }}</view>
</view>
<view class="item" style="margin-top: 2rpx">
<view class="item-title">有效期</view>
<view v-if="info.fingerprintType === 1">永久</view>
<view v-else-if="info.fingerprintType === 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.fingerprintType === 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.fingerprintType === 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="button" @click="deletePassword">删除</view>
</view>
</view>
</template>
<script setup></script>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { timeFormat } from 'uview-plus'
import { useLockStore } from '@/stores/lock'
<style scoped lang="scss"></style>
const instance = getCurrentInstance().proxy
const eventChannel = instance.getOpenerEventChannel()
const $lock = useLockStore()
const info = ref(null)
onLoad(options => {
if (options.info) {
info.value = JSON.parse(options.info)
console.log(info.value)
}
})
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

@ -1,7 +1,463 @@
<template>
<view> </view>
<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_fingerprint_white.png"
mode="aspectFill"
></image>
<view class="item-right">
<view style="display: flex; align-items: center">
<view class="item-right-top">{{ item.fingerprintName }}</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></script>
<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 { deleteFingerprintRequest, getFingerprintList } from '@/api/fingerprint'
<style scoped lang="scss"></style>
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: 'fingerprint',
keyId: $bluetooth.keyId.toString(),
uid: $user.userInfo.uid.toString(),
no: Number(info.fingerprintNumber) || 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,
fingerprintId: info.fingerprintId,
type: 0
}
}
const { code: requestCode, message } = await deleteFingerprintRequest(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 getFingerprintList({
...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].fingerprintStatus === 1 && data.list[i].startDate > timestamp) {
data.list[i].statusText = '未生效'
} else if (data.list[i].fingerprintStatus === 2) {
data.list[i].statusText = '已失效'
}
if (data.list[i].fingerprintType === 1) {
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
} else if (data.list[i].fingerprintType === 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: 'createFingerprint',
events: {
refresherList() {
pageNo.value = 1
getList({
pageNo: pageNo.value
})
}
}
})
}
const toDetail = item => {
$basic.routeJump({
name: 'fingerprintDetail',
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

@ -68,11 +68,19 @@
<image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image>
<view>密码</view>
</view>
<view class="menu-main-view" @click="routeJump({ name: 'cardList' })">
<view
v-if="currentLockInfo.lockFeature.icCard || currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'cardList' })"
>
<image class="menu-main-image" src="/static/images/icon_card.png"></image>
<view></view>
</view>
<view class="menu-main-view" @click="routeJump({ name: 'fingerprintList' })">
<view
v-if="currentLockInfo.lockFeature.fingerprint || currentLockInfo.keyRight === 1"
class="menu-main-view"
@click="routeJump({ name: 'fingerprintList' })"
>
<image class="menu-main-image" src="/static/images/icon_fingerprint.png"></image>
<view>指纹</view>
</view>
@ -129,6 +137,9 @@
import { deleteKeyRequest } from '@/api/key'
export default {
components: {
SwitchLoading
},
data() {
return {
time: 0,
@ -143,9 +154,6 @@
...mapState(useUserStore, ['userInfo']),
...mapState(useLockStore, ['lockSearch'])
},
components: {
SwitchLoading
},
onLoad() {
this.getServeTime()
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -146,6 +146,11 @@ const pages = [
name: 'fingerprintDetail',
path: '/pages/fingerprintDetail/fingerprintDetail',
tabBar: false
},
{
name: 'bindFingerprint',
path: '/pages/bindFingerprint/bindFingerprint',
tabBar: false
}
]

View File

@ -53,7 +53,27 @@ const subCmdIds = {
// 注册卡片确认
registerCardConfirm: 22,
// 注册卡片取消
registerCardCancel: 25
registerCardCancel: 25,
// 注册指纹
registerFingerprint: 36,
// 注册指纹确认
registerFingerprintConfirm: 32,
// 注册指纹取消
registerFingerprintCancel: 37,
// 注册指纹过程
registerFingerprintProcess: 33,
// 注册人脸
registerFace: 81,
// 注册人脸确认
registerFaceConfirm: 82,
// 注册人脸取消
registerFaceCancel: 86,
// 注册遥控
registerRemote: 26,
// 注册遥控确认
registerRemoteConfirm: 27,
// 注册遥控取消
registerRemoteCancel: 28
}
export const useBluetoothStore = defineStore('ble', {
@ -377,6 +397,9 @@ export const useBluetoothStore = defineStore('ble', {
})
break
case subCmdIds.registerCard:
case subCmdIds.registerFingerprint:
case subCmdIds.registerFace:
case subCmdIds.registerRemote:
that.updateCurrentLockInfo({
...that.currentLockInfo,
token: decrypted.slice(5, 9)
@ -385,7 +408,7 @@ export const useBluetoothStore = defineStore('ble', {
code: decrypted[2],
data: {
status: decrypted[9],
cardNo: decrypted[10] * 256 + decrypted[11]
no: decrypted[10] * 256 + decrypted[11]
}
})
break
@ -395,6 +418,18 @@ export const useBluetoothStore = defineStore('ble', {
cardNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerFingerprintConfirm:
uni.$emit('registerFingerprintConfirm', {
status: decrypted[5],
fingerprintNumber: decrypted[6] * 256 + decrypted[7]
})
break
case subCmdIds.registerFingerprintProcess:
uni.$emit('registerFingerprintProcess', {
status: decrypted[5],
process: decrypted[6]
})
break
}
break
case cmdIds.openDoor:
@ -2187,8 +2222,8 @@ export const useBluetoothStore = defineStore('ble', {
return new Uint8Array(timeList)
},
// 注册卡片
async registerCard(data) {
// 注册身份认证
async registerAuthentication(data) {
// 确认蓝牙状态正常
if (this.bluetoothStatus !== 0) {
console.log('写入未执行', this.bluetoothStatus)
@ -2227,9 +2262,10 @@ export const useBluetoothStore = defineStore('ble', {
}
const {
type,
keyId,
uid,
cardNo,
no,
operate,
isAdmin,
userCountLimit,
@ -2250,7 +2286,15 @@ export const useBluetoothStore = defineStore('ble', {
contentArray[1] = cmdIds.expandCmd % 256
// 子命令
contentArray[2] = subCmdIds.registerCard
if (type === 'card') {
contentArray[2] = subCmdIds.registerCard
} else if (type === 'fingerprint') {
contentArray[2] = subCmdIds.registerFingerprint
} else if (type === 'face') {
contentArray[2] = subCmdIds.registerFace
} else {
contentArray[2] = subCmdIds.registerRemote
}
contentArray[3] = length - 3
@ -2262,8 +2306,8 @@ export const useBluetoothStore = defineStore('ble', {
contentArray[i + 44] = uid.charCodeAt(i)
}
contentArray[64] = (cardNo || 0) / 256
contentArray[65] = (cardNo || 0) % 256
contentArray[64] = (no || 0) / 256
contentArray[65] = (no || 0) % 256
contentArray[66] = (userCountLimit || 0xffff) / 256
contentArray[67] = (userCountLimit || 0xffff) % 256
@ -2307,10 +2351,11 @@ export const useBluetoothStore = defineStore('ble', {
await this.writeBLECharacteristicValue(packageArray)
return this.getWriteResult(this.registerCard, data)
return this.getWriteResult(this.registerAuthentication, data)
},
async registerCardCancel(data) {
const { keyId, uid } = data
// 注册身份认证取消
async registerAuthenticationCancel(data) {
const { type, keyId, uid } = data
const length = 2 + 1 + 1 + 40 + 20 + 4 + 1 + 16
const headArray = this.createPackageHeader(3, length)
@ -2320,7 +2365,15 @@ export const useBluetoothStore = defineStore('ble', {
contentArray[1] = cmdIds.expandCmd % 256
// 子命令
contentArray[2] = subCmdIds.registerCardCancel
if (type === 'card') {
contentArray[2] = subCmdIds.registerCardCancel
} else if (type === 'fingerprint') {
contentArray[2] = subCmdIds.registerFingerprintCancel
} else if (type === 'face') {
contentArray[2] = subCmdIds.registerFaceCancel
} else {
contentArray[2] = subCmdIds.registerRemoteCancel
}
contentArray[3] = length - 3
@ -2353,7 +2406,7 @@ export const useBluetoothStore = defineStore('ble', {
await this.writeBLECharacteristicValue(packageArray)
return this.getWriteResult(this.registerCardCancel, data)
return this.getWriteResult(this.registerAuthenticationCancel, data)
}
}
})