index.vue 5.8 KB

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