|
|
@ -235,7 +235,10 @@ export default {
|
|
|
|
let res2 = await ApiGetGoodsSkus({ productId: id });
|
|
|
|
let res2 = await ApiGetGoodsSkus({ productId: id });
|
|
|
|
let res3 = await ApiGetRecommendedGoodsList();
|
|
|
|
let res3 = await ApiGetRecommendedGoodsList();
|
|
|
|
vm.detailData = res1.result;
|
|
|
|
vm.detailData = res1.result;
|
|
|
|
vm.skuData = res2.result;
|
|
|
|
vm.skuData = res2.result.map(i => {
|
|
|
|
|
|
|
|
i.attributeSymbolList = i.attributeSymbolList.split(',')
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
});
|
|
|
|
vm.recommendedData = res3.result;
|
|
|
|
vm.recommendedData = res3.result;
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
vm.detailData.productActivityVO.isActivity &&
|
|
|
|
vm.detailData.productActivityVO.isActivity &&
|
|
|
@ -266,7 +269,7 @@ export default {
|
|
|
|
curSku() {
|
|
|
|
curSku() {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
this.skuData.find(
|
|
|
|
this.skuData.find(
|
|
|
|
(i) => i.attributeSymbolList === this.selectedSymbol.join(",")
|
|
|
|
(i) => i.attributeSymbolList.join(',') === this.selectedSymbol.join(",")
|
|
|
|
) || {}
|
|
|
|
) || {}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -275,9 +278,9 @@ export default {
|
|
|
|
return this.detailData.attributeGroupList
|
|
|
|
return this.detailData.attributeGroupList
|
|
|
|
.map((item) => {
|
|
|
|
.map((item) => {
|
|
|
|
const activeAttr = item.attributes.find((i) => i.active);
|
|
|
|
const activeAttr = item.attributes.find((i) => i.active);
|
|
|
|
return activeAttr ? activeAttr.symbol : ".";
|
|
|
|
return activeAttr?.symbol;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.filter((i) => i); //.sort();
|
|
|
|
.filter((i) => i).sort();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 最大可购买数量
|
|
|
|
* 最大可购买数量
|
|
|
@ -378,26 +381,6 @@ export default {
|
|
|
|
vm.activeImg++;
|
|
|
|
vm.activeImg++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 设置默认选中规格
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
setDefaultAttr() {
|
|
|
|
|
|
|
|
let vm = this;
|
|
|
|
|
|
|
|
const curSku = vm.skuData.find((i) => i.stock > 0);
|
|
|
|
|
|
|
|
if (!curSku) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vm.detailData.attributeGroupList.forEach((item, index) => {
|
|
|
|
|
|
|
|
for (let i of item.attributes) {
|
|
|
|
|
|
|
|
if (curSku.attributeSymbolList.includes(i.symbol)) {
|
|
|
|
|
|
|
|
this.$set(i, "active", true);
|
|
|
|
|
|
|
|
this.setDisabledItem(i, index, true);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$emit("input", this.curSku);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 点击属性项,设置选中和禁用项
|
|
|
|
* 点击属性项,设置选中和禁用项
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -426,26 +409,43 @@ export default {
|
|
|
|
setDisabledItem(item, groupIndex) {
|
|
|
|
setDisabledItem(item, groupIndex) {
|
|
|
|
let vm = this;
|
|
|
|
let vm = this;
|
|
|
|
vm.detailData.attributeGroupList.forEach((group, idx) => {
|
|
|
|
vm.detailData.attributeGroupList.forEach((group, idx) => {
|
|
|
|
// 拿到已选项数组,这个是按照项组顺序排序好的缓存数组
|
|
|
|
// if(groupIndex === idx) return false;
|
|
|
|
let symbolCache = Object.assign([], this.selectedSymbol);
|
|
|
|
// 拿到已选项数组
|
|
|
|
// 跳过当前属性组
|
|
|
|
group.attributes.forEach( item => {
|
|
|
|
if (groupIndex === idx) return false;
|
|
|
|
let symbolCache = Object.assign([],vm.selectedSymbol);
|
|
|
|
// 遍历其他选项组中的选项
|
|
|
|
symbolCache.push(item.symbol);
|
|
|
|
group.attributes.forEach((item) => {
|
|
|
|
symbolCache.sort();
|
|
|
|
// 根据选项组下标,补位选项属性
|
|
|
|
const res = vm.skuData.filter(item =>
|
|
|
|
symbolCache[idx] = item.symbol;
|
|
|
|
symbolCache.map(i => item.attributeSymbolList.includes(i.toString())).every(i => i)
|
|
|
|
const reg = new RegExp(symbolCache.join(","));
|
|
|
|
).find(i => i.stock > 0);
|
|
|
|
// 根据补位选项寻找是否有有效SKU,有则可选,没有则禁用
|
|
|
|
if(res){
|
|
|
|
const res = vm.skuData
|
|
|
|
|
|
|
|
.filter((i) => reg.test(i.attributeSymbolList))
|
|
|
|
|
|
|
|
.find((i) => i.stock > 0);
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
|
|
|
item.disabled = false;
|
|
|
|
item.disabled = false;
|
|
|
|
} else {
|
|
|
|
}else{
|
|
|
|
item.disabled = true;
|
|
|
|
item.disabled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
// vm.detailData.attributeGroupList.forEach((group, idx) => {
|
|
|
|
|
|
|
|
// // 拿到已选项数组,这个是按照项组顺序排序好的缓存数组
|
|
|
|
|
|
|
|
// let symbolCache = Object.assign([], this.selectedSymbol);
|
|
|
|
|
|
|
|
// // 跳过当前属性组
|
|
|
|
|
|
|
|
// if (groupIndex === idx) return false;
|
|
|
|
|
|
|
|
// // 遍历其他选项组中的选项
|
|
|
|
|
|
|
|
// group.attributes.forEach((item) => {
|
|
|
|
|
|
|
|
// // 根据选项组下标,补位选项属性
|
|
|
|
|
|
|
|
// symbolCache[idx] = item.symbol;
|
|
|
|
|
|
|
|
// const reg = new RegExp(symbolCache.join(","));
|
|
|
|
|
|
|
|
// // 根据补位选项寻找是否有有效SKU,有则可选,没有则禁用
|
|
|
|
|
|
|
|
// const res = vm.skuData
|
|
|
|
|
|
|
|
// .filter((i) => reg.test(i.attributeSymbolList))
|
|
|
|
|
|
|
|
// .find((i) => i.stock > 0);
|
|
|
|
|
|
|
|
// if (res) {
|
|
|
|
|
|
|
|
// item.disabled = false;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// item.disabled = true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
buyNow() {
|
|
|
|
buyNow() {
|
|
|
|
if (!this.$isLoginValidate()) {
|
|
|
|
if (!this.$isLoginValidate()) {
|
|
|
|