fix(uniapp): 字符转义 & 起送价展示

This commit is contained in:
Kroytz committed 2026-07-24 14:02:35 +08:00
1 parent 7db9eb12cb
commit b9246f3e97
3 files changed
+37 -22

No files matched your search

+2 -2
View File
@@ -13,7 +13,7 @@
"path" : "pages/menu/menu",
"style" :
{
"navigationBarTitleText": "点餐",
"navigationBarTitleText": "点单",
"enablePullDownRefresh": true
}
@@ -224,7 +224,7 @@
},
{
"pagePath": "pages/menu/menu",
"text": "点餐",
"text": "点单",
"iconPath": "static/images/tabBar/drink.png",
"selectedIconPath": "static/images/tabBar/drink-selected.png"
}, {
@@ -77,7 +77,7 @@
<view class="index-service__title">自取</view>
<view class="index-service__desc">下单免排队</view>
<view class="index-service__btn index-service__btn--orange">
去下单 >
去下单 >
</view>
</view>
<image
@@ -91,7 +91,7 @@
<view class="index-service__title">外卖</view>
<view class="index-service__desc">美食送到家</view>
<view class="index-service__btn index-service__btn--gold">
去下单 >
去下单 >
</view>
</view>
<image
@@ -115,7 +115,7 @@
</view>
<view class="index-extra__desc">可抵扣商品价格哦</view>
</view>
<view class="index-extra__link">去领个券 ></view>
<view class="index-extra__link">去领个券 ></view>
</view>
<view class="index-extra index-extra--last" @tap="goScore">
<view class="index-extra__icon index-extra__icon--score">
@@ -127,7 +127,7 @@
</view>
<view class="index-extra__desc">进入积分商城兑换优惠券</view>
</view>
<view class="index-extra__link">逛一逛 ></view>
<view class="index-extra__link">逛一逛 ></view>
</view>
</view>
</view>
+31 -16
View File
@@ -147,7 +147,7 @@
@tap="onCartPayTap"
:disabled="cart.length > 0 && disabledPay"
>
{{ !cart.length ? '去点餐' : (disabledPay ? `差${spread}元起送` : '去结算') }}
{{ !cart.length ? '去点单' : (disabledPay ? `差${spread}元起送` : '去结算') }}
</button>
</view>
<!-- 购物车栏 end -->
@@ -390,25 +390,40 @@ const formatMoney = (n) => {
return Math.round(x * 100) % 100 === 0 ? String(Math.round(x)) : x.toFixed(2)
}
const deliveryTipText = computed(() => {
if (!canShowDeliveryTip.value || !deliveryTipReady.value) return ''
const fee = menuDeliveryFee.value
const freeAt = freeDeliveryAmount.value
const cartAmount = parseFloat(getCartGoodsPrice.value) || 0
if (fee <= 0) {
return cartAmount > 0 ? '已免配送费' : (freeAt > 0
? `另需配送费 0 元(满 ${formatMoney(freeAt)} 元免配送费)`
: '')
}
if (cartAmount <= 0) {
return freeAt > 0
? `另需配送费 ${formatMoney(fee)} 元(满 ${formatMoney(freeAt)} 元免配送费)`
const minPrice = parseFloat(store.value?.minPrice) || 0
const underMin = orderType.value === 'takeout' && minPrice > 0 && cartAmount < minPrice
const minOrderTip = underMin ? `满 ${formatMoney(minPrice)} 元起送` : ''
if (canShowDeliveryTip.value && deliveryTipReady.value) {
const fee = menuDeliveryFee.value
const freeAt = freeDeliveryAmount.value
let suffix = ''
if (underMin) {
suffix = minOrderTip
} else if (freeAt > 0 && fee > 0) {
if (cartAmount <= 0) {
suffix = `满 ${formatMoney(freeAt)} 元免配送费`
} else {
const need = Math.max(0, parseFloat((freeAt - cartAmount).toFixed(2)))
suffix = `还需 ${formatMoney(need)} 元免配送费`
}
}
if (fee <= 0) {
if (cartAmount > 0 && !underMin) return '已免配送费'
return suffix || ''
}
return suffix
? `另需配送费 ${formatMoney(fee)} 元(${suffix})`
: `另需配送费 ${formatMoney(fee)} 元`
}
if (freeAt > 0) {
const need = Math.max(0, parseFloat((freeAt - cartAmount).toFixed(2)))
return `另需配送费 ${formatMoney(fee)} 元(还需 ${formatMoney(need)} 元免配送费)`
// 未达起送价时,即使暂无配送费预估也展示起送提示
if (minOrderTip && (cart.value.length > 0 || canShowDeliveryTip.value)) {
return minOrderTip
}
return `另需配送费 ${formatMoney(fee)} 元`
return ''
})
const filteredGoods = computed(() => {
const query = keyword.value.trim().toLowerCase()