Commit 59f29e86 authored by Mac's avatar Mac

1

parent 5ac19883
...@@ -307,39 +307,47 @@ ...@@ -307,39 +307,47 @@
this.lists[index].error = false; this.lists[index].error = false;
this.uploading = true; this.uploading = true;
// 创建上传对象 // 创建上传对象
const task = uni.uploadFile({ uni.compressImage({
url: this.action, src: this.lists[index].url,
filePath: this.lists[index].url, quality: 80,
name: this.name, success: res => {
formData: this.formData, console.log(res.tempFilePath)
header: this.header, const task = uni.uploadFile({
success: (res) => { url: this.action,
if (res.statusCode != 200) { filePath: res.tempFilePath,
this.uploadError(index, res.data); name: this.name,
} else { formData: this.formData,
// 上传成功 header: this.header,
this.lists[index].response = res.data; success: (res) => {
this.lists[index].progress = 100; if (res.statusCode != 200) {
this.lists[index].error = false; this.uploadError(index, res.data);
this.$emit('on-success', res.data, index, this.lists); } else {
// 上传成功
this.lists[index].response = res.data;
this.lists[index].progress = 100;
this.lists[index].error = false;
this.$emit('on-success', res.data, index, this.lists);
}
},
fail: (e) => {
this.uploadError(index, e);
},
complete: (res) => {
uni.hideLoading();
this.uploading = false;
this.uploadFile(index + 1);
this.$emit('on-change', res, index, this.lists);
} }
}, });
fail: (e) => { task.onProgressUpdate((res) => {
this.uploadError(index, e); if (res.progress > 0) {
}, this.lists[index].progress = res.progress;
complete: (res) => { this.$emit('on-progress', res, index, this.lists);
uni.hideLoading(); }
this.uploading = false; });
this.uploadFile(index + 1); }
this.$emit('on-change', res, index, this.lists); })
}
});
task.onProgressUpdate((res) => {
if (res.progress > 0) {
this.lists[index].progress = res.progress;
this.$emit('on-progress', res, index, this.lists);
}
});
}, },
// 上传失败 // 上传失败
uploadError(index, err) { uploadError(index, err) {
......
...@@ -418,6 +418,7 @@ ...@@ -418,6 +418,7 @@
}, },
uploadSuccessHandler(data, index, lists) { uploadSuccessHandler(data, index, lists) {
let r = JSON.parse(data); let r = JSON.parse(data);
console.log(r)
this.addMsg.FileList.push(r.data); this.addMsg.FileList.push(r.data);
}, },
onRemove1(index) { onRemove1(index) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment