|
@@ -1,35 +1,24 @@
|
|
|
<template>
|
|
|
<div class="show-case-container">
|
|
|
+ <audio v-if="audio" ref="audioSound" :src="audio"></audio>
|
|
|
<div class="show-case" v-if="isModel">
|
|
|
<iframe ref="iframeRef" frameborder="0" :src="iframeURL"></iframe>
|
|
|
</div>
|
|
|
<div class="show-case" v-if="isVideo">
|
|
|
- <video
|
|
|
- src="https://4dscene.4dage.com/new4dkk/v2/video/homeVideoNew.mp4"
|
|
|
- autoplay
|
|
|
- playsinline
|
|
|
- ></video>
|
|
|
+ <video :src="video" autoplay playsinline></video>
|
|
|
</div>
|
|
|
<div class="show-case" v-if="isGallery">
|
|
|
- <n-carousel draggable :show-dots="false" show-arrow>
|
|
|
- <img
|
|
|
- class="carousel-img"
|
|
|
- src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel1.jpeg"
|
|
|
- />
|
|
|
- <img
|
|
|
- class="carousel-img"
|
|
|
- src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel2.jpeg"
|
|
|
- />
|
|
|
- <img
|
|
|
- class="carousel-img"
|
|
|
- src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel3.jpeg"
|
|
|
- />
|
|
|
- <img
|
|
|
- class="carousel-img"
|
|
|
- src="https://naive-ui.oss-cn-beijing.aliyuncs.com/carousel-img/carousel4.jpeg"
|
|
|
- />
|
|
|
+ <n-carousel
|
|
|
+ draggable
|
|
|
+ :show-dots="false"
|
|
|
+ show-arrow
|
|
|
+ @update:current-index="handleSlideUpdate"
|
|
|
+ >
|
|
|
+ <template v-for="img in gallery">
|
|
|
+ <img class="carousel-img" :src="img" />
|
|
|
+ </template>
|
|
|
|
|
|
- <template #arrow="{ prev, next }">
|
|
|
+ <template #arrow="{ prev, next }" v-if="gallery.length > 1">
|
|
|
<div class="custom-arrow">
|
|
|
<img class="btn-img" src="@/assets/arrow-left.png" @click="prev" />
|
|
|
<img class="btn-img" src="@/assets/arrow-right.png" @click="next" />
|
|
@@ -50,6 +39,7 @@
|
|
|
<img src="@/assets/icon_model.png" /> 模型
|
|
|
</n-button>
|
|
|
<n-button
|
|
|
+ v-if="video"
|
|
|
class="video btn"
|
|
|
:class="{
|
|
|
active: isVideo,
|
|
@@ -66,7 +56,10 @@
|
|
|
round
|
|
|
@click="handleSwitchType('gallery')"
|
|
|
>
|
|
|
- <img src="@/assets/icon_photo.png" />图片</n-button
|
|
|
+ <img src="@/assets/icon_photo.png" />图片
|
|
|
+ <span v-if="gallery.length > 0">{{
|
|
|
+ `${currentSlideIndex}/${gallery.length}`
|
|
|
+ }}</span></n-button
|
|
|
>
|
|
|
</n-space>
|
|
|
<div class="actions">
|
|
@@ -75,12 +68,9 @@
|
|
|
<img src="@/assets/zoom-out.png" />
|
|
|
<img src="@/assets/reload.png" @click="reloadIframe" />
|
|
|
</div>
|
|
|
- <div v-if="isGallery">
|
|
|
- <img src="@/assets/audio-muted.png" @click="stop" />
|
|
|
- <img
|
|
|
- src="@/assets/audio-unmuted.png"
|
|
|
- @click="!isPlaying ? play() : () => {}"
|
|
|
- />
|
|
|
+ <div v-if="isGallery && audio">
|
|
|
+ <img src="@/assets/audio-muted.png" @click="audioPause" />
|
|
|
+ <img src="@/assets/audio-unmuted.png" @click="audioPlay" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -88,34 +78,21 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, computed } from "vue";
|
|
|
-import { useSound } from "@vueuse/sound";
|
|
|
+import { ref, computed, unref, watch } from "vue";
|
|
|
|
|
|
const iframeRef = ref();
|
|
|
const type = ref("model");
|
|
|
const defaultType = ref(["model", "video", "audio", "gallery"]);
|
|
|
+
|
|
|
const iframeURL = ref("https://www.4dmodel.com/SuperTwo/index.html?m=TEST");
|
|
|
|
|
|
const isModel = computed(() => type.value === "model");
|
|
|
const isVideo = computed(() => type.value === "video");
|
|
|
-const isAudio = computed(() => type.value === "audio");
|
|
|
+// const isAudio = computed(() => type.value === "audio");
|
|
|
const isGallery = computed(() => type.value === "gallery");
|
|
|
-const { play, isPlaying, stop } = useSound(
|
|
|
- "//samplelib.com/lib/preview/mp3/sample-15s.mp3"
|
|
|
-);
|
|
|
-
|
|
|
-const handleSwitchType = (value) => {
|
|
|
- if (defaultType.value.includes(value)) {
|
|
|
- type.value = value;
|
|
|
- if (value === "gallery") {
|
|
|
- play();
|
|
|
- } else {
|
|
|
- stop();
|
|
|
- }
|
|
|
- } else {
|
|
|
- type.value = "model";
|
|
|
- }
|
|
|
-};
|
|
|
+const domain = ref(import.meta.env.VITE_DOMAIN_URL);
|
|
|
+const audioSound = ref("");
|
|
|
+const currentSlideIndex = ref(1);
|
|
|
|
|
|
defineOptions({
|
|
|
name: "show-case",
|
|
@@ -134,12 +111,38 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: () => "",
|
|
|
},
|
|
|
- photos: {
|
|
|
+ gallery: {
|
|
|
type: Array,
|
|
|
default: () => [""],
|
|
|
},
|
|
|
});
|
|
|
|
|
|
+const handleSwitchType = (value) => {
|
|
|
+ if (defaultType.value.includes(value)) {
|
|
|
+ type.value = value;
|
|
|
+ if (value === "gallery") {
|
|
|
+ audioPlay();
|
|
|
+ } else {
|
|
|
+ audioPause();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ type.value = "model";
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const audioPlay = () => {
|
|
|
+ audioSound.value && audioSound.value.play();
|
|
|
+};
|
|
|
+
|
|
|
+const audioPause = () => {
|
|
|
+ audioSound.value && audioSound.value.pause();
|
|
|
+};
|
|
|
+const handleSlideUpdate = (index) => {
|
|
|
+ if (unref(props.gallery).length > 1) {
|
|
|
+ currentSlideIndex.value = index + 1;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const reloadIframe = () => {
|
|
|
if (iframeRef.value) {
|
|
|
try {
|
|
@@ -156,7 +159,7 @@ const reloadIframe = () => {
|
|
|
--show-case-border-radius: 0.625rem;
|
|
|
--show-case-background: #c1b2b2;
|
|
|
--show-case-tools-padding: 1rem;
|
|
|
- --show-case-btn-font-size: 1.125rem;
|
|
|
+ --show-case-btn-font-size: 16px;
|
|
|
--show-case-btn-model-bg: url("/img/show_case_m_bg.png");
|
|
|
--show-case-btn-model-bg-active: url("/img/show_case_m_bg_active.png");
|
|
|
--show-case-btn-video-bg: url("/img/show_case_v_bg.png");
|
|
@@ -250,8 +253,8 @@ const reloadIframe = () => {
|
|
|
// min-width: 80px;
|
|
|
// padding: 10px 40px;
|
|
|
img {
|
|
|
- height: 1.25rem;
|
|
|
- margin-right: 0.5rem;
|
|
|
+ height: 1.0625rem;
|
|
|
+ margin-right: 0.3125rem;
|
|
|
width: auto;
|
|
|
}
|
|
|
&.btn {
|