|
@@ -1,56 +1,25 @@
|
|
|
<template>
|
|
|
<div class="antiquity-detail">
|
|
|
- <img
|
|
|
- class="icon-back"
|
|
|
- src="@/assets/images/back.png"
|
|
|
- @click="$router.back()"
|
|
|
- />
|
|
|
-
|
|
|
+ <img class="icon-back" src="@/assets/images/back.png" @click="$router.push('/antiquity')" />
|
|
|
+ <div class="antiquity-detail-iconLeft" @click="onChangePreItem"><img src="@/assets/images/left.png" alt="" /></div>
|
|
|
<div class="antiquity-detail-two">
|
|
|
<template v-if="!isThree">
|
|
|
- <div
|
|
|
- v-if="Array.isArray(detail?.img) && detail.img.length"
|
|
|
- class="antiquity-detail-two-left"
|
|
|
- >
|
|
|
+ <div v-if="Array.isArray(detail?.img) && detail.img.length" class="antiquity-detail-two-left">
|
|
|
<ElImage :src="getEnvImagePath(detail?.minImg)" />
|
|
|
|
|
|
<div class="antiquity-detail-two-left-tools">
|
|
|
- <img
|
|
|
- draggable="false"
|
|
|
- src="@/assets/images/icon_2-min.png"
|
|
|
- @click="handlePreviewImg"
|
|
|
- />
|
|
|
+ <img draggable="false" src="@/assets/images/icon_2-min.png" @click="handlePreviewImg" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<div v-else class="antiquity-detail-two-left">
|
|
|
- <iframe
|
|
|
- ref="iframe"
|
|
|
- :src="`./model.html?m=${detail?.link}`"
|
|
|
- allowfullscreen="true"
|
|
|
- />
|
|
|
+ <iframe ref="iframe" :src="`./model.html?m=${detail?.link}`" allowfullscreen="true" />
|
|
|
<div class="antiquity-detail-two-left-tools">
|
|
|
- <img
|
|
|
- draggable="false"
|
|
|
- :src="isFullscreen ? UnFullscreenImg : FullscreenImg"
|
|
|
- @click="toggle"
|
|
|
- />
|
|
|
- <img
|
|
|
- draggable="false"
|
|
|
- src="@/assets/images/icon_5-min.png"
|
|
|
- @click="handleZoom"
|
|
|
- />
|
|
|
- <img
|
|
|
- draggable="false"
|
|
|
- :src="autoPlay ? PauseImg : PlayImg"
|
|
|
- @click="handleAutoPlay"
|
|
|
- />
|
|
|
- <img
|
|
|
- draggable="false"
|
|
|
- src="@/assets/images/icon_7-min.png"
|
|
|
- @click="handleResetView"
|
|
|
- />
|
|
|
+ <img draggable="false" :src="isFullscreen ? UnFullscreenImg : FullscreenImg" @click="toggle" />
|
|
|
+ <img draggable="false" src="@/assets/images/icon_5-min.png" @click="handleZoom" />
|
|
|
+ <img draggable="false" :src="autoPlay ? PauseImg : PlayImg" @click="handleAutoPlay" />
|
|
|
+ <img draggable="false" src="@/assets/images/icon_7-min.png" @click="handleResetView" />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -68,66 +37,84 @@
|
|
|
</div>
|
|
|
</ElScrollbar>
|
|
|
</div>
|
|
|
+ <div class="antiquity-detail-iconRight" @click="onChangeNextItem"><img src="@/assets/images/right.png" alt="" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<ElImageViewer v-if="preview" :url-list="imgs" @close="preview = false" />
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { useFullscreen } from "@vueuse/core";
|
|
|
-import { computed, ref } from "vue";
|
|
|
-import { antiquityData, getEnvImagePath } from "@lbc/base";
|
|
|
-import { useRoute } from "vue-router";
|
|
|
-import FullscreenImg from "@/assets/images/icon_2-min.png";
|
|
|
-import UnFullscreenImg from "@/assets/images/icon_4-min.png";
|
|
|
-import PlayImg from "@/assets/images/icon_6-min.png";
|
|
|
-import PauseImg from "@/assets/images/icon_8-min.png";
|
|
|
-
|
|
|
-const { isFullscreen } = useFullscreen();
|
|
|
-const route = useRoute();
|
|
|
+import { useFullscreen } from "@vueuse/core"
|
|
|
+import { computed, ref } from "vue"
|
|
|
+import { antiquityData, getEnvImagePath } from "@lbc/base"
|
|
|
+import { useRoute, useRouter } from "vue-router"
|
|
|
+import FullscreenImg from "@/assets/images/icon_2-min.png"
|
|
|
+import UnFullscreenImg from "@/assets/images/icon_4-min.png"
|
|
|
+import PlayImg from "@/assets/images/icon_6-min.png"
|
|
|
+import PauseImg from "@/assets/images/icon_8-min.png"
|
|
|
+
|
|
|
+const { isFullscreen } = useFullscreen()
|
|
|
+const route = useRoute()
|
|
|
+const router = useRouter()
|
|
|
const detail = computed(() =>
|
|
|
antiquityData.find((i) => i.id === Number(route.params.id))
|
|
|
-);
|
|
|
+)
|
|
|
const imgs = computed(() =>
|
|
|
detail.value?.img ? detail.value.img.map((i) => getEnvImagePath(i)) : []
|
|
|
-);
|
|
|
-const preview = ref(false);
|
|
|
+)
|
|
|
+const preview = ref(false)
|
|
|
// 是否三维文物
|
|
|
-const isThree = computed(() => Boolean(detail.value.link));
|
|
|
-const iframe = ref(null);
|
|
|
+const isThree = computed(() => Boolean(detail.value.link))
|
|
|
+const iframe = ref(null)
|
|
|
// 模型自动旋转
|
|
|
-const autoPlay = ref(true);
|
|
|
+const autoPlay = ref(true)
|
|
|
|
|
|
const handlePreviewImg = () => {
|
|
|
- preview.value = true;
|
|
|
-};
|
|
|
+ preview.value = true
|
|
|
+}
|
|
|
|
|
|
const handleZoom = () => {
|
|
|
- iframe.value.contentWindow.webview.zoomIn(); // 放大
|
|
|
-};
|
|
|
+ iframe.value.contentWindow.webview.zoomIn() // 放大
|
|
|
+}
|
|
|
|
|
|
const handleAutoPlay = () => {
|
|
|
- if (!iframe.value.contentWindow.modelLoding) return;
|
|
|
+ if (!iframe.value.contentWindow.modelLoding) return
|
|
|
|
|
|
- iframe.value.contentWindow.webview.stopRotate();
|
|
|
- autoPlay.value = !autoPlay.value;
|
|
|
-};
|
|
|
+ iframe.value.contentWindow.webview.stopRotate()
|
|
|
+ autoPlay.value = !autoPlay.value
|
|
|
+}
|
|
|
|
|
|
const handleResetView = () => {
|
|
|
- iframe.value.contentWindow.webview.resetView();
|
|
|
+ iframe.value.contentWindow.webview.resetView()
|
|
|
|
|
|
- if (!autoPlay.value) handleAutoPlay();
|
|
|
-};
|
|
|
+ if (!autoPlay.value) handleAutoPlay()
|
|
|
+}
|
|
|
|
|
|
const toggle = () => {
|
|
|
- if (!iframe.value) return;
|
|
|
+ if (!iframe.value) return
|
|
|
|
|
|
- if (iframe.value.requestFullscreen) iframe.value.requestFullscreen();
|
|
|
+ if (iframe.value.requestFullscreen) iframe.value.requestFullscreen()
|
|
|
else if (iframe.value.mozRequestFullScreen)
|
|
|
- iframe.value.mozRequestFullScreen();
|
|
|
+ iframe.value.mozRequestFullScreen()
|
|
|
else if (iframe.value.webkitRequestFullscreen)
|
|
|
- iframe.value.webkitRequestFullscreen();
|
|
|
-};
|
|
|
+ iframe.value.webkitRequestFullscreen()
|
|
|
+}
|
|
|
+
|
|
|
+const currentIndex = computed(() =>
|
|
|
+ antiquityData.findIndex((i) => i.id === Number(route.params.id))
|
|
|
+)
|
|
|
+const nextIndex = computed(() => currentIndex.value + 1)
|
|
|
+const preIndex = computed(() => currentIndex.value - 1)
|
|
|
+const onChangePreItem = () => {
|
|
|
+ if (preIndex.value < 0) return
|
|
|
+ router.push(`/antiquity/detail/${antiquityData[preIndex.value].id}`)
|
|
|
+}
|
|
|
+
|
|
|
+const onChangeNextItem = () => {
|
|
|
+ if (nextIndex.value >= antiquityData.length) return
|
|
|
+ router.push(`/antiquity/detail/${antiquityData[nextIndex.value].id}`)
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|