lrf402788946 4 år sedan
förälder
incheckning
8ec5043c8b
1 ändrade filer med 9 tillägg och 4 borttagningar
  1. 9 4
      src/views/user/chuanzuoye.vue

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

@@ -146,10 +146,15 @@ export default {
     async afterRead(data) {
       // 此时可以自行将文件上传至服务器
       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 }) {
       this.$set(this.pic, 0, { uri: data.uri });