From c2907a03cd7dae6982d4f6c38f0240a066dcecba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E6=99=93=E8=8C=B9?= <1935832701@qq.com> Date: Thu, 27 Apr 2023 16:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/stationAvatar/index.vue | 143 +++++++++++++++++------ 1 file changed, 105 insertions(+), 38 deletions(-) diff --git a/src/views/system/stationAvatar/index.vue b/src/views/system/stationAvatar/index.vue index 896a540..72660b4 100644 --- a/src/views/system/stationAvatar/index.vue +++ b/src/views/system/stationAvatar/index.vue @@ -25,7 +25,6 @@ " > -
请上传图片为800x800px的正方形
@@ -109,8 +112,9 @@ @click="rotateRight()" > --> - - 提 交 + + 提 交 + 提 交 中...
@@ -123,15 +127,18 @@ import baseurl from "@/api/baseurl.js"; import { updateNurseStationHeads, posts, - updatePoserHeads + uploadVideoUrl, + uploadTrainingCategoryPicture, + updatePoserHeads, + uploadUrl } from "@/api/system/stationAvatar.js"; export default { components: { VueCropper }, - props: ["img", "type", "item", "tovideo"], data() { return { + uploadbtn: true, //上传中不允许点击 imageUrl: "", types: "", // 是否显示弹出层 @@ -175,7 +182,7 @@ export default { } else { this.options.img = baseurl + this.img; } - if (this.types == "posterVideoUrl") { + if (this.types == "posterVideoUrl" || this.types == "itemDirectoryUrl") { this.title = "上传视频"; } else { this.title = "上传图片"; @@ -233,7 +240,7 @@ export default { }, // 上传预处理 beforeUpload(file) { - if (this.types == "posterVideoUrl") { + if (this.types == "posterVideoUrl" || this.types == "itemDirectoryUrl") { const reader = new FileReader(); this.previews.data = file; this.previews.url = URL.createObjectURL(file); @@ -260,50 +267,110 @@ export default { }, // 上传图片 uploadImg() { + this.uploadbtn = true; let formData = new FormData(); if (this.previews.data) { formData.append("file", this.previews.data); formData.append("type", this.types); - if (this.types == "posterVideoUrl") { + if (this.types == "itemDirectoryUrl") { + this.$modal.msgSuccess("上传视频中,请耐心等待"); + this.uploadbtn = false; + uploadVideoUrl(formData).then(response => { + if (response.code == 200) { + this.video.VideoPath = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + this.items.itemDirectoryUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + this.openimg = false; + } else { + setTimeout(e => { + this.openimg = false; + }, 1000); + } + this.uploadbtn = true; + }); + } else if ( + this.types == "trainingItemCoverUrl" || + this.types == "trainingItemContentUrl" || + this.types == "trainingItemPosterUrl" + ) { + uploadUrl(formData).then(response => { + if (response.code == 200) { + this.options.img = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + this.openimg = false; + } else { + setTimeout(e => { + this.openimg = false; + }, 1000); + } + }); + } else if (this.types == "trainingCategoryPictureUrl") { + uploadTrainingCategoryPicture(formData).then(response => { + if (response.code == 200) { + this.options.img = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + this.openimg = false; + } else { + setTimeout(e => { + this.openimg = false; + }, 1000); + } + }); + } else if (this.types == "posterVideoUrl") { updatePoserHeads(formData).then(response => { - this.video.VideoPath = baseurl + response.imgUrl; - this.$emit("imgUrl", response.imgUrl); - this.openimg = false; + if (response.code == 200) { + this.video.VideoPath = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + this.openimg = false; + } else { + setTimeout(e => { + this.openimg = false; + }, 1000); + } }); } else { updateNurseStationHeads(formData).then(response => { - this.options.img = baseurl + response.imgUrl; - this.$emit("imgUrl", response.imgUrl); - if (this.types == "attributePitureUrl") { - this.items.attributePitureUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); + if (response.code == 200) { + this.options.img = baseurl + response.imgUrl; + this.$emit("imgUrl", response.imgUrl); + if (this.types == "attributePitureUrl") { + this.items.attributePitureUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + if (this.types == "nurseItemClassifyUrl") { + this.items.classifyPictureUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + if (this.types == "nurseStationClassifyUrl") { + this.items.classifyPictureUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + if (this.types == "posterPictureUrl") { + this.items.posterPictureUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + if (this.types == "certificateUrl") { + this.items.certificateUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + if (this.types == "personCertificateUrl") { + this.items.certificateUrl = response.imgUrl; + this.$emit("item", JSON.stringify(this.items)); + } + this.openimg = false; + } else { + setTimeout(e => { + this.openimg = false; + }, 1000); } - if (this.types == "nurseItemClassifyUrl") { - this.items.classifyPictureUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } - if (this.types == "nurseStationClassifyUrl") { - this.items.classifyPictureUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } - if (this.types == "posterPictureUrl") { - this.items.posterPictureUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } - if (this.types == "certificateUrl") { - this.items.certificateUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } - if (this.types == "personCertificateUrl") { - this.items.certificateUrl = response.imgUrl; - this.$emit("item", JSON.stringify(this.items)); - } - this.openimg = false; }); } } else { this.openimg = false; } + this.videoForm.showVideoPath = null; + this.previews.data = null; }, // 实时预览 realTime(data) {