feat:绑定设备和设备详情

This commit is contained in:
李伊帆
2026-10-10 11:11:44 +08:00
parent 179bd3b66c
commit d4b02745e1
64 changed files with 3526 additions and 221 deletions

View File

@@ -45,18 +45,21 @@ import { BIND_STEPS } from '../use-add-device'
import PairCheckList from './components/pair-check-list/index.vue'
import PairDeviceSummary from './components/pair-device-summary/index.vue'
import PairHero from './components/pair-hero/index.vue'
import { readBindDeviceContext } from '../add-device.types'
import { usePairDevice } from './use-pair-device'
const { currentStep, device, progress, etaSeconds, checkItems, onCancelPair } =
usePairDevice()
onLoad((query) => {
if (query?.name) {
device.value.name = decodeURIComponent(String(query.name))
}
if (query?.serial) {
device.value.serialMasked = decodeURIComponent(String(query.serial))
}
const ctx = readBindDeviceContext(query ?? {})
if (ctx.name) device.value.name = ctx.name
if (ctx.serialMasked) device.value.serialMasked = ctx.serialMasked
if (ctx.deviceNo) device.value.deviceNo = ctx.deviceNo
if (ctx.productId != null) device.value.productId = ctx.productId
if (ctx.model) device.value.model = ctx.model
if (ctx.imei) device.value.imei = ctx.imei
if (ctx.mac) device.value.mac = ctx.mac
})
</script>

View File

@@ -10,4 +10,9 @@ export interface PairCheckItem {
export interface PairDeviceInfo {
name: string
serialMasked: string
deviceNo: string
productId?: number
model?: string
imei?: string
mac?: string
}

View File

@@ -1,9 +1,11 @@
import { onUnmounted, ref, watch } from 'vue'
import { buildBindDeviceQuery } from '../add-device.types'
import type { PairCheckItem, PairDeviceInfo } from './pair.types'
const DEFAULT_DEVICE: PairDeviceInfo = {
name: 'Z2 空气净化器',
serialMasked: '****A3B2',
name: '',
serialMasked: '',
deviceNo: '',
}
export function usePairDevice(initial?: Partial<PairDeviceInfo>) {
@@ -45,10 +47,15 @@ export function usePairDevice(initial?: Partial<PairDeviceInfo>) {
if (value < 100 || navigated) return
navigated = true
const d = device.value
const q = [
`name=${encodeURIComponent(d.name)}`,
`serial=${encodeURIComponent(d.serialMasked)}`,
].join('&')
const q = buildBindDeviceQuery({
deviceNo: d.deviceNo,
name: d.name,
serialMasked: d.serialMasked,
productId: d.productId,
model: d.model,
imei: d.imei,
mac: d.mac,
})
setTimeout(() => {
uni.redirectTo({ url: `/pages/add-device/complete/index?${q}` })
}, 600)