From 9f2d2f876483aa693b31adbbd04de08c6675cc00 Mon Sep 17 00:00:00 2001 From: ISFP_T <68358856@qq.com> Date: Tue, 3 Mar 2026 09:42:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env.development | 4 +- src/locale/en.json | 7 + src/locale/zh-Hans.json | 7 + src/manifest.json | 4 +- src/pages-store/pages/list/index.vue | 2 +- src/pages-store/pages/order/checkout.vue | 446 ++++++++++++++--- src/pages-store/pages/store/index.vue | 121 ++++- src/pages-user/pages/add-card/index.vue | 56 ++- src/pages-user/pages/cart/index.vue | 456 ++++++++++++++---- src/pages-user/pages/member/index.vue | 5 +- .../tabbar-home/components/class-bullet.vue | 18 +- .../tabbar-home/components/tabs-type.vue | 2 +- .../components/tabbar-home/tabbar-home.vue | 40 +- src/service/merchant.ts | 27 +- src/service/merchantCart.ts | 47 ++ src/service/merchantOrder.ts | 184 +++++++ src/service/types.ts | 16 +- 17 files changed, 1232 insertions(+), 210 deletions(-) diff --git a/env/.env.development b/env/.env.development index 52da8f1..8285797 100644 --- a/env/.env.development +++ b/env/.env.development @@ -4,7 +4,7 @@ NODE_ENV=development VITE_DELETE_CONSOLE=false #本地环境 -#VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api -VITE_SERVER_BASEURL=http://192.168.5.33:8889 +VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api +#VITE_SERVER_BASEURL=http://192.168.5.64:8080 #VITE_SERVER_BASEURL=http://192.168.0.148:8888 #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai \ No newline at end of file diff --git a/src/locale/en.json b/src/locale/en.json index 1f6680e..b3d9679 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -261,6 +261,9 @@ "onTheWay": "OTW", "title": "History" }, + "store": { + "all": "All" + }, "search": { "hot-title": "Popular Categories", "recently": "Recently", @@ -516,6 +519,10 @@ } }, "pages-user": { + "add-card": { + "loading": "Loading...", + "loadFailed": "Loading failed, please try again" + }, "balance": { "all": "All", "detail-list": "Detail list", diff --git a/src/locale/zh-Hans.json b/src/locale/zh-Hans.json index b6095cf..ce58485 100644 --- a/src/locale/zh-Hans.json +++ b/src/locale/zh-Hans.json @@ -261,6 +261,9 @@ "onTheWay": "在路上", "title": "订单" }, + "store": { + "all": "全部" + }, "search": { "hot-title": "热搜", "recently": "历史记录", @@ -516,6 +519,10 @@ } }, "pages-user": { + "add-card": { + "loading": "加载中...", + "loadFailed": "加载失败,请重试" + }, "balance": { "all": "全部", "detail-list": "明细列表", diff --git a/src/manifest.json b/src/manifest.json index 88c895d..bf3b0fd 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "CHEFLINK delivery", "appid" : "__UNI__06509BE", "description" : "", - "versionName" : "1.0.11", - "versionCode" : 111, + "versionName" : "1.0.13", + "versionCode" : 113, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/src/pages-store/pages/list/index.vue b/src/pages-store/pages/list/index.vue index 04e6abf..d640b66 100644 --- a/src/pages-store/pages/list/index.vue +++ b/src/pages-store/pages/list/index.vue @@ -29,7 +29,7 @@ function getList(pageNum: number, pageSize: number) { recipeCategoryId:props.id }, }).then(res => { - resolve(res) + resolve(res.data) }) }) } diff --git a/src/pages-store/pages/order/checkout.vue b/src/pages-store/pages/order/checkout.vue index fa97f33..5b1bc74 100644 --- a/src/pages-store/pages/order/checkout.vue +++ b/src/pages-store/pages/order/checkout.vue @@ -16,6 +16,10 @@ import { type MerchantVo, appMerchantOrderCalculatePriceCartPost, appUserCardSelectDefaultPost, appMerchantOrderCreateOrderCartPost, appMerchantOrderPayOrderPost, + appMerchantOrderCreateOrderCartBatchPost, + appMerchantOrderCalculatePriceCartBatchPost, + appMerchantCartListMerchantPost, + appMerchantOrderPayOrderBatchPost } from "@/service"; import useEventEmit from "@/hooks/useEventEmit"; import {EventEnum} from "@/constant/enums"; @@ -27,8 +31,8 @@ const userStore = useUserStore(); // 送达偏好 const visitMethodRef = ref(); const visitMethod = ref({ - value: 0, - label: t("components.visit.leaveItToMePersonally"), + value: 2, + label: t("components.visit.putItAtTheDoor"), }); function chooseVisitMethod() { visitMethodRef.value?.onOpen(visitMethod.value.value); @@ -236,6 +240,8 @@ useEventEmit(EventEnum.CHOOSE_PAYMENT_METHOD, (data) => { const storeId = ref('') +const orderType = ref('') // 订单类型:batch-批量下单,normal-普通下单 +const batchCartIds = ref([]) // 批量下单的购物车ID列表 const formData = ref({ orderRemark: '', phone: '', @@ -249,7 +255,26 @@ const formData = ref({ const needTableware = ref(false) onLoad((options: any)=> { loading.value = true - if(options.storeId) { + + // 判断是批量下单还是普通下单 + if(options.type == 'batch' && options.cartIds) { + // 批量下单模式 + orderType.value = 'batch' + batchCartIds.value = options.cartIds.split(',') + console.log("下单类型",options.type); + + // 默认取用户信息中的手机号作为收货手机号 + formData.value.phone = userStore.userInfo.phone || '' + contact.value.areaCode = userStore.userInfo.areaCode || '' + // 获取用户地址列表 + getAddressList() + // 查询批量购物车详情 + getBatchCartInfo() + // 查询用户默认信用卡 + appUserCardSelectDefault() + } else if(options.storeId) { + // 普通下单模式 + orderType.value = 'normal' storeId.value = options.storeId as string formData.value.orderRemark = options.orderRemark as string @@ -310,11 +335,77 @@ function getCartInfo() { loading.value = false }) } + +// 批量下单:查询购物车详情 +async function getBatchCartInfo() { + try { + // 根据购物车ID列表,按店铺分组查询 + const cartIds = batchCartIds.value + console.log('批量购物车ID列表', cartIds) + + // 1. 先获取所有店铺列表 + const merchantRes = await appMerchantCartListMerchantPost({}); + console.log('批量模式-购物车店铺列表', merchantRes); + + if (!merchantRes.data || merchantRes.data.length === 0) { + cartDataList.value = []; + return; + } + + // 2. 对每个店铺查询完整的商品信息 + const merchantPromises = merchantRes.data.map(async (merchant: any) => { + try { + const cartRes = await appMerchantCartListByMerchantIdPost({ + params: { + merchantId: merchant.id + } + }); + console.log(`批量模式-店铺 ${merchant.merchantName} 的商品列表`, cartRes); + + // 只保留选中的商品(根据 cartIds 过滤) + const filteredItems = (cartRes.data || []).filter((item: any) => + cartIds.includes(String(item.id)) + ); + + // 如果该店铺有选中的商品,才返回 + if (filteredItems.length > 0) { + return { + ...merchant, + merchantCartVoList: filteredItems + }; + } + return null; + } catch (error) { + console.error(`获取店铺 ${merchant.id} 商品失败`, error); + return null; + } + }); + + // 3. 等待所有店铺的商品信息加载完成,并过滤掉 null + const results = await Promise.all(merchantPromises); + cartDataList.value = results.filter(item => item !== null); + console.log('批量模式-最终购物车数据', cartDataList.value); + + // 查询菜品会员折扣价 + if(cartIds.length > 0) { + appMerchantCartCalculateSavings() + // 注意:价格计算会在地址加载完成后自动调用 + // 这里不需要立即调用 appMerchantOrderCalculatePriceCart() + } + } catch (error) { + console.error('获取批量购物车详情失败', error) + cartDataList.value = []; + } finally { + loading.value = false + } +} + // 查询菜品会员折扣价 const cartSavingsData = ref({}) function appMerchantCartCalculateSavings() { + const cartIds = orderType.value == 'batch' ? batchCartIds.value : cartDataList.value.map(item => item.id) appMerchantCartCalculateSavingsPost({ - body: cartDataList.value.map(item => item.id) + body: cartIds }).then(res=> { console.log('菜品会员折扣价', res) cartSavingsData.value = res.data @@ -390,21 +481,43 @@ function appMerchantOrderCalculatePriceCart() { // 优先使用新选择的地址id const targetAddressId = selectedAddressId.value || currentAddressId.value // if(!targetAddressId) return - appMerchantOrderCalculatePriceCartPost({ - body: { - addressId: targetAddressId, - cartIds: cartDataList.value.map(item => item.id), - receiveMethod: deliveryMethod.value === 0 ? 1 : 2, - couponId: couponInfo.value ? couponInfo.value.id : '', - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 - // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) - phone: formData.value.phone, - areaCode: contact.value.areaCode, - } - }).then(res=> { - console.log('购物车下单价格', res) - priceData.value = res.data - }) + + const cartIds = orderType.value == 'batch' ? batchCartIds.value : cartDataList.value.map(item => item.id) + + // 批量模式使用批量计算价格接口 + if(orderType.value == 'batch') { + appMerchantOrderCalculatePriceCartBatchPost({ + body: { + addressId: targetAddressId, + cartIds: cartIds, + receiveMethod: deliveryMethod.value === 0 ? 1 : 2, + couponId: couponInfo.value ? couponInfo.value.id : '', + tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + phone: formData.value.phone, + areaCode: contact.value.areaCode, + } + }).then(res=> { + console.log('批量购物车下单价格', res) + priceData.value = res.data + }) + } else { + // 普通模式使用单店铺计算价格接口 + appMerchantOrderCalculatePriceCartPost({ + body: { + addressId: targetAddressId, + cartIds: cartIds, + receiveMethod: deliveryMethod.value === 0 ? 1 : 2, + couponId: couponInfo.value ? couponInfo.value.id : '', + tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) + phone: formData.value.phone, + areaCode: contact.value.areaCode, + } + }).then(res=> { + console.log('购物车下单价格', res) + priceData.value = res.data + }) + } } // 获取用户地址列表 @@ -439,9 +552,16 @@ function getAddressList() { // 回显送达偏好 if(+data.deliveryRemark === 1) { visitMethod.value.label = t('components.visit.leaveItToMePersonally') + visitMethod.value.value = 1 } if(+data.deliveryRemark === 2) { visitMethod.value.label = t('components.visit.putItAtTheDoor') + visitMethod.value.value = 2 + } + + // 如果是批量模式,地址加载完成后重新计算价格 + if(orderType.value === 'batch') { + appMerchantOrderCalculatePriceCart() } } }) @@ -495,6 +615,7 @@ const isShowWeeklyDelivery = computed(()=> { const passwordInputRef = ref(null) const resOrderId = ref('') +const resOrderIds = ref([]) // 批量下单返回的订单ID列表 function handleGoSettle() { // 优先使用新选择的地址id const targetAddressId = selectedAddressId.value || currentAddressId.value @@ -512,59 +633,116 @@ function handleGoSettle() { }) return } - if(!resOrderId.value) { - let data = { - addressId: targetAddressId, - phone: formData.value.phone, - areaCode: contact.value.areaCode, - cartIds: cartDataList.value.map(item => item.id), - couponId: couponInfo.value ? couponInfo.value.id : '', - deliveryMethod: visitMethod.value.label, // 派送方式(如放门口或者交到顾客手中) - deliveryType: deliveryTimeType.value, // 1-立即交付 2-预约交付 - orderRemark: formData.value.orderRemark, - receiveMethod: deliveryMethod.value === 0 ? 1 : 2, // 收货方式(1-派送 2-自取) - startScheduledTime: '', // - endScheduledTime: '', // - tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 - // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) - needTableware: needTableware.value ? 1 : 2, // 餐具 1是 2否 - } + + // 批量下单 + if(orderType.value == 'batch') { + if(resOrderIds.value.length === 0) { + let data = { + addressId: targetAddressId, + phone: formData.value.phone, + areaCode: contact.value.areaCode, + cartIds: batchCartIds.value, + couponId: couponInfo.value ? couponInfo.value.id : '', + deliveryMethod: visitMethod.value.label, // 派送方式(如放门口或者交到顾客手中) + deliveryType: deliveryTimeType.value, // 1-立即交付 2-预约交付 + orderRemark: formData.value.orderRemark, + receiveMethod: deliveryMethod.value === 0 ? 1 : 2, // 收货方式(1-派送 2-自取) + startScheduledTime: '', // + endScheduledTime: '', // + tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + needTableware: needTableware.value ? 1 : 2, // 餐具 1是 2否 + } - // 如果是预约派送 - if(deliveryTimeType.value === 1) { - const result = getTimeStamps(showDeliveryTime.value); - data.startScheduledTime = result.startTimestamp - data.endScheduledTime = result.endTimestamp + // 如果是预约派送 + if(deliveryTimeType.value === 1) { + const result = getTimeStamps(showDeliveryTime.value); + data.startScheduledTime = result.startTimestamp + data.endScheduledTime = result.endTimestamp + } else { + data.startScheduledTime = diyTime.value.startTime + data.endScheduledTime = diyTime.value.endTime + } + console.log('批量下单参数', data) + appMerchantOrderCreateOrderCartBatchPost({ + body: data + }).then(res=> { + console.log('批量下单成功', res) + resOrderIds.value = res.data.orderIds || [] + // 如果是余额支付,弹出支付密码弹窗 + if(payMethodOptions.value.payMethod === 2) { + passwordInputRef.value?.showPasswordInput() + } else { + appMerchantOrderPayOrderBatch() + } + }) } else { - data.startScheduledTime = diyTime.value.startTime - data.endScheduledTime = diyTime.value.endTime + // 如果是余额支付,弹出支付密码弹窗 + if(payMethodOptions.value.payMethod === 2) { + passwordInputRef.value?.showPasswordInput() + } else { + appMerchantOrderPayOrderBatch() + } } - console.log('下单参数', data) - appMerchantOrderCreateOrderCartPost({ - body: data - }).then(res=> { - console.log('下单成功', res) - resOrderId.value = res.data || '' + } else { + // 普通下单 + if(!resOrderId.value) { + let data = { + addressId: targetAddressId, + phone: formData.value.phone, + areaCode: contact.value.areaCode, + cartIds: cartDataList.value.map(item => item.id), + couponId: couponInfo.value ? couponInfo.value.id : '', + deliveryMethod: visitMethod.value.label, // 派送方式(如放门口或者交到顾客手中) + deliveryType: deliveryTimeType.value, // 1-立即交付 2-预约交付 + orderRemark: formData.value.orderRemark, + receiveMethod: deliveryMethod.value === 0 ? 1 : 2, // 收货方式(1-派送 2-自取) + startScheduledTime: '', // + endScheduledTime: '', // + tipDiscount: deliveryMethod.value === 1 ? 0 : (diyTipValue.value ? Number(diyTipValue.value) / 100 : (selectedTipIndex.value || 0) / 100), // 小费比例,自取订单不需要小费 + // weeklyDeliveryFee: isWeeklyDelivery.value ? 1 : 2, // 是否支付周配送费(1-是 2-否) + needTableware: needTableware.value ? 1 : 2, // 餐具 1是 2否 + } + + // 如果是预约派送 + if(deliveryTimeType.value === 1) { + const result = getTimeStamps(showDeliveryTime.value); + data.startScheduledTime = result.startTimestamp + data.endScheduledTime = result.endTimestamp + } else { + data.startScheduledTime = diyTime.value.startTime + data.endScheduledTime = diyTime.value.endTime + } + console.log('下单参数', data) + appMerchantOrderCreateOrderCartPost({ + body: data + }).then(res=> { + console.log('下单成功', res) + resOrderId.value = res.data || '' + // 如果是余额支付,弹出支付密码弹窗 + if(payMethodOptions.value.payMethod === 2) { + passwordInputRef.value?.showPasswordInput() + } else { + appMerchantOrderPayOrder() + } + }) + } else { // 如果是余额支付,弹出支付密码弹窗 if(payMethodOptions.value.payMethod === 2) { passwordInputRef.value?.showPasswordInput() } else { appMerchantOrderPayOrder() } - }) - } else { - // 如果是余额支付,弹出支付密码弹窗 - if(payMethodOptions.value.payMethod === 2) { - passwordInputRef.value?.showPasswordInput() - } else { - appMerchantOrderPayOrder() } } } function payPawSuccess(password: string) { payMethodOptions.value.payPassword = password - appMerchantOrderPayOrder() + if(orderType.value === 'batch') { + appMerchantOrderPayOrderBatch() + } else { + appMerchantOrderPayOrder() + } } function appMerchantOrderPayOrder() { @@ -588,6 +766,37 @@ function appMerchantOrderPayOrder() { }) } +// 批量订单支付 +function appMerchantOrderPayOrderBatch() { + // 使用批量支付接口 + appMerchantOrderPayOrderBatchPost({ + body: { + orderIds: resOrderIds.value, + cardId: payMethodOptions.value.cardId, + payMethod: payMethodOptions.value.payMethod, + payPassword: payMethodOptions.value.payPassword + } + }).then(res=> { + console.log('批量支付结果', res) + uni.showToast({ + title: t('pages-store.checkout.paymentSuccess'), + icon: 'none' + }) + + setTimeout(()=> { + uni.navigateBack({ + delta: 2, + }) + }, 500) + }).catch(err => { + console.error('批量支付失败', err) + uni.showToast({ + title: '支付失败', + icon: 'none' + }) + }) +} + function getTimeStamps(timeStr: string) { // 验证输入是否为空 if (!timeStr || typeof timeStr !== 'string') { @@ -980,7 +1189,7 @@ function handleClose() { - + {{ t("pages-store.checkout.orderInfoSummary") }} + + + + + {{ t("pages-store.checkout.orderInfoSummary") }} + + + + + + + {{ merchant.merchantName }} + {{ merchant.merchantCartVoList.length }} {{ t('pages-user.cart.items') }} + + + + + + + + + + + {{ + item.merchantDishVo?.dishName + }} + + + + + + + + + + ${{ item.merchantDishVo?.discountPrice }} + ${{ item.merchantDishVo?.originalPrice }} + + + x{{ item.count }} + + + + + + + + + + + + {{ t("pages-store.checkout.orderInfoSummary") }} + + 已选择 {{ batchCartIds.length }} 件商品 + + + + @@ -1173,7 +1477,8 @@ function handleClose() { {{ t('pages-store.order.subtotal') }} - ${{ priceData?.actualAmount }} + ${{ priceData?.totalActualAmount || '0.00' }} + ${{ priceData?.actualAmount || '0.00' }} @@ -1184,13 +1489,17 @@ function handleClose() { mode="aspectFit" /> - - ${{ (Number(priceData?.tax) + Number(priceData?.tip) + Number(priceData?.deliveryFee)).toFixed(2) }} + + ${{ (Number(priceData?.totalTax || 0) + Number(priceData?.totalTip || 0) + Number(priceData?.totalDeliveryFee || 0)).toFixed(2) }} + + + ${{ (Number(priceData?.tax || 0) + Number(priceData?.tip || 0) + Number(priceData?.deliveryFee || 0)).toFixed(2) }} {{ t('pages-store.order.total') }} - ${{ priceData?.paidAmount }} + ${{ priceData?.totalPaidAmount || '0.00' }} + ${{ priceData?.paidAmount || '0.00' }} @@ -1245,19 +1554,24 @@ function handleClose() { {{ t('common.goSettle') }} - - {{ t('common.goSettle') }} + --> + diff --git a/src/pages-store/pages/store/index.vue b/src/pages-store/pages/store/index.vue index 18efd3d..0225b5f 100644 --- a/src/pages-store/pages/store/index.vue +++ b/src/pages-store/pages/store/index.vue @@ -8,6 +8,7 @@ import { useScrollThreshold } from '@/hooks/useScrollThreshold' import { appCollectCollectPost, appMerchantCartCalculateSavingsPost, appMerchantCartListByMerchantIdPost, appMerchantDetailMerchantIdGet, + appMerchantDishDishIdGet, appMerchantMenuMenuListByUserPost, type MerchantCartVo, type MerchantVo } from "@/service"; @@ -138,7 +139,7 @@ function getStoreDetail() { console.log('商家详情', res) storeDetail.value = res.data as MerchantVo - getMerchantCouponReceiveList() + // getMerchantCouponReceiveList() // 解析营业时间并判断闭店提示 if (res.data.businessHours) { @@ -149,13 +150,19 @@ function getStoreDetail() { } } - if(res.data.merchantMenuVoList && res.data.merchantMenuVoList.length > 0) { - tabs.value = res.data.merchantMenuVoList.map((item) => { - return { - title: item.menuName, - key: item.id - } - }) + if(res.data.merchantCategoryIds && res.data.merchantCategoryIds.length > 0) { + tabs.value = [ + { + title: t('pages.store.all'), + key: '' + }, + ...res.data.merchantCategoryIds.map((item) => { + return { + title: item.menuName, + key: item.id + } + }) + ] } // 商户的经纬度存在,并且用户的经纬度也存在 @@ -283,7 +290,90 @@ function handleClickSegmented(index: number) { } const activeTab = ref(0); -const tabs = ref([]); +const tabs = ref([]); + +// 分页相关状态 +const pageNum = ref(1); +const pageSize = ref(10); +const hasMore = ref(true); +const isLoadingMore = ref(false); +const dishListByQuery = ref([]); + +// 计算当前显示的商品列表 +const currentDishList = computed(() => { + if(tabs.value[activeTab.value].key==''&&pageNum.value===1){ + return storeDetail.value?.dishPage?.records + } + console.log(tabs.value[activeTab.value].key==''); + // 使用 dishListByQuery 作为数据源 + return dishListByQuery.value || [] +}) + +// 加载菜品列表 +async function loadDishList(isLoadMore = false) { + if (isLoadingMore.value) return; + + const currentTab = tabs.value[activeTab.value]; + if (!currentTab) return; + + try { + isLoadingMore.value = true; + + // 构建请求参数 + const body: any = { + merchantId: storeID.value, + pageNum: isLoadMore ? pageNum.value : 1, + pageSize: pageSize.value + }; + + // 如果选中的tab的key不为空,则传递menuId + if (currentTab.key !== '') { + body.menuId = currentTab.key; + } + + console.log('加载菜品列表参数', body); + + const res = await appMerchantDishDishIdGet({ body }); + + if (res.data && res.data.rows) { + if (isLoadMore) { + // 加载更多,追加数据 + dishListByQuery.value = [ + ...dishListByQuery.value, + ...res.data.rows + ]; + } else { + // 首次加载或刷新 + dishListByQuery.value = res.data.rows; + } + + // 更新分页信息 + hasMore.value = res.data.rows.length >= pageSize.value; + + if (isLoadMore) { + pageNum.value++; + } + } + } catch (error) { + console.error('加载菜品列表失败:', error); + } finally { + isLoadingMore.value = false; + } +} + +// 监听tab切换,重置分页并加载数据 +watch(activeTab, () => { + pageNum.value = 1; + hasMore.value = true; + loadDishList(false); +}); + +// 触底加载更多 +onReachBottom(() => { + if (hasMore.value && !isLoadingMore.value) { + loadDishList(true); + } +}); const showStatusBar = useScrollThreshold() onPageScroll((e) => { @@ -540,9 +630,9 @@ function handleShare() { - {{ t('pages-store.store.recommend') }} - -