|
@@ -10,8 +10,8 @@
|
|
<div class="swiper-dom view-container">
|
|
<div class="swiper-dom view-container">
|
|
<div class="swiper-wrapper">
|
|
<div class="swiper-wrapper">
|
|
<div class="swiper-slide" v-for="(i, index) in picList">
|
|
<div class="swiper-slide" v-for="(i, index) in picList">
|
|
- <div class="item-box" @click="changeIframe(i)">
|
|
|
|
- <img v-if="iframeData.deatilsImg" :src="`resource/img/details/${i}`" alt="" />
|
|
|
|
|
|
+ <div class="item-box" @click="lookImg(`resource/img/details/${i}`)">
|
|
|
|
+ <img ref="test" v-if="iframeData.deatilsImg" :src="`resource/img/details/${i}`" alt="" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -31,14 +31,18 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <audio v-if="iframeData.deatilsAudio" ref="audioRef" preload="auto" loop class="bgm" :src="`resource/audio/${iframeData.deatilsAudio ? iframeData.deatilsAudio : 'music-user.mp3'}`"></audio>
|
|
|
|
|
|
+ <div class="image-view">
|
|
|
|
+ <viewer :images="images" ref="myViewer" @inited="inited">
|
|
|
|
+ <img v-for="src in images" :key="src" :src="src" />
|
|
|
|
+ </viewer>
|
|
|
|
+ </div>
|
|
|
|
+ <audio v-if="iframeData.deatilsAudio" ref="audioRef" preload="auto" class="bgm" :src="`resource/audio/${iframeData.deatilsAudio ? iframeData.deatilsAudio : 'music-user.mp3'}`"></audio>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
import "swiper/css/swiper.css";
|
|
import "swiper/css/swiper.css";
|
|
import Swiper from "swiper";
|
|
import Swiper from "swiper";
|
|
-import { reactive, ref, toRefs, onBeforeMount, onMounted, defineEmits, defineProps, nextTick, watch } from "vue";
|
|
|
|
|
|
+import { reactive, ref, toRefs, onBeforeMount, onMounted, onUnmounted, defineEmits, defineProps, nextTick, watch } from "vue";
|
|
const props = defineProps(["iframeData"]);
|
|
const props = defineProps(["iframeData"]);
|
|
const emits = defineEmits(["close"]);
|
|
const emits = defineEmits(["close"]);
|
|
const audioRef = ref(null);
|
|
const audioRef = ref(null);
|
|
@@ -53,6 +57,7 @@ let imageSwiper = null;
|
|
const options = {
|
|
const options = {
|
|
freeMode: false,
|
|
freeMode: false,
|
|
};
|
|
};
|
|
|
|
+const images = ref(["https://picsum.photos/200/200", "https://picsum.photos/300/200", "https://picsum.photos/250/200"]);
|
|
const setSwiper = () => {
|
|
const setSwiper = () => {
|
|
imageSwiper = new Swiper(".view-container", options);
|
|
imageSwiper = new Swiper(".view-container", options);
|
|
};
|
|
};
|
|
@@ -66,24 +71,61 @@ watch(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
+const myViewer = ref(null);
|
|
|
|
+const dom = ref(null);
|
|
const handlerPicList = () => {
|
|
const handlerPicList = () => {
|
|
if (props.iframeData.deatilsImg) {
|
|
if (props.iframeData.deatilsImg) {
|
|
//按规则截取字符串
|
|
//按规则截取字符串
|
|
picList.value = props.iframeData.deatilsImg.split("_");
|
|
picList.value = props.iframeData.deatilsImg.split("_");
|
|
}
|
|
}
|
|
- setSwiper();
|
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ setSwiper();
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+const onPause = () => {
|
|
|
|
+ isPlay.value = false;
|
|
};
|
|
};
|
|
-nextTick(() => {
|
|
|
|
- handlerPicList();
|
|
|
|
- rectH.value = contentRef.value.getBoundingClientRect().height;
|
|
|
|
- let domBox = null;
|
|
|
|
- if (props.iframeData.type == "2D") {
|
|
|
|
- domBox = document.querySelector(".image-box");
|
|
|
|
- domBox.style.height = `calc(100% - ${rectH.value - 20}px )`;
|
|
|
|
- } else if (props.iframeData.type == "3D") {
|
|
|
|
- domBox = document.querySelector(".iframe-box");
|
|
|
|
- domBox.style.height = `calc(100% - ${rectH.value - 20}px )`;
|
|
|
|
|
|
+const test = ref(null);
|
|
|
|
+const lookImg = (url) => {
|
|
|
|
+ // if (!dom.value) {
|
|
|
|
+
|
|
|
|
+ // dom.value = myViewer.value.$viewer;
|
|
|
|
+ // }
|
|
|
|
+ // console.error( myViewer.value.$viewer)
|
|
|
|
+
|
|
|
|
+ images.value = [url];
|
|
|
|
+ console.error(myViewer.value.$viewer);
|
|
|
|
+ // myViewer.value.show();
|
|
|
|
+
|
|
|
|
+ if (dom.value) {
|
|
|
|
+ dom.value.show();
|
|
}
|
|
}
|
|
|
|
+};
|
|
|
|
+const inited = (viewer) => {
|
|
|
|
+ dom.value = viewer;
|
|
|
|
+};
|
|
|
|
+onMounted(() => {
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ handlerPicList();
|
|
|
|
+ rectH.value = contentRef.value.getBoundingClientRect().height;
|
|
|
|
+ let domBox = null;
|
|
|
|
+ if (props.iframeData.type == "2D") {
|
|
|
|
+ domBox = document.querySelector(".image-box");
|
|
|
|
+ domBox.style.height = `calc(100% - ${rectH.value - 20}px )`;
|
|
|
|
+ } else if (props.iframeData.type == "3D") {
|
|
|
|
+ domBox = document.querySelector(".iframe-box");
|
|
|
|
+ domBox.style.height = `calc(100% - ${rectH.value - 20}px )`;
|
|
|
|
+ }
|
|
|
|
+ if (audioRef.value) {
|
|
|
|
+ audioRef.value.addEventListener("pause", onPause);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ onUnmounted(() => {
|
|
|
|
+ if (audioRef.value) {
|
|
|
|
+ audioRef.value.removeEventListener("pause", onPause);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
@@ -228,6 +270,26 @@ nextTick(() => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@media screen and (min-height: 1024px) {
|
|
@media screen and (min-height: 1024px) {
|
|
-
|
|
|
|
|
|
+}
|
|
|
|
+.image-view {
|
|
|
|
+ position: absolute;
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ z-index: 100;
|
|
|
|
+ display: none;
|
|
|
|
+ > div {
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 100%;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|
|
|
|
+<style>
|
|
|
|
+.viewer-backdrop {
|
|
|
|
+ background: rgba(0, 0, 0, 0.8);
|
|
|
|
+ backdrop-filter: blur(4px);
|
|
|
|
+ -webkit-backdrop-filter: blur(4px);
|
|
|
|
+}
|
|
|
|
+.viewer-footer {
|
|
|
|
+ display: none;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|