|
|
@@ -1,7 +1,19 @@
|
|
|
<template>
|
|
|
<div class="agri-record-index" :style="{ height: `calc(100vh - ${tabBarHeight}px)` }">
|
|
|
<div class="record-content">
|
|
|
- <div>天气</div>
|
|
|
+ <div>
|
|
|
+ <!-- 天气遮罩 -->
|
|
|
+ <div class="weather-mask" v-show="isExpanded" @click="handleMaskClick"></div>
|
|
|
+ <!-- 天气 -->
|
|
|
+ <weather-info
|
|
|
+ ref="weatherInfoRef"
|
|
|
+ class="weather-info"
|
|
|
+ @weatherExpanded="weatherExpanded"
|
|
|
+ @changeGarden="changeGarden"
|
|
|
+ :isGarden="true"
|
|
|
+ :gardenId="defaultGardenId"
|
|
|
+ ></weather-info>
|
|
|
+ </div>
|
|
|
<div class="record-list">
|
|
|
<div class="line-title">农事记录</div>
|
|
|
<div class="task-content" v-loading="loading">
|
|
|
@@ -24,6 +36,7 @@
|
|
|
<script setup>
|
|
|
import { ref, onMounted, computed, onActivated } from "vue";
|
|
|
import { useStore } from "vuex";
|
|
|
+import weatherInfo from "@/components/weatherInfo.vue";
|
|
|
import taskItem from "@/components/taskItem.vue";
|
|
|
|
|
|
const store = useStore();
|
|
|
@@ -36,6 +49,7 @@ onActivated(() => {
|
|
|
getRecordList();
|
|
|
});
|
|
|
|
|
|
+const defaultGardenId = ref(null);
|
|
|
const taskList = ref([]);
|
|
|
const loading = ref(false);
|
|
|
const noData = ref(false);
|
|
|
@@ -49,13 +63,37 @@ const getRecordList = () => {
|
|
|
.getSimpleList(params)
|
|
|
.then(({ data }) => {
|
|
|
loading.value = false;
|
|
|
- taskList.value = data;
|
|
|
+ taskList.value = [...data, ...data];
|
|
|
if(data.length === 0) {
|
|
|
noData.value = true;
|
|
|
}
|
|
|
})
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+const isExpanded = ref(false);
|
|
|
+const weatherExpanded = (isExpandedValue) => {
|
|
|
+ isExpanded.value = isExpandedValue;
|
|
|
+};
|
|
|
+
|
|
|
+const weatherInfoRef = ref(null);
|
|
|
+// 点击遮罩时收起天气
|
|
|
+const handleMaskClick = () => {
|
|
|
+ if (weatherInfoRef.value && weatherInfoRef.value.toggleExpand) {
|
|
|
+ weatherInfoRef.value.toggleExpand();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const finished = ref(false);
|
|
|
+const gardenId = ref(store.state.home.gardenId);
|
|
|
+const changeGarden = ({ id }) => {
|
|
|
+ localStorage.setItem('isGarden', true);
|
|
|
+ gardenId.value = id;
|
|
|
+ // 更新 store 中的状态
|
|
|
+ store.commit("home/SET_GARDEN_ID", id);
|
|
|
+ finished.value = false;
|
|
|
+};
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -63,7 +101,6 @@ const getRecordList = () => {
|
|
|
width: 100%;
|
|
|
height: 100vh;
|
|
|
box-sizing: border-box;
|
|
|
- padding: 10px 12px;
|
|
|
background: linear-gradient(180deg, #F9F9F9 0%, #F0F8FF 31.47%, #F9F9F9 46.81%, #F9F9F9 69.38%, #F9F9F9 100%);
|
|
|
.line-title {
|
|
|
padding: 10px 0;
|
|
|
@@ -82,5 +119,31 @@ const getRecordList = () => {
|
|
|
border-radius: 20px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .record-content {
|
|
|
+ position: relative;
|
|
|
+ height: 100%;
|
|
|
+ padding: 10px 12px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+ .weather-mask {
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: rgba(0, 0, 0, 0.52);
|
|
|
+ z-index: 2;
|
|
|
+ }
|
|
|
+ .weather-info {
|
|
|
+ width: calc(100% - 20px);
|
|
|
+ position: absolute;
|
|
|
+ z-index: 3;
|
|
|
+ }
|
|
|
+ .record-list {
|
|
|
+ position: relative;
|
|
|
+ top: 100px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|