This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
<ExplainGuideStopCatalog
|
||||
:guide-stops="explainGuideStopItems"
|
||||
:selected-hall-name="selectedExplainHallName"
|
||||
:show-embedded-back="shouldReturnToHallList"
|
||||
:loading="explainLoading"
|
||||
:loading-more="loadingMore"
|
||||
:has-more="hasMore"
|
||||
@@ -21,15 +20,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onUnmounted, ref } from 'vue'
|
||||
import { onBackPress, onLoad } from '@dcloudio/uni-app'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import GuidePageFrame from '@/components/navigation/GuidePageFrame.vue'
|
||||
import ExplainGuideStopCatalog, { type ExplainGuideStopCatalogItem } from '@/components/explain/ExplainGuideStopCatalog.vue'
|
||||
import { explainUseCase } from '@/usecases/explainUseCase'
|
||||
import type { ExplainGuideStop } from '@/domain/museum'
|
||||
import { normalizeExplainDetailTargetFromGuideStop } from '@/domain/explainDetailTarget'
|
||||
import { navigateToGuideTopTab, type GuideTopTab } from '@/utils/guideTopTabs'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
import { returnToWechatMiniProgram } from '@/services/WechatMiniProgramBridgeService'
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
const selectedExplainHallId = ref('')
|
||||
@@ -41,10 +38,8 @@ const explainError = ref('')
|
||||
const loadMoreError = ref('')
|
||||
const hasMore = ref(false)
|
||||
const nextPageNo = ref(1)
|
||||
const shouldReturnToHallList = ref(false)
|
||||
let requestVersion = 0
|
||||
let disposed = false
|
||||
let returningToMiniProgram = false
|
||||
|
||||
const toGuideStopItems = (stops: ExplainGuideStop[]): ExplainGuideStopCatalogItem[] => stops.map((stop) => ({
|
||||
id: stop.id,
|
||||
@@ -121,7 +116,6 @@ onLoad((options: Record<string, string | string[] | undefined> = {}) => {
|
||||
const first = (value: string | string[] | undefined) => Array.isArray(value) ? value[0] : value
|
||||
selectedExplainHallId.value = first(options.hallId) || ''
|
||||
selectedExplainHallName.value = first(options.hallName) || '讲解对象'
|
||||
shouldReturnToHallList.value = first(options.returnToHallList) === '1'
|
||||
syncPageTitle('讲解对象')
|
||||
if (!selectedExplainHallId.value) {
|
||||
explainError.value = '缺少展厅参数,请返回展厅列表后重试'
|
||||
@@ -147,8 +141,6 @@ const handleExplainGuideStopClick = (stop: ExplainGuideStopCatalogItem) => {
|
||||
if (hallName) params.set('hallName', hallName)
|
||||
if (stop.floorId) params.set('floorId', stop.floorId)
|
||||
if (stop.poiId) params.set('poiId', stop.poiId)
|
||||
params.set('returnToGuideStopList', '1')
|
||||
if (shouldReturnToHallList.value) params.set('returnToHallList', '1')
|
||||
uni.navigateTo({ url: `/pages/exhibit/detail?${params.toString()}` })
|
||||
}
|
||||
|
||||
@@ -161,7 +153,7 @@ type ExplainPageStackEntry = {
|
||||
}
|
||||
}
|
||||
|
||||
const returnToHallList = async () => {
|
||||
const returnToHallList = () => {
|
||||
const pages = getCurrentPages()
|
||||
const previousPage = pages[pages.length - 2] as ExplainPageStackEntry | undefined
|
||||
const previousRoute = previousPage?.route
|
||||
@@ -178,33 +170,11 @@ const returnToHallList = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
// H5 web-view 有时不会暴露完整页面栈,保留入口上下文即可回到展厅列表。
|
||||
if (shouldReturnToHallList.value) {
|
||||
fallbackToHallList()
|
||||
return
|
||||
}
|
||||
|
||||
if (isEmbeddedInWechatMiniProgram()) {
|
||||
if (returningToMiniProgram) return
|
||||
returningToMiniProgram = true
|
||||
const result = await returnToWechatMiniProgram()
|
||||
if (result.status === 'returned') return
|
||||
|
||||
returningToMiniProgram = false
|
||||
uni.showToast({ title: '返回小程序失败,请重试', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
fallbackToHallList()
|
||||
}
|
||||
|
||||
const handleBack = () => { void returnToHallList() }
|
||||
const handleBack = returnToHallList
|
||||
const handleTopTabChange = (tab: GuideTopTab) => navigateToGuideTopTab(tab)
|
||||
|
||||
onBackPress(() => {
|
||||
void returnToHallList()
|
||||
return true
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user