index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="home-index" :style="{ height: `calc(100vh - ${tabBarHeight}px)` }">
  3. <!-- 地图 -->
  4. <div class="map-container" ref="mapContainer"></div>
  5. <!-- 新建按钮 -->
  6. <div class="add-button" v-show="showAddButton" @click="toSubPage">
  7. <el-icon class="add-button-icon"><CircleCloseFilled /></el-icon>
  8. <span>创建我的农场</span>
  9. </div>
  10. <!-- 天气遮罩 -->
  11. <div class="weather-mask" v-show="isExpanded"></div>
  12. <!-- 天气 -->
  13. <weather-info class="weather-info" @weatherExpanded="weatherExpanded"></weather-info>
  14. <!-- 操作按钮 -->
  15. <div class="operation-button">
  16. <div class="button-group">
  17. <div class="button-item">
  18. <img class="button-icon" src="@/assets/img/tab_bar/home-active.png" alt="">
  19. <span>基本信息</span>
  20. </div>
  21. <div class="button-item" @click="toFarmPhoto">
  22. <img class="button-icon" src="@/assets/img/home/photo-icon.png" alt="">
  23. <span>农场相册</span>
  24. </div>
  25. </div>
  26. <div class="add-farm-button">
  27. <el-icon class="icon"><CircleCloseFilled /></el-icon>
  28. <span>新增农场</span>
  29. </div>
  30. </div>
  31. <!-- 浮动面板 -->
  32. <home-floating-panel
  33. class="home-floating-panel"
  34. :style="{ zIndex: zIndex }"
  35. @heightChange="heightChange"
  36. ></home-floating-panel>
  37. <!-- 农事信息弹窗 -->
  38. <detail-dialog></detail-dialog>
  39. </div>
  40. </template>
  41. <script setup>
  42. import IndexMap from "./map/index.js";
  43. import { onMounted, computed, ref } from "vue";
  44. import { useStore } from "vuex";
  45. import { useRouter } from "vue-router";
  46. import weatherInfo from "@/components/weatherInfo.vue";
  47. import detailDialog from "@/components/detailDialog.vue"
  48. import homeFloatingPanel from "./components/homeFloatingPanel.vue";
  49. const router = useRouter();
  50. const store = useStore();
  51. const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  52. const indexMap = new IndexMap();
  53. const mapContainer = ref(null);
  54. onMounted(() => {
  55. const point = store.state.home.miniUserLocationPoint
  56. indexMap.initMap(point, mapContainer.value);
  57. });
  58. const isExpanded = ref(false);
  59. const weatherExpanded = (isExpandedValue) => {
  60. isExpanded.value = isExpandedValue;
  61. };
  62. const zIndex = ref(1);
  63. const showAddButton = ref(true);
  64. const heightChange = (height) => {
  65. zIndex.value = 1;
  66. showAddButton.value = true;
  67. if (height === 0) {
  68. showAddButton.value = false;
  69. } else if (height > 310 + tabBarHeight.value) {
  70. zIndex.value = 3;
  71. }
  72. };
  73. function toSubPage() {
  74. router.push({
  75. path: "/create_farm",
  76. });
  77. }
  78. function toFarmPhoto() {
  79. router.push({
  80. path: "/farm_photo",
  81. });
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .home-index {
  86. position: relative;
  87. width: 100%;
  88. height: calc(100vh - 50px);
  89. overflow: hidden;
  90. .map-container {
  91. width: 100%;
  92. height: 100%;
  93. }
  94. .add-button {
  95. position: absolute;
  96. bottom: 20px;
  97. left: 50%;
  98. transform: translateX(-50%);
  99. z-index: 2;
  100. display: flex;
  101. align-items: center;
  102. justify-content: center;
  103. color: #fff;
  104. background-image: linear-gradient(180deg, #70bffe 0%, #2199f8 100%);
  105. border-radius: 25px;
  106. padding: 12px 0;
  107. width: 187px;
  108. .add-button-icon {
  109. font-size: 20px;
  110. margin-right: 5px;
  111. transform: rotate(45deg);
  112. }
  113. }
  114. .weather-mask {
  115. position: absolute;
  116. top: 0;
  117. left: 0;
  118. width: 100%;
  119. height: 100%;
  120. background-color: rgba(0, 0, 0, 0.52);
  121. z-index: 2;
  122. }
  123. .weather-info {
  124. position: absolute;
  125. top: 12px;
  126. left: 12px;
  127. width: calc(100% - 24px);
  128. z-index: 2;
  129. }
  130. .operation-button{
  131. position: absolute;
  132. top: 117px;
  133. left: 12px;
  134. width: calc(100% - 24px);
  135. z-index: 1;
  136. display: flex;
  137. align-items: center;
  138. justify-content: space-between;
  139. font-size: 12px;
  140. font-weight: 500;
  141. .button-group{
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. .button-item{
  146. display: flex;
  147. align-items: center;
  148. justify-content: center;
  149. gap: 4px;
  150. color: rgba(0, 0, 0, 0.8);
  151. background-color: #fff;
  152. .button-icon{
  153. width: 13px;
  154. height: 13px;
  155. }
  156. }
  157. .button-item:first-child{
  158. margin-right: 10px;
  159. }
  160. }
  161. .add-farm-button{
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. gap: 4px;
  166. background: rgba(0, 0, 0, 0.5);
  167. border: 1px solid rgba(255, 255, 255, 0.5);
  168. color: #fff;
  169. .icon{
  170. font-size: 16px;
  171. transform: rotate(45deg);
  172. }
  173. }
  174. .button-item,
  175. .add-farm-button{
  176. border-radius: 25px;
  177. padding: 8px 12px;
  178. }
  179. }
  180. .home-floating-panel {
  181. position: fixed;
  182. bottom: 0;
  183. left: 0;
  184. width: 100%;
  185. z-index: 1;
  186. }
  187. }
  188. </style>