diff --git a/src/pages/Home.vue b/src/pages/Home.vue index 065ab2f..fc76354 100644 --- a/src/pages/Home.vue +++ b/src/pages/Home.vue @@ -314,10 +314,16 @@ const getCurrentLocation = async () => { // 获取当前位置 // const location = localStorage.getItem('userLocation')?JSON.parse(localStorage.getItem('userLocation')):await WechatLocation.getLocation('gcj02'); // 修改为从 cookie 获取位置信息 - const location = getCookie('userLocation') || await WechatLocation.getLocation('gcj02'); + let location = getCookie('userLocation') || await WechatLocation.getLocation('gcj02'); console.log('当前位置:', location); const userStore = useUserStore(); // 解析位置获取城市信息 + if (!location || !location.latitude || !location.longitude) { + location = { + latitude: '24.479627', + longitude: '118.08891' + }; + } if (location && location.latitude && location.longitude) { // if(localStorage.getItem('cityInfo')){ // 修改为从 cookie 获取城市信息