liutao_branch
chenshuichuan 2 years ago
parent 27a84369c7
commit 93ee24b7ce

@ -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`})
},
}

@ -194,7 +194,7 @@ export default {
}, },
workplace: { workplace: {
welcome: '你好', welcome: '你好',
happyDay: '祝你开心每一天!', happyDay: '!',
toady: '今日晴', toady: '今日晴',
notice: '通知公告', notice: '通知公告',
project: '项目数', project: '项目数',

@ -3,7 +3,7 @@
<el-card shadow="never"> <el-card shadow="never">
<el-skeleton :loading="loading" animated> <el-skeleton :loading="loading" animated>
<el-row :gutter="16" justify="space-between"> <el-row :gutter="16" justify="space-between">
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24"> <el-col :xl="8" :lg="8" :md="12" :sm="24" :xs="24">
<div class="flex items-center"> <div class="flex items-center">
<el-avatar :src="avatar" :size="70" class="mr-16px"> <el-avatar :src="avatar" :size="70" class="mr-16px">
<img src="@/assets/imgs/avatar.gif" alt="" /> <img src="@/assets/imgs/avatar.gif" alt="" />
@ -12,43 +12,33 @@
<div class="text-20px"> <div class="text-20px">
{{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }} {{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
</div> </div>
<div class="mt-10px text-14px text-gray-500"> <div v-if="weatherData.isEnable" class="mt-10px text-14px text-gray-500">
{{ t('workplace.toady') }}20 - 32 {{ weatherData.city }}白天{{ todayWeather.dayweather }}晚上{{ todayWeather.nightweather }}
</div>
<div v-if="weatherData.isEnable" class="mt-10px text-14px text-gray-500">
气温{{ todayWeather.daytemp }}°C~{{ todayWeather.nighttemp }}°C {{ todayWeather.daywind }}{{ todayWeather.daypower }}
</div> </div>
</div> </div>
</div> </div>
</el-col> </el-col>
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24"> <el-col :xl="8" :lg="8" :md="12" :sm="24" :xs="24">
<div class="h-70px flex items-center justify-end lt-sm:mt-10px"> <div class="flex items-center">
<div class="px-8px text-right"> <el-col v-for="item in weatherList.slice(1, 4)" :key="item.date" :xl="12" :lg="12" :md="12" :sm="12" :xs="12">
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.project') }}</div> <div>
<CountTo <div class="text-16px">
class="text-20px" {{ item.date }}
:start-val="0" </div>
:end-val="totalSate.project" <div class="mt-10px text-14px text-gray-500">
:duration="2600" 白天{{ item.dayweather }}晚上{{ item.nightweather }}气温{{ item.daytemp }}°C~{{ item.nighttemp }}°C
/> {{ item.daywind }}{{ item.daypower }}
</div> </div>
<el-divider direction="vertical" /> </div>
<div class="px-8px text-right"> </el-col>
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.toDo') }}</div> </div>
<CountTo </el-col>
class="text-20px" <el-col :xl="8" :lg="8" :md="12" :sm="24" :xs="24">
:start-val="0" <div>
:end-val="totalSate.todo"
:duration="2600"
/>
</div>
<el-divider direction="vertical" border-style="dashed" />
<div class="px-8px text-right">
<div class="mb-16px text-14px text-gray-400">{{ t('workplace.access') }}</div>
<CountTo
class="text-20px"
:start-val="0"
:end-val="totalSate.access"
:duration="2600"
/>
</div>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
@ -180,6 +170,8 @@ import { useUserStore } from '@/store/modules/user'
import { useWatermark } from '@/hooks/web/useWatermark' import { useWatermark } from '@/hooks/web/useWatermark'
import type { WorkplaceTotal, Project, Notice, Shortcut } from './types' import type { WorkplaceTotal, Project, Notice, Shortcut } from './types'
import { pieOptions, barOptions } from './echarts-data' import { pieOptions, barOptions } from './echarts-data'
import {HomeApi} from "@/api/home/info";
import {WeatherVO} from "@/api/home/info";
defineOptions({ name: 'Home' }) defineOptions({ name: 'Home' })
@ -197,6 +189,18 @@ let totalSate = reactive<WorkplaceTotal>({
todo: 0 todo: 0
}) })
const weatherList = ref<WeatherVO[]>([])
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 getCount = async () => {
const data = { const data = {
project: 40, project: 40,

Loading…
Cancel
Save