detail.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <div class="main-background main-background main-background-type2">
  3. <div class="nav-placeholder"></div>
  4. <section class="main-section">
  5. <div class="content">
  6. <div class="d-flex flex-column village-details">
  7. <div
  8. v-if="loading"
  9. class="d-flex justify-content-center align-items-center"
  10. style="min-height: 200px;"
  11. >
  12. <a-spin tip="加载中" />
  13. </div>
  14. <template v-else>
  15. <!-- 轮播图 -->
  16. <ImageSwiper
  17. v-if="data.images && data.images.length > 0"
  18. :items="data.images"
  19. :autoplay="2500"
  20. style="height:300px"
  21. >
  22. <template #item="{ item }">
  23. <img class="swiper-slide" :src="item" />
  24. </template>
  25. </ImageSwiper>
  26. <img
  27. v-else
  28. :src="data.image"
  29. class="swiper-slide"
  30. />
  31. <div class="mt-3" />
  32. <div class="d-flex flex-col content-box">
  33. <SimpleRichHtml
  34. v-if="data.overview"
  35. :contents="[ data.overview ]"
  36. :tag-style="{
  37. a: 'text-decoration: underline ; color: #fff;',
  38. p: 'color: #fff; margin-bottom: 20px;',
  39. img: 'border-radius: 10px;'
  40. }"
  41. />
  42. <span v-else>无内容,请添加内容!</span>
  43. </div>
  44. <div class="mt-3" />
  45. <div class="d-flex flex-row flex-wrap">
  46. <div
  47. v-for="(item, k) in tagsData"
  48. :key="k"
  49. class="tag-item"
  50. >
  51. <NuxtLink :to="{
  52. path: '/village/list',
  53. query: {
  54. id: item.id,
  55. model_id: item.modelId,
  56. main_body_column_id: item.mainBodyColumnId,
  57. region: item.region,
  58. },
  59. }">
  60. <img :src="item.logo" />
  61. <span>{{ item.name }}</span>
  62. </NuxtLink>
  63. </div>
  64. </div>
  65. <div class="mt-3" />
  66. <div class="map-container">
  67. <el-amap
  68. style="width: 100%;"
  69. :center="center"
  70. :zoom="zoom"
  71. @init="handleInit"
  72. >
  73. <el-amap-marker
  74. :position="center"
  75. />
  76. </el-amap>
  77. </div>
  78. <div style="height: 40px;flex-shrink: 0;" />
  79. </template>
  80. </div>
  81. </div>
  82. </section>
  83. </div>
  84. </template>
  85. <script setup lang="ts">
  86. import SimpleRichHtml from '@/components/display/SimpleRichHtml.vue';
  87. import { useRoute } from 'vue-router';
  88. import { ref, watch } from 'vue';
  89. import { ElAmap, ElAmapMarker } from '@vuemap/vue-amap';
  90. import VillageApi, { VillageMenuListItem } from '@/api/village/VillageApi';
  91. import ImageSwiper from '@/components/content/ImageSwiper.vue';
  92. const tagsData = ref<VillageMenuListItem[]>([]);
  93. const route = useRoute();
  94. const data = ref({
  95. image: '',
  96. images: [],
  97. overview: '',
  98. longitude: "",
  99. latitude: '',
  100. modelId: 0,
  101. mainBodyColumnId: 0,
  102. region: 0,
  103. })
  104. const loading = ref(true);
  105. const zoom = ref(12);
  106. const center = ref([121.59996, 31.197646]);
  107. let map: any = null;
  108. function handleInit(mapRef: any) {
  109. map = mapRef;
  110. console.log('handleInit', mapRef);
  111. }
  112. watch(route, () => {
  113. loading.value = true;
  114. if (import.meta.client) {
  115. setTimeout(() => {
  116. loadInfo();
  117. }, 500);
  118. }
  119. }, { immediate: true })
  120. async function loadInfo() {
  121. loading.value = true;
  122. const id = Number(route.query.id);
  123. data.value = {
  124. ...data.value,
  125. ...JSON.parse(localStorage.getItem('VillageTemp') || '{}'),
  126. };
  127. if (data.value.longitude && data.value.latitude) {
  128. center.value = [Number(data.value.longitude), Number(data.value.latitude)];
  129. } else {
  130. center.value = [118.850895, 28.982787];
  131. }
  132. const menu = await VillageApi.getVillageMenuList(id);
  133. loading.value = false;
  134. tagsData.value = menu;
  135. }
  136. </script>
  137. <style lang="scss">
  138. @use "@/assets/scss/colors";
  139. .village-details {
  140. .swiper-slide {
  141. width: 100%;
  142. height: 400px;
  143. object-fit: cover;
  144. }
  145. .tag-item {
  146. width: 13%;
  147. a {
  148. display: flex;
  149. flex-direction: column;
  150. align-items: center;
  151. justify-content: center;
  152. cursor: pointer;
  153. text-decoration: none;
  154. color: colors.$text-color;
  155. img {
  156. width: 40px;
  157. height: 40px;
  158. }
  159. }
  160. }
  161. .content-box {
  162. width: 100%;
  163. padding: 20px;
  164. background-color: colors.$box-color;
  165. border: 1px solid colors.$border-split-color;
  166. box-shadow: 0 0 10px 5px colors.$box-dark-trans-color2;
  167. border-radius: 8px;
  168. }
  169. .map-container {
  170. position: relative;
  171. width: 100%;
  172. height: 250px;
  173. margin: 40px 0;
  174. overflow: hidden;
  175. border-radius: 8px;
  176. flex-shrink: 0;
  177. .el-vue-amap-container {
  178. width: 100%;
  179. }
  180. }
  181. }
  182. </style>