Commit fe727bf0 authored by 张娇(东信)'s avatar 张娇(东信)

购物车数量

parent 68cd7bc8
......@@ -119,7 +119,7 @@
</view>
<!-- 购物车悬浮按钮 -->
<view class="cart-floating" @tap="toCart">
<wd-badge modelValue="4">
<wd-badge :modelValue="subscript">
<img
class="shop-car"
src="/static/assistingAgriculture/presale/cart.png"
......@@ -136,7 +136,8 @@ import {
getGoodSaleProdList,
getPlatformProdList,
} from '../../../api/assistingAgriculture/building';
import { onMounted } from 'vue';
import { getshoppingCartList } from '@/api/packageDetail';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
const current = ref(0);
......@@ -144,6 +145,7 @@ const rightList = ref([]);
const light = ref(0);
const hotImgList = ref([]);
const testData = ref([]);
const subscript = ref(0);
let sortData;
// 轮播图
const swiperList = ref([
......@@ -169,8 +171,18 @@ const filteredProdList = ref([]);
onMounted(async () => {
getGoodSaleProd();
platformProdList();
getshoppingCartListFn();
});
// 获取购物车列表
const getshoppingCartListFn = () => {
getshoppingCartList({}).then((res) => {
// 累加prodInfos长度
const totalLength = res.data.reduce((accumulator, current) => {
return accumulator + (current.prodInfos ? current.prodInfos.length : 0);
}, 0);
subscript.value = totalLength;
});
};
// 好货热卖
const getGoodSaleProd = () => {
getGoodSaleProdList(params).then((res) => {
......
......@@ -113,7 +113,7 @@
</view>
<!-- 购物车悬浮按钮 -->
<view class="cart-floating" @tap="toCart">
<wd-badge modelValue="4">
<wd-badge :modelValue="subscript">
<img
class="shop-car"
src="/static/assistingAgriculture/presale/cart.png"
......@@ -133,6 +133,8 @@ import {
getPresaleProdList,
getStrictSelection,
} from '../../../api/assistingAgriculture/building';
import { getshoppingCartList } from '@/api/packageDetail';
const swiperList = ref([]);
const current = ref(0);
// 轮播图数据
......@@ -149,11 +151,23 @@ const params = {
size: 10,
categoryId: router.query.categoryId,
};
const subscript = ref(0);
const tabsList = ref([]);
onMounted(async () => {
getPresale();
presaleSortList();
getshoppingCartListFn();
});
// 获取购物车列表
const getshoppingCartListFn = () => {
getshoppingCartList({}).then((res) => {
// 累加prodInfos长度
const totalLength = res.data.reduce((accumulator, current) => {
return accumulator + (current.prodInfos ? current.prodInfos.length : 0);
}, 0);
subscript.value = totalLength;
});
};
// 预售板块轮播图
const getPresale = () => {
getPresaleList({ place: 'presale' }).then((res) => {
......
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