hookehuyr

fix(Activities): 添加老版本进入时的兼容处理

- 恢复 getMapUrlAPI 导入以支持老版本跳转方式
- 新版本从 ActivitiesDetail 进入时使用 URL 参数 mapUrl
- 老版本从 ActivitiesCover 进入时调用 getMapUrlAPI 接口获取
- 两种方式都能正常工作,确保向后兼容

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
...@@ -39,6 +39,7 @@ import Taro from '@tarojs/taro' ...@@ -39,6 +39,7 @@ import Taro from '@tarojs/taro'
39 import BottomNav from '../../components/BottomNav.vue' 39 import BottomNav from '../../components/BottomNav.vue'
40 // 获取接口信息 40 // 获取接口信息
41 import { getUserProfileAPI } from '@/api/user' 41 import { getUserProfileAPI } from '@/api/user'
42 +import { getMapUrlAPI } from '@/api/map'
42 43
43 /** 44 /**
44 * 活动页面WebView组件 45 * 活动页面WebView组件
...@@ -135,20 +136,29 @@ const initPageData = async () => { ...@@ -135,20 +136,29 @@ const initPageData = async () => {
135 const { mapUrl, current_lng, current_lat, discount_title, activityId } = 136 const { mapUrl, current_lng, current_lat, discount_title, activityId } =
136 instance.router?.params || {} 137 instance.router?.params || {}
137 138
138 - // 解码地图 URL 139 + // 兼容处理:优先使用 URL 参数中的 mapUrl,如果没有则调用接口获取
139 if (mapUrl) { 140 if (mapUrl) {
141 + // 新版本:从 ActivitiesDetail 传递的 mapUrl 参数
140 baseUrl.value = decodeURIComponent(mapUrl) 142 baseUrl.value = decodeURIComponent(mapUrl)
141 console.log('✅ 从 URL 参数获取到的地图URL:', baseUrl.value) 143 console.log('✅ 从 URL 参数获取到的地图URL:', baseUrl.value)
142 } else { 144 } else {
143 - console.error('❌ 未接收到地图URL参数') 145 + // 老版本:从 ActivitiesCover 进入,需要调用接口获取地图 URL
144 - // 显示错误提示 146 + console.log('⚠️ 未接收到 mapUrl 参数,尝试调用接口获取(老版本兼容)')
145 - error.value = true 147 + const mapUrlResponse = await getMapUrlAPI()
146 - loading.value = false 148 + if (mapUrlResponse.code === 1 && mapUrlResponse.data?.url) {
147 - Taro.showToast({ 149 + baseUrl.value = mapUrlResponse.data.url
148 - title: '缺少地图信息', 150 + console.log('✅ 通过接口获取到的地图URL:', baseUrl.value)
149 - icon: 'none', 151 + } else {
150 - }) 152 + console.error('❌ 获取地图URL失败:', mapUrlResponse.msg)
151 - return 153 + // 显示错误提示
154 + error.value = true
155 + loading.value = false
156 + Taro.showToast({
157 + title: mapUrlResponse.msg || '获取地图信息失败',
158 + icon: 'none',
159 + })
160 + return
161 + }
152 } 162 }
153 163
154 // 获取用户信息 164 // 获取用户信息
......