diff --git a/src/page/bigScreen.vue b/src/page/bigScreen.vue index 2f49673..39ab4da 100644 --- a/src/page/bigScreen.vue +++ b/src/page/bigScreen.vue @@ -46,7 +46,6 @@ import { get } from '@/utils/request'; import chartContainer from './components/chartContainer.vue'; import { initTop5 } from './ts/initTop5'; import AMapLoader from "@amap/amap-jsapi-loader"; -import { log } from 'echarts/types/src/util/log.js'; // 全局状态 const cityGDPStore = useCityGDPStore(); // dom节点 @@ -86,16 +85,25 @@ const getLocation = async (lng: number, lat: number, key: string) => { const now = new Date().getTime(); const cd = 1000 * 60 //会话存储取出json - const location = JSON.parse(sessionStorage.getItem('location')!).time; - if (now - location > cd) { + const location: { time: number, citycode: string } = JSON.parse(sessionStorage.getItem('location')!); + if (!location) { console.log("开始请求"); return true } - console.log(`剩余cd:${(cd - (now - location)) / 1000}s`); + const _time = now - location.time + if (_time > cd) { + console.log("开始请求"); + return true + } + console.log(_time, now, location); + + console.log(`剩余cd:${(cd - _time) / 1000}s`); return false } if (lng && lat && checkTime()) { const res = await get(`${url}/v3/geocode/regeo?key=${key}&location=${lng},${lat}`); + console.log(res); + if (res.status === '1') { const time = new Date().getTime() let data = {} @@ -109,6 +117,11 @@ const getLocation = async (lng: number, lat: number, key: string) => { console.log("地理逆编码错误"); console.log(res); } + let adcode: any = sessionStorage.getItem("location") + adcode = JSON.parse(adcode) + adcode = adcode.citycode + const weather = await get(`${url}/v3/weather/weatherInfo?key=${key}&city=${adcode}`) + console.log(weather); } return null; }; @@ -127,6 +140,7 @@ const initAMap = async (key1: string, key2: string, key3: string) => { console.log("定位成功!"); lng = data.position.lng; lat = data.position.lat; + // 调用逆地理编码获取位置详情 getLocation(lng, lat, key3).then(() => { @@ -141,7 +155,7 @@ const initAMap = async (key1: string, key2: string, key3: string) => { AMap.plugin('AMap.Geolocation', function () { const geolocation = new AMap.Geolocation({ enableHighAccuracy: true, - timeout: 10000, + timeout: 1000000, buttonPosition: "RB", }); geolocation.getCurrentPosition(function (status: any, result: any) { @@ -160,8 +174,8 @@ const initAMap = async (key1: string, key2: string, key3: string) => { onMounted(async () => { //地图传入key,安全密钥,定位服务key - // await initAMap("fe533a0fc1658158460a31b3ae0add51", "43029a44482fc7cdf66b0b590d138278", "48da806104e4bf77be4eeecf83f440aa"); // 初始化高德地图安全配置 - getLocation(120.126893, 30.276614, "48da806104e4bf77be4eeecf83f440aa") + await initAMap("fe533a0fc1658158460a31b3ae0add51", "43029a44482fc7cdf66b0b590d138278", "48da806104e4bf77be4eeecf83f440aa"); // 初始化高德地图安全配置 + // getLocation(120.126893, 30.276614, "48da806104e4bf77be4eeecf83f440aa") await getData(); // 获取数据 calcGDP(); // 计算GDP await initChinaMap(chinaMapRef.value!); // 初始化地图 diff --git a/打开.exe b/打开.exe deleted file mode 100644 index beb36e5..0000000 Binary files a/打开.exe and /dev/null differ