Browse Source

更新判断

lex 2 năm trước cách đây
mục cha
commit
83ad607e08
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      src/views/massMessage/operation.vue

+ 8 - 2
src/views/massMessage/operation.vue

@@ -159,7 +159,7 @@ export default {
   },
   methods: {
     beforeRead(file) {
-      const isLt2M = file.size / 1024 / 1024 < 5;
+      const isLt2M = file.size / 1000 / 1000 < 5;
       if (!isLt2M) {
         this.$toast("上传文件大小不能超过 5MB");
         return false;
@@ -173,6 +173,11 @@ export default {
     },
     async afterRead(file) {
       // 上传头像
+      this.$toast.loading({
+        duration: 0,
+        forbidClick: true,
+        message: "上传中...",
+      });
       const form = this.form;
       try {
         file.status = "uploading";
@@ -180,7 +185,7 @@ export default {
         let formData = new FormData();
         formData.append("file", file.file);
         let res = await uploadFile(formData);
-        console.log(file, res);
+        this.$toast.clear();
         let result = res.data;
         if (result.code == 200) {
           file.status = "done";
@@ -196,6 +201,7 @@ export default {
           return false;
         }
       } catch (err) {
+        this.$toast.clear();
         file.status = "failed";
         file.message = "上传失败";
         form.fileName = "";