feat: 临时改造讲解页方案 B 链路
接入展厅列表、展厅讲解点分组生成临时业务单元,并迁移讲解详情播放正文到新接口链路。
This commit is contained in:
@@ -204,9 +204,16 @@
|
||||
<view v-else-if="currentTab === 'explain'" class="explain-page">
|
||||
<ExplainHallSelect
|
||||
:halls="explainHallItems"
|
||||
:business-units="explainBusinessUnitItems"
|
||||
:guide-stops="explainGuideStopItems"
|
||||
:stage="explainStage"
|
||||
:selected-hall-name="selectedExplainHallName"
|
||||
:selected-business-unit-name="selectedExplainBusinessUnitName"
|
||||
:loading="explainLoading"
|
||||
:error="explainError"
|
||||
@hall-click="handleExplainHallClick"
|
||||
@business-unit-click="handleExplainBusinessUnitClick"
|
||||
@guide-stop-click="handleExplainGuideStopClick"
|
||||
@back="handleExplainBack"
|
||||
/>
|
||||
</view>
|
||||
@@ -224,6 +231,9 @@ import type {
|
||||
RoutePointOption
|
||||
} from '@/components/navigation/RoutePointPicker.vue'
|
||||
import ExplainHallSelect, {
|
||||
type ExplainBusinessUnitSelectItem,
|
||||
type ExplainGuideStopSelectItem,
|
||||
type ExplainSelectStage,
|
||||
type ExplainHallSelectItem
|
||||
} from '@/components/explain/ExplainHallSelect.vue'
|
||||
import {
|
||||
@@ -246,7 +256,7 @@ import type {
|
||||
import type {
|
||||
GuideRouteResult,
|
||||
GuideRouteTarget,
|
||||
MuseumExhibit,
|
||||
ExplainBusinessUnit,
|
||||
MuseumFloor,
|
||||
MuseumHall
|
||||
} from '@/domain/museum'
|
||||
@@ -435,10 +445,40 @@ const routeSimulationStepText = computed(() => {
|
||||
})
|
||||
|
||||
const explainHallItems = ref<ExplainHallSelectItem[]>([])
|
||||
const explainBusinessUnits = ref<ExplainBusinessUnit[]>([])
|
||||
const explainStage = ref<ExplainSelectStage>('hall')
|
||||
const selectedExplainHallId = ref('')
|
||||
const selectedExplainHallName = ref('')
|
||||
const selectedExplainBusinessUnitId = ref('')
|
||||
const selectedExplainBusinessUnitName = ref('')
|
||||
const explainLoading = ref(false)
|
||||
const explainError = ref('')
|
||||
let explainLoadPromise: Promise<void> | null = null
|
||||
|
||||
const selectedExplainBusinessUnit = computed(() => (
|
||||
explainBusinessUnits.value.find((unit) => unit.id === selectedExplainBusinessUnitId.value) || null
|
||||
))
|
||||
const explainBusinessUnitItems = computed<ExplainBusinessUnitSelectItem[]>(() => (
|
||||
explainBusinessUnits.value.map((unit) => ({
|
||||
id: unit.id,
|
||||
name: unit.name,
|
||||
hallId: unit.hallId,
|
||||
guideStopCount: unit.guideStopCount
|
||||
}))
|
||||
))
|
||||
const explainGuideStopItems = computed<ExplainGuideStopSelectItem[]>(() => (
|
||||
selectedExplainBusinessUnit.value?.stops.map((stop) => ({
|
||||
id: stop.id,
|
||||
name: stop.name,
|
||||
hallId: stop.hallId,
|
||||
hallName: stop.hallName,
|
||||
floorId: stop.floorId,
|
||||
coverImageUrl: stop.coverImageUrl,
|
||||
description: stop.description,
|
||||
hasAudio: stop.hasAudio
|
||||
})) || []
|
||||
))
|
||||
|
||||
// Tab 切换处理
|
||||
const syncTopTabToUrl = (tabId: GuideTopTab) => {
|
||||
if (typeof window === 'undefined') return
|
||||
@@ -452,7 +492,7 @@ const syncTopTabToUrl = (tabId: GuideTopTab) => {
|
||||
|
||||
const loadTopTabData = (tabId: GuideTopTab) => {
|
||||
if (tabId === 'explain') {
|
||||
void loadExplainExhibits()
|
||||
void loadExplainHalls()
|
||||
} else {
|
||||
void loadGuideFloors()
|
||||
}
|
||||
@@ -554,7 +594,7 @@ const loadGuideFloors = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const loadExplainExhibits = async () => {
|
||||
const loadExplainHalls = async () => {
|
||||
if (explainHallItems.value.length) return
|
||||
if (explainLoadPromise) return explainLoadPromise
|
||||
|
||||
@@ -563,11 +603,8 @@ const loadExplainExhibits = async () => {
|
||||
|
||||
explainLoadPromise = (async () => {
|
||||
try {
|
||||
const [halls, exhibits] = await Promise.all([
|
||||
explainUseCase.listHalls(),
|
||||
explainUseCase.listExplainExhibits()
|
||||
])
|
||||
explainHallItems.value = buildExplainHallItems(halls, exhibits)
|
||||
const halls = await explainUseCase.loadExplainHalls()
|
||||
explainHallItems.value = buildExplainHallItems(halls)
|
||||
} catch (error) {
|
||||
console.error('加载讲解内容失败:', error)
|
||||
explainError.value = '讲解内容加载失败,请稍后重试'
|
||||
@@ -584,52 +621,14 @@ const loadExplainExhibits = async () => {
|
||||
const normalizeExplainKeyword = (value?: string) => (value || '').trim().toLowerCase()
|
||||
|
||||
const buildExplainHallItems = (
|
||||
halls: Awaited<ReturnType<typeof explainUseCase.listHalls>>,
|
||||
exhibits: MuseumExhibit[]
|
||||
halls: Awaited<ReturnType<typeof explainUseCase.loadExplainHalls>>
|
||||
): ExplainHallSelectItem[] => {
|
||||
const countsByHallId = new Map<string, number>()
|
||||
const countsByHallName = new Map<string, number>()
|
||||
const keywordsByHallId = new Map<string, Set<string>>()
|
||||
const keywordsByHallName = new Map<string, Set<string>>()
|
||||
|
||||
exhibits.forEach((exhibit) => {
|
||||
const keywordParts = [
|
||||
exhibit.name,
|
||||
exhibit.hallName,
|
||||
exhibit.floorLabel,
|
||||
exhibit.description,
|
||||
exhibit.guideTitle,
|
||||
exhibit.guideText,
|
||||
...(exhibit.tags || [])
|
||||
].filter(Boolean) as string[]
|
||||
|
||||
if (exhibit.hallId) {
|
||||
countsByHallId.set(exhibit.hallId, (countsByHallId.get(exhibit.hallId) || 0) + 1)
|
||||
const keywords = keywordsByHallId.get(exhibit.hallId) || new Set<string>()
|
||||
keywordParts.forEach((part) => keywords.add(part))
|
||||
keywordsByHallId.set(exhibit.hallId, keywords)
|
||||
}
|
||||
|
||||
if (exhibit.hallName) {
|
||||
countsByHallName.set(exhibit.hallName, (countsByHallName.get(exhibit.hallName) || 0) + 1)
|
||||
const keywords = keywordsByHallName.get(exhibit.hallName) || new Set<string>()
|
||||
keywordParts.forEach((part) => keywords.add(part))
|
||||
keywordsByHallName.set(exhibit.hallName, keywords)
|
||||
}
|
||||
})
|
||||
|
||||
return halls.map((hall) => {
|
||||
const explainCount = countsByHallId.get(hall.id)
|
||||
|| countsByHallName.get(hall.name)
|
||||
|| hall.exhibitCount
|
||||
|| 0
|
||||
const keywordParts = [
|
||||
hall.name,
|
||||
hall.floorLabel,
|
||||
hall.description,
|
||||
hall.area,
|
||||
...Array.from(keywordsByHallId.get(hall.id) || []),
|
||||
...Array.from(keywordsByHallName.get(hall.name) || [])
|
||||
hall.area
|
||||
].filter(Boolean) as string[]
|
||||
|
||||
return {
|
||||
@@ -637,7 +636,7 @@ const buildExplainHallItems = (
|
||||
name: hall.name,
|
||||
floorLabel: hall.floorLabel,
|
||||
image: hall.image,
|
||||
explainCount,
|
||||
explainCount: hall.exhibitCount || 0,
|
||||
searchText: normalizeExplainKeyword(keywordParts.join(' '))
|
||||
}
|
||||
})
|
||||
@@ -1222,13 +1221,67 @@ const guideSearchText = computed(() => {
|
||||
})
|
||||
|
||||
// 讲解页面处理
|
||||
const handleExplainHallClick = (hallId: string) => {
|
||||
const handleExplainHallClick = async (hallId: string) => {
|
||||
const hall = explainHallItems.value.find((item) => item.id === hallId)
|
||||
selectedExplainHallId.value = hallId
|
||||
selectedExplainHallName.value = hall?.name || '业务单元'
|
||||
selectedExplainBusinessUnitId.value = ''
|
||||
selectedExplainBusinessUnitName.value = ''
|
||||
explainBusinessUnits.value = []
|
||||
explainError.value = ''
|
||||
explainLoading.value = true
|
||||
|
||||
try {
|
||||
explainBusinessUnits.value = await explainUseCase.loadTemporaryBusinessUnitsByHall(hallId)
|
||||
explainStage.value = 'unit'
|
||||
} catch (error) {
|
||||
console.error('加载展厅讲解点失败:', error)
|
||||
explainError.value = '展厅讲解点加载失败,请稍后重试'
|
||||
explainStage.value = 'unit'
|
||||
} finally {
|
||||
explainLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleExplainBusinessUnitClick = (unitId: string) => {
|
||||
const unit = explainBusinessUnits.value.find((item) => item.id === unitId)
|
||||
selectedExplainBusinessUnitId.value = unitId
|
||||
selectedExplainBusinessUnitName.value = unit?.name || '讲解点'
|
||||
explainStage.value = 'stop'
|
||||
}
|
||||
|
||||
const handleExplainGuideStopClick = (stopId: string) => {
|
||||
const params = new URLSearchParams({
|
||||
id: stopId,
|
||||
tab: 'explain',
|
||||
targetType: 'STOP',
|
||||
targetId: stopId
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/hall/detail?id=${encodeURIComponent(hallId)}&tab=explain`
|
||||
url: `/pages/exhibit/detail?${params.toString()}`
|
||||
})
|
||||
}
|
||||
|
||||
const handleExplainBack = () => {
|
||||
if (explainStage.value === 'stop') {
|
||||
explainStage.value = 'unit'
|
||||
selectedExplainBusinessUnitId.value = ''
|
||||
selectedExplainBusinessUnitName.value = ''
|
||||
explainError.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
if (explainStage.value === 'unit') {
|
||||
explainStage.value = 'hall'
|
||||
selectedExplainHallId.value = ''
|
||||
selectedExplainHallName.value = ''
|
||||
selectedExplainBusinessUnitId.value = ''
|
||||
selectedExplainBusinessUnitName.value = ''
|
||||
explainBusinessUnits.value = []
|
||||
explainError.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
currentTab.value = 'guide'
|
||||
syncTopTabToUrl('guide')
|
||||
loadTopTabData('guide')
|
||||
|
||||
Reference in New Issue
Block a user