@@ -69,7 +69,7 @@
|
||||
|
||||
<view
|
||||
class="arrival-primary"
|
||||
:class="{ disabled: !selectedTarget }"
|
||||
:class="{ disabled: !selectedTarget || isOpeningNavigation }"
|
||||
@tap="handleNavigateTap"
|
||||
>
|
||||
<text class="arrival-primary-text">{{ primaryActionText }}</text>
|
||||
@@ -124,10 +124,6 @@ import {
|
||||
THIRD_PARTY_MAP_PROVIDERS,
|
||||
type ThirdPartyMapProviderOption
|
||||
} from '@/services/ThirdPartyMapSearchService'
|
||||
import {
|
||||
isNativeWechatMiniProgram,
|
||||
isWechatMiniProgramRuntime
|
||||
} from '@/utils/hostEnvironment'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
visible?: boolean
|
||||
@@ -151,13 +147,13 @@ const emit = defineEmits<{
|
||||
|
||||
const typeOptions = computed(() => ARRIVAL_TARGET_TYPES)
|
||||
const mapProviders = computed(() => THIRD_PARTY_MAP_PROVIDERS)
|
||||
const shouldUseMiniProgramLocation = computed(() => isWechatMiniProgramRuntime())
|
||||
const primaryActionText = computed(() => (
|
||||
shouldUseMiniProgramLocation.value ? '打开地图导航' : '第三方导航'
|
||||
isOpeningNavigation.value ? '正在打开...' : '打开地图导航'
|
||||
))
|
||||
const arrivalPanelRef = ref<unknown>(null)
|
||||
const isCollapsed = ref(false)
|
||||
const providerSheetVisible = ref(false)
|
||||
const isOpeningNavigation = ref(false)
|
||||
let resizeObserver: ResizeObserver | null = null
|
||||
|
||||
const activeTypeLabel = computed(() => (
|
||||
@@ -243,6 +239,7 @@ const startLayoutObserver = () => {
|
||||
}
|
||||
|
||||
const handleNavigateTap = async () => {
|
||||
if (isOpeningNavigation.value) return
|
||||
if (!props.selectedTarget) {
|
||||
uni.showToast({
|
||||
title: '请先选择点位',
|
||||
@@ -257,14 +254,15 @@ const handleNavigateTap = async () => {
|
||||
name: props.selectedTarget.title,
|
||||
address: props.selectedTarget.subtitle
|
||||
}
|
||||
const isNativeMiniProgram = isNativeWechatMiniProgram()
|
||||
const openedInMiniProgram = await openWechatMiniProgramLocation(target)
|
||||
|
||||
if (openedInMiniProgram || isNativeMiniProgram || isWechatMiniProgramRuntime()) {
|
||||
return
|
||||
isOpeningNavigation.value = true
|
||||
try {
|
||||
const result = await openWechatMiniProgramLocation(target)
|
||||
if (result.status === 'not-embedded') {
|
||||
providerSheetVisible.value = true
|
||||
}
|
||||
} finally {
|
||||
isOpeningNavigation.value = false
|
||||
}
|
||||
|
||||
providerSheetVisible.value = true
|
||||
}
|
||||
|
||||
const handleProviderSelect = (provider: ThirdPartyMapProviderOption) => {
|
||||
|
||||
Reference in New Issue
Block a user