邓洁 : 绑定首页实时数据

This commit is contained in:
邓洁
2023-12-11 00:25:13 +08:00
parent 10268ab2ba
commit 86709fb13d
31 changed files with 588 additions and 279 deletions

View File

@@ -1,7 +1,8 @@
<template>
<div id="item-info">
<div class="label">
<img :src="icon" alt="" />
<div :style="{ backgroundImage: 'url(' +getImageUrl(windIcon)+')' }" class="wind-icon"></div>
<!-- <img :src="params.icon" alt="" />-->
<span>{{ params.name }}</span>
</div>
<div class="container" ref="length">
@@ -15,7 +16,8 @@
</template>
<script setup>
import { onMounted, watch, defineProps, computed } from "vue";
import {onMounted, watch, defineProps, computed} from "vue";
const params = defineProps({
wp: Object,
icon: String,
@@ -28,32 +30,37 @@ const params = defineProps({
// value: 40, //测量值
// point: 60, //阈值
// };
// const wp = reactive(info);
const windIcon = reactive(params.icon);
const length = ref(null);
const value = ref(null);
const point = ref(null);
onMounted(handleOnMounted);
function handleOnMounted() {
// const = length.value.offsetWidth);
setValue();
}
watch(
() => params.wp.value,
(value) => {
setValue();
}
() => params.wp.value,
(value) => {
setValue();
}
);
function setValue() {
const getImageUrl = (name) => {
return new URL(`../../../../assets/images/airInfo/${name}`, import.meta.url).href
}
const setValue = () => {
let width = (params.wp.value * length.value.offsetWidth) / params.wp.max;
value.value.style.width = `${width}px`;
let flag = (params.wp.point * length.value.offsetWidth) / params.wp.max;
point.value.style.left = `${flag}px`;
if (width >= flag) {
value.value.style.background =
"linear-gradient(270deg, #FB3838 0%, #E98526 100%)";
"linear-gradient(270deg, #FB3838 0%, #E98526 100%)";
} else {
value.value.style.background =
"linear-gradient(270deg, #38CAFB 0%, #E9D726 100%)";
"linear-gradient(270deg, #38CAFB 0%, #E9D726 100%)";
}
}
let isWaring = computed(() => {
@@ -69,30 +76,34 @@ const valueAndUnit = computed(() => params.wp.value + params.unit + "");
align-items: center;
width: 100%;
padding: 20px 0px 14px 0px;
.label {
display: flex;
align-items: center;
img {
height: 34px;
.wind-icon{
height: 36px;
width: 34px;
}
span {
width: 101px;
width:70px;
height: 37px;
font-size: 28px;
font-family: MicrosoftYaHei;
color: #d6f1fa;
line-height: 37px;
margin: 0px 20px 0px 14px;
margin: 0 20px 0 22px;
}
}
.container {
width: 422px;
height: 24px;
border-radius: 12px;
border: 1px solid #0f82af;
position: relative;
.value {
height: inherit;
width: 0px;
@@ -100,6 +111,7 @@ const valueAndUnit = computed(() => params.wp.value + params.unit + "");
border-radius: 10px;
transition: width 0.5s linear 0s;
}
#point {
position: absolute;
height: inherit;
@@ -109,6 +121,7 @@ const valueAndUnit = computed(() => params.wp.value + params.unit + "");
left: 1px;
}
}
.value-num {
height: 37px;
width: 160px;
@@ -119,6 +132,7 @@ const valueAndUnit = computed(() => params.wp.value + params.unit + "");
margin-left: 20px;
text-align: right;
}
.warning {
color: #f75f34;
font-size: 28px;