From d86f24566e3af7431ee9d7da6e7131353873a1c5 Mon Sep 17 00:00:00 2001
From: lyf <2514544224@qq.com>
Date: Sat, 18 Jul 2026 01:29:06 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=B2=E8=A7=A3=E8=AF=A6?=
=?UTF-8?q?=E6=83=85=E8=BF=94=E5=9B=9E=E5=AF=B9=E8=B1=A1=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/explain/guide-stop-list.vue | 7 ++++--
.../ExplainGuideStopListNavigation.spec.ts | 24 ++++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/src/pages/explain/guide-stop-list.vue b/src/pages/explain/guide-stop-list.vue
index 703967e..089602a 100644
--- a/src/pages/explain/guide-stop-list.vue
+++ b/src/pages/explain/guide-stop-list.vue
@@ -134,8 +134,11 @@ const handleExplainGuideStopClick = (stop: ExplainGuideStopCatalogItem) => {
? { targetType: stop.playTargetType, targetId: stop.playTargetId }
: normalizeExplainDetailTargetFromGuideStop({ id: stop.id })
const params = new URLSearchParams({ id: stop.id, tab: 'explain', targetType: target.targetType, targetId: target.targetId })
- if (stop.hallId) params.set('hallId', stop.hallId)
- if (stop.hallName) params.set('hallName', stop.hallName)
+ // 分页对象可能未回填展厅字段,详情返回必须保留当前列表的展厅上下文。
+ const hallId = stop.hallId || selectedExplainHallId.value
+ const hallName = stop.hallName || selectedExplainHallName.value
+ if (hallId) params.set('hallId', hallId)
+ if (hallName) params.set('hallName', hallName)
if (stop.floorId) params.set('floorId', stop.floorId)
if (stop.poiId) params.set('poiId', stop.poiId)
uni.navigateTo({ url: `/pages/exhibit/detail?${params.toString()}` })
diff --git a/tests/unit/ExplainGuideStopListNavigation.spec.ts b/tests/unit/ExplainGuideStopListNavigation.spec.ts
index f3ce7cd..c375dc8 100644
--- a/tests/unit/ExplainGuideStopListNavigation.spec.ts
+++ b/tests/unit/ExplainGuideStopListNavigation.spec.ts
@@ -34,7 +34,12 @@ const ExplainGuideStopCatalogStub = defineComponent({
name: 'ExplainGuideStopCatalog',
props: ['guideStops', 'selectedHallName', 'loading', 'loadingMore', 'hasMore', 'error', 'loadMoreError'],
emits: ['back', 'retry', 'retryMore', 'guideStopClick'],
- template: ''
+ setup(_, { emit }) {
+ return {
+ emitDetail: () => emit('guideStopClick', { id: 'stop-1', name: '对象', playTargetType: 'STOP', playTargetId: 'target-1' })
+ }
+ },
+ template: ''
})
const mountGuideStopList = () => mount(ExplainGuideStopListPage, {
@@ -93,6 +98,23 @@ describe('讲解对象列表返回', () => {
wrapper.unmount()
})
+ it('keeps the selected hall context when an object payload omits hall fields', async () => {
+ const wrapper = mountGuideStopList()
+ testState.onLoadHandler?.({ hallId: 'hall-1', hallName: '恐龙厅' })
+ await flushPromises()
+
+ await wrapper.get('[data-testid="detail-click"]').trigger('click')
+
+ const url = vi.mocked(uni.navigateTo).mock.calls[0]?.[0]?.url || ''
+ const params = new URLSearchParams(url.split('?')[1])
+ expect(url.split('?')[0]).toBe('/pages/exhibit/detail')
+ expect(params.get('hallId')).toBe('hall-1')
+ expect(params.get('hallName')).toBe('恐龙厅')
+ expect(params.get('targetType')).toBe('STOP')
+ expect(params.get('targetId')).toBe('target-1')
+ wrapper.unmount()
+ })
+
it('上一页是独立展厅列表时回到该列表', async () => {
vi.stubGlobal('getCurrentPages', vi.fn(() => [
{ route: 'pages/explain/list', options: {} },