修复馆内导览楼层点位展示
This commit is contained in:
@@ -45,7 +45,9 @@
|
||||
:outdoor-nav-polylines="outdoorNavPolylines"
|
||||
@search-tap="handleGuideSearchTap"
|
||||
@mode-change="handleModeChange"
|
||||
@floor-request="handleFloorRequest"
|
||||
@floor-change="handleFloorChange"
|
||||
@floor-switch-failed="handleFloorSwitchFailed"
|
||||
@indoor-view-change="handleIndoorViewChange"
|
||||
@poi-click="handleGuidePoiClick"
|
||||
@selection-clear="handleGuideSelectionClear"
|
||||
@@ -291,7 +293,12 @@ const initialTopTab = (): GuideTopTab => topTabFromHash() || 'guide'
|
||||
const is3DMode = ref(true)
|
||||
const guideOutdoorState = ref<'home' | 'entrance'>('home')
|
||||
const indoorView = ref<GuideIndoorView>('overview')
|
||||
const activeGuideFloor = ref('1F')
|
||||
const activeGuideFloor = ref('')
|
||||
const requestedFloorId = ref('')
|
||||
const requestedFloorLabel = ref('')
|
||||
const loadingFloorId = ref('')
|
||||
const renderedFloorId = ref('')
|
||||
const failedFloorId = ref('')
|
||||
const selectedGuidePoi = ref<GuideRenderPoi | null>(null)
|
||||
|
||||
// 状态
|
||||
@@ -330,6 +337,12 @@ const indoorNavAssetBaseUrl = guideUseCase.getAssetBaseUrl()
|
||||
const indoorModelSource = guideUseCase.getModelSource()
|
||||
const guideFloors = ref<MuseumFloor[]>([])
|
||||
const normalizeGuideFloorId = (labelOrId: string) => guideUseCase.normalizeFloorId(labelOrId)
|
||||
const getGuideFloorById = (floorId: string) => (
|
||||
guideFloors.value.find((floor) => floor.id === floorId)
|
||||
)
|
||||
const getGuideFloorLabel = (floorId: string) => (
|
||||
getGuideFloorById(floorId)?.label || floorId
|
||||
)
|
||||
const indoorLayerMode = computed<LayerDisplayMode>(() => (
|
||||
indoorView.value === 'multi' ? 'multi' : 'single'
|
||||
))
|
||||
@@ -527,10 +540,14 @@ const loadGuideFloors = async () => {
|
||||
try {
|
||||
const floors = await guideUseCase.getFloors()
|
||||
guideFloors.value = floors
|
||||
activeGuideFloor.value = floors.find((floor) => floor.label === activeGuideFloor.value)?.label
|
||||
|| floors.find((floor) => floor.label === '1F')?.label
|
||||
|| floors[0]?.label
|
||||
const normalizedActiveFloorId = activeGuideFloor.value
|
||||
? normalizeGuideFloorId(activeGuideFloor.value)
|
||||
: ''
|
||||
activeGuideFloor.value = floors.find((floor) => floor.id === normalizedActiveFloorId)?.id
|
||||
|| floors.find((floor) => floor.label === '1F')?.id
|
||||
|| floors[0]?.id
|
||||
|| activeGuideFloor.value
|
||||
renderedFloorId.value = activeGuideFloor.value
|
||||
} catch (error) {
|
||||
console.error('加载导览楼层失败:', error)
|
||||
guideFloors.value = []
|
||||
@@ -632,13 +649,36 @@ const handleGuideSearchTap = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleFloorChange = (floor: string) => {
|
||||
activeGuideFloor.value = floor
|
||||
const handleFloorRequest = ({ floorId, floorLabel }: { floorId: string; floorLabel: string }) => {
|
||||
requestedFloorId.value = floorId
|
||||
requestedFloorLabel.value = floorLabel
|
||||
loadingFloorId.value = floorId
|
||||
failedFloorId.value = ''
|
||||
}
|
||||
|
||||
const handleFloorChange = (floorId: string) => {
|
||||
activeGuideFloor.value = floorId
|
||||
renderedFloorId.value = floorId
|
||||
if (loadingFloorId.value === floorId) {
|
||||
loadingFloorId.value = ''
|
||||
}
|
||||
if (failedFloorId.value === floorId) {
|
||||
failedFloorId.value = ''
|
||||
}
|
||||
indoorView.value = 'floor'
|
||||
selectedGuidePoi.value = null
|
||||
isPoiCardCollapsed.value = false
|
||||
showIndoorHint(`已切换到 ${floor},单指旋转、双指可平移`, 3200)
|
||||
console.log('切换楼层:', floor)
|
||||
showIndoorHint(`已切换到 ${getGuideFloorLabel(floorId)},单指旋转、双指可平移`, 3200)
|
||||
console.log('楼层渲染完成:', floorId)
|
||||
}
|
||||
|
||||
const handleFloorSwitchFailed = ({ floorId, floorLabel }: { floorId: string; floorLabel: string }) => {
|
||||
if (loadingFloorId.value === floorId) {
|
||||
loadingFloorId.value = ''
|
||||
}
|
||||
failedFloorId.value = floorId
|
||||
showIndoorHint(`${floorLabel || getGuideFloorLabel(floorId)} 加载失败,请稍后重试`, 3600)
|
||||
console.warn('楼层渲染失败:', floorId)
|
||||
}
|
||||
|
||||
const handleIndoorViewChange = (view: GuideIndoorView) => {
|
||||
@@ -682,8 +722,8 @@ const handleGuidePoiClick = (poi: GuideRenderPoi) => {
|
||||
isPoiCardCollapsed.value = !selectedGuidePoiIsHall.value
|
||||
indoorView.value = 'floor'
|
||||
isSimulatingRoute.value = false
|
||||
const matchedFloor = guideFloors.value.find((floor) => floor.id === poi.floorId)
|
||||
activeGuideFloor.value = matchedFloor?.label || poi.floorId
|
||||
activeGuideFloor.value = poi.floorId
|
||||
renderedFloorId.value = poi.floorId
|
||||
showIndoorHint('已在当前楼层标出点位', 3000)
|
||||
}
|
||||
|
||||
@@ -887,9 +927,9 @@ const handleRoutePickerSearch = ({ keyword }: { mode: 'start' | 'end'; keyword:
|
||||
}
|
||||
|
||||
const focusRouteFloor = (route: GuideRouteResult) => {
|
||||
const floor = guideFloors.value.find((item) => item.id === route.start.floorId)
|
||||
const routeFloorCount = new Set(route.floorSegments.map((segment) => segment.floorId)).size
|
||||
activeGuideFloor.value = floor?.label || route.start.floorLabel
|
||||
activeGuideFloor.value = route.start.floorId
|
||||
renderedFloorId.value = route.start.floorId
|
||||
indoorView.value = routeFloorCount > 1 ? 'multi' : 'floor'
|
||||
}
|
||||
|
||||
@@ -975,7 +1015,13 @@ const guideStatusLabel = computed(() => {
|
||||
if (is3DMode.value) {
|
||||
if (indoorView.value === 'overview') return '建筑外观'
|
||||
if (indoorView.value === 'multi') return '馆内多层'
|
||||
return '馆内单层'
|
||||
if (loadingFloorId.value) {
|
||||
return `切换${requestedFloorLabel.value || getGuideFloorLabel(requestedFloorId.value || loadingFloorId.value)}`
|
||||
}
|
||||
if (failedFloorId.value) {
|
||||
return `${getGuideFloorLabel(failedFloorId.value)}失败`
|
||||
}
|
||||
return getGuideFloorLabel(renderedFloorId.value || activeGuideFloor.value) || '馆内单层'
|
||||
}
|
||||
|
||||
if (guideOutdoorState.value === 'entrance') {
|
||||
|
||||
Reference in New Issue
Block a user