字典

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