Browse Source

feat: 恢复天气功能

ShangHai_LongXiang
jiannibang 3 years ago
parent
commit
968f333ddb
  1. 13
      src/composables/useInitConfigAndMallInfo.js
  2. 2
      src/composables/useWeather.js
  3. 3
      src/http/api.js

13
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 { useStore } from '@/store/root'
import VConsole from 'vconsole' import VConsole from 'vconsole'
@ -41,9 +41,18 @@ export const useInitConfigAndMallInfo = async () => {
const { buildingList, shopList } = _guideList.data const { buildingList, shopList } = _guideList.data
store.SET_SHOP_LIST(shopList.filter(({ yaxis }) => !!yaxis)) store.SET_SHOP_LIST(shopList.filter(({ yaxis }) => !!yaxis))
store.SET_BUILDING_LIST(buildingList) store.SET_BUILDING_LIST(buildingList)
let weather = {}
try {
const { data } = await getWeather()
console.log(data)
weather = data
} catch (error) {
console.log(error)
}
const { const {
data: { searchList, recommendList } data: { searchList, recommendList }
} = await getQMGoShopData() } = await getQMGoShopData()
const shopMap = shopList.reduce((acc, nxt) => ({ ...acc, [nxt.shopCode]: nxt }), {}) 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] })) })
} }

2
src/composables/useWeather.js

@ -10,7 +10,7 @@ export const useWeather = () => {
{ icon: 'icon-duoyunzhuanyin', status: '阴' } { icon: 'icon-duoyunzhuanyin', status: '阴' }
] ]
const store = useStore() 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]) const icon = computed(() => status.find(item => weather.value?.status?.includes(item.status)) ?? status[0])
return { weather, icon } return { weather, icon }

3
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 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`) export const getCurrentFloor = () => get(`./static/offline/JSON/getDevCoordinateByIP.json`)

Loading…
Cancel
Save