This commit is contained in:
@@ -117,7 +117,7 @@
|
||||
|
||||
<view v-if="!floorResults.length" class="empty-state">
|
||||
<text class="empty-title">{{ emptyTitle }}</text>
|
||||
<text class="empty-desc">可切换楼层或搜索服务设施</text>
|
||||
<text class="empty-desc">{{ emptyDesc }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -192,6 +192,7 @@ const floors = ref<MuseumFloor[]>([])
|
||||
const activeFloor = ref('1F')
|
||||
const pois = ref<MuseumPoi[]>([])
|
||||
const isLoading = ref(false)
|
||||
const initialSpaceLoadError = ref('')
|
||||
|
||||
const showSearchContent = computed(() => props.variant === 'page' || homeExpanded.value)
|
||||
const collapseDragThreshold = 48
|
||||
@@ -206,7 +207,13 @@ const floorResults = computed(() => {
|
||||
})
|
||||
|
||||
const emptyTitle = computed(() => (
|
||||
isLoading.value ? '正在读取点位' : '暂无匹配点位'
|
||||
isLoading.value ? '正在读取点位' : initialSpaceLoadError.value || '暂无匹配点位'
|
||||
))
|
||||
|
||||
const emptyDesc = computed(() => (
|
||||
initialSpaceLoadError.value
|
||||
? '请检查 SGS 空间点位数据接口后重试'
|
||||
: '可切换楼层或搜索服务设施'
|
||||
))
|
||||
|
||||
const isVisiblePoi = (poi: MuseumPoi) => poi.primaryCategory.id !== 'touring_poi'
|
||||
@@ -277,6 +284,7 @@ const loadFloors = async () => {
|
||||
|
||||
const loadPois = async (keyword = '') => {
|
||||
isLoading.value = true
|
||||
initialSpaceLoadError.value = ''
|
||||
try {
|
||||
const result = await guideUseCase.searchPois(keyword)
|
||||
pois.value = result.filter(isVisiblePoi)
|
||||
@@ -292,6 +300,26 @@ const loadPois = async (keyword = '') => {
|
||||
}
|
||||
}
|
||||
|
||||
const loadInitialSpacePoints = async () => {
|
||||
isLoading.value = true
|
||||
initialSpaceLoadError.value = ''
|
||||
|
||||
try {
|
||||
const result = await guideUseCase.getInitialSearchSpacePoints()
|
||||
pois.value = result.filter(isVisiblePoi)
|
||||
} catch (error) {
|
||||
console.error('加载 SDK 空间点位失败:', error)
|
||||
pois.value = []
|
||||
initialSpaceLoadError.value = '空间点位读取失败'
|
||||
uni.showToast({
|
||||
title: '空间点位读取失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const focusSearchInput = async () => {
|
||||
searchInputFocused.value = false
|
||||
await nextTick()
|
||||
@@ -365,7 +393,7 @@ const handleSearchInput = (event: any) => {
|
||||
const handleSearchClear = async () => {
|
||||
searchDraftKeyword.value = ''
|
||||
searchKeyword.value = ''
|
||||
await loadPois()
|
||||
await loadInitialSpacePoints()
|
||||
await focusSearchInput()
|
||||
}
|
||||
|
||||
@@ -443,10 +471,17 @@ const handleResultTap = (poi: MuseumPoi) => {
|
||||
}
|
||||
|
||||
const applyInitialKeyword = async (keyword: string) => {
|
||||
searchKeyword.value = keyword
|
||||
searchDraftKeyword.value = keyword
|
||||
const normalizedKeyword = keyword.trim()
|
||||
searchKeyword.value = normalizedKeyword
|
||||
searchDraftKeyword.value = normalizedKeyword
|
||||
homeExpanded.value = props.variant === 'page' || Boolean(keyword)
|
||||
await loadPois(keyword)
|
||||
|
||||
if (normalizedKeyword) {
|
||||
await loadPois(normalizedKeyword)
|
||||
return
|
||||
}
|
||||
|
||||
await loadInitialSpacePoints()
|
||||
}
|
||||
|
||||
watch(() => props.initialKeyword, (keyword) => {
|
||||
|
||||
Reference in New Issue
Block a user