From 93ee24b7ce3db7460602483b1db7b64732438558 Mon Sep 17 00:00:00 2001 From: chenshuichuan <1154693969@qq.com> Date: Tue, 25 Jun 2024 15:51:17 +0800 Subject: [PATCH] fix bug --- src/api/home/info/index.ts | 35 ++++++++++++++++++ src/locales/zh-CN.ts | 2 +- src/views/Home/Index.vue | 72 ++++++++++++++++++++------------------ 3 files changed, 74 insertions(+), 35 deletions(-) create mode 100644 src/api/home/info/index.ts diff --git a/src/api/home/info/index.ts b/src/api/home/info/index.ts new file mode 100644 index 00000000..676feb35 --- /dev/null +++ b/src/api/home/info/index.ts @@ -0,0 +1,35 @@ +import request from '@/config/axios' + +// date": "2024-06-25", +// "week": "2", +// "dayweather": "晴", +// "nightweather": "晴", +// "daytemp": "29", +// "nighttemp": "15", +// "daywind": "东南", +// "nightwind": "东南", +// "daypower": "1-3", +// "nightpower": "1-3" +// 天气 VO +export interface WeatherVO { + date: string + week: string, + dayweather: string, + nightweather: string, + daytemp: string, + nighttemp: string, + daywind: string, + nightwind: string, + daypower: string, + nightpower: string +} +// 生产计划 API +export const HomeApi = { + + + // 查询天气 + getWeatherInfo: async () => { + return await request.get({ url: `/home/info/weatherInfo`}) + }, + +} diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 0721651d..22177264 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -194,7 +194,7 @@ export default { }, workplace: { welcome: '你好', - happyDay: '祝你开心每一天!', + happyDay: '!', toady: '今日晴', notice: '通知公告', project: '项目数', diff --git a/src/views/Home/Index.vue b/src/views/Home/Index.vue index 938c934b..8df1a746 100644 --- a/src/views/Home/Index.vue +++ b/src/views/Home/Index.vue @@ -3,7 +3,7 @@ - +
@@ -12,43 +12,33 @@
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
-
- {{ t('workplace.toady') }},20℃ - 32℃! +
+ {{ weatherData.city }},白天{{ todayWeather.dayweather }},晚上{{ todayWeather.nightweather }} +
+
+ 气温{{ todayWeather.daytemp }}°C~{{ todayWeather.nighttemp }}°C ,{{ todayWeather.daywind }}风{{ todayWeather.daypower }}级
- -
-
-
{{ t('workplace.project') }}
- -
- -
-
{{ t('workplace.toDo') }}
- -
- -
-
{{ t('workplace.access') }}
- -
+ +
+ +
+
+ {{ item.date }} +
+
+ 白天{{ item.dayweather }},晚上{{ item.nightweather }},气温{{ item.daytemp }}°C~{{ item.nighttemp }}°C + ,{{ item.daywind }}风{{ item.daypower }}级 +
+
+
+
+
+ +
+
@@ -180,6 +170,8 @@ import { useUserStore } from '@/store/modules/user' import { useWatermark } from '@/hooks/web/useWatermark' import type { WorkplaceTotal, Project, Notice, Shortcut } from './types' import { pieOptions, barOptions } from './echarts-data' +import {HomeApi} from "@/api/home/info"; +import {WeatherVO} from "@/api/home/info"; defineOptions({ name: 'Home' }) @@ -197,6 +189,18 @@ let totalSate = reactive({ todo: 0 }) +const weatherList = ref([]) +let weatherData = null +let todayWeather = null +/** 初始化 **/ +onMounted(async () => { + // 加载 + weatherData = await HomeApi.getWeatherInfo() + weatherList.value = weatherData.casts + if(weatherData.isEnable && weatherList) + todayWeather = weatherList.value[0]; +}) + const getCount = async () => { const data = { project: 40,