购物车调试
This commit is contained in:
parent
16654b14cf
commit
6da2117f17
@ -55,7 +55,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="good-price-num">
|
<div class="good-price-num">
|
||||||
<div class="good-price-num-pos">
|
<div class="good-price-num-pos">
|
||||||
<div class="price" @click="toCheckGood(index, indexg)">{{ g.netWeightInfoVO.goodSpecs }}</div>
|
<div class="price" @click="toCheckGood(index, indexg)">{{ g.netWeightInfoVO?.goodSpecs }}</div>
|
||||||
<div class="total" @click="toCheckGood(index, indexg)">{{ (g.price * g.quantity).toFixed(2) }}</div>
|
<div class="total" @click="toCheckGood(index, indexg)">{{ (g.price * g.quantity).toFixed(2) }}</div>
|
||||||
<div class="num">
|
<div class="num">
|
||||||
<div class="right-item">
|
<div class="right-item">
|
||||||
@ -171,28 +171,46 @@ const pagination = (value) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function addIsCheckProperty(data) {
|
function addIsCheckProperty(data) {
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
item.ischeck = false; // 为当前层级添加属性
|
item.ischeck = false;
|
||||||
if (item.cartDetails) {
|
// 只处理明确知道的嵌套属性,避免无限递归
|
||||||
// 处理子集
|
item.cartDetails && addIsCheckProperty(item.cartDetails);
|
||||||
addIsCheckProperty(item.cartDetails);
|
item.records && addIsCheckProperty(item.records);
|
||||||
}
|
|
||||||
if (item.records) {
|
|
||||||
// 处理父级(如存在嵌套结构)
|
|
||||||
addIsCheckProperty(item.records);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else if (typeof data === 'object' && data !== null) {
|
} else if (typeof data === 'object') {
|
||||||
data.ischeck = false;
|
data.ischeck = false;
|
||||||
for (let key in data) {
|
// 不自动遍历所有属性,只处理已知的特定属性
|
||||||
if (typeof data[key] === 'object') {
|
data.cartDetails && addIsCheckProperty(data.cartDetails);
|
||||||
addIsCheckProperty(data[key]); // 递归处理嵌套对象
|
data.records && addIsCheckProperty(data.records);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function addIsCheckProperty(data) {
|
||||||
|
// if (Array.isArray(data)) {
|
||||||
|
// data.forEach((item) => {
|
||||||
|
// item.ischeck = false; // 为当前层级添加属性
|
||||||
|
// if (item.cartDetails) {
|
||||||
|
// // 处理子集
|
||||||
|
// addIsCheckProperty(item.cartDetails);
|
||||||
|
// }
|
||||||
|
// if (item.records) {
|
||||||
|
// // 处理父级(如存在嵌套结构)
|
||||||
|
// addIsCheckProperty(item.records);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// } else if (typeof data === 'object' && data !== null) {
|
||||||
|
// data.ischeck = false;
|
||||||
|
// for (let key in data) {
|
||||||
|
// if (typeof data[key] === 'object') {
|
||||||
|
// addIsCheckProperty(data[key]); // 递归处理嵌套对象
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const numberChange = (value, index, indexg) => {
|
const numberChange = (value, index, indexg) => {
|
||||||
console.log(value, index, indexg);
|
console.log(value, index, indexg);
|
||||||
setGoodsCount({ goodsId: data.value[index].cartDetails[indexg].id, count: value });
|
setGoodsCount({ goodsId: data.value[index].cartDetails[indexg].id, count: value });
|
||||||
@ -612,6 +630,7 @@ function removeCheckedItems(data) {
|
|||||||
}
|
}
|
||||||
.price {
|
.price {
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
width: 200px;
|
||||||
}
|
}
|
||||||
.total {
|
.total {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@ -623,6 +642,7 @@ function removeCheckedItems(data) {
|
|||||||
.good-del {
|
.good-del {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: $color-999;
|
color: $color-999;
|
||||||
|
width: 44px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user