修改定位
This commit is contained in:
@@ -101,8 +101,10 @@ export default {
|
||||
cityName: result.data.cityName,
|
||||
cityId: result.data.cityId
|
||||
};
|
||||
localStorage.setItem('cityInfo', JSON.stringify(result.data));
|
||||
localStorage.setItem('userLocation', JSON.stringify({ ...location, time: new Date().getTime() }));
|
||||
// localStorage.setItem('cityInfo', JSON.stringify(result.data));
|
||||
// localStorage.setItem('userLocation', JSON.stringify({ ...location, time: new Date().getTime() }));
|
||||
setCookie('cityInfo', JSON.stringify(result.data),1);
|
||||
setCookie('userLocation', JSON.stringify({...location, time: new Date().getTime()},1));
|
||||
userStore.setCity(result.data);
|
||||
this.$emit('cityItem',{
|
||||
cityName: result.data.cityName,
|
||||
|
||||
+5
-2
@@ -317,13 +317,16 @@ const getCurrentLocation = async () => {
|
||||
let location = getCookie('userLocation') || await WechatLocation.getLocation('gcj02');
|
||||
console.log('当前位置:', location);
|
||||
const userStore = useUserStore();
|
||||
// 解析位置获取城市信息
|
||||
if (!location || !location.latitude || !location.longitude) {
|
||||
if(!location || !location.latitude || !location.longitude){
|
||||
//删除cookie
|
||||
setCookie('cityInfo', null);
|
||||
//重新赋值location
|
||||
location = {
|
||||
latitude: '24.479627',
|
||||
longitude: '118.08891'
|
||||
};
|
||||
}
|
||||
// 解析位置获取城市信息
|
||||
if (location && location.latitude && location.longitude) {
|
||||
// if(localStorage.getItem('cityInfo')){
|
||||
// 修改为从 cookie 获取城市信息
|
||||
|
||||
Reference in New Issue
Block a user