Commit 0df24380 authored by yaya's avatar yaya

feat:优化

parent 7758ac29
......@@ -239,18 +239,20 @@ export default {
}
},
handleRemove: function(file, fileList) {
for (var i = 0; i < this.goods.images.length; i++) {
// 这里存在两种情况
// 1. 如果所删除图片是刚刚上传的图片,那么图片地址是file.response.data.url
// 此时的file.url虽然存在,但是是本机地址,而不是远程地址。
// 2. 如果所删除图片是后台返回的已有图片,那么图片地址是file.url
var url
if (file.response === undefined) {
url = file.url
} else {
url = file.response.data.url
}
if (url === this.goods.topImage) {
this.goods.topImage = ''
}
for (var i = 0; i < this.goods.images.length; i++) {
// 这里存在两种情况
// 1. 如果所删除图片是刚刚上传的图片,那么图片地址是file.response.data.url
// 此时的file.url虽然存在,但是是本机地址,而不是远程地址。
// 2. 如果所删除图片是后台返回的已有图片,那么图片地址是file.url
if (url === this.goods.topImage) {
this.goods.topImage = ''
}
......
......@@ -341,7 +341,7 @@ export default {
if (response.data.data.images && response.data.data.images.length > 0) {
this.goodsParams.images = response.data.data.images.split(';') || []
}
this.imageList = this.goodsParams.images
this.imageList = this.goodsParams.images || []
if (this.goodsParams.topImage && this.goodsParams.topImage.length > 0) {
this.imageList = this.imageList.filter((item) => {
if (item !== this.goodsParams.topImage) {
......
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