修复讲解详情接口并展示展厅统计
This commit is contained in:
@@ -185,11 +185,15 @@ onLoad(async (options: any = {}) => {
|
||||
if (!exhibitId) return
|
||||
|
||||
const rawTargetType = Array.isArray(options.targetType) ? options.targetType[0] : options.targetType
|
||||
const targetType: AudioPlayTargetType | undefined = rawTargetType === 'ITEM' || rawTargetType === 'STOP'
|
||||
? rawTargetType
|
||||
: undefined
|
||||
const targetType: AudioPlayTargetType | undefined = rawTargetType === 'ITEM'
|
||||
? 'ITEM'
|
||||
: rawTargetType === 'STOP' || rawTargetType === 'GUIDE_STOP'
|
||||
? 'STOP'
|
||||
: undefined
|
||||
const rawTargetId = Array.isArray(options.targetId) ? options.targetId[0] : options.targetId
|
||||
const targetId = rawTargetId ? String(rawTargetId) : undefined
|
||||
const targetId = rawTargetType === 'GUIDE_STOP'
|
||||
? String(exhibitId)
|
||||
: rawTargetId ? String(rawTargetId) : undefined
|
||||
|
||||
try {
|
||||
const exhibitData = await explainUseCase.enterExplainDetail({
|
||||
|
||||
@@ -41,6 +41,9 @@ import ExplainHallSelect, {
|
||||
import {
|
||||
explainUseCase
|
||||
} from '@/usecases/explainUseCase'
|
||||
import {
|
||||
normalizeExplainDetailTargetFromGuideStop
|
||||
} from '@/domain/explainDetailTarget'
|
||||
import type {
|
||||
ExplainBusinessUnit,
|
||||
MuseumHall
|
||||
@@ -63,13 +66,18 @@ let explainLoadPromise: Promise<void> | null = null
|
||||
|
||||
const normalizeExplainKeyword = (value?: string) => (value || '').trim().toLowerCase()
|
||||
|
||||
const buildExplainHallItems = (halls: MuseumHall[]): ExplainHallSelectItem[] => (
|
||||
const buildExplainHallItems = (
|
||||
halls: MuseumHall[],
|
||||
summaries: Awaited<ReturnType<typeof explainUseCase.loadExplainHallSummaries>> = {}
|
||||
): ExplainHallSelectItem[] => (
|
||||
halls.map((hall) => ({
|
||||
id: hall.id,
|
||||
name: hall.name,
|
||||
floorLabel: hall.floorLabel,
|
||||
image: hall.image,
|
||||
explainCount: hall.exhibitCount || 0,
|
||||
businessUnitCount: summaries[hall.id]?.businessUnitCount,
|
||||
guideStopCount: summaries[hall.id]?.guideStopCount,
|
||||
searchText: normalizeExplainKeyword([
|
||||
hall.name,
|
||||
hall.floorLabel,
|
||||
@@ -115,7 +123,8 @@ const loadExplainHalls = async () => {
|
||||
explainLoadPromise = (async () => {
|
||||
try {
|
||||
const halls = await explainUseCase.loadExplainHalls()
|
||||
explainHallItems.value = buildExplainHallItems(halls)
|
||||
const summaries = await explainUseCase.loadExplainHallSummaries(halls.map((hall) => hall.id))
|
||||
explainHallItems.value = buildExplainHallItems(halls, summaries)
|
||||
} catch (error) {
|
||||
console.error('加载讲解展厅失败:', error)
|
||||
explainError.value = '讲解展厅加载失败,请稍后重试'
|
||||
@@ -178,11 +187,12 @@ const handleExplainBusinessUnitClick = (unitId: string) => {
|
||||
}
|
||||
|
||||
const handleExplainGuideStopClick = (stopId: string) => {
|
||||
const target = normalizeExplainDetailTargetFromGuideStop({ id: stopId })
|
||||
const params = new URLSearchParams({
|
||||
id: stopId,
|
||||
id: target.targetId,
|
||||
tab: 'explain',
|
||||
targetType: 'STOP',
|
||||
targetId: stopId
|
||||
targetType: target.targetType,
|
||||
targetId: target.targetId
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/exhibit/detail?${params.toString()}`
|
||||
|
||||
@@ -250,6 +250,9 @@ import {
|
||||
import {
|
||||
explainUseCase
|
||||
} from '@/usecases/explainUseCase'
|
||||
import {
|
||||
normalizeExplainDetailTargetFromGuideStop
|
||||
} from '@/domain/explainDetailTarget'
|
||||
import type {
|
||||
GuideRenderPoi
|
||||
} from '@/domain/guideModel'
|
||||
@@ -604,7 +607,8 @@ const loadExplainHalls = async () => {
|
||||
explainLoadPromise = (async () => {
|
||||
try {
|
||||
const halls = await explainUseCase.loadExplainHalls()
|
||||
explainHallItems.value = buildExplainHallItems(halls)
|
||||
const summaries = await explainUseCase.loadExplainHallSummaries(halls.map((hall) => hall.id))
|
||||
explainHallItems.value = buildExplainHallItems(halls, summaries)
|
||||
} catch (error) {
|
||||
console.error('加载讲解内容失败:', error)
|
||||
explainError.value = '讲解内容加载失败,请稍后重试'
|
||||
@@ -621,7 +625,8 @@ const loadExplainHalls = async () => {
|
||||
const normalizeExplainKeyword = (value?: string) => (value || '').trim().toLowerCase()
|
||||
|
||||
const buildExplainHallItems = (
|
||||
halls: Awaited<ReturnType<typeof explainUseCase.loadExplainHalls>>
|
||||
halls: Awaited<ReturnType<typeof explainUseCase.loadExplainHalls>>,
|
||||
summaries: Awaited<ReturnType<typeof explainUseCase.loadExplainHallSummaries>> = {}
|
||||
): ExplainHallSelectItem[] => {
|
||||
return halls.map((hall) => {
|
||||
const keywordParts = [
|
||||
@@ -637,6 +642,8 @@ const buildExplainHallItems = (
|
||||
floorLabel: hall.floorLabel,
|
||||
image: hall.image,
|
||||
explainCount: hall.exhibitCount || 0,
|
||||
businessUnitCount: summaries[hall.id]?.businessUnitCount,
|
||||
guideStopCount: summaries[hall.id]?.guideStopCount,
|
||||
searchText: normalizeExplainKeyword(keywordParts.join(' '))
|
||||
}
|
||||
})
|
||||
@@ -1251,11 +1258,12 @@ const handleExplainBusinessUnitClick = (unitId: string) => {
|
||||
}
|
||||
|
||||
const handleExplainGuideStopClick = (stopId: string) => {
|
||||
const target = normalizeExplainDetailTargetFromGuideStop({ id: stopId })
|
||||
const params = new URLSearchParams({
|
||||
id: stopId,
|
||||
id: target.targetId,
|
||||
tab: 'explain',
|
||||
targetType: 'STOP',
|
||||
targetId: stopId
|
||||
targetType: target.targetType,
|
||||
targetId: target.targetId
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: `/pages/exhibit/detail?${params.toString()}`
|
||||
|
||||
Reference in New Issue
Block a user