This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
/>
|
||||
<view class="hero-image-shade"></view>
|
||||
<button
|
||||
v-if="shouldShowDetailBack"
|
||||
v-if="!shouldUseHostNavigation"
|
||||
class="hero-back"
|
||||
aria-label="返回上级"
|
||||
@tap.stop="handleBack"
|
||||
@@ -159,7 +159,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { onBackPress, onHide, onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import { onHide, onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import GuidePageFrame from '@/components/navigation/GuidePageFrame.vue'
|
||||
import GuideFeedbackState from '@/components/navigation/GuideFeedbackState.vue'
|
||||
import GuideLoadingState from '@/components/navigation/GuideLoadingState.vue'
|
||||
@@ -188,7 +188,6 @@ import {
|
||||
} from '@/utils/placeholders'
|
||||
import { normalizeSameOriginPublicUrl } from '@/utils/publicUrl'
|
||||
import { isEmbeddedInWechatMiniProgram } from '@/utils/hostEnvironment'
|
||||
import { returnToWechatMiniProgram } from '@/services/WechatMiniProgramBridgeService'
|
||||
import { normalizeGuideAudioLanguage } from '@/data/adapters/guideStopInfoAdapter'
|
||||
import { explainGuideStopListUrl } from '@/utils/explainNavigation'
|
||||
import {
|
||||
@@ -234,8 +233,6 @@ const detailEntryRequest = ref<{
|
||||
floorId?: string
|
||||
floorLabel?: string
|
||||
poiId?: string
|
||||
returnToGuideStopList?: boolean
|
||||
returnToHallList?: boolean
|
||||
} | null>(null)
|
||||
const detailTextByLanguage = ref<Record<AudioLanguage, string>>({
|
||||
'zh-CN': defaultDetail.body,
|
||||
@@ -253,9 +250,6 @@ const detailTextLoadedByLanguage = ref<Record<AudioLanguage, boolean>>({
|
||||
'en-US': false
|
||||
})
|
||||
const shouldUseHostNavigation = computed(() => isEmbeddedInWechatMiniProgram())
|
||||
const shouldShowDetailBack = computed(() => (
|
||||
!shouldUseHostNavigation.value || detailEntryRequest.value?.returnToGuideStopList === true
|
||||
))
|
||||
|
||||
const isAudioLanguage = (value: unknown): value is AudioLanguage => (
|
||||
value === 'zh-CN' || value === 'yue-HK' || value === 'en-US'
|
||||
@@ -361,7 +355,6 @@ const isCurrentDetailAudioTarget = computed(() => {
|
||||
)
|
||||
})
|
||||
let detailAudioClosedOnExit = false
|
||||
let returningToMiniProgram = false
|
||||
|
||||
const closeDetailAudioOnExit = () => {
|
||||
if (detailAudioClosedOnExit || !isCurrentDetailAudioTarget.value) return
|
||||
@@ -574,13 +567,7 @@ onLoad(async (options: any = {}) => {
|
||||
hallId: Array.isArray(options.hallId) ? options.hallId[0] : options.hallId,
|
||||
hallName: Array.isArray(options.hallName) ? options.hallName[0] : options.hallName,
|
||||
floorId: Array.isArray(options.floorId) ? options.floorId[0] : options.floorId,
|
||||
poiId: Array.isArray(options.poiId) ? options.poiId[0] : options.poiId,
|
||||
returnToGuideStopList: (Array.isArray(options.returnToGuideStopList)
|
||||
? options.returnToGuideStopList[0]
|
||||
: options.returnToGuideStopList) === '1',
|
||||
returnToHallList: (Array.isArray(options.returnToHallList)
|
||||
? options.returnToHallList[0]
|
||||
: options.returnToHallList) === '1'
|
||||
poiId: Array.isArray(options.poiId) ? options.poiId[0] : options.poiId
|
||||
}
|
||||
await loadExplainDetail(detailEntryRequest.value, lang)
|
||||
} catch (error) {
|
||||
@@ -783,12 +770,6 @@ function buildDetailRoute(lang: AudioLanguage = selectedAudioLanguage.value) {
|
||||
if (lang) {
|
||||
params.set('lang', lang)
|
||||
}
|
||||
if (request?.hallId) params.set('hallId', request.hallId)
|
||||
if (request?.hallName) params.set('hallName', request.hallName)
|
||||
if (request?.floorId) params.set('floorId', request.floorId)
|
||||
if (request?.poiId) params.set('poiId', request.poiId)
|
||||
if (request?.returnToGuideStopList) params.set('returnToGuideStopList', '1')
|
||||
if (request?.returnToHallList) params.set('returnToHallList', '1')
|
||||
return `/pages/exhibit/detail?${params.toString()}`
|
||||
}
|
||||
|
||||
@@ -953,9 +934,7 @@ const fallbackToExplainObjectList = () => {
|
||||
const hallId = detailEntryRequest.value?.hallId || exhibit.value.hallId
|
||||
const hallName = decodeRouteParam(detailEntryRequest.value?.hallName || exhibit.value.hallName || '讲解')
|
||||
const url = hallId
|
||||
? explainGuideStopListUrl(hallId, hallName, {
|
||||
returnToHallList: detailEntryRequest.value?.returnToHallList
|
||||
})
|
||||
? explainGuideStopListUrl(hallId, hallName)
|
||||
: '/pages/explain/list'
|
||||
|
||||
uni.redirectTo({
|
||||
@@ -966,47 +945,15 @@ const fallbackToExplainObjectList = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const cameFromExplainObjectList = () => {
|
||||
const pages = getCurrentPages()
|
||||
const previousPage = pages[pages.length - 2] as { route?: string } | undefined
|
||||
return previousPage?.route === 'pages/explain/guide-stop-list'
|
||||
}
|
||||
|
||||
const returnToExplainObjectList = async () => {
|
||||
const returnToExplainObjectList = () => {
|
||||
closeDetailAudioOnExit()
|
||||
if (cameFromExplainObjectList()) {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: fallbackToExplainObjectList
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (detailEntryRequest.value?.returnToGuideStopList) {
|
||||
fallbackToExplainObjectList()
|
||||
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
|
||||
}
|
||||
|
||||
fallbackToExplainObjectList()
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: fallbackToExplainObjectList
|
||||
})
|
||||
}
|
||||
|
||||
const handleBack = () => { void returnToExplainObjectList() }
|
||||
|
||||
onBackPress(() => {
|
||||
void returnToExplainObjectList()
|
||||
return true
|
||||
})
|
||||
const handleBack = returnToExplainObjectList
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user