lrf402788946 4 年之前
父节点
当前提交
8ec5043c8b
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      src/views/user/chuanzuoye.vue

+ 9 - 4
src/views/user/chuanzuoye.vue

@@ -146,10 +146,15 @@ export default {
     async afterRead(data) {
     async afterRead(data) {
       // 此时可以自行将文件上传至服务器
       // 此时可以自行将文件上传至服务器
       this.pic.splice(this.pic.length - 1, 1, { status: 'uploading', message: '上传中...' });
       this.pic.splice(this.pic.length - 1, 1, { status: 'uploading', message: '上传中...' });
-      const { file } = data;
-      const res = await this.taskUpload(file);
-      const { uri } = res.data;
-      if (uri) this.pic.splice(this.pic.length - 1, 1, { url: uri });
+      try {
+        const { file } = data;
+        const res = await this.taskUpload(file);
+        const { uri } = res.data;
+        if (uri) this.pic.splice(this.pic.length - 1, 1, { url: uri });
+        else this.pic.splice(this.pic.length - 1, 1, { status: 'failed', message: '上传失败' });
+      } catch (error) {
+        this.pic.splice(this.pic.length - 1, 1, { status: 'failed', message: '上传失败' });
+      }
     },
     },
     uploadSuccess({ type, data }) {
     uploadSuccess({ type, data }) {
       this.$set(this.pic, 0, { uri: data.uri });
       this.$set(this.pic, 0, { uri: data.uri });