|
@@ -123,6 +123,7 @@
|
|
import dayjs from "dayjs";
|
|
import dayjs from "dayjs";
|
|
import Header from "@/components/header";
|
|
import Header from "@/components/header";
|
|
import SelectGroup from "./selectGroup";
|
|
import SelectGroup from "./selectGroup";
|
|
|
|
+import qs from "qs";
|
|
import { uploadFile } from "@/api/app";
|
|
import { uploadFile } from "@/api/app";
|
|
import {
|
|
import {
|
|
imSendGroupMessageSend,
|
|
imSendGroupMessageSend,
|
|
@@ -130,6 +131,7 @@ import {
|
|
imSendGroupMessageUpdate,
|
|
imSendGroupMessageUpdate,
|
|
policy,
|
|
policy,
|
|
} from "./api";
|
|
} from "./api";
|
|
|
|
+import axios from "axios";
|
|
export default {
|
|
export default {
|
|
name: "operation",
|
|
name: "operation",
|
|
components: { Header, SelectGroup },
|
|
components: { Header, SelectGroup },
|
|
@@ -157,6 +159,15 @@ export default {
|
|
sendTime: query.sendTime || "",
|
|
sendTime: query.sendTime || "",
|
|
targetIds: targetIds || "",
|
|
targetIds: targetIds || "",
|
|
},
|
|
},
|
|
|
|
+ ossUploadUrl: "https://ks3-cn-beijing.ksyuncs.com/daya",
|
|
|
|
+ dataObj: {
|
|
|
|
+ policy: "",
|
|
|
|
+ signature: "",
|
|
|
|
+ key: "",
|
|
|
|
+ KSSAccessKeyId: "",
|
|
|
|
+ acl: "public-read",
|
|
|
|
+ name: "",
|
|
|
|
+ },
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -185,11 +196,15 @@ export default {
|
|
},
|
|
},
|
|
async afterRead(file) {
|
|
async afterRead(file) {
|
|
// 上传头像
|
|
// 上传头像
|
|
-
|
|
|
|
|
|
+ // console.log(file);
|
|
|
|
+ const form = this.form;
|
|
try {
|
|
try {
|
|
- let fileName = file.name.replaceAll(" ", "_");
|
|
|
|
|
|
+ file.status = "uploading";
|
|
|
|
+ file.message = "上传中...";
|
|
|
|
+ let tempName = file.file.name || "";
|
|
|
|
+ const fileName = tempName && tempName.replace(/ /gi, "_");
|
|
let key = new Date().getTime() + fileName;
|
|
let key = new Date().getTime() + fileName;
|
|
- let obj = {
|
|
|
|
|
|
+ let objTemp = {
|
|
filename: fileName,
|
|
filename: fileName,
|
|
bucketName: this.bucket_name,
|
|
bucketName: this.bucket_name,
|
|
postData: {
|
|
postData: {
|
|
@@ -200,8 +215,8 @@ export default {
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
|
|
- const res = await policy(obj);
|
|
|
|
- this.dataObj = {
|
|
|
|
|
|
+ const res = await policy(objTemp);
|
|
|
|
+ const obj = {
|
|
policy: res.data.policy,
|
|
policy: res.data.policy,
|
|
signature: res.data.signature,
|
|
signature: res.data.signature,
|
|
key: key,
|
|
key: key,
|
|
@@ -209,15 +224,38 @@ export default {
|
|
acl: "public-read",
|
|
acl: "public-read",
|
|
name: fileName,
|
|
name: fileName,
|
|
};
|
|
};
|
|
- } catch {
|
|
|
|
|
|
+
|
|
|
|
+ let formData = new FormData();
|
|
|
|
+ for (let key in obj) {
|
|
|
|
+ formData.append(key, obj[key]);
|
|
|
|
+ }
|
|
|
|
+ formData.append("file", file.file);
|
|
|
|
+ await axios({
|
|
|
|
+ method: "post",
|
|
|
|
+ url: this.ossUploadUrl,
|
|
|
|
+ data: formData,
|
|
|
|
+ });
|
|
|
|
+ const uploadUrl = this.ossUploadUrl + "/" + key;
|
|
|
|
+ file.status = "done";
|
|
|
|
+ form.fileName = file.file.name;
|
|
|
|
+ form.fileUrl = uploadUrl;
|
|
|
|
+ form.messageType = this.onCheckFileType(file.file.type);
|
|
|
|
+
|
|
|
|
+ // console.log(form);
|
|
|
|
+ } catch (e) {
|
|
//
|
|
//
|
|
|
|
+ file.status = "failed";
|
|
|
|
+ file.message = "上传失败";
|
|
|
|
+ form.fileName = "";
|
|
|
|
+ form.fileUrl = "";
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
// this.$toast.loading({
|
|
// this.$toast.loading({
|
|
// duration: 0,
|
|
// duration: 0,
|
|
// forbidClick: true,
|
|
// forbidClick: true,
|
|
// message: "上传中...",
|
|
// message: "上传中...",
|
|
// });
|
|
// });
|
|
- // const form = this.form;
|
|
|
|
|
|
+ //
|
|
// try {
|
|
// try {
|
|
// file.status = "uploading";
|
|
// file.status = "uploading";
|
|
// file.message = "上传中...";
|
|
// file.message = "上传中...";
|