...
|
...
|
@@ -184,6 +184,19 @@ |
|
|
module.exports = {
|
|
|
init() {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
colors: [],
|
|
|
sizes: [],
|
|
|
colorSizes: {},
|
|
|
thumbnails: {},
|
|
|
selection: {
|
|
|
color: null,
|
|
|
size: null,
|
|
|
thumbnail: ''
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
props: {
|
|
|
/** 是否可见 */
|
|
|
isVisible: Boolean,
|
...
|
...
|
@@ -224,7 +237,7 @@ |
|
|
// 缩略图
|
|
|
thumbnails[goods.colorId] = goods.colorImage;
|
|
|
|
|
|
// 更新颜色对应尺码 生成colorId 与 size的 映射
|
|
|
// 生成colorId 与 size的 映射
|
|
|
colorSizes[goods.colorId] = goods.goodsSizeBoList.map((size)=> {
|
|
|
if (!stocks[goods.colorId]) {
|
|
|
stocks[goods.colorId] = 0;
|
...
|
...
|
@@ -249,10 +262,9 @@ |
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
// 计算所有尺码的库存
|
|
|
stocks[goods.colorId] += size.goodsSizeStorageNum;
|
|
|
}
|
|
|
// 计算所有尺码的库存
|
|
|
stocks[goods.colorId] += size.goodsSizeStorageNum;
|
|
|
|
|
|
return {
|
|
|
text: size.sizeName,
|
...
|
...
|
@@ -269,6 +281,10 @@ |
|
|
};
|
|
|
});
|
|
|
|
|
|
if (!selection.color) {
|
|
|
this.selection.color = selection.color = this.colors[0];
|
|
|
}
|
|
|
|
|
|
this.sizes = colorSizes[selection.color.value];
|
|
|
this.colorSizes = colorSizes;
|
|
|
this.thumbnails = thumbnails;
|
...
|
...
|
@@ -278,19 +294,6 @@ |
|
|
this.$emit('feature:size.select', selection.size);
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
colors: [],
|
|
|
sizes: [],
|
|
|
colorSizes: {},
|
|
|
thumbnails: {},
|
|
|
selection: {
|
|
|
color: null,
|
|
|
size: null,
|
|
|
thumbnail: ''
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
components: {
|
|
|
featureOptions: require('./feature-options.vue')
|
|
|
},
|
...
|
...
|
@@ -306,21 +309,26 @@ |
|
|
|
|
|
// 选择颜色
|
|
|
this.$on('feature:color.select', (opt)=> {
|
|
|
const selection = {
|
|
|
color: opt,
|
|
|
size: ((color, size)=> {
|
|
|
// 切换颜色后选择匹配的尺码
|
|
|
const sizes = this.colorSizes[color];
|
|
|
let setSelectedSize = function(color, size) {
|
|
|
const sizes = self.colorSizes[color.value];
|
|
|
|
|
|
if (!size) {
|
|
|
let canSelectSizes = sizes.filter(item => {
|
|
|
return item.disabled === false;
|
|
|
});
|
|
|
|
|
|
return canSelectSizes.length ? canSelectSizes[0] : null;
|
|
|
} else {
|
|
|
// 切换颜色后选择匹配的尺码
|
|
|
if (sizes && sizes.length > 0) {
|
|
|
const oldSizes = sizes.filter((item) => {
|
|
|
return item.value === size;
|
|
|
return item.value === size.value;
|
|
|
});
|
|
|
|
|
|
if (oldSizes && oldSizes.length > 0) {
|
|
|
const newSizes = this.colorSizes[opt.value];
|
|
|
const newSizes = self.colorSizes[opt.value];
|
|
|
|
|
|
const matchedSize = newSizes.filter((item)=> {
|
|
|
const matchedSize = newSizes.filter((item) => {
|
|
|
return !item.disabled && item.text === oldSizes[0].text;
|
|
|
});
|
|
|
|
...
|
...
|
@@ -329,9 +337,12 @@ |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
return null;
|
|
|
})(self.selection.color.value, self.selection.size.value),
|
|
|
const selection = {
|
|
|
color: opt,
|
|
|
size: setSelectedSize(self.selection.color, self.selection.size),
|
|
|
|
|
|
thumbnail: this.thumbnails[opt.value]
|
|
|
};
|
...
|
...
|
|