From 968f333ddb1fc6ee35b942bfa99df6a273ecf646 Mon Sep 17 00:00:00 2001 From: jiannibang <271381693@qq.com> Date: Thu, 29 Jun 2023 10:19:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=81=A2=E5=A4=8D=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useInitConfigAndMallInfo.js | 13 +++++++++++-- src/composables/useWeather.js | 2 +- src/http/api.js | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/composables/useInitConfigAndMallInfo.js b/src/composables/useInitConfigAndMallInfo.js index 7e699e5..593e9cf 100644 --- a/src/composables/useInitConfigAndMallInfo.js +++ b/src/composables/useInitConfigAndMallInfo.js @@ -1,4 +1,4 @@ -import { getConfig, getCurrentFloor, getGuideList, getTheme, getQMGoShopData, getMenuList, getFoodIIndustryList } from '@/http/api' +import { getConfig, getCurrentFloor, getGuideList, getTheme, getQMGoShopData, getMenuList, getFoodIIndustryList, getWeather } from '@/http/api' import { useStore } from '@/store/root' import VConsole from 'vconsole' @@ -41,9 +41,18 @@ export const useInitConfigAndMallInfo = async () => { const { buildingList, shopList } = _guideList.data store.SET_SHOP_LIST(shopList.filter(({ yaxis }) => !!yaxis)) store.SET_BUILDING_LIST(buildingList) + let weather = {} + try { + const { data } = await getWeather() + console.log(data) + weather = data + } catch (error) { + console.log(error) + } const { data: { searchList, recommendList } } = await getQMGoShopData() const shopMap = shopList.reduce((acc, nxt) => ({ ...acc, [nxt.shopCode]: nxt }), {}) - store.SET_INDEX_LIST({ recommendList, hotSearch: searchList.filter(({ shopName }) => shopName).map(item => ({ ...item, ...shopMap[item.shopCode] })) }) + + store.SET_INDEX_LIST({ ...weather, recommendList, hotSearch: searchList.filter(({ shopName }) => shopName).map(item => ({ ...item, ...shopMap[item.shopCode] })) }) } diff --git a/src/composables/useWeather.js b/src/composables/useWeather.js index a7d7015..06ad2f8 100644 --- a/src/composables/useWeather.js +++ b/src/composables/useWeather.js @@ -10,7 +10,7 @@ export const useWeather = () => { { icon: 'icon-duoyunzhuanyin', status: '阴' } ] const store = useStore() - const weather = computed(() => ({ temperature_Now: store.indexList.temperature, status: store.indexList.status })) + const weather = computed(() => ({ temperature_Now: store.indexList.temperatureNow, status: store.indexList.weather })) const icon = computed(() => status.find(item => weather.value?.status?.includes(item.status)) ?? status[0]) return { weather, icon } diff --git a/src/http/api.js b/src/http/api.js index bd2ed33..26c0a12 100644 --- a/src/http/api.js +++ b/src/http/api.js @@ -30,6 +30,9 @@ export const getGuideList = () => get(`./static/offline/JSON/getMapInfo.json`) //获取配置项 export const getConfig = () => get('./static/offline/JSON/config.json') +//获取天气 +export const getWeather = () => get('./static/offline/JSON/getWeather.json') + //获取当前所处楼层 export const getCurrentFloor = () => get(`./static/offline/JSON/getDevCoordinateByIP.json`)