商品sku只展示一个问题
parent
14feac43fe
commit
f7167912e7
|
@ -84,14 +84,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 选择颜色 -->
|
<!-- 选择颜色 -->
|
||||||
<div class="item-select" v-for="(sku, index) in formatList" :key="sku.id">
|
<div class="item-select" v-for="(sku, index) in formatList" :key="sku.name">
|
||||||
<div class="item-select-title">
|
<div class="item-select-title">
|
||||||
<p>{{ sku.name }}</p>
|
<p>{{ sku.name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-select-column">
|
<div class="item-select-column">
|
||||||
<div class="item-select-row" v-for="(item) in sku.values" :key="item.id">
|
<div class="item-select-row" v-for="(item) in sku.values" :key="item.value">
|
||||||
<div class="item-select-box" @click="select(index, sku.id, item.id)"
|
<div class="item-select-box" @click="select(index, item.value)"
|
||||||
:class="{ 'item-select-box-active': item.id === currentSelceted[index] }"
|
:class="{ 'item-select-box-active': item.value === currentSelceted[index] }"
|
||||||
>
|
>
|
||||||
<div class="item-select-intro">
|
<div class="item-select-intro">
|
||||||
<p>{{ item.value }}</p>
|
<p>{{ item.value }}</p>
|
||||||
|
@ -170,14 +170,14 @@ export default {
|
||||||
Promotion
|
Promotion
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
select (index, id, valueId) { // 选择规格
|
select (index, value) { // 选择规格
|
||||||
this.$set(this.currentSelceted, index, valueId);
|
this.$set(this.currentSelceted, index, value);
|
||||||
|
|
||||||
let selectedSkuId = this.goodsSpecList.find((i) => {
|
let selectedSkuId = this.goodsSpecList.find((i) => {
|
||||||
let matched = true;
|
let matched = true;
|
||||||
let specValues = i.specValues.filter((j) => j.specName !== 'images');
|
let specValues = i.specValues.filter((j) => j.specName !== 'images');
|
||||||
for (let n = 0; n < specValues.length; n++) {
|
for (let n = 0; n < specValues.length; n++) {
|
||||||
if (specValues[n].specValueId !== this.currentSelceted[n]) {
|
if (specValues[n].specValue !== this.currentSelceted[n]) {
|
||||||
matched = false;
|
matched = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -267,15 +267,13 @@ export default {
|
||||||
},
|
},
|
||||||
formatSku (list) {
|
formatSku (list) {
|
||||||
// 格式化数据
|
// 格式化数据
|
||||||
|
console.log(list);
|
||||||
let arr = [{}];
|
let arr = [{}];
|
||||||
|
|
||||||
list.forEach((item, index) => {
|
list.forEach((item, index) => {
|
||||||
item.specValues.forEach((spec, specIndex) => {
|
item.specValues.forEach((spec, specIndex) => {
|
||||||
let id = spec.specNameId;
|
|
||||||
let name = spec.specName;
|
let name = spec.specName;
|
||||||
let values = {
|
let values = {
|
||||||
id: spec.specValueId,
|
|
||||||
value: spec.specValue,
|
value: spec.specValue,
|
||||||
quantity: item.quantity
|
quantity: item.quantity
|
||||||
};
|
};
|
||||||
|
@ -287,7 +285,7 @@ export default {
|
||||||
if (
|
if (
|
||||||
arrItem.name === name &&
|
arrItem.name === name &&
|
||||||
arrItem.values &&
|
arrItem.values &&
|
||||||
!arrItem.values.find((i) => i.id === values.id)
|
!arrItem.values.find((i) => i.value === values.value)
|
||||||
) {
|
) {
|
||||||
arrItem.values.push(values);
|
arrItem.values.push(values);
|
||||||
}
|
}
|
||||||
|
@ -297,7 +295,6 @@ export default {
|
||||||
});
|
});
|
||||||
if (!keys.includes(name)) {
|
if (!keys.includes(name)) {
|
||||||
arr.push({
|
arr.push({
|
||||||
id: id,
|
|
||||||
name: name,
|
name: name,
|
||||||
values: [values]
|
values: [values]
|
||||||
});
|
});
|
||||||
|
@ -307,12 +304,12 @@ export default {
|
||||||
});
|
});
|
||||||
arr.shift();
|
arr.shift();
|
||||||
this.formatList = arr;
|
this.formatList = arr;
|
||||||
|
console.log(this.formatList);
|
||||||
let cur = list.filter((i) => i.skuId === this.$route.query.skuId)[0];
|
let cur = list.filter((i) => i.skuId === this.$route.query.skuId)[0];
|
||||||
if (cur) {
|
if (cur) {
|
||||||
cur.specValues.filter((i) => i.specName !== 'images')
|
cur.specValues.filter((i) => i.specName !== 'images')
|
||||||
.forEach((value, _index) => {
|
.forEach((value, _index) => {
|
||||||
this.currentSelceted[_index] = value.specValueId;
|
this.currentSelceted[_index] = value.specValue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.skuList = list;
|
this.skuList = list;
|
||||||
|
|
|
@ -77,7 +77,6 @@ export default {
|
||||||
name: cateName[index]
|
name: cateName[index]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
console.log(cateArr);
|
|
||||||
this.categoryBar = cateArr;
|
this.categoryBar = cateArr;
|
||||||
this.goodsMsg = res.result;
|
this.goodsMsg = res.result;
|
||||||
// 判断是否收藏
|
// 判断是否收藏
|
||||||
|
|
|
@ -17,14 +17,14 @@ export default {
|
||||||
* @description api请求基础路径
|
* @description api请求基础路径
|
||||||
*/
|
*/
|
||||||
api_dev: {
|
api_dev: {
|
||||||
// common: "https://common-api.pickmall.cn",
|
common: "https://common-api.pickmall.cn",
|
||||||
// buyer: "https://buyer-api.pickmall.cn",
|
buyer: "https://buyer-api.pickmall.cn",
|
||||||
// seller: "https://store-api.pickmall.cn",
|
seller: "https://store-api.pickmall.cn",
|
||||||
// manager: "https://admin-api.pickmall.cn"
|
manager: "https://admin-api.pickmall.cn"
|
||||||
common: 'http://192.168.0.109:8890',
|
// common: 'http://192.168.0.109:8890',
|
||||||
buyer: 'http://192.168.0.109:8888',
|
// buyer: 'http://192.168.0.109:8888',
|
||||||
seller: 'http://192.168.0.109:8889',
|
// seller: 'http://192.168.0.109:8889',
|
||||||
manager: 'http://192.168.0.109:8887'
|
// manager: 'http://192.168.0.109:8887'
|
||||||
},
|
},
|
||||||
api_prod: {
|
api_prod: {
|
||||||
common: "https://common-api.pickmall.cn",
|
common: "https://common-api.pickmall.cn",
|
||||||
|
|
Loading…
Reference in New Issue