detail.vue 3.8 KB

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