index copy.vue 6.1 KB

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