上传文件

This commit is contained in:
2020-11-12 09:53:30 +08:00
parent 84d3e45292
commit 4b83d61df7
4 changed files with 55 additions and 36 deletions

View File

@@ -14,7 +14,7 @@
<a-upload
list-type="picture"
:customRequest="uploadspic"
:before-upload="beforeUploadpic"
:before-upload="imgs"
>
<div
class="upload-image"
@@ -61,7 +61,7 @@
<a-upload
list-type="picture"
:customRequest="uploads"
:before-upload="beforeUpload"
:before-upload="video"
>
<div class="upload-image" v-if="form.fileurl.length == 0">
<PlaySquareOutlined
@@ -233,7 +233,7 @@ import { PlaySquareOutlined, PlusOutlined } from "@ant-design/icons-vue";
import { useForm } from "@ant-design-vue/use";
import NavBottom from "@/components/NavBottom.vue";
import RankList from "./RankList.vue";
import { previewCover } from "@/utils/common";
import { previewCover, provenimg, provenvideo } from "@/utils/common";
import { FromSend, ImgInfo } from "@/types/index";
import { uploadflie } from "@/utils/vod";
import { cancellive, getlivest, liveadd, liveinfo, setlive } from "@/api";
@@ -475,7 +475,6 @@ export default defineComponent({
}
}
async function uploads(file: AntUpload) {
if (ifallowupload.value) {
console.log(file);
videofile.value = file.file;
videos.value[0].addEventListener("durationchange", () => {
@@ -490,11 +489,9 @@ export default defineComponent({
form.value.fileid = res.fileId;
form.value.fileurl = res.video.url;
}
}
const ifallowpic = ref<boolean>(false);
async function uploadspic(file: AntUpload) {
if (ifallowpic.value) {
const res = await uploadflie(file.file, (info: any) => {
console.log(info);
uploadpicprogress.value = info.percent.toFixed(2) * 100;
@@ -504,7 +501,6 @@ export default defineComponent({
// picinfo.fileId=res.fileId
// picinfo.url=res.video.url
form.value.img = res.video.url;
}
}
getlivest().then((res) => {
@@ -540,6 +536,12 @@ export default defineComponent({
})
}
}
function video(file: any){
return provenvideo(file)
}
function imgs(file: any){
return provenimg(file)
}
return {
labelCol: { span: 4 },
@@ -574,7 +576,9 @@ export default defineComponent({
disabledDate,
isbianji,
onquxiao,
isquxiao
isquxiao,
video,
imgs
};
},
});