Commit 59f29e86 authored by Mac's avatar Mac

1

parent 5ac19883
......@@ -307,39 +307,47 @@
this.lists[index].error = false;
this.uploading = true;
// 创建上传对象
const task = uni.uploadFile({
url: this.action,
filePath: this.lists[index].url,
name: this.name,
formData: this.formData,
header: this.header,
success: (res) => {
if (res.statusCode != 200) {
this.uploadError(index, res.data);
} 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);
uni.compressImage({
src: this.lists[index].url,
quality: 80,
success: res => {
console.log(res.tempFilePath)
const task = uni.uploadFile({
url: this.action,
filePath: res.tempFilePath,
name: this.name,
formData: this.formData,
header: this.header,
success: (res) => {
if (res.statusCode != 200) {
this.uploadError(index, res.data);
} 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) => {
this.uploadError(index, e);
},
complete: (res) => {
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);
}
});
});
task.onProgressUpdate((res) => {
if (res.progress > 0) {
this.lists[index].progress = res.progress;
this.$emit('on-progress', res, index, this.lists);
}
});
}
})
},
// 上传失败
uploadError(index, err) {
......
......@@ -418,6 +418,7 @@
},
uploadSuccessHandler(data, index, lists) {
let r = JSON.parse(data);
console.log(r)
this.addMsg.FileList.push(r.data);
},
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