2025-02-20 15:50:28 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view>
|
|
|
|
|
|
<view class="mx-4 pt-5 text-base">
|
|
|
|
|
|
<view class="text-sm">
|
2025-03-06 19:05:48 +08:00
|
|
|
|
<view> 本操作将上传锁内数据到服务器,过程可能需要几分钟,请耐心等待</view>
|
2025-02-20 15:50:28 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view
|
|
|
|
|
|
@click="asyncData"
|
2025-07-29 11:07:43 +08:00
|
|
|
|
class="w-full bg-#4777ee text-white line-height-80rpx h-80 rounded-40rpx text-center mt-4 text-lg font-bold"
|
2025-02-20 15:50:28 +08:00
|
|
|
|
>
|
|
|
|
|
|
开始
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
2025-02-27 11:29:53 +08:00
|
|
|
|
import { getLockSettingRequest, lockDataUploadRequest } from '@/api/setting'
|
2025-03-06 19:05:48 +08:00
|
|
|
|
import { useBasicStore } from '@/stores/basic'
|
2025-02-20 15:50:28 +08:00
|
|
|
|
|
|
|
|
|
|
const $bluetooth = useBluetoothStore()
|
|
|
|
|
|
const $user = useUserStore()
|
2025-03-06 19:05:48 +08:00
|
|
|
|
const $basic = useBasicStore()
|
2025-02-20 15:50:28 +08:00
|
|
|
|
|
|
|
|
|
|
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
|
2025-03-06 19:05:48 +08:00
|
|
|
|
const netWork = await $basic.getNetworkType()
|
|
|
|
|
|
if (!netWork) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-02-20 15:50:28 +08:00
|
|
|
|
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
|
|
|
|
|
|
})
|
|
|
|
|
|
$bluetooth.closeBluetoothConnection()
|
|
|
|
|
|
if (resultCode === 0) {
|
2025-02-27 11:29:53 +08:00
|
|
|
|
const { code, data } = await getLockSettingRequest({
|
|
|
|
|
|
lockId: $bluetooth.currentLockInfo.lockId
|
|
|
|
|
|
})
|
2025-07-08 16:19:19 +08:00
|
|
|
|
pending.value = false
|
2025-02-27 11:29:53 +08:00
|
|
|
|
if (code === 0) {
|
2025-03-05 18:51:12 +08:00
|
|
|
|
if (data.lockSettingInfo.catEyeConfig[0]) {
|
2025-03-06 19:05:48 +08:00
|
|
|
|
data.lockSettingInfo.catEyeConfig[0].catEyeModeConfig.recordTime = Number(
|
|
|
|
|
|
data.lockSettingInfo.catEyeConfig[0].catEyeModeConfig.recordTime
|
|
|
|
|
|
)
|
|
|
|
|
|
data.lockSettingInfo.catEyeConfig[0].catEyeModeConfig.detectionDistance = Number(
|
|
|
|
|
|
data.lockSettingInfo.catEyeConfig[0].catEyeModeConfig.detectionDistance
|
|
|
|
|
|
)
|
2025-03-05 18:51:12 +08:00
|
|
|
|
}
|
2025-02-27 11:29:53 +08:00
|
|
|
|
$bluetooth.updateCurrentLockSetting(data)
|
|
|
|
|
|
}
|
2025-07-08 10:24:49 +08:00
|
|
|
|
uni.hideLoading()
|
2025-02-20 15:50:28 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '上传成功',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2025-07-08 16:19:19 +08:00
|
|
|
|
pending.value = false
|
2025-07-08 10:24:49 +08:00
|
|
|
|
uni.hideLoading()
|
2025-02-20 15:50:28 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '上传失败,请重试',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-07-08 16:19:19 +08:00
|
|
|
|
progress.value = 0
|
|
|
|
|
|
page.value = 0
|
|
|
|
|
|
list.value = []
|
2025-02-20 15:50:28 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
list.value = list.value.concat(data.list)
|
2025-07-08 10:24:49 +08:00
|
|
|
|
if (list.value.length === 0) {
|
|
|
|
|
|
page.value = 0
|
|
|
|
|
|
list.value = []
|
|
|
|
|
|
progress.value++
|
|
|
|
|
|
return await asyncData(true)
|
|
|
|
|
|
}
|
2025-02-20 15:50:28 +08:00
|
|
|
|
if (data.size === 10) {
|
|
|
|
|
|
page.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'
|
|
|
|
|
|
})
|
2025-07-08 16:19:19 +08:00
|
|
|
|
progress.value = 0
|
|
|
|
|
|
page.value = 0
|
|
|
|
|
|
list.value = []
|
2025-02-20 15:50:28 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-02-27 11:29:53 +08:00
|
|
|
|
page.value = 0
|
2025-02-20 15:50:28 +08:00
|
|
|
|
list.value = []
|
|
|
|
|
|
progress.value++
|
|
|
|
|
|
}
|
|
|
|
|
|
await asyncData(true)
|
2025-03-07 10:06:47 +08:00
|
|
|
|
} else if (code === -21) {
|
2025-03-06 19:05:48 +08:00
|
|
|
|
pending.value = false
|
|
|
|
|
|
$bluetooth.closeBluetoothConnection()
|
|
|
|
|
|
uni.hideLoading()
|
2025-07-08 16:19:19 +08:00
|
|
|
|
progress.value = 0
|
|
|
|
|
|
page.value = 0
|
|
|
|
|
|
list.value = []
|
2025-02-20 15:50:28 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
pending.value = false
|
|
|
|
|
|
$bluetooth.closeBluetoothConnection()
|
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
|
uni.showToast({
|
2025-03-07 10:06:47 +08:00
|
|
|
|
title: '上传失败,请保持在锁附近',
|
2025-02-20 15:50:28 +08:00
|
|
|
|
icon: 'none'
|
|
|
|
|
|
})
|
2025-07-08 16:19:19 +08:00
|
|
|
|
progress.value = 0
|
|
|
|
|
|
page.value = 0
|
|
|
|
|
|
list.value = []
|
2025-02-20 15:50:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
page {
|
|
|
|
|
|
background-color: $uni-bg-color-grey;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|