字典

parent 10bd6f5a
......@@ -16,3 +16,11 @@ export function searchProdPage(data) {
data,
});
}
// 筑农首页-店铺购物车列表
export function sgyBasketlist(data) {
return request({
url: `/sgyrdd/sgyBasket/list`,
method: 'GET',
data,
});
}
......@@ -7,7 +7,7 @@
<view class="top-bar">
<view class="header">分类</view>
<view class="search">
<wd-search hide-cancel placeholder="请输入要搜索的内容" />
<wd-search @search="searchFn" hide-cancel placeholder="请输入要搜索的内容" />
</view>
</view>
<view class="content">
......@@ -16,6 +16,7 @@
v-for="(v, i) in listOfDishCategories"
:key="i"
@click="changeCate(v)"
@clear="clearFn"
:class="{ active: acitveNav == v.categoryId }"
>
{{ v.categoryName }}
......@@ -42,8 +43,6 @@
class="scroll-Y"
lower-threshold="50"
@scrolltolower="scrolltolowerFn"
@scrolltoupper="upper"
@scroll="scroll"
>
<view class="item" v-for="(item, i) in prodList" :key="i">
<view class="image-wrap" :class="{ border: isPreSale }">
......@@ -72,10 +71,11 @@
<span class="unit">/只</span>
</view>
</view>
<view class="add-shopping-cart">
<view class="add-shopping-cart" @click="addShoppingCart(item)">
<img src="/src/static/assistingAgriculture/shop/add.png" alt="" />
</view>
</view>
<wd-status-tip v-if="prodList.length === 0" image="content" tip="暂无内容" />
</scroll-view>
</view>
</view>
......@@ -83,7 +83,7 @@
</view>
<!-- 购物车悬浮按钮 -->
<view class="cart-floating">
<wd-badge modelValue="12">
<wd-badge :modelValue="addPurchase">
<img class="cart" @tap="toCart" src="/static/assistingAgriculture/presale/cart.png" />
</wd-badge>
</view>
......@@ -99,7 +99,8 @@
<script setup>
import { ref } from 'vue';
import { shopCategoryByShop, searchProdPage } from '@/api/assistingAgriculture/shop';
import { shopCategoryByShop, searchProdPage, sgyBasketlist } from '@/api/assistingAgriculture/shop';
import { addOrder } from '@/api/packageDetail';
const format = ref('DD-HH:mm:ss');
const imgUrl = import.meta.env.VITE_APP_IMG_URL;
const currentShopId = ref('');
......@@ -120,6 +121,7 @@ onLoad((options) => {
shopCategoryByShopFn(options.shopId).then((res) => {
searchProdPageFn();
});
sgyBasketlistFn();
});
const shopCategoryByShopFn = (shopId) => {
return new Promise((resolve, reject) => {
......@@ -134,8 +136,27 @@ const shopCategoryByShopFn = (shopId) => {
};
const acitveNav = ref(1);
const searchFn = (e) => {
const { value } = e;
params.value.prodName = value;
refreshData().then((res) => {
searchProdPageFn();
});
};
const changeCate = (item) => {
acitveNav.value = item.categoryId;
params.value.shopCategoryId = item.categoryId;
refreshData().then((res) => {
searchProdPageFn();
});
};
const refreshData = (item) => {
return new Promise((resolve, reject) => {
params.value.isEnd = false;
params.value.current = 1;
prodList.value = [];
resolve();
});
};
const activeFilter = ref(false);
function toCart() {
......@@ -144,10 +165,46 @@ function toCart() {
url: '/pages/assistingAgriculture/cart/cart',
});
}
const sgyBasketlistFn = () => {
const query = {
shopId: currentShopId.value,
shopType: '3',
};
sgyBasketlist(query).then((res) => {
if (res.code === 0) {
res.data.forEach((shop) => {
addPurchase.value += shop.prodInfos.length;
});
}
});
};
const scrolltolowerFn = () => {
console.log('触底了');
searchProdPageFn();
};
function clearFn() {
console.log('111111111111111111111111');
params.value.prodName = '';
searchProdPageFn();
}
const addPurchase = ref(0);
const addShoppingCart = (item) => {
const params = {
shopId: item.shopId,
prodId: item.prodId,
skuId: item.skuIds,
shopType: '3',
basketCount: 1,
};
addOrder(params).then((res) => {
addPurchase.value = 0;
if (res.code === 0) {
sgyBasketlistFn();
}
});
};
const searchProdPageFn = () => {
if (params.value.isEnd === true)
return new Promise((resolve) => {
......
......@@ -242,7 +242,6 @@ onMounted(() => {
getCouponMainList();
});
onPullDownRefresh(() => {
orderStatus();
getClassification();
rotatingBroadcast();
nearbyFood();
......
......@@ -28,7 +28,7 @@ export const signIn = () => {
export const orderStatus = () => {
sgyOrderGetStatus().then((res) => {
if (res.code === 0) {
setOrderDic(res.data.store);
setOrderDic(res.data);
}
});
};
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