feat:客服

This commit is contained in:
李伊帆
2026-10-16 08:53:45 +08:00
parent e22ebd6bef
commit 03839624ed
42 changed files with 1375 additions and 483 deletions

View File

@@ -1,5 +1,6 @@
import { onUnload } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { getErrorMessage } from '@/utils/api-error'
import {
closeBleConnection,
ensureBleConnection,
@@ -130,22 +131,32 @@ export function useDeviceBluetoothSync(context: DeviceBluetoothSyncContext) {
const runtimePatch = context.getRuntimePatch()
const signalLevel = rssiToSignalLevel(foundDevice?.RSSI)
const hasBleData = Object.keys(blePayload).length > 0
await updateDeviceRuntime({
deviceId,
...runtimePatch,
...blePayload,
status: '1',
bluetoothConnected: '1',
signalLevel,
})
if (!Object.keys(blePayload).length) {
setSyncText('蓝牙已连接,等待设备上报数据…')
} else {
setSyncText('刚刚更新 · 数据实时同步中')
try {
await updateDeviceRuntime({
deviceId,
...runtimePatch,
...blePayload,
status: '1',
bluetoothConnected: '1',
signalLevel,
})
if (!hasBleData) {
setSyncText('蓝牙已连接,等待设备上报数据…')
} else {
setSyncText('刚刚更新 · 数据实时同步中')
}
await context.onSynced?.()
} catch (apiErr) {
if (hasBleData) {
setSyncText('蓝牙已连接 · 本地数据已更新,云端同步失败')
} else {
setSyncText(
`蓝牙已连接 · 云端同步失败:${getErrorMessage(apiErr, '请检查网络')}`,
)
}
}
await context.onSynced?.()
return true
} catch (err) {
setSyncText(getBluetoothErrorMessage(err))