index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. <!-- 问题提醒 -->
  40. <problem-reminder></problem-reminder>
  41. </div>
  42. </template>
  43. <script setup>
  44. import IndexMap from "./map/index.js";
  45. import { onMounted, computed, ref } from "vue";
  46. import { useStore } from "vuex";
  47. import { useRouter } from "vue-router";
  48. import weatherInfo from "@/components/weatherInfo.vue";
  49. import detailDialog from "@/components/detailDialog.vue"
  50. import homeFloatingPanel from "./components/homeFloatingPanel.vue";
  51. import problemReminder from "./components/problemReminder.vue";
  52. const router = useRouter();
  53. const store = useStore();
  54. const tabBarHeight = computed(() => store.state.home.tabBarHeight);
  55. const indexMap = new IndexMap();
  56. const mapContainer = ref(null);
  57. onMounted(() => {
  58. const point = store.state.home.miniUserLocationPoint
  59. indexMap.initMap(point, mapContainer.value);
  60. });
  61. const isExpanded = ref(false);
  62. const weatherExpanded = (isExpandedValue) => {
  63. isExpanded.value = isExpandedValue;
  64. };
  65. const zIndex = ref(1);
  66. const showAddButton = ref(true);
  67. const heightChange = (height) => {
  68. zIndex.value = 1;
  69. showAddButton.value = true;
  70. if (height === 0) {
  71. showAddButton.value = false;
  72. } else if (height > 310 + tabBarHeight.value) {
  73. zIndex.value = 3;
  74. }
  75. };
  76. function toSubPage() {
  77. router.push({
  78. path: "/create_farm",
  79. });
  80. }
  81. function toFarmPhoto() {
  82. router.push({
  83. path: "/farm_photo",
  84. });
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .home-index {
  89. position: relative;
  90. width: 100%;
  91. height: calc(100vh - 50px);
  92. overflow: hidden;
  93. .map-container {
  94. width: 100%;
  95. height: 100%;
  96. }
  97. .add-button {
  98. position: absolute;
  99. bottom: 20px;
  100. left: 50%;
  101. transform: translateX(-50%);
  102. z-index: 2;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. color: #fff;
  107. background-image: linear-gradient(180deg, #70bffe 0%, #2199f8 100%);
  108. border-radius: 25px;
  109. padding: 12px 0;
  110. width: 187px;
  111. .add-button-icon {
  112. font-size: 20px;
  113. margin-right: 5px;
  114. transform: rotate(45deg);
  115. }
  116. }
  117. .weather-mask {
  118. position: absolute;
  119. top: 0;
  120. left: 0;
  121. width: 100%;
  122. height: 100%;
  123. background-color: rgba(0, 0, 0, 0.52);
  124. z-index: 2;
  125. }
  126. .weather-info {
  127. position: absolute;
  128. top: 12px;
  129. left: 12px;
  130. width: calc(100% - 24px);
  131. z-index: 2;
  132. }
  133. .operation-button{
  134. position: absolute;
  135. top: 117px;
  136. left: 12px;
  137. width: calc(100% - 24px);
  138. z-index: 1;
  139. display: flex;
  140. align-items: center;
  141. justify-content: space-between;
  142. font-size: 12px;
  143. font-weight: 500;
  144. .button-group{
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. .button-item{
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. gap: 4px;
  153. color: rgba(0, 0, 0, 0.8);
  154. background-color: #fff;
  155. .button-icon{
  156. width: 13px;
  157. height: 13px;
  158. }
  159. }
  160. .button-item:first-child{
  161. margin-right: 10px;
  162. }
  163. }
  164. .add-farm-button{
  165. display: flex;
  166. align-items: center;
  167. justify-content: center;
  168. gap: 4px;
  169. background: rgba(0, 0, 0, 0.5);
  170. border: 1px solid rgba(255, 255, 255, 0.5);
  171. color: #fff;
  172. .icon{
  173. font-size: 16px;
  174. transform: rotate(45deg);
  175. }
  176. }
  177. .button-item,
  178. .add-farm-button{
  179. border-radius: 25px;
  180. padding: 8px 12px;
  181. }
  182. }
  183. .home-floating-panel {
  184. position: fixed;
  185. bottom: 0;
  186. left: 0;
  187. width: 100%;
  188. z-index: 1;
  189. }
  190. }
  191. </style>