购物车商品数量

parent 66413769
...@@ -190,10 +190,11 @@ const addOrderFn = () => { ...@@ -190,10 +190,11 @@ const addOrderFn = () => {
// 获取购物车列表 // 获取购物车列表
const getshoppingCartListFn = () => { const getshoppingCartListFn = () => {
getshoppingCartList({}).then((res) => { getshoppingCartList({}).then((res) => {
res.data.forEach((item) => { // 累加prodInfos长度
// item.img = imgUrl + item.img; const totalLength = res.data.reduce((accumulator, current) => {
}); return accumulator + (current.prodInfos ? current.prodInfos.length : 0);
subscript.value = res.data.length; }, 0);
subscript.value = totalLength;
}); });
}; };
// 进入页面回到顶部 // 进入页面回到顶部
......
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