index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="antiquity-detail">
  3. <topbar />
  4. <div class="antiquity-detail-two">
  5. <template v-if="!isThree">
  6. <div
  7. v-if="Array.isArray(detail?.img) && detail.img.length"
  8. class="antiquity-detail-two-left"
  9. >
  10. <ElImage :src="getEnvImagePath(detail?.minImg)" />
  11. <img
  12. class="antiquity-detail-two-left__preview"
  13. draggable="false"
  14. :src="FullscreenImg"
  15. @click="handlePreviewImg"
  16. />
  17. </div>
  18. </template>
  19. <div v-else class="antiquity-detail-two-left is-model">
  20. <iframe ref="iframe" :src="`./model.html?m=${detail?.link}`" />
  21. <div class="antiquity-detail-two-left-tools">
  22. <img
  23. draggable="false"
  24. :src="isFullscreen ? UnFullscreenImg : FullscreenImg"
  25. @click="toggle"
  26. />
  27. <img
  28. draggable="false"
  29. src="@/assets/images/2.png"
  30. @click="handleZoom"
  31. />
  32. <img
  33. draggable="false"
  34. :src="autoPlay ? PauseImg : PlayImg"
  35. @click="handleAutoPlay"
  36. />
  37. <img
  38. draggable="false"
  39. src="@/assets/images/4.png"
  40. @click="handleResetView"
  41. />
  42. </div>
  43. </div>
  44. <ElScrollbar class="antiquity-detail-two-right">
  45. <h3>{{ detail?.name }}</h3>
  46. <div class="antiquity-detail-two-right-content">
  47. <!-- <p v-if="detail?.level">文物等级:{{ detail?.level || "--" }}</p> -->
  48. <p v-if="detail?.size">尺寸:{{ detail?.size || "--" }}</p>
  49. <p v-if="detail?.sd">时代:{{ detail?.sd || "--" }}</p>
  50. <p v-if="detail?.zd">质地:{{ detail?.zd || "--" }}</p>
  51. <p v-if="detail?.from">来源:{{ detail?.from || "--" }}</p>
  52. <p v-if="detail?.type">类别:{{ detail?.type || "--" }}</p>
  53. <p v-if="detail?.address">存放位置:{{ detail?.address || "--" }}</p>
  54. <p v-html="detail?.content" />
  55. </div>
  56. </ElScrollbar>
  57. </div>
  58. </div>
  59. <ElImageViewer v-if="preview" :url-list="imgs" @close="preview = false" />
  60. </template>
  61. <script setup>
  62. import { useFullscreen } from "@vueuse/core";
  63. import { computed, ref } from "vue";
  64. import { antiquityData, getEnvImagePath } from "@helong/base";
  65. import { useRoute } from "vue-router";
  66. import Topbar from "@/components/Topbar.vue";
  67. import FullscreenImg from "@/assets/images/icon.png";
  68. import UnFullscreenImg from "@/assets/images/1.png";
  69. import PlayImg from "@/assets/images/3.png";
  70. import PauseImg from "@/assets/images/3-1.png";
  71. const { isFullscreen, toggle } = useFullscreen();
  72. const route = useRoute();
  73. const detail = computed(() =>
  74. antiquityData.find((i) => i.id === Number(route.params.id))
  75. );
  76. const imgs = computed(() =>
  77. detail.value?.img ? detail.value.img.map((i) => getEnvImagePath(i)) : []
  78. );
  79. const preview = ref(false);
  80. // 是否三维文物
  81. const isThree = computed(() => Boolean(detail.value.link));
  82. const iframe = ref(null);
  83. // 模型自动旋转
  84. const autoPlay = ref(true);
  85. const handlePreviewImg = () => {
  86. preview.value = true;
  87. };
  88. const handleZoom = () => {
  89. iframe.value.contentWindow.webview.zoomIn(); // 放大
  90. };
  91. const handleAutoPlay = () => {
  92. if (!iframe.value.contentWindow.modelLoding) return;
  93. iframe.value.contentWindow.webview.stopRotate();
  94. autoPlay.value = !autoPlay.value;
  95. };
  96. const handleResetView = () => {
  97. iframe.value.contentWindow.webview.resetView();
  98. if (!autoPlay.value) handleAutoPlay();
  99. };
  100. </script>
  101. <style lang="scss" scoped>
  102. @use "./index.scss";
  103. </style>