improve: 移动端上传

This commit is contained in:
From-wh 2023-06-15 15:51:50 +08:00
parent 80101af87c
commit fac9b3fa85

View File

@ -69,22 +69,38 @@ export default {
}
}
},
handleRemove(file) {
console.log(file);
let index = this.imgList.findIndex((e) => {
e.url == file.url;
});
this.imgList.splice(index, 1);
this.$nextTick((e) => {
this.imgList.map((e) => {
this.allSize += e.size;
});
});
},
uploadItem(file) {
return new Promise((resolve, reject) => {
const formData = new FormData();
formData.append('file', file);
formData.append('uploadToken', this.token);
scanUpload(formData).then((res) => {
if (res.status == 200) {
resolve();
} else {
this.$message({
message: '上传失败',
type: 'error',
duration: 1000,
});
}
});
scanUpload(formData)
.then((res) => {
if (res.status == 200) {
resolve();
} else {
this.$message({
message: '上传失败',
type: 'error',
duration: 1000,
});
}
})
.catch((err) => {
this.$Message.error(err.msg);
});
});
},
fileChange(file, fileList) {
@ -122,6 +138,11 @@ export default {
line-height: 113px;
overflow: inherit;
}
/deep/ .el-upload-list--picture-card .el-upload-list__item img {
width: 111px;
height: 111px;
border-radius: 6px;
}
.btndel {
position: absolute;
z-index: 1;