Commit 24548856 by yancanhua

fix: 上传图片预览及视频预览优化

1 parent 40614fc7
Pipeline #155 for 24548856 failed in 0 seconds
...@@ -95,20 +95,39 @@ function previewImage(url: string) { ...@@ -95,20 +95,39 @@ function previewImage(url: string) {
imagePreview.value = true; imagePreview.value = true;
} }
// 视频预览
const videoShow = ref(false);
const sourceUrl = ref([]);
function previewVideo(url: string) {
sourceUrl.value = [url];
console.log("sourceUrl.value", sourceUrl.value);
videoShow.value = true;
}
</script> </script>
<template> <template>
<div> <div>
<van-overlay :show="uploading" <van-overlay :show="uploading" teleport="#vant-portal-host" z-index="2000">
teleport="#vant-portal-host"
z-index="2000">
<div class="loadingBox"> <div class="loadingBox">
<van-loading color="#1989fa" size="24px" vertical>上传中...</van-loading> <van-loading color="#1989fa" size="24px" vertical>上传中...</van-loading>
</div> </div>
</van-overlay> </van-overlay>
<!-- 图片预览 -->
<van-image-preview v-model:show="imagePreview" :images="previewImagesList"></van-image-preview> <van-image-preview v-model:show="imagePreview" :images="previewImagesList"></van-image-preview>
<!-- 视频预览 -->
<van-image-preview v-model:show="videoShow" :images="sourceUrl" :close-on-click-image="false">
<template #image="{ src }">
<video style="width: 100%;" :src="src" controls>
您的浏览器不支持 video 标签。
</video>
</template>
</van-image-preview>
<div class="buttonSelect"> <div class="buttonSelect">
<div class="title"> <div class="title">
<div class="titleContent"> <div class="titleContent">
...@@ -134,15 +153,19 @@ function previewImage(url: string) { ...@@ -134,15 +153,19 @@ function previewImage(url: string) {
<van-icon color="#999999" name="clear" size="20" /> <van-icon color="#999999" name="clear" size="20" />
</div> </div>
<!-- 图片 --> <!-- 图片 -->
<van-image v-if="item.interactionType == 'image_upload'" :src="url" class="uploadBoxImg" width="96" height="96" radius="8px" @click="previewImage(url)" /> <van-image v-if="item.interactionType == 'image_upload'" :src="url" class="uploadBoxImg" width="96"
height="96" radius="8px" @click="previewImage(url)" />
<!-- 视频 --> <!-- 视频 -->
<video v-if="item.interactionType == 'video_upload'" :src="url" class="uploadBoxImg" controls> <video v-if="item.interactionType == 'video_upload'" :src="url" class="uploadBoxImg" controls>
您的浏览器不支持 video 标签。 您的浏览器不支持 video 标签。
</video> </video>
<!-- 点击视频预览 -->
<div v-if="item.interactionType == 'video_upload'" class="videoPreviewBox"
@click="previewVideo(url)"></div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -240,7 +263,7 @@ function previewImage(url: string) { ...@@ -240,7 +263,7 @@ function previewImage(url: string) {
position: absolute; position: absolute;
top: 2px; top: 2px;
right: 2px; right: 2px;
z-index: 99; z-index: 999;
width: 20px; width: 20px;
height: 20px; height: 20px;
cursor: pointer; cursor: pointer;
...@@ -255,4 +278,14 @@ function previewImage(url: string) { ...@@ -255,4 +278,14 @@ function previewImage(url: string) {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.videoPreviewBox {
position: absolute;
top: 0px;
left: 0;
width: 96px;
height: 96px;
background: rgba(0, 0, 0, 0.5);
opacity: 0.1;
z-index: 9;
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!