demandHall.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="demand-hall" :style="{ height: `calc(100vh - ${tabBarHeight}px - 50px)` }">
  3. <!-- 地图 -->
  4. <div class="map-container" ref="mapContainer"></div>
  5. <div class="search-wrap">
  6. <el-input
  7. class="search"
  8. v-model="searchValue"
  9. placeholder="搜索位置"
  10. @search="search"
  11. :prefix-icon="Search"
  12. />
  13. </div>
  14. <floating-panel
  15. class="floating-panel"
  16. v-model:height="height"
  17. :anchors="anchors"
  18. :content-draggable="false"
  19. @height-change="handleHeightChange"
  20. >
  21. <template #header>
  22. <div class="header-bar"></div>
  23. <div class="select-group">
  24. <el-select class="select-item" v-model="dateValue" placeholder="Select">
  25. <el-option
  26. v-for="item in dateOptions"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. />
  31. </el-select>
  32. <el-select class="select-item" v-model="areaValue" placeholder="Select">
  33. <el-option
  34. v-for="item in areaOptions"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value"
  38. />
  39. </el-select>
  40. <el-select class="select-item" v-model="areaValue1" placeholder="Select">
  41. <el-option
  42. v-for="item in areaOptions1"
  43. :key="item.value"
  44. :label="item.label"
  45. :value="item.value"
  46. />
  47. </el-select>
  48. </div>
  49. <div class="user-btn" v-if="height === anchors[0]" @click.stop="toPage">
  50. <img class="user-icon" src="@/assets/img/home/user-icon.png" alt="">
  51. 新增用户
  52. </div>
  53. </template>
  54. <div class="hall-content">
  55. <div class="farm-list" ref="cardContentRef" :style="{ height: `${cardContentHeight}px` }">
  56. <div class="task-item" v-for="item in 10" :key="item">
  57. <task-item></task-item>
  58. </div>
  59. </div>
  60. </div>
  61. </floating-panel>
  62. </div>
  63. </template>
  64. <script setup>
  65. import { FloatingPanel } from "vant";
  66. import { computed, nextTick, onMounted, ref } from "vue";
  67. import { useStore } from "vuex";
  68. import IndexMap from "../map/index";
  69. import taskItem from "@/components/taskItem.vue";
  70. import { Search } from "@element-plus/icons-vue";
  71. const props = defineProps({
  72. isCapital: {
  73. type: Boolean,
  74. default: false
  75. }
  76. })
  77. const store = useStore();
  78. const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  79. // const tabBarHeight = ref(localStorage.getItem("tabBarHeight") * 1 || 50);
  80. const anchors = ref([310 + tabBarHeight.value, Math.round(1 * window.innerHeight) - 44]);
  81. const height = ref(anchors.value[0]);
  82. const indexMap = new IndexMap();
  83. const mapContainer = ref(null);
  84. onMounted(() => {
  85. const point = store.state.home.miniUserLocationPoint;
  86. nextTick(() => {
  87. indexMap.initMap(point, mapContainer.value, props.isCapital);
  88. });
  89. });
  90. const cardContentHeight = ref(230);
  91. const searchValue = ref("");
  92. const search = () => {
  93. console.log(searchValue.value);
  94. };
  95. const dateValue = ref("1");
  96. const dateOptions = [
  97. { value: "1", label: "农事类型" },
  98. { value: "2", label: "2" },
  99. { value: "3", label: "3" },
  100. ];
  101. const areaValue = ref("1");
  102. const areaOptions = [
  103. { value: "1", label: "距离" },
  104. { value: "2", label: "2" },
  105. { value: "3", label: "3" },
  106. ];
  107. const areaValue1 = ref("1");
  108. const areaOptions1 = [
  109. { value: "1", label: "区域筛选" },
  110. { value: "2", label: "2" },
  111. { value: "3", label: "3" },
  112. ];
  113. const cardContentRef = ref(null);
  114. const handleHeightChange = ({ height }) => {
  115. if (height === anchors.value[0]) {
  116. cardContentHeight.value = 230;
  117. cardContentRef.value.scrollTo({ top: 0, behavior: "smooth" });
  118. } else if (height === anchors.value[1]) {
  119. cardContentHeight.value = Math.round(1 * window.innerHeight) - (tabBarHeight.value - 40) - 170;
  120. }
  121. };
  122. function toPage() {
  123. console.log('topage');
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .demand-hall {
  128. width: 100%;
  129. height: 100%;
  130. position: relative;
  131. overflow: hidden;
  132. .map-container {
  133. width: 100%;
  134. height: calc(100% - 290px);
  135. }
  136. .search {
  137. position: absolute;
  138. top: 8px;
  139. width: calc(100% - 24px);
  140. left: 12px;
  141. ::v-deep {
  142. .el-input__wrapper {
  143. box-shadow: none;
  144. border-radius: 20px;
  145. }
  146. }
  147. }
  148. .expand-btn-wrap {
  149. position: absolute;
  150. bottom: 12px;
  151. left: 12px;
  152. width: calc(100% - 24px);
  153. background-image: linear-gradient(180deg, #d7eafc 0%, #ffffff 100%);
  154. border-radius: 14px;
  155. padding: 15px 12px;
  156. box-sizing: border-box;
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. font-weight: 500;
  161. font-size: 15px;
  162. .expand-btn {
  163. display: flex;
  164. align-items: center;
  165. justify-content: center;
  166. gap: 4px;
  167. font-size: 13px;
  168. color: #2199f8;
  169. }
  170. }
  171. .hall-content {
  172. height: 100%;
  173. position: relative;
  174. .farm-list {
  175. overflow: auto;
  176. height: calc(100% - 60px);
  177. border-top: 1px solid rgba(0, 0, 0, 0.1);
  178. padding: 8px 12px 12px 12px;
  179. }
  180. .task-item + .task-item {
  181. margin-top: 10px;
  182. }
  183. }
  184. .select-group {
  185. display: flex;
  186. padding: 0 12px;
  187. .select-item {
  188. width: 100%;
  189. ::v-deep {
  190. .el-select__wrapper {
  191. text-align: center;
  192. gap: 2px;
  193. box-shadow: none;
  194. justify-content: center;
  195. background: none;
  196. }
  197. .el-select__selection {
  198. flex: none;
  199. width: fit-content;
  200. }
  201. .el-select__placeholder {
  202. position: static;
  203. transform: none;
  204. width: fit-content;
  205. color: rgba(0, 0, 0, 0.2);
  206. }
  207. .el-select__caret {
  208. color: rgba(0, 0, 0, 0.2);
  209. }
  210. }
  211. }
  212. }
  213. .header-bar {
  214. width: 20px;
  215. height: 3px;
  216. margin: 10px auto 10px auto;
  217. border-radius: 4px;
  218. background: #969799;
  219. }
  220. }
  221. .user-btn {
  222. position: absolute;
  223. z-index: 10;
  224. top: -42px;
  225. right: 12px;
  226. background: #fff;
  227. height: 32px;
  228. display: flex;
  229. align-items: center;
  230. border-radius: 5px;
  231. padding: 0 8px;
  232. font-size: 12px;
  233. color: #2199F8;
  234. .user-icon {
  235. width: 16px;
  236. margin-right: 4px;
  237. }
  238. }
  239. .floating-panel {
  240. width: 100%;
  241. background: #ffffff;
  242. ::v-deep {
  243. .van-floating-panel__content {
  244. background: transparent;
  245. overflow: hidden;
  246. }
  247. .van-floating-panel__header {
  248. position: relative;
  249. &::after {
  250. content: "";
  251. height: 100px;
  252. width: 100%;
  253. position: absolute;
  254. top: 0px;
  255. left: 0;
  256. }
  257. }
  258. }
  259. }
  260. </style>