|
@@ -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 });
|