123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <template>
- <div class="demand-hall" :style="{ height: `calc(100vh - ${tabBarHeight}px - 50px)` }">
- <!-- 地图 -->
- <div class="map-container" ref="mapContainer"></div>
- <div class="search-wrap">
- <el-input
- class="search"
- v-model="searchValue"
- placeholder="搜索位置"
- @search="search"
- :prefix-icon="Search"
- />
- </div>
- <floating-panel
- class="floating-panel"
- v-model:height="height"
- :anchors="anchors"
- :content-draggable="false"
- @height-change="handleHeightChange"
- >
- <template #header>
- <div class="header-bar"></div>
- <div class="select-group">
- <el-select class="select-item" v-model="dateValue" placeholder="Select">
- <el-option
- v-for="item in dateOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <el-select class="select-item" v-model="areaValue" placeholder="Select">
- <el-option
- v-for="item in areaOptions"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- <el-select class="select-item" v-model="areaValue1" placeholder="Select">
- <el-option
- v-for="item in areaOptions1"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
- </div>
- <div class="user-btn" v-if="height === anchors[0]" @click.stop="toPage">
- <img class="user-icon" src="@/assets/img/home/user-icon.png" alt="">
- 新增用户
- </div>
- </template>
- <div class="hall-content">
- <div class="farm-list" ref="cardContentRef" :style="{ height: `${cardContentHeight}px` }">
- <div class="task-item" v-for="item in 10" :key="item">
- <task-item></task-item>
- </div>
- </div>
- </div>
- </floating-panel>
- </div>
- </template>
- <script setup>
- import { FloatingPanel } from "vant";
- import { computed, nextTick, onMounted, ref } from "vue";
- import { useStore } from "vuex";
- import IndexMap from "../map/index";
- import taskItem from "@/components/taskItem.vue";
- import { Search } from "@element-plus/icons-vue";
- const props = defineProps({
- isCapital: {
- type: Boolean,
- default: false
- }
- })
- const store = useStore();
- const tabBarHeight = computed(() => store.state.home.tabBarHeight);
- // const tabBarHeight = ref(localStorage.getItem("tabBarHeight") * 1 || 50);
- const anchors = ref([310 + tabBarHeight.value, Math.round(1 * window.innerHeight) - 44]);
- const height = ref(anchors.value[0]);
- const indexMap = new IndexMap();
- const mapContainer = ref(null);
- onMounted(() => {
- const point = store.state.home.miniUserLocationPoint;
- nextTick(() => {
- indexMap.initMap(point, mapContainer.value, props.isCapital);
- });
- });
- const cardContentHeight = ref(230);
- const searchValue = ref("");
- const search = () => {
- console.log(searchValue.value);
- };
- const dateValue = ref("1");
- const dateOptions = [
- { value: "1", label: "农事类型" },
- { value: "2", label: "2" },
- { value: "3", label: "3" },
- ];
- const areaValue = ref("1");
- const areaOptions = [
- { value: "1", label: "距离" },
- { value: "2", label: "2" },
- { value: "3", label: "3" },
- ];
- const areaValue1 = ref("1");
- const areaOptions1 = [
- { value: "1", label: "区域筛选" },
- { value: "2", label: "2" },
- { value: "3", label: "3" },
- ];
- const cardContentRef = ref(null);
- const handleHeightChange = ({ height }) => {
- if (height === anchors.value[0]) {
- cardContentHeight.value = 230;
- cardContentRef.value.scrollTo({ top: 0, behavior: "smooth" });
- } else if (height === anchors.value[1]) {
- cardContentHeight.value = Math.round(1 * window.innerHeight) - (tabBarHeight.value - 40) - 170;
- }
- };
- function toPage() {
- console.log('topage');
- }
- </script>
- <style lang="scss" scoped>
- .demand-hall {
- width: 100%;
- height: 100%;
- position: relative;
- overflow: hidden;
- .map-container {
- width: 100%;
- height: calc(100% - 290px);
- }
- .search {
- position: absolute;
- top: 8px;
- width: calc(100% - 24px);
- left: 12px;
- ::v-deep {
- .el-input__wrapper {
- box-shadow: none;
- border-radius: 20px;
- }
- }
- }
- .expand-btn-wrap {
- position: absolute;
- bottom: 12px;
- left: 12px;
- width: calc(100% - 24px);
- background-image: linear-gradient(180deg, #d7eafc 0%, #ffffff 100%);
- border-radius: 14px;
- padding: 15px 12px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-weight: 500;
- font-size: 15px;
- .expand-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 4px;
- font-size: 13px;
- color: #2199f8;
- }
- }
- .hall-content {
- height: 100%;
- position: relative;
- .farm-list {
- overflow: auto;
- height: calc(100% - 60px);
- border-top: 1px solid rgba(0, 0, 0, 0.1);
- padding: 8px 12px 12px 12px;
- }
- .task-item + .task-item {
- margin-top: 10px;
- }
- }
-
- .select-group {
- display: flex;
- padding: 0 12px;
- .select-item {
- width: 100%;
- ::v-deep {
- .el-select__wrapper {
- text-align: center;
- gap: 2px;
- box-shadow: none;
- justify-content: center;
- background: none;
- }
- .el-select__selection {
- flex: none;
- width: fit-content;
- }
- .el-select__placeholder {
- position: static;
- transform: none;
- width: fit-content;
- color: rgba(0, 0, 0, 0.2);
- }
- .el-select__caret {
- color: rgba(0, 0, 0, 0.2);
- }
- }
- }
- }
- .header-bar {
- width: 20px;
- height: 3px;
- margin: 10px auto 10px auto;
- border-radius: 4px;
- background: #969799;
- }
- }
- .user-btn {
- position: absolute;
- z-index: 10;
- top: -42px;
- right: 12px;
- background: #fff;
- height: 32px;
- display: flex;
- align-items: center;
- border-radius: 5px;
- padding: 0 8px;
- font-size: 12px;
- color: #2199F8;
- .user-icon {
- width: 16px;
- margin-right: 4px;
- }
- }
- .floating-panel {
- width: 100%;
- background: #ffffff;
- ::v-deep {
- .van-floating-panel__content {
- background: transparent;
- overflow: hidden;
- }
- .van-floating-panel__header {
- position: relative;
- &::after {
- content: "";
- height: 100px;
- width: 100%;
- position: absolute;
- top: 0px;
- left: 0;
- }
- }
- }
- }
- </style>
|