| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <template>
- <div class="select-group">
- <el-select class="custom-select" v-model="farmVal" size="large" v-show="!toggle">
- <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- <div class="weather-wrap" :class="{'weather-transition':toggle}">
- <div class="weather-t">
- <div class="weather-l">
- <div class="weather-icon">
- <i :class="'qi-' + weatherInfo.iconDay + '-fill'"></i>
- </div>
- <span>{{ weatherInfo.tempAvg }}°C</span>
- </div>
- <div class="weather-r">
- <div class="line"></div>
- {{ formattedDate }}
- </div>
- <div class="arrow" @click="handleToggle">
- <el-icon v-show="!toggle" size="12"><ArrowDownBold /></el-icon>
- <el-icon v-show="toggle" size="12"><ArrowUpBold /></el-icon>
- </div>
- </div>
- <div class="weather-b">近14天晴天占比80%,温度波动较小,有利于荔枝糖分与风味积累</div>
- <div v-if="toggle" class="weather-chart">
- <span class="title">14天天气预报</span>
- <div class="chart-wrap">
- <weather-chart class="chart-dom"></weather-chart>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { onMounted, ref } from "vue";
- import { convertPointToArray } from "@/utils/index";
- import weatherChart from "./weatherChart.vue"
- const toggle = ref(false)
- const handleToggle = () =>{
- toggle.value = !toggle.value
- emit('toggle',toggle.value)
- }
- const farmVal = ref("");
- const options = ref([]);
- const emit = defineEmits(['gardenList','toggle'])
- const getGardenList = () => {
- VE_API.index.fetchGardenList({current: 1, size: 50}).then(res => {
- options.value = res.data;
- farmVal.value = res.data[0].id
- emit('gardenList',res.data)
- });
- };
- const weatherInfo = ref({});
- // 气象信息
- const fetchData = () => {
- VE_API.home.weatherInfo({ point: localStorage.getItem('MINI_USER_LOCATION_POINT') }).then(({ data }) => {
- data.tempAvg = (data.tempMin + data.tempMax) / 2;
- weatherInfo.value = data || {};
- });
- };
- const currentDate = new Date();
- const month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
- const day = currentDate.getDate().toString().padStart(2, '0');
- // MM/DD
- const formattedDate = `${month}/${day}`;
- onMounted(() => {
- fetchData();
- getGardenList()
- });
- </script>
- <style lang="scss" scoped>
- .select-group {
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: space-between;
- align-items: baseline;
- .custom-select{
- width: 110px;
- ::v-deep{
- .el-select__wrapper{
- box-shadow: none;
- background: rgba(0, 0, 0, 0.3);
- border: 1px solid rgba(255, 255, 255, 0.4);
- border-radius: 20px;
- }
- .el-select__caret,.el-select__placeholder{
- color: #fff;
- }
- }
- }
- .weather-wrap {
- color: #fff;
- background: rgba(0, 0, 0, 0.6);
- border: 1px solid rgba(255, 255, 255, 0.4);
- border-radius: 10px;
- font-size: 12px;
- width: calc(100% - 125px);
- padding: 8px 10px;
- box-sizing: border-box;
- transition: all 0.3s;
- backdrop-filter: blur(2px);
- .weather-t{
- display: flex;
- align-items: center;
- position: relative;
- .arrow{
- position: absolute;
- right: 0;
- top: 0;
- width: 20px;
- height: 20px;
- text-align: center;
- line-height: 22px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.12);
- }
- .weather-l,
- .weather-r {
- display: flex;
- align-items: center;
- }
- .weather-icon {
- width: 18px;
- height: 18px;
- margin-right: 4px;
- i {
- display: block;
- width: 18px;
- height: 18px;
- font-size: 18px;
- left: 1px;
- top: 2px;
- }
- }
- .line {
- margin: 0 6px 0 6px;
- width: 1px;
- height: 12px;
- background: rgba(255, 255, 255, 0.3);
- }
- }
- .weather-b{
- margin-top: 6px;
- }
- &.weather-transition{
- width: 100%;
- .weather-b{
- border-bottom: 1px solid rgba(255, 255, 255, 0.4);
- padding-bottom: 10px;
- }
- .weather-chart{
- margin-top: 12px;
- .title{
- color: #bbbbbb;
- font-size: 11px;
- }
- .chart-wrap{
- width: 100%;
- height: 150px;
- overflow-x: auto;
- .chart-dom{
- width: 120%;
- height: 100%;
- }
- }
- }
- }
- }
- }
- </style>
|