index.vue 5.5 KB

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