Merge branch 'fanpeng' into 'develop'
1. 完成锁设置页UI See merge request StarlockTeam/wx-starlock!22
@ -1,12 +0,0 @@
|
||||
import request from '../utils/request'
|
||||
|
||||
// lockSetting 锁设置模块
|
||||
|
||||
// 更新锁设置
|
||||
export function updateLockSettingRequest(data) {
|
||||
return request({
|
||||
url: '/lockSetting/updateLockSetting',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
@ -5,7 +5,70 @@ import request from '../utils/request'
|
||||
// 获取锁设置
|
||||
export function getLockSettingRequest(data) {
|
||||
return request({
|
||||
url: '/lockSetting/getLockSetting',
|
||||
url: '/lock/getLockSettingData',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新锁设置
|
||||
export function updateLockSettingRequest(data) {
|
||||
return request({
|
||||
url: '/lockSetting/updateLockSetting',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 更新锁名称
|
||||
export function updateLockNameRequest(data) {
|
||||
return request({
|
||||
url: '/lock/updateLockName',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改管理员密码
|
||||
export function updateAdminPasswordRequest(data) {
|
||||
return request({
|
||||
url: '/room/modifyPwd',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取分组列表
|
||||
export function getGroupListRequest(data) {
|
||||
return request({
|
||||
url: '/authorizedAdmin/listGroup',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 创建分组
|
||||
export function createGroupRequest(data) {
|
||||
return request({
|
||||
url: '/keyGroup/add',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 设置分组
|
||||
export function setGroupRequest(data) {
|
||||
return request({
|
||||
url: '/keyGroup/setGroup',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 上传锁数据
|
||||
export function lockDataUploadRequest(data) {
|
||||
return request({
|
||||
url: '/lockRecords/lockDataUpload',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
"name" : "wx-starlock",
|
||||
"appid" : "__UNI__933D519",
|
||||
"description" : "",
|
||||
"versionName" : "1.1.3",
|
||||
"versionCode" : "30",
|
||||
"versionName" : "1.2.0",
|
||||
"versionCode" : "31",
|
||||
"transformPx" : false,
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
|
||||
63
pages.json
@ -337,6 +337,69 @@
|
||||
"navigationBarTitleText": "修改有效期",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/lockInfo/lockInfo",
|
||||
"style": {
|
||||
"navigationBarTitleText": "基本信息",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/syncElec/syncElec",
|
||||
"style": {
|
||||
"navigationBarTitleText": "电量",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/selectGroup/selectGroup",
|
||||
"style": {
|
||||
"navigationBarTitleText": "选择分组",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/updateSetting/updateSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/lockSound/lockSound",
|
||||
"style": {
|
||||
"navigationBarTitleText": "锁声音",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/autoLock/autoLock",
|
||||
"style": {
|
||||
"navigationBarTitleText": "自动闭锁",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/faceSetting/faceSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "面容开锁设置",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/lockDate/lockDate",
|
||||
"style": {
|
||||
"navigationBarTitleText": "锁时间",
|
||||
"disableScroll": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/uploadLockData/uploadLockData",
|
||||
"style": {
|
||||
"navigationBarTitleText": "上传数据",
|
||||
"disableScroll": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
112
pages/LockDate/LockDate.vue
Normal file
@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="text-xl text-center py-10 h-100 line-height-100rpx">
|
||||
<view v-if="show">{{
|
||||
timeFormat($bluetooth.currentLockInfo.lockConfig.indate, 'yyyy-mm-dd hh:MM')
|
||||
}}</view>
|
||||
</view>
|
||||
<view
|
||||
class="bg-#63b8af mt-4 rounded-3xl w-600 h-80 line-height-80rpx text-center mx-75rpx text-white text-xl font-bold"
|
||||
@click="update"
|
||||
>
|
||||
校准
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const show = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
})
|
||||
const { code } = await $bluetooth.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
const date = new Date()
|
||||
const timestamp = $bluetooth.serverTimestamp - date.getTimezoneOffset() * 60
|
||||
const { code: lockStatus } = await $bluetooth.getLockStatus({
|
||||
name: $bluetooth.currentLockInfo.lockId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
nowTime: $bluetooth.serverTimestamp,
|
||||
localTime: timestamp
|
||||
})
|
||||
uni.hideLoading()
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (lockStatus === 0) {
|
||||
show.value = true
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取锁时间失败,请返回重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '获取锁时间失败,请返回重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const update = async () => {
|
||||
if (pending.value && show.value) return
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
pending.value = true
|
||||
const { code, message } = await $bluetooth.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
const { code: lockStatus } = await $bluetooth.calibrationTime({
|
||||
lockId: $bluetooth.currentLockInfo.lockId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
nowTime: $bluetooth.serverTimestamp
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (lockStatus === 0) {
|
||||
$bluetooth.updateCurrentLockInfo({
|
||||
...$bluetooth.currentLockInfo,
|
||||
lockConfig: {
|
||||
...$bluetooth.currentLockInfo.lockConfig,
|
||||
indate: $bluetooth.serverTimestamp * 1000
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -4,7 +4,7 @@
|
||||
<view class="item" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.keyName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.keyName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -88,7 +88,7 @@
|
||||
<view>{{
|
||||
info.keyRight === 1
|
||||
? '取消授权会在用户APP连网后生效'
|
||||
: '授权用户拥有管理员的大部分权限,比如发送要是、发送密码'
|
||||
: '授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'
|
||||
}}</view>
|
||||
</view>
|
||||
</up-modal>
|
||||
|
||||
199
pages/autoLock/autoLock.vue
Normal file
@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base">
|
||||
<view class="item-title">自动闭锁</view>
|
||||
<switch
|
||||
@click="changeCheck"
|
||||
:checked="check"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
:color="$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1 ? '#002ce5' : '#71acff'"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
v-if="check"
|
||||
class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base mt-1"
|
||||
@click="open"
|
||||
>
|
||||
<view class="item-title">延迟时间</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">{{ custom ? '自定义' : value + 's' }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-1" v-if="custom && check">
|
||||
<LockInput
|
||||
:value="text"
|
||||
title="时间"
|
||||
type="number"
|
||||
:maxlength="2"
|
||||
placeholder="请输入时间,范围为5-60"
|
||||
@change-input="changeDuration"
|
||||
></LockInput>
|
||||
</view>
|
||||
<view class="m-4 text-sm">
|
||||
经过以上设定的时间,锁会自动关闭。开启或修改设置后,请先开一次锁,使时间生效。
|
||||
</view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1"
|
||||
:class="[canUpdate ? 'bg-#63b8af' : 'bg-#a3a3a3']"
|
||||
class="mt-4 rounded-3xl w-600 h-80 line-height-80rpx text-center mx-75rpx text-white text-xl font-bold"
|
||||
@click="update"
|
||||
>
|
||||
保存
|
||||
</view>
|
||||
<up-picker
|
||||
:show="show"
|
||||
:columns="columns"
|
||||
:defaultIndex="picker"
|
||||
title="选择时间"
|
||||
keyName="name"
|
||||
:itemHeight="70"
|
||||
:visibleItemCount="5"
|
||||
@close="show = false"
|
||||
@cancel="show = false"
|
||||
@confirm="confirm"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { updateLockSettingRequest } from '@/api/setting'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const check = ref(false)
|
||||
const value = ref(0)
|
||||
const picker = ref([0])
|
||||
|
||||
const text = ref('')
|
||||
|
||||
const show = ref(false)
|
||||
const pending = ref(false)
|
||||
const custom = ref(false)
|
||||
|
||||
const columns = ref([
|
||||
[
|
||||
{ name: '5s', value: 5 },
|
||||
{ name: '10s', value: 10 },
|
||||
{ name: '15s', value: 15 },
|
||||
{ name: '30s', value: 30 },
|
||||
{ name: '60s', value: 60 },
|
||||
{ name: '自定义', value: -1 }
|
||||
]
|
||||
])
|
||||
|
||||
const canUpdate = computed(() => {
|
||||
return (
|
||||
(($bluetooth.currentLockSetting.lockSettingInfo.autoLock === 1) !== check.value ||
|
||||
value.value !== $bluetooth.currentLockSetting.lockSettingInfo.autoLockSecond) &&
|
||||
((check.value && value.value >= 5 && value.value <= 60) || !check.value)
|
||||
)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
check.value = $bluetooth.currentLockSetting.lockSettingInfo.autoLock === 1
|
||||
value.value = $bluetooth.currentLockSetting.lockSettingInfo.autoLockSecond
|
||||
const index = columns.value[0].findIndex(item => item.value === value.value)
|
||||
if (index === -1) {
|
||||
custom.value = true
|
||||
picker.value = [5]
|
||||
text.value = $bluetooth.currentLockSetting.lockSettingInfo.autoLockSecond.toString()
|
||||
} else {
|
||||
picker.value = [index]
|
||||
}
|
||||
})
|
||||
|
||||
const open = () => {
|
||||
if ($bluetooth.currentLockSetting.lockBasicInfo.keyRight !== 1) return
|
||||
show.value = true
|
||||
}
|
||||
|
||||
const changeDuration = data => {
|
||||
if (custom.value) {
|
||||
value.value = Number(data)
|
||||
}
|
||||
}
|
||||
|
||||
const update = async () => {
|
||||
if (!canUpdate.value) return
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '保存中'
|
||||
})
|
||||
const featureBit = 29
|
||||
const { code } = await $bluetooth.updateSetting({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
featureBit,
|
||||
params: [Number(value.value)],
|
||||
withParams: true
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
autoLock: check.value ? 1 : 0,
|
||||
autoLockSecond: value.value
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockSettingInfo: {
|
||||
...$bluetooth.currentLockSetting.lockSettingInfo,
|
||||
autoLock: check.value ? 1 : 0,
|
||||
autoLockSecond: value.value
|
||||
}
|
||||
})
|
||||
$basic.backAndToast('更新成功')
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const confirm = data => {
|
||||
if (data.indexs[0] === 5) {
|
||||
custom.value = true
|
||||
} else {
|
||||
custom.value = false
|
||||
value.value = columns.value[0][data.indexs[0]].value
|
||||
}
|
||||
show.value = false
|
||||
}
|
||||
|
||||
const changeCheck = () => {
|
||||
if ($bluetooth.currentLockSetting.lockBasicInfo.keyRight !== 1) return
|
||||
check.value = !check.value
|
||||
if (!check.value) {
|
||||
value.value = 0
|
||||
} else {
|
||||
value.value = 5
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -39,13 +39,6 @@
|
||||
onLoad(async options => {
|
||||
if (options.card) {
|
||||
const params = JSON.parse(options.card)
|
||||
const { code } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '已连接到锁,请将卡靠近锁的读卡区'
|
||||
} else {
|
||||
$basic.backAndToast('操作失败,请重试')
|
||||
}
|
||||
|
||||
uni.$on('registerCardConfirm', async data => {
|
||||
if (data.status === 0) {
|
||||
@ -67,27 +60,18 @@
|
||||
})
|
||||
if (code === 0) {
|
||||
eventChannel.emit('refresherList', {})
|
||||
$basic.backAndToast('绑卡成功', 2)
|
||||
$basic.backAndToast('添加成功', 2)
|
||||
} else {
|
||||
$basic.backAndToast(message)
|
||||
}
|
||||
} else if (data.status === 0xff) {
|
||||
$basic.backAndToast('添加失败,请重试')
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('管理员已满')
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('用户已满')
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '卡片已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('卡片已满')
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '卡片已存在',
|
||||
@ -95,6 +79,14 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const { code } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '已连接到锁,请将卡靠近锁的读卡区'
|
||||
} else if (code === -21) {
|
||||
$basic.backAndToast('请先打开蓝牙')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -76,20 +76,11 @@
|
||||
if (data.status === 0xff) {
|
||||
$basic.backAndToast('添加失败,请重试')
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('管理员已满')
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('用户已满')
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '人脸已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('人脸已满')
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '人脸已存在',
|
||||
@ -103,13 +94,16 @@
|
||||
const ready = async () => {
|
||||
showProcess.value = true
|
||||
const { code } = await $bluetooth.registerAuthentication(params.value)
|
||||
if (code !== 0) {
|
||||
$basic.backAndToast('操作失败,请重试')
|
||||
if (code === 0) {
|
||||
/* empty */
|
||||
} else if (code === -21) {
|
||||
$basic.backAndToast('请先打开蓝牙')
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('registerFaceConfirm')
|
||||
uni.$off('registerFaceProcess')
|
||||
if (!bindFlag.value) {
|
||||
$bluetooth.registerAuthenticationCancel({
|
||||
type: 'face',
|
||||
|
||||
@ -40,16 +40,6 @@
|
||||
onLoad(async options => {
|
||||
if (options.info) {
|
||||
const params = JSON.parse(options.info)
|
||||
const { code, data } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '请将您的手指按下'
|
||||
maxProcess.value = data.maxProcess
|
||||
showProcess.value = true
|
||||
} else {
|
||||
$basic.backAndToast('操作失败,请重试')
|
||||
}
|
||||
|
||||
uni.$on('registerFingerprintConfirm', async data => {
|
||||
if (data.status === 0) {
|
||||
bindFlag.value = true
|
||||
@ -82,20 +72,11 @@
|
||||
} else if (data.status === 0xff) {
|
||||
$basic.backAndToast('添加失败,请重试')
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('管理员已满')
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('用户已满')
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '指纹已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('指纹已满')
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '指纹已存在',
|
||||
@ -103,11 +84,21 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
const { code, data } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '请将您的手指按下'
|
||||
maxProcess.value = data.maxProcess
|
||||
showProcess.value = true
|
||||
} else if (code === -21) {
|
||||
$basic.backAndToast('请先打开蓝牙')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off('registerFingerprintConfirm')
|
||||
uni.$off('registerFingerprintProcess')
|
||||
if (!bindFlag.value) {
|
||||
$bluetooth.registerAuthenticationCancel({
|
||||
type: 'fingerprint',
|
||||
|
||||
@ -36,13 +36,6 @@
|
||||
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) {
|
||||
@ -64,27 +57,18 @@
|
||||
})
|
||||
if (code === 0) {
|
||||
eventChannel.emit('refresherList', {})
|
||||
$basic.backAndToast('绑卡成功', 2)
|
||||
$basic.backAndToast('添加成功', 2)
|
||||
} else {
|
||||
$basic.backAndToast(message)
|
||||
}
|
||||
} else if (data.status === 0xff) {
|
||||
$basic.backAndToast('添加失败,请重试')
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('管理员已满')
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('用户已满')
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '掌静脉已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('掌静脉已满')
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '掌静脉已存在',
|
||||
@ -92,6 +76,14 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const { code } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '已连接到锁,请自然张开手掌,掌心对准摄像头'
|
||||
} else if (code === -21) {
|
||||
$basic.backAndToast('请先打开蓝牙')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -39,13 +39,6 @@
|
||||
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) {
|
||||
@ -74,20 +67,11 @@
|
||||
} else if (data.status === 0xff) {
|
||||
$basic.backAndToast('添加失败,请重试')
|
||||
} else if (data.status === 0xfe) {
|
||||
uni.showToast({
|
||||
title: '管理员已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('管理员已满')
|
||||
} else if (data.status === 0xfd) {
|
||||
uni.showToast({
|
||||
title: '用户已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('用户已满')
|
||||
} else if (data.status === 0xfc) {
|
||||
uni.showToast({
|
||||
title: '遥控已满',
|
||||
icon: 'none'
|
||||
})
|
||||
$basic.backAndToast('遥控已满')
|
||||
} else if (data.status === 0xfb) {
|
||||
uni.showToast({
|
||||
title: '遥控已存在',
|
||||
@ -95,6 +79,14 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const { code } = await $bluetooth.registerAuthentication(params)
|
||||
|
||||
if (code === 0) {
|
||||
text.value = '已连接到锁,请按遥控'
|
||||
} else if (code === -21) {
|
||||
$basic.backAndToast('请先打开蓝牙')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.cardName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.cardName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -192,6 +192,10 @@
|
||||
}
|
||||
|
||||
const changeCoerced = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
|
||||
@ -291,7 +291,7 @@
|
||||
}
|
||||
|
||||
if (data.list[i].cardType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
data.list[i].timeText = timeFormat(data.list[i].createDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
} else if (data.list[i].cardType === 2) {
|
||||
data.list[i].timeText =
|
||||
timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') +
|
||||
|
||||
@ -43,6 +43,9 @@
|
||||
@change="changeAdmin('permanent', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="text-sm text-#262626 mt-3 mx-4">
|
||||
授权管理员拥有操作这把锁的重要权限,请确保只发给你信任的人
|
||||
</view>
|
||||
<view class="button mt-5" @click="create('permanent')">发送</view>
|
||||
</swiper-item>
|
||||
<swiper-item :style="{ height: deviceInfo.windowHeight - 44 + 'px' }">
|
||||
@ -50,13 +53,13 @@
|
||||
:value="temporaryAccount"
|
||||
title="接收者"
|
||||
placeholder="请输入手机号或者邮箱"
|
||||
@change-input="changeAccount('permanent', $event)"
|
||||
@change-input="changeAccount('temporary', $event)"
|
||||
></LockInput>
|
||||
<LockInput
|
||||
:value="temporaryName"
|
||||
title="姓名"
|
||||
placeholder="请输入"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
@change-input="changeName('temporary', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<LockDatetimePicker
|
||||
@ -64,7 +67,6 @@
|
||||
:value="temporaryStartTime"
|
||||
:minDate="minDate"
|
||||
:maxDate="maxDate"
|
||||
type="datehour"
|
||||
@change-time="changeDate('temporaryStartTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
@ -74,7 +76,6 @@
|
||||
:value="temporaryEndTime"
|
||||
:minDate="minDate"
|
||||
:maxDate="maxDate"
|
||||
type="datehour"
|
||||
@change-time="changeDate('temporaryEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
@ -83,9 +84,12 @@
|
||||
:value="temporaryManageSelf"
|
||||
title="仅管理自己创建的用户"
|
||||
:tip="tip"
|
||||
@change="changeAdmin('permanent', $event)"
|
||||
@change="changeAdmin('temporary', $event)"
|
||||
></LockSwitch>
|
||||
</view>
|
||||
<view class="text-sm text-#262626 mt-3 mx-4">
|
||||
授权管理员拥有操作这把锁的重要权限,请确保只发给你信任的人
|
||||
</view>
|
||||
<view class="button mt-5" @click="create('temporary')">发送</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
placeholder="请输入"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="permanentAdmin"
|
||||
title="是否为管理员"
|
||||
@ -71,7 +71,7 @@
|
||||
@change-time="changeDate('temporaryEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="temporaryAdmin"
|
||||
title="是否为管理员"
|
||||
@ -98,7 +98,7 @@
|
||||
<view class="mt-3">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="cycleAdmin"
|
||||
title="是否为管理员"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
placeholder="请输入"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="permanentAdmin"
|
||||
title="是否为管理员"
|
||||
@ -63,7 +63,7 @@
|
||||
@change-time="changeDate('temporaryEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="temporaryAdmin"
|
||||
title="是否为管理员"
|
||||
@ -83,7 +83,7 @@
|
||||
<view class="mt-3">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="cycleAdmin"
|
||||
title="是否为管理员"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
placeholder="请输入"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="permanentAdmin"
|
||||
title="是否为管理员"
|
||||
@ -71,7 +71,7 @@
|
||||
@change-time="changeDate('temporaryEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="temporaryAdmin"
|
||||
title="是否为管理员"
|
||||
@ -98,7 +98,7 @@
|
||||
<view class="mt-3">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="cycleAdmin"
|
||||
title="是否为管理员"
|
||||
|
||||
@ -89,7 +89,10 @@
|
||||
placeholder="请输入姓名"
|
||||
@change-input="changeName('single', $event)"
|
||||
></LockInput>
|
||||
<view class="text mt-5 mb-50rpx">单次钥匙有效期为1小时,只能使用一次</view>
|
||||
<view class="text mt-5">单次钥匙有效期为1小时,只能使用一次</view>
|
||||
<view class="text" style="margin-bottom: 50rpx">
|
||||
小程序暂不支持邮箱登录,若接收者账号为邮箱可先使用星星锁APP登录,绑定手机号后可使用小程序登录
|
||||
</view>
|
||||
<view class="button" @click="createKey('single')">发送</view>
|
||||
</swiper-item>
|
||||
<swiper-item>
|
||||
@ -108,7 +111,10 @@
|
||||
<view style="margin-top: 20rpx">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="text mt-5 mb-50rpx">接收者可以在有效期内的固定时间段里,不限次数使用</view>
|
||||
<view class="text mt-5">接收者可以在有效期内的固定时间段里,不限次数使用</view>
|
||||
<view class="text" style="margin-bottom: 50rpx"
|
||||
>小程序暂不支持邮箱登录,若接收者账号为邮箱可先使用星星锁APP登录,绑定手机号后可使用小程序登录</view
|
||||
>
|
||||
<view class="button" @click="createKey('cycle')">发送</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
placeholder="请输入"
|
||||
@change-input="changeName('permanent', $event)"
|
||||
></LockInput>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="permanentAdmin"
|
||||
title="是否为管理员"
|
||||
@ -71,7 +71,7 @@
|
||||
@change-time="changeDate('temporaryEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="temporaryAdmin"
|
||||
title="是否为管理员"
|
||||
@ -99,7 +99,7 @@
|
||||
<view class="mt-3">
|
||||
<LockCycle @change="changeCycle"></LockCycle>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="cycleAdmin"
|
||||
title="是否为管理员"
|
||||
@ -123,11 +123,11 @@
|
||||
<script setup>
|
||||
import { getCurrentInstance, ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkPalmVeinNameRequest } from '@/api/palmVein'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
@change-time="changeDate('customEndTime', $event)"
|
||||
></LockDatetimePicker>
|
||||
</view>
|
||||
<view class="mt-3">
|
||||
<view class="mt-3" v-if="$bluetooth.currentLockInfo.userType === 110301">
|
||||
<LockSwitch
|
||||
:value="customAdmin"
|
||||
title="是否为管理员"
|
||||
|
||||
@ -251,6 +251,7 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!info.value.type) {
|
||||
const data = {
|
||||
startDate: updateTime(startDate.value, startTimeText.value),
|
||||
@ -263,6 +264,11 @@
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.faceName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.faceName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -292,7 +292,7 @@
|
||||
}
|
||||
|
||||
if (data.list[i].faceType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
data.list[i].timeText = timeFormat(data.list[i].createDate, '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') +
|
||||
|
||||
200
pages/faceSetting/faceSetting.vue
Normal file
@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base">
|
||||
<view>面容开锁</view>
|
||||
<switch
|
||||
@click="changeCheck"
|
||||
:checked="check"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base mt-1"
|
||||
@click="showDistance = true"
|
||||
v-if="distance !== null"
|
||||
>
|
||||
<view class="max-w-500">
|
||||
<view>感应距离</view>
|
||||
<view class="text-xs">{{ distanceColumns[0][distanceIndex].text }}</view>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">{{ distanceColumns[0][distanceIndex].name }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
@click="showEnErrUnlock = true"
|
||||
class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base mt-1"
|
||||
v-if="enErrUnlock !== null"
|
||||
>
|
||||
<view class="max-w-500">
|
||||
<view>防误开</view>
|
||||
<view class="text-xs">{{ enErrUnlockColumns[0][enErrUnlock].text }}</view>
|
||||
</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">{{ enErrUnlockColumns[0][enErrUnlock].name }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="pos-fixed bottom-[calc(env(safe-area-inset-bottom)+48rpx)] mx-3 py-5 px-3 bg-white text-sm rounded-md"
|
||||
>
|
||||
<view class="text-base font-bold mb-3">添加和使用面容开锁时:</view>
|
||||
<view>1、请尽量保持单人在门前操作;</view>
|
||||
<view>2、请站立在门锁正前方约0.5~0.8米,面向门锁;</view>
|
||||
<view>3、请保持脸部无遮挡,露出五官;</view>
|
||||
<view>4、面容识别异常时,可触摸数字键盘任意按键,手动重启人脸识别。</view>
|
||||
</view>
|
||||
<up-picker
|
||||
:show="showDistance"
|
||||
:columns="distanceColumns"
|
||||
:defaultIndex="[distanceIndex]"
|
||||
title="感应距离"
|
||||
keyName="name"
|
||||
:itemHeight="70"
|
||||
:visibleItemCount="5"
|
||||
@close="showDistance = false"
|
||||
@cancel="showDistance = false"
|
||||
@confirm="confirmDistance"
|
||||
></up-picker>
|
||||
<up-picker
|
||||
:show="showEnErrUnlock"
|
||||
:columns="enErrUnlockColumns"
|
||||
:defaultIndex="[enErrUnlock]"
|
||||
title="防误开"
|
||||
keyName="name"
|
||||
:itemHeight="70"
|
||||
:visibleItemCount="5"
|
||||
@close="showEnErrUnlock = false"
|
||||
@cancel="showEnErrUnlock = false"
|
||||
@confirm="confirmEnErrUnlock"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { updateLockSettingRequest } from '@/api/setting'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const showDistance = ref(false)
|
||||
const showEnErrUnlock = ref(false)
|
||||
const distanceIndex = ref(0)
|
||||
|
||||
const check = ref(false)
|
||||
const distance = ref(null)
|
||||
const enErrUnlock = ref(null)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const distanceColumns = ref([
|
||||
[
|
||||
{ name: '远距离', value: 3, text: '感应到门前约1.5米有人时,将自动启动面部识别开锁。' },
|
||||
{ name: '中距离', value: 2, text: '感应到门前约0.8米有人时,将自动启动面部识别开锁。' },
|
||||
{ name: '近距离', value: 1, text: '感应到门前约0.5米有人时,将自动启动面部识别开锁。' },
|
||||
{ name: '关闭', value: 0, text: '感应距离已关闭,需手动触摸键盘任意键,进行面部识别开锁。' }
|
||||
]
|
||||
])
|
||||
|
||||
const enErrUnlockColumns = ref([])
|
||||
|
||||
onMounted(() => {
|
||||
const list = []
|
||||
for (let i = 0; i <= 30; i++) {
|
||||
list.push({
|
||||
name: i + '秒',
|
||||
value: i,
|
||||
text:
|
||||
i === 0
|
||||
? '防误开已关闭,关门后仍可使用面容开锁'
|
||||
: `防误开已打开,开锁后${i}秒内不可使用面容开锁`
|
||||
})
|
||||
}
|
||||
enErrUnlockColumns.value = [list]
|
||||
check.value = $bluetooth.currentLockSetting.lockSettingInfo.faceSwitch === 1
|
||||
distance.value = $bluetooth.currentLockSetting.lockSettingInfo.faceInductionDistance
|
||||
distanceIndex.value = distanceColumns.value[0].findIndex(item => item.value === distance.value)
|
||||
enErrUnlock.value = $bluetooth.currentLockSetting.lockSettingInfo.faceEnErrUnlock
|
||||
})
|
||||
|
||||
const confirmEnErrUnlock = data => {
|
||||
enErrUnlock.value = data.indexs[0]
|
||||
showEnErrUnlock.value = false
|
||||
change('faceEnErrUnlock', enErrUnlock.value)
|
||||
}
|
||||
|
||||
const confirmDistance = data => {
|
||||
distance.value = distanceColumns.value[0][data.indexs[0]].value
|
||||
distanceIndex.value = data.indexs[0]
|
||||
showDistance.value = false
|
||||
change('faceInductionDistance', distance.value)
|
||||
}
|
||||
|
||||
const changeCheck = () => {
|
||||
check.value = !check.value
|
||||
change('faceSwitch', check.value ? 1 : 0)
|
||||
}
|
||||
|
||||
const change = async (type, value) => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '设置中'
|
||||
})
|
||||
const featureBit = 5
|
||||
const { code } = await $bluetooth.updateSetting({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
featureBit,
|
||||
params: [check.value ? 1 : 0, distance.value, enErrUnlock.value],
|
||||
withParams: true
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
[type]: value
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockSettingInfo: {
|
||||
...$bluetooth.currentLockSetting.lockSettingInfo,
|
||||
autoLock: check.value ? 1 : 0,
|
||||
autoLockSecond: value.value
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '设置成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '设置失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -8,7 +8,7 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.fingerprintName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.fingerprintName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -134,6 +134,10 @@
|
||||
}
|
||||
|
||||
const changeCoerced = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
|
||||
@ -291,7 +291,7 @@
|
||||
}
|
||||
|
||||
if (data.list[i].fingerprintType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
data.list[i].timeText = timeFormat(data.list[i].createDate, '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') +
|
||||
|
||||
@ -518,6 +518,13 @@
|
||||
this.getBluetoothStatus()
|
||||
return
|
||||
}
|
||||
if (lock.keyStatus === 110403) {
|
||||
uni.showToast({
|
||||
title: '您的钥匙未生效',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (lock.keyStatus === 110412) {
|
||||
uni.showToast({
|
||||
title: '钥匙已过期',
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
<view class="item" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title" style="width: 350rpx">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentKeyInfo.keyName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{
|
||||
$lock.currentKeyInfo.keyName
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -91,11 +93,17 @@
|
||||
</view>
|
||||
<view class="m-4 flex items-center justify-between text-base">
|
||||
<view
|
||||
v-if="$lock.currentKeyInfo.keyType !== 3"
|
||||
:class="[$lock.currentKeyInfo.keyStatus === 110405 ? 'text-#63b8af' : 'text-red']"
|
||||
@click="freeze"
|
||||
>{{ $lock.currentKeyInfo.keyStatus === 110405 ? '解冻' : '冻结' }}</view
|
||||
>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.userType === 110301 &&
|
||||
$lock.currentKeyInfo.keyType !== 3 &&
|
||||
$lock.currentKeyInfo.keyType !== 4
|
||||
"
|
||||
:class="[$lock.currentKeyInfo.keyRight === 1 ? 'text-red' : 'text-#63b8af']"
|
||||
@click="authorize"
|
||||
>{{ $lock.currentKeyInfo.keyRight === 1 ? '取消授权管理员' : '授权管理员' }}</view
|
||||
@ -157,7 +165,7 @@
|
||||
<view>{{
|
||||
$lock.currentKeyInfo.keyRight === 1
|
||||
? '取消授权会在用户APP连网后生效'
|
||||
: '授权用户拥有管理员的大部分权限,比如发送要是、发送密码'
|
||||
: '授权用户拥有管理员的大部分权限,比如发送钥匙、发送密码'
|
||||
}}</view>
|
||||
</view>
|
||||
</up-modal>
|
||||
|
||||
@ -176,7 +176,7 @@
|
||||
mask: true
|
||||
})
|
||||
const that = this
|
||||
const { code } = await deleteKeyRequest({
|
||||
const { code, message } = await deleteKeyRequest({
|
||||
keyId: that.deleteKeyId,
|
||||
includeUnderlings: that.checked ? 1 : 0
|
||||
})
|
||||
@ -195,7 +195,7 @@
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu" v-if="currentLockInfo.keyRight === 1">
|
||||
<view class="menu">
|
||||
<view class="menu-title">
|
||||
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
||||
<view>功能</view>
|
||||
@ -57,19 +57,19 @@
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'keyList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/tabbar_key_select.png"></image>
|
||||
<image class="menu-main-image" src="/static/images/icon_key.png"></image>
|
||||
<view>电子钥匙</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.password || currentLockInfo.keyRight === 1"
|
||||
v-if="currentLockInfo.lockFeature.password && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'passwordList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_lock_transparent.png"></image>
|
||||
<image class="menu-main-image" src="/static/images/icon_password_green.png"></image>
|
||||
<view>密码</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.icCard || currentLockInfo.keyRight === 1"
|
||||
v-if="currentLockInfo.lockFeature.icCard && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'cardList' })"
|
||||
>
|
||||
@ -77,7 +77,7 @@
|
||||
<view>卡</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.fingerprint || currentLockInfo.keyRight === 1"
|
||||
v-if="currentLockInfo.lockFeature.fingerprint && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'fingerprintList' })"
|
||||
>
|
||||
@ -86,7 +86,7 @@
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
currentLockInfo.lockFeature.bluetoothRemoteControl || currentLockInfo.keyRight === 1
|
||||
currentLockInfo.lockFeature.bluetoothRemoteControl && currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'remoteList' })"
|
||||
@ -95,18 +95,15 @@
|
||||
<view>遥控</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.d3Face || currentLockInfo.keyRight === 1"
|
||||
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>
|
||||
<image class="menu-main-image" src="/static/images/icon_face.png"></image>
|
||||
<view>人脸</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.palmVein || currentLockInfo.keyRight === 1"
|
||||
v-if="currentLockInfo.lockFeature.palmVein && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'palmVeinList' })"
|
||||
>
|
||||
@ -250,7 +247,7 @@
|
||||
if (this.pending) {
|
||||
return
|
||||
}
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline) {
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline && type !== 'close') {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
@ -265,7 +262,7 @@
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline) {
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline && type !== 'close') {
|
||||
const result = await this.getNetToken()
|
||||
if (!result) {
|
||||
this.$refs.loading.close()
|
||||
@ -322,9 +319,14 @@
|
||||
this.backAndToast('单次钥匙已在被使用后删除', 1)
|
||||
}
|
||||
}
|
||||
} else if (code === 7) {
|
||||
uni.showToast({
|
||||
title: `钥匙过期`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === 13) {
|
||||
uni.showToast({
|
||||
title: `只能在循环时间内操作门锁`,
|
||||
title: `钥匙当前不可用`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === -1) {
|
||||
@ -523,10 +525,9 @@
|
||||
margin-bottom: 48rpx;
|
||||
|
||||
.menu-main-image {
|
||||
filter: sepia(100%) saturate(10000%) hue-rotate(180deg) brightness(0.1);
|
||||
margin-bottom: 10rpx;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
272
pages/lockInfo/lockInfo.vue
Normal file
@ -0,0 +1,272 @@
|
||||
<template>
|
||||
<view class="break-all">
|
||||
<view class="py-3 px-4 bg-white flex items-center justify-between text-base">
|
||||
<view>锁编号</view>
|
||||
<view>{{ $bluetooth.currentLockSetting.lockBasicInfo.lockName }}</view>
|
||||
</view>
|
||||
<view class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx">
|
||||
<view>MAC/ID</view>
|
||||
<view
|
||||
>{{ $bluetooth.currentLockSetting.lockBasicInfo.mac }}/{{
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.lockId
|
||||
}}</view
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mt-2.5"
|
||||
@click="toJump('syncElec')"
|
||||
>
|
||||
<view>电量</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2"
|
||||
>{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantity }}%</view
|
||||
>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx">
|
||||
<view>有效期</view>
|
||||
<view>
|
||||
<view v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyType === 4"
|
||||
>{{ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'yyyy-mm-dd') }}~{{
|
||||
timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'yyyy-mm-dd')
|
||||
}}</view
|
||||
>
|
||||
<view v-else-if="$bluetooth.currentLockSetting.lockBasicInfo.keyType === 2">
|
||||
<view>{{
|
||||
timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
<view>{{
|
||||
timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view v-else-if="$bluetooth.currentLockSetting.lockBasicInfo.keyType === 3">单次</view>
|
||||
<view v-else>永久</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx"
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyType === 4"
|
||||
>
|
||||
<view>有效日</view>
|
||||
<view>
|
||||
<view>{{
|
||||
$lock.convertWeekDaysToChineseString($bluetooth.currentLockSetting.lockBasicInfo.weekDays)
|
||||
}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx"
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyType === 4"
|
||||
>
|
||||
<view>有效时间</view>
|
||||
<view>
|
||||
<view
|
||||
>{{ timeFormat($bluetooth.currentLockSetting.lockBasicInfo.startDate, 'h:M') }}~{{
|
||||
timeFormat($bluetooth.currentLockSetting.lockBasicInfo.endDate, 'h:M')
|
||||
}}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-2.5"></view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
@click="() => $refs.modalInput.open()"
|
||||
>
|
||||
<view>名称</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">{{
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.lockAlias
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
@click="toJump('selectGroup')"
|
||||
>
|
||||
<view>锁分组</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">{{
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.groupName
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.isLockOwner === 1"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
@click="() => $refs.modalPassword.open()"
|
||||
>
|
||||
<view>管理员开锁密码</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2">{{ $bluetooth.currentLockSetting.lockBasicInfo.adminPwd }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="py-3 px-4 bg-white flex items-center justify-between text-base">
|
||||
<view>位置信息</view>
|
||||
<view class="flex items-center max-w-400">
|
||||
<view>{{ $bluetooth.currentLockSetting.lockBasicInfo.address }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="请输入名称"
|
||||
:autoClose="false"
|
||||
placeholder="请输入名称"
|
||||
:value="$bluetooth.currentLockSetting.lockBasicInfo.lockAlias"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
<ModalInput
|
||||
ref="modalPassword"
|
||||
title="修改密码"
|
||||
:autoClose="false"
|
||||
:maxlength="9"
|
||||
type="number"
|
||||
placeholder="密码为6-9位数字"
|
||||
:value="$bluetooth.currentLockSetting.lockBasicInfo.adminPwd"
|
||||
@confirm="changePassword"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { ref } from 'vue'
|
||||
import test from 'uview-plus/libs/function/test'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { updateAdminPasswordRequest, updateLockNameRequest } from '@/api/setting'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const modalInput = ref(null)
|
||||
const modalPassword = ref(null)
|
||||
const pending = ref(false)
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入名称',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await updateLockNameRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
lockName: name
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockBasicInfo: {
|
||||
...$bluetooth.currentLockSetting.lockBasicInfo,
|
||||
lockAlias: name
|
||||
}
|
||||
})
|
||||
$bluetooth.updateCurrentLockInfo({
|
||||
...$bluetooth.currentLockInfo,
|
||||
lockAlias: name
|
||||
})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changePassword = async password => {
|
||||
if (!test.rangeLength(password, [6, 9])) {
|
||||
uni.showToast({
|
||||
title: '密码为6-9位纯数字',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
|
||||
const params = {
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
adminPwd: password,
|
||||
userCountLimit: 0xffff,
|
||||
startDate: Math.floor($bluetooth.currentLockSetting.lockBasicInfo.startDate / 1000),
|
||||
endDate: Math.floor($bluetooth.currentLockSetting.lockBasicInfo.endDate / 1000)
|
||||
}
|
||||
const { code } = await $bluetooth.updateAdminPassword(params)
|
||||
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateAdminPasswordRequest({
|
||||
password,
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
passwordType: '1'
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalPassword.value.close()
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockBasicInfo: {
|
||||
...$bluetooth.currentLockSetting.lockBasicInfo,
|
||||
adminPwd: password
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toJump = name => {
|
||||
$basic.routeJump({
|
||||
name
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
138
pages/lockSound/lockSound.vue
Normal file
@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base">
|
||||
<view class="item-title">锁声音</view>
|
||||
<switch
|
||||
@click="changeCheck"
|
||||
:checked="check"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="m-4 text-sm">
|
||||
功能开启后,你将可以智能锁的提示音。包括电量过低,密码错误等提示。
|
||||
</view>
|
||||
<view class="bg-white" v-if="check">
|
||||
<view class="py-3 px-4">请选择音量</view>
|
||||
<view
|
||||
v-for="(item, index) in volumeList"
|
||||
:key="index"
|
||||
class="py-3 px-4 border-t-solid border-t-gray-200 border-t-2 flex items-center justify-between"
|
||||
@click="value = index + 1"
|
||||
>
|
||||
<view>{{ item }}</view>
|
||||
<view
|
||||
class="rounded-50% w-40 h-40 border-solid border-2 flex items-center justify-center"
|
||||
:class="[value === index + 1 ? 'border-#002ce5' : 'border-black']"
|
||||
>
|
||||
<up-icon v-if="value === index + 1" name="checkmark" color="#002ce5"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
:class="[canUpdate ? 'bg-#63b8af' : 'bg-#a3a3a3']"
|
||||
class="mt-4 rounded-3xl w-600 h-80 line-height-80rpx text-center mx-75rpx text-white text-xl font-bold"
|
||||
@click="update"
|
||||
>
|
||||
保存
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { updateLockSettingRequest } from '@/api/setting'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const check = ref(false)
|
||||
|
||||
const volumeList = ['低', '较低', '中', '较高', '高']
|
||||
|
||||
const value = ref(0)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const canUpdate = computed(() => {
|
||||
return (
|
||||
($bluetooth.currentLockSetting.lockSettingInfo.lockSound === 1) !== check.value ||
|
||||
value.value !== $bluetooth.currentLockSetting.lockSettingInfo.lockSoundVolume
|
||||
)
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
check.value = $bluetooth.currentLockSetting.lockSettingInfo.lockSound === 1
|
||||
value.value = $bluetooth.currentLockSetting.lockSettingInfo.lockSoundVolume
|
||||
})
|
||||
|
||||
const update = async () => {
|
||||
if (!canUpdate.value) return
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '保存中'
|
||||
})
|
||||
const featureBit = 33
|
||||
const { code } = await $bluetooth.updateSetting({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
featureBit,
|
||||
params: [value.value],
|
||||
withParams: true
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
lockSound: check.value ? 1 : 0,
|
||||
lockSoundVolume: value.value
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockSettingInfo: {
|
||||
...$bluetooth.currentLockSetting.lockSettingInfo,
|
||||
lockSound: check.value ? 1 : 0,
|
||||
lockSoundVolume: value.value
|
||||
}
|
||||
})
|
||||
$basic.backAndToast('更新成功')
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeCheck = () => {
|
||||
check.value = !check.value
|
||||
if (!check.value) {
|
||||
value.value = 0
|
||||
} else {
|
||||
value.value = 3
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -8,7 +8,7 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.palmVeinName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.palmVeinName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -126,6 +126,10 @@
|
||||
const pending = ref(false)
|
||||
|
||||
const changeCoerced = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
|
||||
@ -296,7 +296,7 @@
|
||||
}
|
||||
|
||||
if (data.list[i].palmVeinType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
data.list[i].timeText = timeFormat(data.list[i].createDate, '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') +
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ $lock.currentPasswordInfo.keyboardPwdName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{
|
||||
$lock.currentPasswordInfo.keyboardPwdName
|
||||
}}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -52,7 +54,11 @@
|
||||
timeFormat($lock.currentPasswordInfo.sendDate, 'yyyy-mm-dd h:M')
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="item !py-2" style="margin-top: 20rpx">
|
||||
<view
|
||||
class="item !py-2"
|
||||
style="margin-top: 20rpx"
|
||||
v-if="$lock.currentPasswordInfo.isCustom === 1"
|
||||
>
|
||||
<view class="item-title">是否为管理员</view>
|
||||
<switch
|
||||
@click="disabled"
|
||||
@ -62,10 +68,18 @@
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view class="item" style="margin-top: 20rpx" @click="toRecordList">
|
||||
<view
|
||||
v-if="$lock.currentPasswordInfo.keyboardPwdType !== 4"
|
||||
class="item"
|
||||
style="margin-top: 20rpx"
|
||||
@click="toRecordList"
|
||||
>
|
||||
<view class="item-title">操作记录</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
<view class="text-sm text-#262626 mt-3 mx-4" v-if="$lock.currentPasswordInfo.isCustom !== 1">
|
||||
密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。
|
||||
</view>
|
||||
<view class="button" @click="deletePassword">删除</view>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
@ -155,6 +169,12 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<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">
|
||||
<view class="bg-[rgba(0,0,0,0.35)] rounded-full px-2 py-1.5 mr-5">
|
||||
<picker :value="timeText" mode="date" @change="changeDate">
|
||||
<up-icon
|
||||
:label="timeText"
|
||||
@ -16,7 +16,7 @@
|
||||
</picker>
|
||||
</view>
|
||||
<view>事件:</view>
|
||||
<view class="bg-[rgba(0,0,0,0.5)] rounded-full px-2 py-1.5 mr-1">
|
||||
<view class="bg-[rgba(0,0,0,0.35)] rounded-full px-2 py-1.5 mr-1">
|
||||
<picker
|
||||
:value="index"
|
||||
mode="selector"
|
||||
@ -35,6 +35,14 @@
|
||||
></up-icon>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="ml-a">
|
||||
<up-icon
|
||||
name="question-circle-fill"
|
||||
@click="tip"
|
||||
size="52"
|
||||
color="rgba(0,0,0,0.35)"
|
||||
></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
@ -91,9 +99,20 @@
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="button">
|
||||
<view class="button-reset" @click="reset">清空记录</view>
|
||||
<view class="button-create" @click="syncRecord">同步记录</view>
|
||||
<view class="button" v-if="$bluetooth.currentLockInfo.keyRight === 1">
|
||||
<view
|
||||
class="button-reset"
|
||||
@click="reset"
|
||||
v-if="$bluetooth.currentLockInfo.userType === 110301"
|
||||
>清空记录</view
|
||||
>
|
||||
<view
|
||||
class="button-create"
|
||||
:style="{ width: $bluetooth.currentLockInfo.userType === 110301 ? '300rpx' : '650rpx' }"
|
||||
@click="syncRecord"
|
||||
>
|
||||
同步记录</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -138,6 +157,15 @@
|
||||
videoContext.requestFullScreen({ direction: 0 })
|
||||
}
|
||||
|
||||
const tip = () => {
|
||||
uni.showModal({
|
||||
title: '操作记录未显示',
|
||||
content: '锁未联网,开门记录无法实时上传,可以点击同步记录进行读取',
|
||||
showCancel: false,
|
||||
confirmText: '我知道了'
|
||||
})
|
||||
}
|
||||
|
||||
const previewImage = url => {
|
||||
uni.previewImage({
|
||||
urls: [url]
|
||||
@ -305,6 +333,10 @@
|
||||
}
|
||||
|
||||
const syncRecord = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '同步中'
|
||||
})
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<view class="item" style="margin-top: 2rpx" @click="() => $refs.modalInput.open()">
|
||||
<view class="item-title">姓名</view>
|
||||
<view class="flex items-center">
|
||||
<view class="item-content mr-2">{{ info.remoteName }}</view>
|
||||
<view class="item-content mr-2 max-w-550 break-all">{{ info.remoteName }}</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -294,7 +294,7 @@
|
||||
}
|
||||
|
||||
if (data.list[i].remoteType === 1) {
|
||||
data.list[i].timeText = timeFormat(data.list[i].startDate, 'yyyy-mm-dd hh:MM') + ' 永久'
|
||||
data.list[i].timeText = timeFormat(data.list[i].createDate, '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') +
|
||||
|
||||
140
pages/selectGroup/selectGroup.vue
Normal file
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
:scroll-y="true"
|
||||
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
|
||||
>
|
||||
<view class="pb-[calc(env(safe-area-inset-bottom)+250rpx)]">
|
||||
<view
|
||||
v-for="(item, index) in list"
|
||||
:key="index"
|
||||
:style="{ marginTop: index !== 0 ? '4rpx' : '0' }"
|
||||
@click="changeGroup(item)"
|
||||
class="flex items-center justify-between h-80 bg-white text-base"
|
||||
>
|
||||
<view class="ml-4 max-w-550 break-all">{{ item.keyGroupName }}</view>
|
||||
<view
|
||||
class="mr-4"
|
||||
v-if="item.keyGroupId === $bluetooth.currentLockSetting.lockBasicInfo.groupId"
|
||||
>
|
||||
<up-icon name="checkbox-mark" color="#63b8af" size="40rpx"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view
|
||||
@click="() => $refs.modalInput.open()"
|
||||
class="bg-#63b8af text-white pos-fixed bottom-[calc(env(safe-area-inset-bottom)+48rpx)] rounded-44rpx w-686 ml-4 h-88 line-height-88rpx text-lg font-bold text-center"
|
||||
>创建新分组</view
|
||||
>
|
||||
<ModalInput
|
||||
ref="modalInput"
|
||||
title="创建新分组"
|
||||
:autoClose="false"
|
||||
placeholder="请输入名称"
|
||||
@confirm="changeName"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { createGroupRequest, getGroupListRequest, setGroupRequest } from '@/api/setting'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
|
||||
const $basic = useBasicStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const deviceInfo = ref(null)
|
||||
const modalInput = ref(null)
|
||||
const list = ref([])
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
getList()
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
const { code, data, message } = await getGroupListRequest({ type: 1 })
|
||||
if (code === 0) {
|
||||
list.value = data.list
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeGroup = async item => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '设置中'
|
||||
})
|
||||
const { code, message } = await setGroupRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
groupId: item.keyGroupId
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockBasicInfo: {
|
||||
...$bluetooth.currentLockSetting.lockBasicInfo,
|
||||
groupId: item.keyGroupId,
|
||||
groupName: item.keyGroupName
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '设置锁分组成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const changeName = async name => {
|
||||
if (!name) {
|
||||
uni.showToast({
|
||||
title: '请输入名称',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
const { code, message } = await createGroupRequest({
|
||||
groupName: name
|
||||
})
|
||||
pending.value = false
|
||||
if (code === 0) {
|
||||
modalInput.value.close()
|
||||
getList()
|
||||
uni.showToast({
|
||||
title: '创建成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
@ -1,98 +1,178 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="view">
|
||||
<view class="view-button">
|
||||
<view style="width: 150rpx">名称</view>
|
||||
<view class="view-button" style="padding: 20rpx 0">
|
||||
<view class="info" style="line-height: 40rpx; word-break: break-all">{{
|
||||
currentLockInfo.lockAlias
|
||||
}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>锁编号</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{ currentLockInfo.name }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>MAC/ID</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{ currentLockInfo.mac }}/{{ currentLockInfo.lockId }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>电量</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{ currentLockInfo.electricQuantity }}%</view>
|
||||
<view v-if="requestFinished" class="pb-100rpx">
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base"
|
||||
@click="toJump('lockInfo')"
|
||||
>
|
||||
<view class="item-title">基本信息</view>
|
||||
<view><up-icon name="arrow-right"></up-icon></view>
|
||||
</view>
|
||||
<view class="mt-2.5"></view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
v-if="$bluetooth.currentLockSetting.lockFeature.autoLock === 1"
|
||||
@click="toJump('autoLock')"
|
||||
>
|
||||
<view class="item-title">自动闭锁</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">
|
||||
{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.autoLock === 1
|
||||
? $bluetooth.currentLockSetting.lockSettingInfo.autoLockSecond + 's'
|
||||
: '已关闭'
|
||||
}}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view" v-if="currentLockInfo.userType === 110301">
|
||||
<view class="view-button">
|
||||
<view>开锁时是否需联网</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<up-switch
|
||||
v-model="unlockApp"
|
||||
:size="40"
|
||||
activeColor="#63b8af"
|
||||
:asyncChange="true"
|
||||
@change="changeUnlockApp"
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
></up-switch>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.lockSound === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
@click="toJump('lockSound')"
|
||||
>
|
||||
<view class="item-title">锁声音</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">
|
||||
{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.lockSound === 1
|
||||
? volumeList[$bluetooth.currentLockSetting.lockSettingInfo.lockSoundVolume - 1]
|
||||
: '已关闭'
|
||||
}}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view">
|
||||
<view v-if="currentLockInfo.keyType === 4">
|
||||
<view class="view-button">
|
||||
<view>有效期</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info"
|
||||
>{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd') }}~{{
|
||||
timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd')
|
||||
}}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>有效日</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info">{{ convertWeekDaysToChineseString(currentLockInfo.weekDays) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="view-line"></view>
|
||||
<view class="view-button">
|
||||
<view>有效时间</view>
|
||||
<view class="view-button" style="padding: 0">
|
||||
<view class="info"
|
||||
>{{ timeFormat(currentLockInfo.startDate, 'h:M') }}~{{
|
||||
timeFormat(currentLockInfo.endDate, 'h:M')
|
||||
}}</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view class="view-button">
|
||||
<view>有效期</view>
|
||||
<view class="view-button" style="padding: 10rpx 0">
|
||||
<view class="info" v-if="currentLockInfo.keyType === 2" style="line-height: 40rpx">
|
||||
<view>{{ timeFormat(currentLockInfo.startDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
<view>{{ timeFormat(currentLockInfo.endDate, 'yyyy-mm-dd h:M') }}</view>
|
||||
</view>
|
||||
<view class="info" v-if="currentLockInfo.keyType === 3">单次</view>
|
||||
<view class="info" v-if="currentLockInfo.keyType === 1">永久</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.antiPrySwitch === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base"
|
||||
@click="toUpdateSetting('antiPrySwitch')"
|
||||
>
|
||||
<view class="item-title">防撬报警</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">
|
||||
{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.antiPrySwitch === 1 ? '已开启' : '已关闭'
|
||||
}}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="button-logout" @click="deleteLock">删除</view>
|
||||
<view class="mt-2.5"></view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.remoteUnlock === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mb-4rpx"
|
||||
@click="toUpdateSetting('remoteUnlock')"
|
||||
>
|
||||
<view class="item-title">远程开锁</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">
|
||||
{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.remoteUnlock === 1 ? '已开启' : '已关闭'
|
||||
}}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.resetSwitch === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.isLockOwner === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base"
|
||||
@click="toUpdateSetting('resetSwitch')"
|
||||
>
|
||||
<view class="item-title">重置键</view>
|
||||
<view class="flex items-center">
|
||||
<view class="mr-2 max-w-400">
|
||||
{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo.resetSwitch === 1 ? '已开启' : '已关闭'
|
||||
}}
|
||||
</view>
|
||||
<up-icon name="arrow-right"></up-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-2.5"></view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.d3Face === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base"
|
||||
@click="toJump('faceSetting')"
|
||||
>
|
||||
<view class="item-title">面容开锁</view>
|
||||
<view><up-icon name="arrow-right"></up-icon></view>
|
||||
</view>
|
||||
<!-- <view class="py-3 px-4 bg-white flex items-center justify-between text-base">-->
|
||||
<!-- <view class="item-title">消息提醒</view>-->
|
||||
<!-- <view><up-icon name="arrow-right"></up-icon></view>-->
|
||||
<!-- </view>-->
|
||||
<view class="mt-2.5"></view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base"
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.unlockReminder === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.isLockOwner === 1
|
||||
"
|
||||
>
|
||||
<view class="item-title">开锁提醒</view>
|
||||
<switch
|
||||
@click="changeSetting('unlockReminder')"
|
||||
:checked="$bluetooth.currentLockSetting.lockSettingInfo.unlockReminder === 1"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockSetting.lockFeature.appUnlockOnline === 1 &&
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.isLockOwner === 1
|
||||
"
|
||||
class="py-3 px-4 bg-white !py-2 flex items-center justify-between text-base mt-4rpx"
|
||||
>
|
||||
<view class="item-title">开锁时是否需联网</view>
|
||||
<switch
|
||||
@click="changeSetting('appUnlockOnline')"
|
||||
:checked="$bluetooth.currentLockSetting.lockSettingInfo.appUnlockOnline === 1"
|
||||
class="transform-scale-90"
|
||||
:disabled="true"
|
||||
color="#002ce5"
|
||||
/>
|
||||
</view>
|
||||
<view
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mt-2.5"
|
||||
@click="toJump('lockDate')"
|
||||
>
|
||||
<view class="item-title">锁时间</view>
|
||||
<view><up-icon name="arrow-right"></up-icon></view>
|
||||
</view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockSetting.lockBasicInfo.keyRight === 1"
|
||||
class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx"
|
||||
@click="toJump('uploadLockData')"
|
||||
>
|
||||
<view class="item-title">上传数据</view>
|
||||
<view><up-icon name="arrow-right"></up-icon></view>
|
||||
</view>
|
||||
<!-- <view class="py-3 px-4 bg-white flex items-center justify-between text-base mt-4rpx">-->
|
||||
<!-- <view class="item-title">锁升级</view>-->
|
||||
<!-- <view><up-icon name="arrow-right"></up-icon></view>-->
|
||||
<!-- </view>-->
|
||||
<view
|
||||
class="mt-4 rounded-3xl w-600 h-80 line-height-80rpx text-center mx-75rpx bg-#ec433c text-white text-xl font-bold"
|
||||
@click="deleteLock"
|
||||
>删除</view
|
||||
>
|
||||
<up-modal
|
||||
:show="showModal"
|
||||
title="是否删除授权管理员钥匙?"
|
||||
@ -111,188 +191,250 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
import { timeFormat } from 'uview-plus'
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { deleteLockRequest } from '@/api/lock'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { updateLockSettingRequest } from '@/api/lockSetting'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { getLockSettingRequest, updateLockSettingRequest } from '@/api/setting'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
unlockApp: 0,
|
||||
showModal: false,
|
||||
checked: false
|
||||
const $user = useUserStore()
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $lock = useLockStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const showModal = ref(false)
|
||||
const checked = ref(false)
|
||||
const requestFinished = ref(false)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const volumeList = ['低', '较低', '中', '较高', '高']
|
||||
|
||||
onMounted(async () => {
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
})
|
||||
const { code, data, message } = await getLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId
|
||||
})
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
requestFinished.value = true
|
||||
$bluetooth.updateCurrentLockSetting(data)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const toUpdateSetting = key => {
|
||||
$basic.routeJump({
|
||||
name: 'updateSetting',
|
||||
params: {
|
||||
key
|
||||
},
|
||||
events: {
|
||||
changeSetting() {
|
||||
changeSetting(key)
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useUserStore, ['userInfo']),
|
||||
...mapState(useBluetoothStore, ['keyId', 'currentLockInfo']),
|
||||
...mapState(useLockStore, ['lockSearch'])
|
||||
},
|
||||
onLoad() {
|
||||
this.unlockApp = this.currentLockInfo.lockSetting.appUnlockOnline
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
|
||||
...mapActions(useLockStore, [
|
||||
'getLockList',
|
||||
'updateLockSearch',
|
||||
'convertWeekDaysToChineseString'
|
||||
]),
|
||||
...mapActions(useBasicStore, ['backAndToast', 'getNetworkType']),
|
||||
changeRadio() {
|
||||
this.checked = !this.checked
|
||||
},
|
||||
cancelModal() {
|
||||
this.showModal = false
|
||||
this.checked = false
|
||||
},
|
||||
async confirmModal() {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const that = this
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: that.keyId,
|
||||
includeUnderlings: that.checked ? 1 : 0
|
||||
})
|
||||
that.showModal = false
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
that.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
async changeUnlockApp(value) {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '更新中',
|
||||
mask: true
|
||||
})
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
appUnlockOnline: value
|
||||
})
|
||||
if (code === 0) {
|
||||
this.unlockApp = value
|
||||
const data = this.currentLockInfo
|
||||
data.lockSetting.appUnlockOnline = value
|
||||
this.updateCurrentLockInfo(data)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteLock() {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
const that = this
|
||||
if (this.currentLockInfo.userType !== 110301 && this.currentLockInfo.keyRight === 1) {
|
||||
this.showModal = true
|
||||
return
|
||||
}
|
||||
const message =
|
||||
that.currentLockInfo.userType === 110301
|
||||
? '删除锁后,所有信息都会一起删除,确定删除锁吗?'
|
||||
: '确定删除该钥匙吗?'
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: message,
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
if (that.currentLockInfo.userType === 110301) {
|
||||
const { code: resetDeviceCode } = await that.resetDevice({
|
||||
name: that.currentLockInfo.name,
|
||||
authUid: that.userInfo.uid.toString(),
|
||||
keyId: that.keyId.toString()
|
||||
})
|
||||
if (resetDeviceCode === 0 || resetDeviceCode === -2) {
|
||||
const { code } = await deleteLockRequest({
|
||||
lockId: that.currentLockInfo.lockId
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
that.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (resetDeviceCode === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: that.keyId
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
that.updateLockSearch({
|
||||
...that.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
that.getLockList(that.lockSearch)
|
||||
that.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changeSetting = async key => {
|
||||
if (pending.value) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
let featureBit
|
||||
if (key === 'unlockReminder') {
|
||||
featureBit = 47
|
||||
} else if (key === 'appUnlockOnline') {
|
||||
featureBit = 55
|
||||
} else if (key === 'remoteUnlock') {
|
||||
featureBit = 28
|
||||
} else if (key === 'resetSwitch') {
|
||||
featureBit = 31
|
||||
} else if (key === 'antiPrySwitch') {
|
||||
featureBit = 30
|
||||
}
|
||||
const { code } = await $bluetooth.updateSetting({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
featureBit,
|
||||
featureEnable: $bluetooth.currentLockSetting.lockSettingInfo[key] === 1 ? 0 : 1,
|
||||
withParams: false
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (code === 0) {
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
[key]: $bluetooth.currentLockSetting.lockSettingInfo[key] === 1 ? 0 : 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockSettingInfo: {
|
||||
...$bluetooth.currentLockSetting.lockSettingInfo,
|
||||
[key]: $bluetooth.currentLockSetting.lockSettingInfo[key] === 1 ? 0 : 1
|
||||
}
|
||||
})
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '更新失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const toJump = name => {
|
||||
$basic.routeJump({
|
||||
name
|
||||
})
|
||||
}
|
||||
|
||||
const changeRadio = () => {
|
||||
checked.value = !checked.value
|
||||
}
|
||||
|
||||
const cancelModal = () => {
|
||||
showModal.value = false
|
||||
checked.value = false
|
||||
}
|
||||
|
||||
const confirmModal = async () => {
|
||||
uni.showLoading({
|
||||
title: '删除中',
|
||||
mask: true
|
||||
})
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: $lock.keyId,
|
||||
includeUnderlings: checked.value ? 1 : 0
|
||||
})
|
||||
showModal.value = false
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
$basic.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const deleteLock = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
if (
|
||||
$bluetooth.currentLockInfo.userType !== 110301 &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
) {
|
||||
showModal.value = true
|
||||
return
|
||||
}
|
||||
const message =
|
||||
$bluetooth.currentLockInfo.userType === 110301
|
||||
? '删除锁后,所有信息都会一起删除,确定删除锁吗?'
|
||||
: '确定删除该钥匙吗?'
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: message,
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '删除中'
|
||||
})
|
||||
if ($bluetooth.currentLockInfo.userType === 110301) {
|
||||
const { code: resetDeviceCode } = await $bluetooth.resetDevice({
|
||||
name: $bluetooth.currentLockInfo.name,
|
||||
authUid: $user.userInfo.uid.toString(),
|
||||
keyId: $bluetooth.keyId.toString()
|
||||
})
|
||||
if (resetDeviceCode === 0 || resetDeviceCode === -2) {
|
||||
const { code } = await deleteLockRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
$basic.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (resetDeviceCode === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const { code } = await deleteKeyRequest({
|
||||
keyId: $bluetooth.keyId
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.hideLoading()
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
$basic.backAndToast('删除成功', 2)
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: 'message',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@ -300,61 +442,3 @@
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.button-logout {
|
||||
position: absolute;
|
||||
border-radius: 46rpx;
|
||||
bottom: calc(env(safe-area-inset-bottom) + 30rpx);
|
||||
width: 600rpx;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
text-align: center;
|
||||
margin-left: 75rpx;
|
||||
background: #ec433c;
|
||||
color: #ffffff;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.view {
|
||||
margin-top: 32rpx;
|
||||
border-radius: 32rpx;
|
||||
width: 710rpx;
|
||||
margin-left: 20rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.view-button {
|
||||
padding: 0 40rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: #292826;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
|
||||
.view-line {
|
||||
width: 100%;
|
||||
height: 3rpx;
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
radio .wx-radio-input.wx-radio-input-checked {
|
||||
border: none;
|
||||
background: #c1885a;
|
||||
}
|
||||
radio .wx-radio-input.wx-radio-input-checked::before {
|
||||
border-radius: 50%; /* 圆角 */
|
||||
width: 28rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
|
||||
height: 28rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
|
||||
line-height: 28rpx;
|
||||
text-align: center;
|
||||
font-size: 20rpx; /* 对勾大小 30rpx */
|
||||
color: #fff; /* 对勾颜色 白色 */
|
||||
background: #c1885a;
|
||||
transform: translate(-50%, -50%) scale(1);
|
||||
}
|
||||
</style>
|
||||
|
||||
115
pages/syncElec/syncElec.vue
Normal file
@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="mx-4 pt-5 text-base">
|
||||
<view>电量信息可以通过网关远程更新,或通过手机蓝牙在锁旁边更新</view>
|
||||
<view class="mt-5"
|
||||
>电池1电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantity }}%</view
|
||||
>
|
||||
<view class="mt-2" v-if="$bluetooth.currentLockSetting?.lockFeature?.isSupportBackupBattery"
|
||||
>电池2电量:{{ $bluetooth.currentLockSetting.lockBasicInfo.electricQuantityStandby }}%</view
|
||||
>
|
||||
<view class="mt-2">
|
||||
电量更新时间:{{
|
||||
timeFormat(
|
||||
$bluetooth.currentLockSetting.lockBasicInfo.electricQuantityDate,
|
||||
'yyyy-mm-dd h:M'
|
||||
)
|
||||
}}
|
||||
</view>
|
||||
<view
|
||||
@click="updateElectricQuantity"
|
||||
class="w-full bg-#63b8af text-white line-height-80rpx h-80 rounded-40rpx text-center mt-4 text-lg font-bold"
|
||||
>更新</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { updateElectricQuantityRequest } from '@/api/room'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $lock = useLockStore()
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const updateElectricQuantity = async () => {
|
||||
if (pending.value) return
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
})
|
||||
pending.value = true
|
||||
const { code } = await $bluetooth.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
const date = new Date()
|
||||
const timestamp = $bluetooth.serverTimestamp - date.getTimezoneOffset() * 60
|
||||
const { code: lockStatus, data } = await $bluetooth.getLockStatus({
|
||||
name: $bluetooth.currentLockInfo.lockId.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
nowTime: $bluetooth.serverTimestamp,
|
||||
localTime: timestamp
|
||||
})
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (lockStatus === 0) {
|
||||
const { code: resultCode, data: resultData } = await updateElectricQuantityRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
electricQuantity: data.lockConfig.electricQuantity,
|
||||
electricQuantityStandby: data.lockConfig.electricQuantityStandby
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
if (resultCode === 0) {
|
||||
$bluetooth.updateCurrentLockInfo({
|
||||
...$bluetooth.currentLockInfo,
|
||||
electricQuantity: data.lockConfig.electricQuantity,
|
||||
electricQuantityStandby: data.lockConfig.electricQuantityStandby,
|
||||
electricQuantityDate: resultData.electricQuantityDate
|
||||
})
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockBasicInfo: {
|
||||
...$bluetooth.currentLockSetting.lockBasicInfo,
|
||||
electricQuantity: data.lockConfig.electricQuantity,
|
||||
electricQuantityStandby: data.lockConfig.electricQuantityStandby,
|
||||
electricQuantityDate: resultData.electricQuantityDate
|
||||
}
|
||||
})
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -133,6 +133,19 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (endDate.value <= new Date().getTime()) {
|
||||
uni.showToast({
|
||||
title: '失效时间需晚于当前时间',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="bg-#faecc9 text-#bc9839 text-24rpx text-center h-40px line-height-40px"
|
||||
>锁未联网,开门记录无法实时上传,可以点击同步记录进行读取
|
||||
</view>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
scroll-y="true"
|
||||
@ -159,6 +162,10 @@
|
||||
}
|
||||
|
||||
const syncRecord = async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '同步中'
|
||||
})
|
||||
|
||||
66
pages/updateSetting/updateSetting.vue
Normal file
@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="mx-4 pt-5 text-base">
|
||||
<view class="text-sm">
|
||||
<view v-if="type === 'remoteUnlock'">
|
||||
功能开启后,你将可以通过网关远程开锁。此功能的开启和关闭只能在锁附近通过手机蓝牙进行。
|
||||
</view>
|
||||
<view v-if="type === 'resetSwitch'">
|
||||
开启后,可通过长按锁上的设置键重新上电,用APP重新添加
|
||||
</view>
|
||||
<view v-if="type === 'resetSwitch'" class="mt-3">
|
||||
关闭后,重置键无效,锁要通过app删除后才能重新添加
|
||||
</view>
|
||||
<view v-if="type === 'antiPrySwitch'"> 开启后,锁被撬动时,会发出报警声 </view>
|
||||
<view class="mt-5 font-bold"
|
||||
>当前模式:{{
|
||||
$bluetooth.currentLockSetting.lockSettingInfo[type] === 1 ? '已开启' : '已关闭'
|
||||
}}</view
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
@click="update"
|
||||
class="w-full bg-#63b8af text-white line-height-80rpx h-80 rounded-40rpx text-center mt-4 text-lg font-bold"
|
||||
>{{ $bluetooth.currentLockSetting.lockSettingInfo[type] === 1 ? '关闭' : '开启' }}</view
|
||||
>
|
||||
</view></view
|
||||
>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getCurrentInstance, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
|
||||
const type = ref('')
|
||||
|
||||
const update = async () => {
|
||||
eventChannel.emit('changeSetting', {})
|
||||
}
|
||||
|
||||
onLoad(options => {
|
||||
type.value = options.key
|
||||
let title = ''
|
||||
if (type.value === 'resetSwitch') {
|
||||
title = '重置键'
|
||||
} else if (type.value === 'remoteUnlock') {
|
||||
title = '远程开锁'
|
||||
} else if (type.value === 'antiPrySwitch') {
|
||||
title = '防撬报警'
|
||||
}
|
||||
uni.setNavigationBarTitle({
|
||||
title
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
116
pages/uploadLockData/uploadLockData.vue
Normal file
@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="mx-4 pt-5 text-base">
|
||||
<view class="text-sm">
|
||||
<view> 本操作将上传锁内数据到服务器,过程可能需要几分钟,请耐心等待 </view>
|
||||
</view>
|
||||
<view
|
||||
@click="asyncData"
|
||||
class="w-full bg-#63b8af text-white line-height-80rpx h-80 rounded-40rpx text-center mt-4 text-lg font-bold"
|
||||
>
|
||||
开始
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { lockDataUploadRequest } from '@/api/setting'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const progress = ref(0)
|
||||
const page = ref(0)
|
||||
|
||||
const list = ref([])
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const typeList = ['password', 'card', 'fingerprint', 'face', 'palmVein', 'remote', 'setting']
|
||||
|
||||
const asyncData = async (flag = false) => {
|
||||
if (pending.value && !flag) return
|
||||
pending.value = true
|
||||
uni.showLoading({
|
||||
title: `上传中${progress.value}/7`
|
||||
})
|
||||
const { code, data } = await $bluetooth.getLockDataList({
|
||||
type: typeList[progress.value],
|
||||
page: page.value,
|
||||
lockId: $bluetooth.currentLockInfo.lockName.toString(),
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
countReq: 10
|
||||
})
|
||||
if (code === 0) {
|
||||
if (typeList[progress.value] === 'setting') {
|
||||
const { code: resultCode } = await lockDataUploadRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
uploadType: 1,
|
||||
records: data.list
|
||||
})
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (resultCode === 0) {
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
list.value = list.value.concat(data.list)
|
||||
if (data.size === 10) {
|
||||
page.value++
|
||||
} else if (data.size === 0) {
|
||||
page.value = 0
|
||||
list.value = []
|
||||
progress.value++
|
||||
} else {
|
||||
const { code: resultCode } = await lockDataUploadRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
uploadType: 2,
|
||||
recordType: progress.value + 2,
|
||||
records: list.value
|
||||
})
|
||||
if (resultCode !== 0) {
|
||||
pending.value = false
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
page.value = 1
|
||||
list.value = []
|
||||
progress.value++
|
||||
}
|
||||
await asyncData(true)
|
||||
} else {
|
||||
pending.value = false
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '上传失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: $uni-bg-color-grey;
|
||||
}
|
||||
</style>
|
||||
|
Before Width: | Height: | Size: 758 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 909 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 460 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
static/images/icon_key.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
static/images/icon_password_green.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.4 KiB |
@ -251,6 +251,51 @@ const pages = [
|
||||
name: 'temporaryDate',
|
||||
path: '/pages/temporaryDate/temporaryDate',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'lockInfo',
|
||||
path: '/pages/lockInfo/lockInfo',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'syncElec',
|
||||
path: '/pages/syncElec/syncElec',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'selectGroup',
|
||||
path: '/pages/selectGroup/selectGroup',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'updateSetting',
|
||||
path: '/pages/updateSetting/updateSetting',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'lockSound',
|
||||
path: '/pages/lockSound/lockSound',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'autoLock',
|
||||
path: '/pages/autoLock/autoLock',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'faceSetting',
|
||||
path: '/pages/faceSetting/faceSetting',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'lockDate',
|
||||
path: '/pages/lockDate/lockDate',
|
||||
tabBar: false
|
||||
},
|
||||
{
|
||||
name: 'uploadLockData',
|
||||
path: '/pages/uploadLockData/uploadLockData',
|
||||
tabBar: false
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@ -40,7 +40,23 @@ const cmdIds = {
|
||||
// 清理用户
|
||||
cleanUser: 0x300c,
|
||||
// 扩展命令
|
||||
expandCmd: 0x3030
|
||||
expandCmd: 0x3030,
|
||||
// 校准时间
|
||||
calibrationTime: 0x30f0,
|
||||
// 锁密码列表
|
||||
lockPasswordList: 0x3021,
|
||||
// 锁卡片列表
|
||||
lockCardList: 0x3022,
|
||||
// 锁指纹列表
|
||||
lockFingerprintList: 0x3023,
|
||||
// 锁人脸列表
|
||||
lockFaceList: 0x3024,
|
||||
// 锁掌静脉列表
|
||||
lockPalmVeinList: 0x3025,
|
||||
// 锁遥控列表
|
||||
lockRemoteList: 0x3026,
|
||||
// 锁设置列表
|
||||
lockSettingList: 0x302a
|
||||
}
|
||||
|
||||
// 子命令ID
|
||||
@ -84,7 +100,13 @@ const subCmdIds = {
|
||||
// 注册掌纹取消
|
||||
registerPalmVeinCancel: 44,
|
||||
// 同步操作记录
|
||||
syncRecord: 41
|
||||
syncRecord: 41,
|
||||
// 更新管理员密码
|
||||
updateAdminPassword: 2,
|
||||
// 修改设置
|
||||
updateSetting: 70,
|
||||
// 修改设置带参数
|
||||
updateSettingWithParams: 72
|
||||
}
|
||||
|
||||
export const useBluetoothStore = defineStore('ble', {
|
||||
@ -103,6 +125,8 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
deviceList: [],
|
||||
// 当前锁信息
|
||||
currentLockInfo: {},
|
||||
// 当前锁设置信息
|
||||
currentLockSetting: null,
|
||||
// 消息序号
|
||||
messageCount: 1,
|
||||
// 是否初始化蓝牙
|
||||
@ -315,6 +339,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
mode: 'ecb',
|
||||
output: 'array'
|
||||
})
|
||||
const length = binaryData[10] * 256 + binaryData[11]
|
||||
console.log('ecb解密后的数据', decrypted)
|
||||
|
||||
const cmdId = decrypted[0] * 256 + decrypted[1]
|
||||
@ -354,11 +379,16 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
),
|
||||
lockConfig
|
||||
})
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2],
|
||||
data: { lockConfig }
|
||||
})
|
||||
console.log('获取锁状态成功', that.currentLockInfo.lockConfig)
|
||||
} else {
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
}
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
break
|
||||
case cmdIds.addUser:
|
||||
that.updateCurrentLockInfo({
|
||||
@ -505,6 +535,33 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
characteristicValueCallback({ code: decrypted[2] })
|
||||
}
|
||||
break
|
||||
case subCmdIds.updateAdminPassword:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
token: decrypted.slice(5, 9)
|
||||
})
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
break
|
||||
case subCmdIds.updateSetting:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
token: decrypted.slice(5, 9)
|
||||
})
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
break
|
||||
case subCmdIds.updateSettingWithParams:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
token: decrypted.slice(5, 9)
|
||||
})
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -512,7 +569,9 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
case cmdIds.openDoor:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
token: decrypted.slice(2, 6)
|
||||
token: decrypted.slice(2, 6),
|
||||
electricQuantity: decrypted[7],
|
||||
electricQuantityStandby: decrypted[9]
|
||||
})
|
||||
console.log('开门', decrypted[6], that.currentLockInfo.token)
|
||||
log.info({
|
||||
@ -568,6 +627,40 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
})
|
||||
}
|
||||
break
|
||||
case cmdIds.calibrationTime:
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2]
|
||||
})
|
||||
break
|
||||
case cmdIds.lockPasswordList:
|
||||
case cmdIds.lockCardList:
|
||||
case cmdIds.lockFingerprintList:
|
||||
case cmdIds.lockFaceList:
|
||||
case cmdIds.lockPalmVeinList:
|
||||
case cmdIds.lockRemoteList:
|
||||
case cmdIds.lockSettingList:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
token: decrypted.slice(3, 7)
|
||||
})
|
||||
let data
|
||||
if (cmdId === cmdIds.lockSettingList) {
|
||||
data = {
|
||||
list: decrypted.slice(7, length)
|
||||
}
|
||||
} else {
|
||||
data = {
|
||||
page: decrypted[7],
|
||||
size: decrypted[8],
|
||||
list: decrypted.slice(9, length)
|
||||
}
|
||||
}
|
||||
console.log(1234, cmdId, data)
|
||||
characteristicValueCallback({
|
||||
code: decrypted[2],
|
||||
data
|
||||
})
|
||||
break
|
||||
default:
|
||||
that.updateCurrentLockInfo({
|
||||
...that.currentLockInfo,
|
||||
@ -884,6 +977,11 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
console.log('更新当前锁信息', lockInfo)
|
||||
this.currentLockInfo = lockInfo
|
||||
},
|
||||
// 更新当前锁设置信息
|
||||
updateCurrentLockSetting(lockSetting) {
|
||||
console.log('更新当前锁设置信息', lockSetting)
|
||||
this.currentLockSetting = lockSetting
|
||||
},
|
||||
// 订阅设备特征值改变
|
||||
notifyBluetoothCharacteristicValueChange() {
|
||||
const that = this
|
||||
@ -2306,7 +2404,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
console.log('写入未执行', this.bluetoothStatus)
|
||||
this.getBluetoothStatus()
|
||||
return {
|
||||
code: -1
|
||||
code: -21
|
||||
}
|
||||
}
|
||||
|
||||
@ -2494,26 +2592,6 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
},
|
||||
// 获取操作记录
|
||||
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)
|
||||
@ -2551,6 +2629,26 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
const { keyId, uid } = data
|
||||
|
||||
const logsCount = 10
|
||||
@ -2612,6 +2710,393 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
await this.writeBLECharacteristicValue(packageArray)
|
||||
|
||||
return this.getWriteResult(this.syncSingleRecord, data)
|
||||
},
|
||||
// 更新管理员密码
|
||||
async updateAdminPassword(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
|
||||
}
|
||||
}
|
||||
|
||||
let { keyId, uid, adminPwd, userCountLimit, startDate, endDate } = data
|
||||
|
||||
const length = 2 + 1 + 1 + 40 + 20 + 2 + 20 + 2 + 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.updateAdminPassword
|
||||
|
||||
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] = 1 / 256
|
||||
contentArray[65] = 1 % 256
|
||||
|
||||
for (let i = 0; i < adminPwd.length; i++) {
|
||||
contentArray[i + 66] = adminPwd.charCodeAt(i)
|
||||
}
|
||||
|
||||
contentArray[86] = (userCountLimit || 0xffff) / 256
|
||||
contentArray[87] = (userCountLimit || 0xffff) % 256
|
||||
|
||||
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 88)
|
||||
|
||||
contentArray.set(this.timestampToArray(startDate), 92)
|
||||
contentArray.set(this.timestampToArray(endDate), 96)
|
||||
|
||||
contentArray[100] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
keyId + uid,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.signKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, 101)
|
||||
|
||||
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.updateAdminPassword, data)
|
||||
},
|
||||
// 更新设置
|
||||
async updateSetting(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
|
||||
}
|
||||
}
|
||||
|
||||
let { keyId, uid, featureBit, featureEnable, withParams, params } = data
|
||||
|
||||
let length = 2 + 1 + 1 + 40 + 20 + 4 + 1 + 16
|
||||
if (withParams) {
|
||||
length += 2 + params.length
|
||||
} else {
|
||||
length += 2
|
||||
}
|
||||
const headArray = this.createPackageHeader(3, length)
|
||||
const contentArray = new Uint8Array(length)
|
||||
|
||||
contentArray[0] = cmdIds.expandCmd / 256
|
||||
contentArray[1] = cmdIds.expandCmd % 256
|
||||
|
||||
contentArray[2] = withParams ? subCmdIds.updateSettingWithParams : subCmdIds.updateSetting
|
||||
|
||||
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] = featureBit
|
||||
|
||||
if (withParams) {
|
||||
contentArray[65] = params.length
|
||||
contentArray.set(new Uint8Array(params), 66)
|
||||
} else {
|
||||
contentArray[65] = featureEnable
|
||||
}
|
||||
|
||||
contentArray.set(
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
withParams ? 66 + params.length : 66
|
||||
)
|
||||
|
||||
contentArray[withParams ? 70 + params.length : 70] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
keyId + uid,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.signKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, withParams ? 71 + params.length : 71)
|
||||
|
||||
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.updateSetting, data)
|
||||
},
|
||||
// 校准时间
|
||||
async calibrationTime(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
|
||||
}
|
||||
}
|
||||
|
||||
let { lockId, uid, nowTime } = data
|
||||
const length = 2 + 40 + 20 + 4 + 4 + 1 + 16
|
||||
const headArray = this.createPackageHeader(3, length)
|
||||
const contentArray = new Uint8Array(length)
|
||||
|
||||
contentArray[0] = cmdIds.calibrationTime / 256
|
||||
contentArray[1] = cmdIds.calibrationTime % 256
|
||||
|
||||
for (let i = 0; i < lockId.length; i++) {
|
||||
contentArray[i + 2] = lockId.charCodeAt(i)
|
||||
}
|
||||
|
||||
for (let i = 0; i < uid.length; i++) {
|
||||
contentArray[i + 42] = uid.charCodeAt(i)
|
||||
}
|
||||
|
||||
contentArray.set(this.timestampToArray(nowTime), 62)
|
||||
|
||||
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 66)
|
||||
contentArray[70] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
lockId + uid,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.signKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, 71)
|
||||
|
||||
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||
mode: 'ecb',
|
||||
output: 'array'
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
this.writeBLECharacteristicValue(packageArray)
|
||||
|
||||
return this.getWriteResult(this.calibrationTime, data)
|
||||
},
|
||||
// 获取锁数据列表
|
||||
async getLockDataList(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
|
||||
}
|
||||
}
|
||||
|
||||
let { lockId, uid, page, countReq, type } = data
|
||||
let length = 2 + 40 + 20 + 4 + 1 + 16
|
||||
if (type !== 'setting') {
|
||||
length += 2
|
||||
}
|
||||
const headArray = this.createPackageHeader(3, length)
|
||||
const contentArray = new Uint8Array(length)
|
||||
|
||||
let id
|
||||
|
||||
if (type === 'password') {
|
||||
id = cmdIds.lockPasswordList
|
||||
} else if (type === 'card') {
|
||||
id = cmdIds.lockCardList
|
||||
} else if (type === 'fingerprint') {
|
||||
id = cmdIds.lockFingerprintList
|
||||
} else if (type === 'face') {
|
||||
id = cmdIds.lockFaceList
|
||||
} else if (type === 'remote') {
|
||||
id = cmdIds.lockRemoteList
|
||||
} else if (type === 'palmVein') {
|
||||
id = cmdIds.lockPalmVeinList
|
||||
} else if (type === 'setting') {
|
||||
id = cmdIds.lockSettingList
|
||||
}
|
||||
|
||||
contentArray[0] = id / 256
|
||||
contentArray[1] = id % 256
|
||||
|
||||
for (let i = 0; i < lockId.length; i++) {
|
||||
contentArray[i + 2] = lockId.charCodeAt(i)
|
||||
}
|
||||
|
||||
for (let i = 0; i < uid.length; i++) {
|
||||
contentArray[i + 42] = uid.charCodeAt(i)
|
||||
}
|
||||
|
||||
if (type !== 'setting') {
|
||||
contentArray[62] = page
|
||||
contentArray[63] = countReq
|
||||
|
||||
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 64)
|
||||
contentArray[68] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
lockId + uid,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.signKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, 69)
|
||||
} else {
|
||||
contentArray.set(this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]), 62)
|
||||
contentArray[66] = 16
|
||||
|
||||
const md5Array = this.md5Encrypte(
|
||||
lockId + uid,
|
||||
this.currentLockInfo.token || new Uint8Array([0, 0, 0, 0]),
|
||||
this.currentLockInfo.signKey
|
||||
)
|
||||
|
||||
contentArray.set(md5Array, 67)
|
||||
}
|
||||
|
||||
const cebArray = sm4.encrypt(contentArray, this.currentLockInfo.commKey, {
|
||||
mode: 'ecb',
|
||||
output: 'array'
|
||||
})
|
||||
|
||||
const packageArray = this.createPackageEnd(headArray, cebArray)
|
||||
this.writeBLECharacteristicValue(packageArray)
|
||||
|
||||
return this.getWriteResult(this.getLockDataList, data)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||