feat:对接首页数据

This commit is contained in:
zjc
2024-12-27 14:50:53 +08:00
parent f7e15899a4
commit 88eb805c46
4 changed files with 84 additions and 29 deletions

9
src/api/home.js Normal file
View File

@@ -0,0 +1,9 @@
import request from './request'
// 彩云天气
export function getWeatherApi() {
return request({
url: '/api/largeScreen/source/weather',
method: 'get'
})
}

View File

@@ -27,11 +27,11 @@
</li> </li>
</ul> </ul>
<div class="weather"> <div class="weather">
<span>25˚C-</span> <span>{{ weatherData?.temperature }}-{{ weatherData?.skycon }}</span>
<span class="line">|</span> <span class="line">|</span>
<span>风速A2-4</span> <span>风速{{ weatherData?.windSpeed }}</span>
<span class="line">|</span> <span class="line">|</span>
<span>空气质量A2-</span> <span>空气质量{{ weatherData?.airQuality }}</span>
<span class="ml-20">{{ currentDate }}</span> <span class="ml-20">{{ currentDate }}</span>
</div> </div>
<div v-if="isBack" class="back" @click="handleBack"> <div v-if="isBack" class="back" @click="handleBack">
@@ -45,6 +45,8 @@
import title2 from '@/assets/images/title-2.png' import title2 from '@/assets/images/title-2.png'
import title2Select from '@/assets/images/title-2-select.png' import title2Select from '@/assets/images/title-2-select.png'
import { getWeatherApi } from '@/api/home'
let props = defineProps({ let props = defineProps({
title: { title: {
type: String, type: String,
@@ -74,6 +76,7 @@
const emit = defineEmits(['change']) const emit = defineEmits(['change'])
const router = useRouter() const router = useRouter()
let currentDate = ref('') let currentDate = ref('')
let weatherData = ref({})
const name = computed(() => { const name = computed(() => {
if (!props.isSkip && props.navLeft.length > 0) { if (!props.isSkip && props.navLeft.length > 0) {
@@ -108,7 +111,13 @@
emit('on-change', index) emit('on-change', index)
} }
} }
const getWeather = async () => {
let res = await getWeatherApi()
weatherData.value = res.data
console.log(res, '====')
}
onMounted(() => { onMounted(() => {
getWeather()
getCurrentDate() getCurrentDate()
setInterval(() => { setInterval(() => {
getCurrentDate() getCurrentDate()

View File

@@ -14,9 +14,9 @@
() => homeData.value?.userPortrait?.ageRate, () => homeData.value?.userPortrait?.ageRate,
() => { () => {
setOption({ setOption({
tooltip: { // tooltip: {
trigger: 'item' // trigger: 'item'
}, // },
legend: { legend: {
orient: 'vertical', orient: 'vertical',
left: '60%', left: '60%',

View File

@@ -198,13 +198,19 @@
<div>调度</div> <div>调度</div>
<div>空余</div> <div>空余</div>
</div> </div>
<div class="cell" v-for="(item, index) in homeData?.carShipData?.car.info" :key="index"> <div class="content">
<div
class="cell"
v-for="(item, index) in homeData?.carShipData?.car.info"
:key="index"
>
<div>{{ item.scenic_area }}</div> <div>{{ item.scenic_area }}</div>
<div>{{ item.started_count }}<span class="unit-1"></span></div> <div>{{ item.started_count }}<span class="unit-1"></span></div>
<div>{{ item.not_started_count }}<span class="unit-1"></span></div> <div>{{ item.not_started_count }}<span class="unit-1"></span></div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div> <div>
<div class="ship"> <div class="ship">
<div class="label">车总数</div> <div class="label">车总数</div>
@@ -218,6 +224,7 @@
<div>调度</div> <div>调度</div>
<div>空余</div> <div>空余</div>
</div> </div>
<div class="content">
<div <div
class="cell" class="cell"
v-for="(item, index) in homeData?.carShipData.ship.info" v-for="(item, index) in homeData?.carShipData.ship.info"
@@ -231,6 +238,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="hotel"> <div class="hotel">
<div> <div>
<div class="item"> <div class="item">
@@ -244,18 +252,19 @@
<div class="item"> <div class="item">
<div class="label">总入住</div> <div class="label">总入住</div>
<countup <countup
class="value" class="value success"
color="#02F9FA"
:end-val="homeData?.hotelData.info.total_guest_count || 0" :end-val="homeData?.hotelData.info.total_guest_count || 0"
/> />
</div> </div>
<div class="item"> <div class="item">
<div class="label">总入住率</div> <div class="label">总入住率</div>
<div class="flex align-center">
<countup <countup
class="value" class="value success"
color="#02F9FA"
:end-val="homeData?.hotelData.info.occupancy_rate || 0" :end-val="homeData?.hotelData.info.occupancy_rate || 0"
/> />
<span class="suffix">%</span>
</div>
</div> </div>
</div> </div>
<div> <div>
@@ -387,7 +396,7 @@
& > div { & > div {
position: relative; position: relative;
flex: 1; flex: 1;
height: vh(110); height: vh(113);
display: flex; display: flex;
align-items: center; align-items: center;
background-image: url('@/assets/images/bg-4.png'); background-image: url('@/assets/images/bg-4.png');
@@ -434,6 +443,7 @@
width: vw(200); width: vw(200);
height: vh(100); height: vh(100);
z-index: 2; z-index: 2;
background: rgba(0, 150, 255, 0.17);
.header { .header {
display: flex; display: flex;
height: vh(18); height: vh(18);
@@ -447,6 +457,23 @@
color: #52b8ff; color: #52b8ff;
} }
} }
.content {
overflow-y: auto;
height: vh(82);
/* 滚动条整体样式 */
&::-webkit-scrollbar {
width: vw(4); /* 滚动条的宽度 */
}
/* 滚动条轨道 */
&::-webkit-scrollbar-track {
background: 'transparent'; /* 轨道的背景色 */
}
/* 滚动条滑块 */
&::-webkit-scrollbar-thumb {
background: rgba(0, 150, 255, 0.63); /* 滑块的背景色 */
border-radius: 5px; /* 滑块的圆角 */
}
}
.cell { .cell {
display: flex; display: flex;
height: vh(27); height: vh(27);
@@ -507,13 +534,23 @@
font-size: vw(24); font-size: vw(24);
color: #ffffff; color: #ffffff;
} }
.success {
color: #02f9fa;
}
.suffix {
margin-top: vh(10);
font-weight: bold;
font-size: vw(24);
color: #02f9fa;
color: #02f9fa;
}
} }
} }
& > div:nth-child(2) { & > div:nth-child(2) {
padding-top: vh(10); padding-top: vh(10);
margin-top: vh(8); margin-top: vh(6);
width: vw(360); width: vw(360);
height: vh(140); height: vh(156);
background-image: url('@/assets/images/bg-4.png'); background-image: url('@/assets/images/bg-4.png');
background-size: 100% 100%; background-size: 100% 100%;
} }
@@ -521,7 +558,7 @@
} }
.occupancy { .occupancy {
:deep(.title-3) { :deep(.title-3) {
margin-top: vh(10); margin-top: vh(6);
} }
} }
.title1 { .title1 {