2025-02-10 09:41:47 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<view class="flex justify-center flex-col pt-10 text-align-center text-base">
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-if="showProcess"
|
2025-03-27 16:57:59 +08:00
|
|
|
|
src="https://oss-lock.xhjcn.ltd/mp/icon_add_face_1.png"
|
2025-02-10 09:41:47 +08:00
|
|
|
|
mode="widthFix"
|
|
|
|
|
|
class="mx-[100rpx] w-550 mt-5 rounded-2xl"
|
|
|
|
|
|
></image>
|
|
|
|
|
|
<image
|
|
|
|
|
|
v-else
|
2025-03-27 16:57:59 +08:00
|
|
|
|
src="https://oss-lock.xhjcn.ltd/mp/icon_add_face_2.png"
|
2025-02-10 09:41:47 +08:00
|
|
|
|
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,
|
2025-02-13 18:53:50 +08:00
|
|
|
|
startTime: params.value.startDate,
|
|
|
|
|
|
endTime: params.value.endDate,
|
2025-02-10 09:41:47 +08:00
|
|
|
|
faceName: params.value.faceName,
|
|
|
|
|
|
faceNumber: String(data.faceNumber),
|
2025-02-11 15:45:53 +08:00
|
|
|
|
faceUserNo: String(data.faceNumber),
|
2025-02-10 09:41:47 +08:00
|
|
|
|
faceType: params.value.faceType,
|
|
|
|
|
|
addType: 1,
|
2025-02-12 18:18:25 +08:00
|
|
|
|
weekDay: params.value.weekDays,
|
2025-02-13 18:53:50 +08:00
|
|
|
|
faceRight: params.value.isAdmin,
|
2025-02-10 09:41:47 +08:00
|
|
|
|
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) {
|
2025-02-22 09:44:58 +08:00
|
|
|
|
$basic.backAndToast('管理员已满')
|
2025-02-10 09:41:47 +08:00
|
|
|
|
} else if (data.status === 0xfd) {
|
2025-02-22 09:44:58 +08:00
|
|
|
|
$basic.backAndToast('用户已满')
|
2025-02-10 09:41:47 +08:00
|
|
|
|
} else if (data.status === 0xfc) {
|
2025-02-22 09:44:58 +08:00
|
|
|
|
$basic.backAndToast('人脸已满')
|
2025-02-10 09:41:47 +08:00
|
|
|
|
} else if (data.status === 0xfb) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '人脸已存在',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const ready = async () => {
|
|
|
|
|
|
showProcess.value = true
|
|
|
|
|
|
const { code } = await $bluetooth.registerAuthentication(params.value)
|
2025-02-22 09:44:58 +08:00
|
|
|
|
if (code === 0) {
|
|
|
|
|
|
/* empty */
|
|
|
|
|
|
} else if (code === -21) {
|
|
|
|
|
|
$basic.backAndToast('请先打开蓝牙')
|
2025-02-10 09:41:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
|
uni.$off('registerFaceConfirm')
|
2025-02-22 09:44:58 +08:00
|
|
|
|
uni.$off('registerFaceProcess')
|
2025-02-10 09:41:47 +08:00
|
|
|
|
if (!bindFlag.value) {
|
|
|
|
|
|
$bluetooth.registerAuthenticationCancel({
|
|
|
|
|
|
type: 'face',
|
|
|
|
|
|
keyId: $bluetooth.keyId.toString(),
|
|
|
|
|
|
uid: $user.userInfo.uid.toString()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.button {
|
|
|
|
|
|
width: 686rpx;
|
|
|
|
|
|
height: 100rpx;
|
2025-07-14 15:00:18 +08:00
|
|
|
|
margin-left: 32rpx;
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: bold;
|
2025-02-10 09:41:47 +08:00
|
|
|
|
line-height: 100rpx;
|
2025-07-14 15:00:18 +08:00
|
|
|
|
color: #fff;
|
2025-02-10 09:41:47 +08:00
|
|
|
|
text-align: center;
|
2025-07-29 11:07:43 +08:00
|
|
|
|
background-color: #4777ee;
|
2025-07-14 15:00:18 +08:00
|
|
|
|
border-radius: 64rpx;
|
2025-02-10 09:41:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|