完成卡片相关功能
This commit is contained in:
parent
2f9bd54361
commit
fffecaa021
27
api/card.js
27
api/card.js
@ -10,3 +10,30 @@ export function getCardList(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除卡片
|
||||||
|
export function deleteCardRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/identityCard/delete',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查卡片名称是否重复
|
||||||
|
export function checkCardNameRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/identityCard/checkIdentityCardName',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加卡片
|
||||||
|
export function addCardRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/identityCard/add',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -156,6 +156,13 @@
|
|||||||
"disableScroll": true
|
"disableScroll": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/bindCard/bindCard",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "添加卡",
|
||||||
|
"disableScroll": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/cardDetail/cardDetail",
|
"path": "pages/cardDetail/cardDetail",
|
||||||
"style": {
|
"style": {
|
||||||
|
|||||||
87
pages/bindCard/bindCard.vue
Normal file
87
pages/bindCard/bindCard.vue
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="flex justify-center flex-col pt-20">
|
||||||
|
<image
|
||||||
|
src="/static/images/icon_add_card.png"
|
||||||
|
mode="aspectFill"
|
||||||
|
class="mx-[200rpx] w-350 h-350"
|
||||||
|
></image>
|
||||||
|
<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"
|
||||||
|
>{{ 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 { addCardRequest } from '@/api/card'
|
||||||
|
|
||||||
|
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.card) {
|
||||||
|
const params = JSON.parse(options.card)
|
||||||
|
const { code } = await $bluetooth.registerCard(params)
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
text.value = '已连接到锁,请将卡靠近锁的读卡区'
|
||||||
|
} else {
|
||||||
|
$basic.backAndToast('操作失败,请重试')
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.$on('registerCardConfirm', async data => {
|
||||||
|
if (data.status === 0) {
|
||||||
|
bindFlag.value = true
|
||||||
|
const { code, message } = await addCardRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
startDate: params.startDate,
|
||||||
|
endDate: params.endDate,
|
||||||
|
cardName: params.cardName,
|
||||||
|
cardNumber: String(data.cardNumber),
|
||||||
|
cardType: params.cardType,
|
||||||
|
addType: 1,
|
||||||
|
cardRight: params.isAdmin,
|
||||||
|
isCoerced: params.isForce === 1 ? 2 : 1
|
||||||
|
})
|
||||||
|
if (code === 0) {
|
||||||
|
eventChannel.emit('refresherList', {})
|
||||||
|
$basic.backAndToast('绑卡成功', 2)
|
||||||
|
} else {
|
||||||
|
$basic.backAndToast(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
uni.$off('registerCardConfirm')
|
||||||
|
if (!bindFlag.value) {
|
||||||
|
$bluetooth.registerCardCancel({
|
||||||
|
keyId: $bluetooth.keyId.toString(),
|
||||||
|
uid: $user.userInfo.uid.toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
page {
|
||||||
|
background-color: $uni-bg-color-grey;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -46,12 +46,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { getCurrentInstance, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
|
||||||
import { useLockStore } from '@/stores/lock'
|
import { useLockStore } from '@/stores/lock'
|
||||||
|
|
||||||
|
const instance = getCurrentInstance().proxy
|
||||||
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
const $lock = useLockStore()
|
const $lock = useLockStore()
|
||||||
|
|
||||||
const info = ref(null)
|
const info = ref(null)
|
||||||
@ -64,64 +66,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const deletePassword = async () => {
|
const deletePassword = async () => {
|
||||||
const netWork = await this.getNetworkType()
|
eventChannel.emit('delete', {})
|
||||||
if (!netWork) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const that = this
|
|
||||||
uni.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '确定要删除该密码',
|
|
||||||
async success(res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
uni.showLoading({
|
|
||||||
title: '删除中',
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
const timestamp = parseInt(new Date().getTime() / 1000, 10)
|
|
||||||
const { code } = await that.setLockPassword({
|
|
||||||
keyId: that.keyId.toString(),
|
|
||||||
uid: that.userInfo.uid.toString(),
|
|
||||||
pwdNo: that.currentPasswordInfo.pwdUserNo,
|
|
||||||
operate: 3,
|
|
||||||
isAdmin: that.currentPasswordInfo.pwdRight,
|
|
||||||
pwd: that.currentPasswordInfo.keyboardPwd,
|
|
||||||
userCountLimit: 0xffff,
|
|
||||||
startTime: timestamp,
|
|
||||||
endTime: timestamp
|
|
||||||
})
|
|
||||||
that.closeBluetoothConnection()
|
|
||||||
if (code === 0) {
|
|
||||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
|
||||||
lockId: that.currentLockInfo.lockId,
|
|
||||||
keyboardPwdId: that.currentPasswordInfo.keyboardPwdId,
|
|
||||||
deleteType: 1
|
|
||||||
})
|
|
||||||
if (requestCode === 0) {
|
|
||||||
uni.hideLoading()
|
|
||||||
that.updatePasswordSearch({
|
|
||||||
...that.passwordSearch,
|
|
||||||
pageNo: 1
|
|
||||||
})
|
|
||||||
that.getPasswordList(that.passwordSearch)
|
|
||||||
that.backAndToast('删除成功')
|
|
||||||
} else {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (code === -1) {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '删除失败,请保持在锁附近',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<view class="button">
|
<view class="button">
|
||||||
<view class="button-reset" @click="toCreate">重置卡片</view>
|
<view class="button-reset" @click="reset">重置卡片</view>
|
||||||
<view class="button-create" @click="toCreate">添加卡片</view>
|
<view class="button-create" @click="toCreate">添加卡片</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -76,15 +76,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { deletePsaawordRequest } from '@/api/keyboardPwd'
|
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import { useLockStore } from '@/stores/lock'
|
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { getCardList } from '@/api/card'
|
import { deleteCardRequest, getCardList } from '@/api/card'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
const $lock = useLockStore()
|
|
||||||
const $bluetooth = useBluetoothStore()
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $user = useUserStore()
|
||||||
|
|
||||||
|
const swipeItem = ref(null)
|
||||||
|
|
||||||
const searchStr = ref('')
|
const searchStr = ref('')
|
||||||
const list = ref([])
|
const list = ref([])
|
||||||
@ -111,7 +112,6 @@
|
|||||||
mask: true
|
mask: true
|
||||||
})
|
})
|
||||||
deviceInfo.value = await $basic.getDeviceInfo()
|
deviceInfo.value = await $basic.getDeviceInfo()
|
||||||
console.log(deviceInfo.value)
|
|
||||||
lockId.value = $bluetooth.currentLockInfo.lockId
|
lockId.value = $bluetooth.currentLockInfo.lockId
|
||||||
const { code, message } = await getList({
|
const { code, message } = await getList({
|
||||||
pageNo: pageNo.value
|
pageNo: pageNo.value
|
||||||
@ -126,68 +126,105 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const deleteItem = async data => {
|
const reset = async () => {
|
||||||
const netWork = await this.getNetworkType()
|
|
||||||
if (!netWork) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const password = data
|
|
||||||
const that = this
|
|
||||||
let index = this.passwordList.findIndex(item => item.keyboardPwdId === password.keyboardPwdId)
|
|
||||||
that.$refs.swipeItem[index].closeHandler()
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定要删除该密码',
|
content: '重置后,该锁的卡都将被删除哦,确认要重置吗?',
|
||||||
async success(res) {
|
async success(res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
uni.showLoading({
|
const netWork = await $basic.getNetworkType()
|
||||||
title: '删除中',
|
if (!netWork) {
|
||||||
mask: true
|
return
|
||||||
})
|
|
||||||
const timestamp = parseInt(new Date().getTime() / 1000, 10)
|
|
||||||
const { code } = await that.setLockPassword({
|
|
||||||
keyId: that.keyId.toString(),
|
|
||||||
uid: that.userInfo.uid.toString(),
|
|
||||||
pwdNo: password.pwdUserNo,
|
|
||||||
operate: 3,
|
|
||||||
isAdmin: password.pwdRight,
|
|
||||||
pwd: password.keyboardPwd,
|
|
||||||
userCountLimit: 0xffff,
|
|
||||||
startTime: timestamp,
|
|
||||||
endTime: timestamp
|
|
||||||
})
|
|
||||||
that.closeBluetoothConnection()
|
|
||||||
if (code === 0) {
|
|
||||||
const { code: requestCode, message } = await deletePsaawordRequest({
|
|
||||||
lockId: that.currentLockInfo.lockId,
|
|
||||||
keyboardPwdId: password.keyboardPwdId,
|
|
||||||
deleteType: 1
|
|
||||||
})
|
|
||||||
if (requestCode === 0) {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '删除成功',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
that.updatePasswordSearch({
|
|
||||||
...$lock.passwordSearch,
|
|
||||||
pageNo: 1
|
|
||||||
})
|
|
||||||
await that.getPasswordList($lock.passwordSearch)
|
|
||||||
} else {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: message,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (code === -1) {
|
|
||||||
uni.hideLoading()
|
|
||||||
uni.showToast({
|
|
||||||
title: '删除失败,请保持在锁附近',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
await deleteData({
|
||||||
|
operate: 3
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteData = async info => {
|
||||||
|
uni.showLoading({
|
||||||
|
title: `${info.operate === 2 ? '删除' : '重置'}中`
|
||||||
|
})
|
||||||
|
|
||||||
|
const { code } = await $bluetooth.registerCard({
|
||||||
|
keyId: $bluetooth.keyId.toString(),
|
||||||
|
uid: $user.userInfo.uid.toString(),
|
||||||
|
cardNo: Number(info.cardNumber) || 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,
|
||||||
|
cardId: info.cardId,
|
||||||
|
type: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const { code: requestCode, message } = await deleteCardRequest(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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -294,7 +331,15 @@
|
|||||||
|
|
||||||
const toCreate = () => {
|
const toCreate = () => {
|
||||||
$basic.routeJump({
|
$basic.routeJump({
|
||||||
name: 'createCard'
|
name: 'createCard',
|
||||||
|
events: {
|
||||||
|
refresherList() {
|
||||||
|
pageNo.value = 1
|
||||||
|
getList({
|
||||||
|
pageNo: pageNo.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,6 +348,11 @@
|
|||||||
name: 'cardDetail',
|
name: 'cardDetail',
|
||||||
params: {
|
params: {
|
||||||
info: JSON.stringify(item)
|
info: JSON.stringify(item)
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
delete() {
|
||||||
|
deleteItem({ ...item, back: true })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,80 +27,87 @@
|
|||||||
:value="permanentName"
|
:value="permanentName"
|
||||||
title="姓名"
|
title="姓名"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
@change-input="changePermanentInput"
|
@change-input="changeName('permanent', $event)"
|
||||||
></LockInput>
|
></LockInput>
|
||||||
<view class="mt-3">
|
<view class="mt-3">
|
||||||
<LockSwitch
|
<LockSwitch
|
||||||
:value="false"
|
:value="permanentAdmin"
|
||||||
title="是否为管理员"
|
title="是否为管理员"
|
||||||
@change="changePermanentInput"
|
@change="changeAdmin('permanent', $event)"
|
||||||
></LockSwitch>
|
></LockSwitch>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3 mb-3">
|
<view class="mt-3 mb-3">
|
||||||
<LockSwitch
|
<LockSwitch
|
||||||
:value="false"
|
:value="permanentCoerced"
|
||||||
title="胁迫卡"
|
title="胁迫卡"
|
||||||
@change="changePermanentInput"
|
@change="changeCoerced('permanent', $event)"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
></LockSwitch>
|
></LockSwitch>
|
||||||
</view>
|
</view>
|
||||||
<view class="button" @click="createPassword('permanent')">下一步</view>
|
<view class="button" @click="create('permanent')">下一步</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||||
<LockInput
|
<LockInput
|
||||||
:value="temporaryName"
|
:value="temporaryName"
|
||||||
title="姓名"
|
title="姓名"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
@change-input="changeTemporaryInput"
|
@change-input="changeName('temporary', $event)"
|
||||||
></LockInput>
|
></LockInput>
|
||||||
<view class="mt-3">
|
<view class="mt-3">
|
||||||
<LockDatetimePicker
|
<LockDatetimePicker
|
||||||
title="生效时间"
|
title="生效时间"
|
||||||
:value="temporaryTime"
|
:value="temporaryStartTime"
|
||||||
:minDate="minDate"
|
:minDate="minDate"
|
||||||
:maxDate="maxDate"
|
:maxDate="maxDate"
|
||||||
type="datehour"
|
type="datehour"
|
||||||
@change-time="changeTemporaryTime"
|
@change-time="changeDate('temporaryStartTime', $event)"
|
||||||
></LockDatetimePicker>
|
></LockDatetimePicker>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3">
|
<view class="mt-3">
|
||||||
<LockDatetimePicker
|
<LockDatetimePicker
|
||||||
title="失效时间"
|
title="失效时间"
|
||||||
:value="temporaryTime"
|
:value="temporaryEndTime"
|
||||||
:minDate="minDate"
|
:minDate="minDate"
|
||||||
:maxDate="maxDate"
|
:maxDate="maxDate"
|
||||||
type="datehour"
|
type="datehour"
|
||||||
@change-time="changeTemporaryTime"
|
@change-time="changeDate('temporaryEndTime', $event)"
|
||||||
></LockDatetimePicker>
|
></LockDatetimePicker>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3">
|
<view class="mt-3">
|
||||||
<LockSwitch
|
<LockSwitch
|
||||||
:value="false"
|
:value="temporaryAdmin"
|
||||||
title="是否为管理员"
|
title="是否为管理员"
|
||||||
@change="changePermanentInput"
|
@change="changeAdmin('temporary', $event)"
|
||||||
></LockSwitch>
|
></LockSwitch>
|
||||||
</view>
|
</view>
|
||||||
<view class="mt-3 mb-3">
|
<view class="mt-3 mb-3">
|
||||||
<LockSwitch
|
<LockSwitch
|
||||||
:value="false"
|
:value="temporaryCoerced"
|
||||||
title="胁迫卡"
|
title="胁迫卡"
|
||||||
@change="changePermanentInput"
|
@change="changeCoerced('temporary', $event)"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
></LockSwitch>
|
></LockSwitch>
|
||||||
</view>
|
</view>
|
||||||
<view class="button" @click="createPassword('temporary')">下一步</view>
|
<view class="button" @click="create('temporary')">下一步</view>
|
||||||
</swiper-item>
|
</swiper-item>
|
||||||
</swiper>
|
</swiper>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { getCurrentInstance, ref } from 'vue'
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { createPsaawordRequest } from '@/api/keyboardPwd'
|
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
|
import { checkCardNameRequest } from '@/api/card'
|
||||||
|
|
||||||
|
const instance = getCurrentInstance().proxy
|
||||||
|
const eventChannel = instance.getOpenerEventChannel()
|
||||||
|
|
||||||
const $basic = useBasicStore()
|
const $basic = useBasicStore()
|
||||||
|
const $bluetooth = useBluetoothStore()
|
||||||
|
const $user = useUserStore()
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
@ -110,20 +117,28 @@
|
|||||||
name: '限时'
|
name: '限时'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const permanentName = ref('')
|
const permanentName = ref('')
|
||||||
|
const permanentAdmin = ref(false)
|
||||||
|
const permanentCoerced = ref(false)
|
||||||
|
|
||||||
const temporaryName = ref('')
|
const temporaryName = ref('')
|
||||||
const temporaryTime = ref(Number(new Date()))
|
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 minDate = ref(Number(new Date()))
|
||||||
const maxDate = ref(Number(4133951940000))
|
const maxDate = ref(Number(4133951940000))
|
||||||
const currentIndex = ref(0)
|
const currentIndex = ref(0)
|
||||||
const deviceInfo = ref(null)
|
const deviceInfo = ref(null)
|
||||||
const pending = ref(false)
|
|
||||||
const placeholder =
|
const placeholder =
|
||||||
'当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息会推送给管理员,该功能需要锁联网。\n请不要将胁迫卡用于日常开锁'
|
'当被胁迫要求强行开锁时,使用胁迫卡会触发报警,报警信息会推送给管理员,该功能需要锁联网。\n请不要将胁迫卡用于日常开锁'
|
||||||
|
|
||||||
onLoad(async () => {
|
onLoad(async () => {
|
||||||
deviceInfo.value = await $basic.getDeviceInfo()
|
deviceInfo.value = await $basic.getDeviceInfo()
|
||||||
temporaryTime.value = setTime()
|
temporaryStartTime.value = setTime()
|
||||||
|
temporaryEndTime.value = setTime()
|
||||||
minDate.value = Number(getNextFullHour())
|
minDate.value = Number(getNextFullHour())
|
||||||
maxDate.value = Number(getFutureTimestamp())
|
maxDate.value = Number(getFutureTimestamp())
|
||||||
})
|
})
|
||||||
@ -158,7 +173,7 @@
|
|||||||
return now.getTime()
|
return now.getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
const createPassword = async type => {
|
const create = async type => {
|
||||||
if (
|
if (
|
||||||
(type === 'temporary' && temporaryName.value === '') ||
|
(type === 'temporary' && temporaryName.value === '') ||
|
||||||
(type === 'permanent' && permanentName.value === '')
|
(type === 'permanent' && permanentName.value === '')
|
||||||
@ -170,58 +185,70 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === 'temporary' && temporaryStartTime.value > temporaryEndTime.value) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '失效时间要大于生效时间',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const netWork = await $basic.getNetworkType()
|
const netWork = await $basic.getNetworkType()
|
||||||
if (!netWork) {
|
if (!netWork) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pending.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pending.value = true
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
lockId: this.currentLockInfo.lockId,
|
keyId: $bluetooth.keyId.toString(),
|
||||||
isCoerced: 2,
|
uid: $user.userInfo.uid.toString(),
|
||||||
pwdRight: 0
|
cardNo: 0,
|
||||||
|
operate: 0,
|
||||||
|
userCountLimit: 0xffff
|
||||||
}
|
}
|
||||||
if (type === 'temporary') {
|
|
||||||
params.keyboardPwdName = this.temporaryName
|
if (type === 'permanent') {
|
||||||
params.keyboardPwdType = 3
|
params = {
|
||||||
params.startDate = new Date().getTime()
|
...params,
|
||||||
params.endDate = this.temporaryTime
|
cardName: permanentName.value,
|
||||||
params.hoursStart = 0
|
isAdmin: permanentAdmin.value ? 1 : 0,
|
||||||
params.hoursEnd = 0
|
isForce: permanentCoerced.value ? 1 : 0,
|
||||||
|
weekDays: [],
|
||||||
|
isRound: 0,
|
||||||
|
startDate: 0,
|
||||||
|
cardType: 1,
|
||||||
|
endDate: 0,
|
||||||
|
startTime: '00:00',
|
||||||
|
endTime: '00:00'
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
params.startDate = 0
|
params = {
|
||||||
params.endDate = 0
|
...params,
|
||||||
params.keyboardPwdName = this.permanentName
|
cardName: temporaryName.value,
|
||||||
params.keyboardPwdType = 2
|
isAdmin: temporaryAdmin.value ? 1 : 0,
|
||||||
params.hoursStart = 0
|
isForce: temporaryCoerced.value ? 1 : 0,
|
||||||
params.hoursEnd = 0
|
weekDays: [],
|
||||||
|
cardType: 2,
|
||||||
|
isRound: 0,
|
||||||
|
startDate: temporaryStartTime.value,
|
||||||
|
endDate: temporaryEndTime.value,
|
||||||
|
startTime: '00:00',
|
||||||
|
endTime: '00:00'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const { code, data, message } = await createPsaawordRequest(params)
|
|
||||||
|
const { code, message } = await checkCardNameRequest({
|
||||||
|
lockId: $bluetooth.currentLockInfo.lockId,
|
||||||
|
cardName: params.cardName
|
||||||
|
})
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
uni.reportEvent('create_password', {})
|
$basic.routeJump({
|
||||||
this.updatePasswordSearch({
|
name: 'bindCard',
|
||||||
...this.passwordSearch,
|
params: {
|
||||||
pageNo: 1
|
card: JSON.stringify(params)
|
||||||
})
|
},
|
||||||
this.getPasswordList(this.passwordSearch)
|
events: {
|
||||||
uni.showModal({
|
refresherList() {
|
||||||
title: '密码生成成功',
|
eventChannel.emit('refresherList', {})
|
||||||
content: `密码:${data.keyboardPwd}`,
|
|
||||||
cancelText: '复制',
|
|
||||||
success: res => {
|
|
||||||
if (res.confirm) {
|
|
||||||
uni.navigateBack()
|
|
||||||
} else {
|
|
||||||
uni.setClipboardData({
|
|
||||||
data: data.keyboardPwd,
|
|
||||||
success: () => {
|
|
||||||
$basic.backAndToast('复制成功')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -231,19 +258,38 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pending.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const changePermanentInput = e => {
|
const changeName = (type, event) => {
|
||||||
permanentName.value = e
|
if (type === 'permanent') {
|
||||||
|
permanentName.value = event
|
||||||
|
} else {
|
||||||
|
temporaryName.value = event
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeTemporaryInput = e => {
|
const changeDate = (type, event) => {
|
||||||
temporaryName.value = e
|
if (type === 'temporaryStartTime') {
|
||||||
|
temporaryStartTime.value = event
|
||||||
|
} else {
|
||||||
|
temporaryEndTime.value = event
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeTemporaryTime = e => {
|
const changeAdmin = (type, event) => {
|
||||||
temporaryTime.value = e
|
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 => {
|
const clickTab = data => {
|
||||||
|
|||||||
BIN
static/images/icon_add_card.png
Executable file
BIN
static/images/icon_add_card.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@ -127,6 +127,11 @@ const pages = [
|
|||||||
path: '/pages/cardDetail/cardDetail',
|
path: '/pages/cardDetail/cardDetail',
|
||||||
tabBar: false
|
tabBar: false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'bindCard',
|
||||||
|
path: '/pages/bindCard/bindCard',
|
||||||
|
tabBar: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'fingerprintList',
|
name: 'fingerprintList',
|
||||||
path: '/pages/fingerprintList/fingerprintList',
|
path: '/pages/fingerprintList/fingerprintList',
|
||||||
@ -164,10 +169,27 @@ export const useBasicStore = defineStore('basic', {
|
|||||||
return page.name === data.name
|
return page.name === data.name
|
||||||
})
|
})
|
||||||
if (page) {
|
if (page) {
|
||||||
uni.$u.route({
|
if (!data.type || data.type === 'navigateTo' || data.type === 'to') {
|
||||||
url: page.path,
|
let url = `${page.path}?`
|
||||||
...data
|
if (data.params) {
|
||||||
})
|
Object.keys(data.params).forEach((key, index) => {
|
||||||
|
if (index === 0) {
|
||||||
|
url += `${key}=${data.params[key]}`
|
||||||
|
} else {
|
||||||
|
url += `&${key}=${data.params[key]}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
uni.navigateTo({
|
||||||
|
url,
|
||||||
|
...data
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.$u.route({
|
||||||
|
url: page.path,
|
||||||
|
...data
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 获取当前网络状态
|
// 获取当前网络状态
|
||||||
|
|||||||
@ -47,7 +47,13 @@ const subCmdIds = {
|
|||||||
// 设置开锁密码
|
// 设置开锁密码
|
||||||
setLockPassword: 3,
|
setLockPassword: 3,
|
||||||
// 重置开锁密码
|
// 重置开锁密码
|
||||||
resetLockPassword: 19
|
resetLockPassword: 19,
|
||||||
|
// 注册卡片
|
||||||
|
registerCard: 24,
|
||||||
|
// 注册卡片确认
|
||||||
|
registerCardConfirm: 22,
|
||||||
|
// 注册卡片取消
|
||||||
|
registerCardCancel: 25
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useBluetoothStore = defineStore('ble', {
|
export const useBluetoothStore = defineStore('ble', {
|
||||||
@ -370,6 +376,25 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case subCmdIds.registerCard:
|
||||||
|
that.updateCurrentLockInfo({
|
||||||
|
...that.currentLockInfo,
|
||||||
|
token: decrypted.slice(5, 9)
|
||||||
|
})
|
||||||
|
characteristicValueCallback({
|
||||||
|
code: decrypted[2],
|
||||||
|
data: {
|
||||||
|
status: decrypted[9],
|
||||||
|
cardNo: decrypted[10] * 256 + decrypted[11]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case subCmdIds.registerCardConfirm:
|
||||||
|
uni.$emit('registerCardConfirm', {
|
||||||
|
status: decrypted[5],
|
||||||
|
cardNumber: decrypted[6] * 256 + decrypted[7]
|
||||||
|
})
|
||||||
|
break
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case cmdIds.openDoor:
|
case cmdIds.openDoor:
|
||||||
@ -1419,7 +1444,6 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 获取写入结果
|
// 获取写入结果
|
||||||
getWriteResult(request, params) {
|
getWriteResult(request, params) {
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
const that = this
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const getWriteResultTimer = setTimeout(() => {
|
const getWriteResultTimer = setTimeout(() => {
|
||||||
log.info({
|
log.info({
|
||||||
@ -1453,27 +1477,6 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
clearTimeout(getWriteResultTimer)
|
clearTimeout(getWriteResultTimer)
|
||||||
resolve(await request(params))
|
resolve(await request(params))
|
||||||
} else if (data.code === 4) {
|
|
||||||
log.info({
|
|
||||||
code: 4,
|
|
||||||
message: `锁端数据返回,无操作权限,添加用户后重新执行`,
|
|
||||||
data: {
|
|
||||||
lockName: this.currentLockInfo.name,
|
|
||||||
lockId: this.currentLockInfo.lockId,
|
|
||||||
uid: $user.userInfo.uid,
|
|
||||||
nickname: $user.userInfo.nickname,
|
|
||||||
mobile: $user.userInfo.mobile,
|
|
||||||
email: $user.userInfo.email
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const checkResult = await that.checkLockUser(true)
|
|
||||||
if (checkResult) {
|
|
||||||
clearTimeout(getWriteResultTimer)
|
|
||||||
resolve(await request(params))
|
|
||||||
} else {
|
|
||||||
clearTimeout(getWriteResultTimer)
|
|
||||||
resolve(data)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(getWriteResultTimer)
|
clearTimeout(getWriteResultTimer)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
@ -2172,6 +2175,185 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
await this.writeBLECharacteristicValue(packageArray)
|
await this.writeBLECharacteristicValue(packageArray)
|
||||||
|
|
||||||
return this.getWriteResult(this.setLockPassword, data)
|
return this.getWriteResult(this.setLockPassword, data)
|
||||||
|
},
|
||||||
|
parseTimeToList(timeString) {
|
||||||
|
let timeList = [0, 0, 0, 0]
|
||||||
|
|
||||||
|
if (timeString.includes(':')) {
|
||||||
|
let timeParts = timeString.split(':')
|
||||||
|
timeList[2] = parseInt(timeParts[0], 10)
|
||||||
|
timeList[3] = parseInt(timeParts[1], 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Uint8Array(timeList)
|
||||||
|
},
|
||||||
|
// 注册卡片
|
||||||
|
async registerCard(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,
|
||||||
|
cardNo,
|
||||||
|
operate,
|
||||||
|
isAdmin,
|
||||||
|
userCountLimit,
|
||||||
|
isForce,
|
||||||
|
isRound,
|
||||||
|
weekDays,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
startTime,
|
||||||
|
endTime
|
||||||
|
} = data
|
||||||
|
|
||||||
|
const length = 2 + 1 + 1 + 40 + 20 + 2 + 2 + 1 + 1 + 1 + 4 + 1 + 1 + 4 + 4 + 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.registerCard
|
||||||
|
|
||||||
|
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] = (cardNo || 0) / 256
|
||||||
|
contentArray[65] = (cardNo || 0) % 256
|
||||||
|
|
||||||
|
contentArray[66] = (userCountLimit || 0xffff) / 256
|
||||||
|
contentArray[67] = (userCountLimit || 0xffff) % 256
|
||||||
|
|
||||||
|
contentArray[68] = operate
|
||||||
|
contentArray[69] = isAdmin || 0
|
||||||
|
contentArray[70] = isForce || 0
|
||||||
|
|
||||||
|
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 71)
|
||||||
|
|
||||||
|
contentArray[75] = isRound
|
||||||
|
contentArray[76] = this.convertWeekdaysToNumber(weekDays)
|
||||||
|
|
||||||
|
contentArray.set(this.timestampToArray(startDate), 77)
|
||||||
|
contentArray.set(this.timestampToArray(endDate), 81)
|
||||||
|
|
||||||
|
if (isRound) {
|
||||||
|
contentArray.set(this.parseTimeToList(startTime), 85)
|
||||||
|
contentArray.set(this.parseTimeToList(endTime), 89)
|
||||||
|
} else {
|
||||||
|
contentArray.set(new Uint8Array([0, 0, 0, 0]), 85)
|
||||||
|
contentArray.set(new Uint8Array([0, 0, 0, 0]), 89)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentArray[93] = 16
|
||||||
|
|
||||||
|
const md5Array = this.md5Encrypte(
|
||||||
|
keyId + uid,
|
||||||
|
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||||
|
this.currentLockInfo.signKey
|
||||||
|
)
|
||||||
|
|
||||||
|
contentArray.set(md5Array, 94)
|
||||||
|
|
||||||
|
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||||
|
mode: 'ecb',
|
||||||
|
output: 'array'
|
||||||
|
})
|
||||||
|
|
||||||
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
|
await this.writeBLECharacteristicValue(packageArray)
|
||||||
|
|
||||||
|
return this.getWriteResult(this.registerCard, data)
|
||||||
|
},
|
||||||
|
async registerCardCancel(data) {
|
||||||
|
const { keyId, uid } = data
|
||||||
|
|
||||||
|
const length = 2 + 1 + 1 + 40 + 20 + 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.registerCardCancel
|
||||||
|
|
||||||
|
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.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64)
|
||||||
|
|
||||||
|
contentArray[68] = 16
|
||||||
|
|
||||||
|
const md5Array = this.md5Encrypte(
|
||||||
|
keyId + uid,
|
||||||
|
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||||
|
this.currentLockInfo.signKey
|
||||||
|
)
|
||||||
|
|
||||||
|
contentArray.set(md5Array, 69)
|
||||||
|
|
||||||
|
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||||
|
mode: 'ecb',
|
||||||
|
output: 'array'
|
||||||
|
})
|
||||||
|
|
||||||
|
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||||
|
|
||||||
|
await this.writeBLECharacteristicValue(packageArray)
|
||||||
|
|
||||||
|
return this.getWriteResult(this.registerCardCancel, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user