Commit 5253a6b2 by yancanhua

feat: 上传新增加载状态

1 parent 7561a064
Pipeline #141 for 5253a6b2 failed in 0 seconds
......@@ -266,11 +266,9 @@ defineExpose({
<template>
<div>
<van-overlay :show="pageLoading">
<van-overlay :show="pageLoading" z-index="2000" >
<div class="loadingBox">
<van-loading color="#1989fa" size="24px" vertical>
加载中...
</van-loading>
<van-loading color="#1989fa" size="24px" vertical>加载中...</van-loading>
</div>
</van-overlay>
<div v-if="!pageLoading">
......
<script setup lang="ts">
import {onMounted, computed, ref } from "vue";
import { onMounted, computed, ref } from "vue";
import { uploadFile } from "@/utils/upload.js";
import { showToast } from "vant";
import { showImagePreview } from 'vant';
......@@ -48,7 +48,7 @@ async function onFileChange(ev: Event) {
const file = input.files?.[0];
input.value = "";
if (!file) return;
const fileSize = file.size / 1024 / 1024;
const fileSize = file.size / 1024 / 1024;
if (fileSize && fileSize > 5) {
return showToast(`文件大小不能超过5MB`);
}
......@@ -88,6 +88,13 @@ function previewImage(url: string) {
</script>
<template>
<div>
<van-overlay :show="uploading" z-index="2000" >
<div class="loadingBox">
<van-loading color="#1989fa" size="24px" vertical>上传中...</van-loading>
</div>
</van-overlay>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
......@@ -110,10 +117,11 @@ function previewImage(url: string) {
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999" name="clear" size="20" />
</div>
<van-image height="96" :src="url" @click="previewImage(url)" style="border-radius: 8px;" width="96" />
<van-image :src="url" @click="previewImage(url)" class="uploadBoxImg" width="96" height="96" radius="8px" />
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
......@@ -182,6 +190,12 @@ function previewImage(url: string) {
border-radius: 8px;
}
.uploadBoxImg {
width: 96px;
height: 96px;
border-radius: 8px;
}
.plusBox {
float: left;
margin-top: 22px;
......@@ -210,4 +224,14 @@ function previewImage(url: string) {
height: 20px;
cursor: pointer;
}
.loadingBox {
position: absolute;
top: 50%;
left: 50%;
width: 80px;
height: 80px;
transform: translate(-50%, -50%);
}
</style>
......@@ -65,9 +65,7 @@ async function onFileChange(ev: Event) {
const url = (typeof res.aliyunAddress === "string" && res.aliyunAddress) || (typeof res.url === "string" && res.url) || "";
showToast("上传成功");
pickerValue.value.push(url);
console.log("pickerValue.value", pickerValue.value);
updateData();
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : String(error);
......@@ -98,6 +96,12 @@ function previewImage(url: string) {
</script>
<template>
<div>
<van-overlay :show="uploading" z-index="2000" >
<div class="loadingBox">
<van-loading color="#1989fa" size="24px" vertical>上传中...</van-loading>
</div>
</van-overlay>
<div class="buttonSelect">
<div class="title">
<div class="titleContent">
......@@ -122,19 +126,16 @@ function previewImage(url: string) {
<div class="deleteBox" @click="handleDelete(url)">
<van-icon color="#999999" name="clear" size="20" />
</div>
<!-- 图片 -->
<van-image v-if="item.interactionType == 'image_upload'" @click="previewImage(url)" height="96" :src="url"
style="border-radius: 8px;height: 96px;width: 96px;" width="96" />
<van-image v-if="item.interactionType == 'image_upload'" :src="url" @click="previewImage(url)" class="uploadBoxImg" width="96" height="96" radius="8px" />
<!-- 视频 -->
<video width="96" v-if="item.interactionType == 'video_upload'" :src="url"
style="border-radius: 8px;height: 96px;width: 96px;" controls>
<video v-if="item.interactionType == 'video_upload'" :src="url" class="uploadBoxImg" controls>
您的浏览器不支持 video 标签。
</video>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
......@@ -203,6 +204,12 @@ function previewImage(url: string) {
border-radius: 8px;
}
.uploadBoxImg {
width: 96px;
height: 96px;
border-radius: 8px;
}
.plusBox {
float: left;
margin-top: 22px;
......@@ -231,4 +238,14 @@ function previewImage(url: string) {
height: 20px;
cursor: pointer;
}
.loadingBox {
position: absolute;
top: 50%;
left: 50%;
width: 80px;
height: 80px;
transform: translate(-50%, -50%);
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!