|
|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
|
- <div class="weather-info" :class="{ expanded: isExpanded, 'is-garden': isGarden ,'bg-white': isWhite}">
|
|
|
+ <div class="weather-info is-garden" :class="{ expanded: isExpanded}">
|
|
|
<div class="header flex-center">
|
|
|
<div class="header-left">
|
|
|
- <div class="address-select flex-center" v-if="isGarden">
|
|
|
+ <div class="address-select flex-center" v-if="hasFarm">
|
|
|
<el-dropdown class="select-garden" trigger="click" popper-class="select-garden-popper">
|
|
|
<div class="el-dropdown-link flex-center">
|
|
|
<span class="ellipsis-l1">{{ farmName }}</span>
|
|
|
@@ -31,6 +31,10 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div class="address-select flex-center farm-name" v-else>
|
|
|
+ 示范农场
|
|
|
+ </div>
|
|
|
<div class="temperature flex-center">
|
|
|
<div class="temperature-number">{{ currentWeather.temp || '--' }}</div>
|
|
|
<div class="temperature-text">
|
|
|
@@ -80,10 +84,6 @@ import { convertPointToArray } from "@/utils/index";
|
|
|
const store = useStore();
|
|
|
|
|
|
const props = defineProps({
|
|
|
- isGarden: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
gardenId: {
|
|
|
type: [Number, String],
|
|
|
default: null
|
|
|
@@ -109,11 +109,7 @@ const handleCommand = ({id, name}) => {
|
|
|
};
|
|
|
|
|
|
const isExpanded = ref(false);
|
|
|
-const isWhite = ref(false);
|
|
|
const toggleExpand = () => {
|
|
|
- if(props.isGarden){
|
|
|
- isWhite.value = !isWhite.value;
|
|
|
- }
|
|
|
isExpanded.value = !isExpanded.value;
|
|
|
emit('weatherExpanded',isExpanded.value);
|
|
|
};
|
|
|
@@ -121,6 +117,7 @@ const toggleExpand = () => {
|
|
|
const farmId = ref(null);
|
|
|
const farmName = ref("");
|
|
|
const farmList = ref([]);
|
|
|
+const hasFarm = ref(true)
|
|
|
const isDefaultFarm = ref(false); // 添加默认农场标识
|
|
|
|
|
|
// 根据传入的gardenId设置农场(先刷新列表再设置)
|
|
|
@@ -154,7 +151,10 @@ async function setFarmByGardenId(gardenIdValue) {
|
|
|
resolve(false);
|
|
|
}
|
|
|
} else {
|
|
|
- farmList.value = [{id: 1, name: '示范农场', defaultOption: false, wkt: localStorage.getItem('MINI_USER_LOCATION_POINT')}];
|
|
|
+ farmList.value = [];
|
|
|
+ hasFarm.value = false;
|
|
|
+ getLocationName();
|
|
|
+ getWeatherData();
|
|
|
resolve(false);
|
|
|
}
|
|
|
}).catch(() => {
|
|
|
@@ -215,12 +215,13 @@ function getFarmListWithoutGardenId() {
|
|
|
// const fullData = data.filter(item => item.userType === 2);
|
|
|
const fullData = data;
|
|
|
farmList.value = fullData || [];
|
|
|
- console.log('getFarmListWithoutGardenId', fullData);
|
|
|
if (fullData && fullData.length > 0) {
|
|
|
selectFarmFromList(fullData);
|
|
|
} else {
|
|
|
- farmList.value = [{id: 1, name: '示范农场', defaultOption: false, wkt: localStorage.getItem('MINI_USER_LOCATION_POINT')}];
|
|
|
- selectFarmFromList(farmList.value);
|
|
|
+ farmList.value = [];
|
|
|
+ hasFarm.value = false;
|
|
|
+ getLocationName();
|
|
|
+ getWeatherData();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -275,19 +276,9 @@ const weatherData = ref(null);
|
|
|
const currentWeather = ref({ temp: "--", text: "--", iconDay: "" });
|
|
|
const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
|
|
|
function getLocationName() {
|
|
|
- const farmLocation = convertPointToArray(localStorage.getItem('selectedFarmPoint'));
|
|
|
- let formattedLocation = null;
|
|
|
-
|
|
|
- if (farmLocation) {
|
|
|
- formattedLocation = `${farmLocation[1]},${farmLocation[0]}`;
|
|
|
- } else {
|
|
|
- const location = store.state.home.miniUserLocation;
|
|
|
- // 将 location 从"经度,纬度"格式转换为"纬度,经度"格式
|
|
|
- if (typeof location === 'string' && location.includes(',')) {
|
|
|
- const [lng, lat] = location.split(',');
|
|
|
- formattedLocation = `${lat},${lng}`;
|
|
|
- }
|
|
|
- }
|
|
|
+ const locationPoint = localStorage.getItem('selectedFarmPoint') || store.state.home.miniUserLocationPoint;
|
|
|
+ const farmLocation = convertPointToArray(locationPoint);
|
|
|
+ let formattedLocation = `${farmLocation[1]},${farmLocation[0]}`;
|
|
|
const params = {
|
|
|
key: MAP_KEY,
|
|
|
location: formattedLocation,
|
|
|
@@ -361,6 +352,7 @@ const currentDateText = computed(() => {
|
|
|
|
|
|
&.expanded {
|
|
|
height: 312px;
|
|
|
+ background-image: linear-gradient(90deg, #e2f1fe 0%, #ffffff 80%);
|
|
|
}
|
|
|
|
|
|
&.bg-white{
|
|
|
@@ -427,6 +419,10 @@ const currentDateText = computed(() => {
|
|
|
border: 1px solid rgba(145, 145, 145, 0.5);
|
|
|
}
|
|
|
}
|
|
|
+ .farm-name {
|
|
|
+ font-size: 16px;
|
|
|
+ color: #1D2129;
|
|
|
+ }
|
|
|
.temperature {
|
|
|
.temperature-number {
|
|
|
font-size: 40px;
|