修复bug

This commit is contained in:
2026-03-09 09:05:21 +08:00
parent 9f2d2f8764
commit 4da4d165cb
17 changed files with 467 additions and 181 deletions
+38 -9
View File
@@ -139,7 +139,7 @@ function getStoreDetail() {
console.log('商家详情', res)
storeDetail.value = res.data as MerchantVo
// getMerchantCouponReceiveList()
getMerchantCouponReceiveList()
// 解析营业时间并判断闭店提示
if (res.data.businessHours) {
@@ -270,6 +270,21 @@ function getMenuList() {
const deliveryMethod = ref(0);
const deliveryMethodOptions = [t('pages-store.store.delivery'), t('pages-store.store.pickup')];
const showDeliverySwitch = ref(true); // 是否显示配送方式切换组件
// 配送时间显示:后端返回分钟;>= 1 天时换算成“天”,否则保持“分钟”
function formatMinutesToDaysText(minutes?: number | string) {
const m = Number(minutes)
if (!Number.isFinite(m) || m <= 0) return '--'
const MINUTES_PER_DAY = 60 * 24
if (m < MINUTES_PER_DAY) return `${m} ${t('common.minutes')}`
const days = m / MINUTES_PER_DAY
// 保留 1 位小数并去掉末尾 0(例如 2.0 -> 2
let daysText = days.toFixed(1).replace(/\.0$/, '')
daysText = '3';
return `${daysText}${t('pages-store.store.days')}`
}
const deliveryTimeText = computed(() => formatMinutesToDaysText(storeDetail.value?.deliveryTime as any))
function handleClickSegmented(index: number) {
console.log("切换配送方式:", index);
if(+storeDetail.value.deliveryService !== 1 && index === 0) {
@@ -318,6 +333,11 @@ async function loadDishList(isLoadMore = false) {
try {
isLoadingMore.value = true;
// 非加载更多场景下,固定先请求第 1 页,并将内部 pageNum 重置为 1
if (!isLoadMore) {
pageNum.value = 1;
}
// 构建请求参数
const body: any = {
@@ -326,7 +346,7 @@ async function loadDishList(isLoadMore = false) {
pageSize: pageSize.value
};
// 如果选中的tabkey不为空,则传递menuId
// 如果选中的 tabkey 不为空,则传递 menuId
if (currentTab.key !== '') {
body.menuId = currentTab.key;
}
@@ -347,12 +367,21 @@ async function loadDishList(isLoadMore = false) {
dishListByQuery.value = res.data.rows;
}
const gotFullPage = res.data.rows.length >= pageSize.value;
// 更新分页信息
hasMore.value = res.data.rows.length >= pageSize.value;
hasMore.value = gotFullPage;
if (isLoadMore) {
pageNum.value++;
// 下一次请求再使用下一页页码
if (gotFullPage) {
pageNum.value++;
}
} else {
// 首次/刷新后,下一次「加载更多」应该从第 2 页开始
pageNum.value = gotFullPage ? 2 : 1;
}
} else {
hasMore.value = false;
}
} catch (error) {
console.error('加载菜品列表失败:', error);
@@ -361,10 +390,10 @@ async function loadDishList(isLoadMore = false) {
}
}
// 监听tab切换,重置分页并加载数据
// 监听 tab 切换,重置数据并加载当前 tab 的第一页
watch(activeTab, () => {
pageNum.value = 1;
hasMore.value = true;
dishListByQuery.value = [];
loadDishList(false);
});
@@ -534,7 +563,7 @@ function handleShare() {
></image>
CHEFLINK
</view>
<text v-if="+storeDetail?.deliveryService === 1" class="text-#7D7D7D"> {{ storeDetail?.deliveryTime }} {{ t('common.minutes') }}</text>
<text v-if="+storeDetail?.deliveryService === 1" class="text-#7D7D7D"> {{ deliveryTimeText }}</text>
</view>
<view class="text-24rpx lh-24rpx text-#7D7D7D text-center mt-16rpx">
{{ t('pages-store.store.title') }} US${{ storeDetail?.minOrderPrice }}
@@ -602,7 +631,7 @@ function handleShare() {
</view>
<view class="h-128rpx w-1rpx rotate-0 bg-#D8D8D8"></view>
<view class="w-full flex-1 center flex-col pl-44rpx">
<view class="text-#333 mb-8rpx">{{ storeDetail?.deliveryTime }} {{ t('common.minutes') }}</view>
<view class="text-#333 mb-8rpx">{{ deliveryTimeText }}</view>
<view class="text-#7D7D7D">{{ t('pages-store.store.earTime') }}</view>
</view>
</template>
@@ -675,7 +704,7 @@ function handleShare() {
<view class="flex-center-sb mt-12rpx">
<view class="text-28rpx text-#999">
<view class="line-through">US${{ item.originalPrice }}</view>
<view>{{ t('pages-store.store.sales') }}:{{ item.salesCount }}</view>
<!-- <view>{{ t('pages-store.store.sales') }}:{{ item.salesCount }}</view> -->
</view>
<view class="center w-64rpx h-64rpx rounded-50% bg-white shadow-lg">