Commit 7be3fa33 by yancanhua

feat: 新增图片预览功能

1 parent 6fb200ae
Pipeline #148 for 7be3fa33 failed in 0 seconds
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { onMounted, computed, ref } from "vue"; import { onMounted, computed, ref } from "vue";
import { uploadFile } from "@/utils/upload.js"; import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant"; import { showToast } from "vant";
import { showImagePreview } from 'vant';
const props = defineProps({ const props = defineProps({
item: { item: {
...@@ -81,10 +80,14 @@ function updateData() { ...@@ -81,10 +80,14 @@ function updateData() {
} }
// 图片预览 // 图片预览
const imagePreview = ref(false);
const previewImagesList = ref([]);
function previewImage(url: string) { function previewImage(url: string) {
showImagePreview([url]); previewImagesList.value = [url];
imagePreview.value = true;
} }
</script> </script>
<template> <template>
...@@ -97,6 +100,8 @@ function previewImage(url: string) { ...@@ -97,6 +100,8 @@ function previewImage(url: string) {
</div> </div>
</van-overlay> </van-overlay>
<van-image-preview v-model:show="imagePreview" :images="previewImagesList"></van-image-preview>
<div class="buttonSelect"> <div class="buttonSelect">
<div class="title"> <div class="title">
<div class="titleContent"> <div class="titleContent">
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { onMounted, computed, ref } from "vue"; import { onMounted, computed, ref } from "vue";
import { uploadFile } from "@/utils/upload.js"; import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant"; import { showToast } from "vant";
import { showImagePreview } from 'vant';
const props = defineProps({ const props = defineProps({
item: { item: {
...@@ -89,8 +88,11 @@ function updateData() { ...@@ -89,8 +88,11 @@ function updateData() {
} }
// 图片预览 // 图片预览
const imagePreview = ref(false);
const previewImagesList = ref([]);
function previewImage(url: string) { function previewImage(url: string) {
showImagePreview([url]); previewImagesList.value = [url];
imagePreview.value = true;
} }
</script> </script>
...@@ -104,6 +106,9 @@ function previewImage(url: string) { ...@@ -104,6 +106,9 @@ function previewImage(url: string) {
<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>
<div class="buttonSelect"> <div class="buttonSelect">
<div class="title"> <div class="title">
<div class="titleContent"> <div class="titleContent">
...@@ -129,7 +134,7 @@ function previewImage(url: string) { ...@@ -129,7 +134,7 @@ 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" @click="previewImage(url)" class="uploadBoxImg" width="96" height="96" radius="8px" /> <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 标签。
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!