fix(uniapp): 字符转义 & 起送价展示
This commit is contained in:
1 parent
7db9eb12cb
commit
b9246f3e97
3 files changed
+35
-20
No files matched your search
@@ -13,7 +13,7 @@
|
|||||||
"path" : "pages/menu/menu",
|
"path" : "pages/menu/menu",
|
||||||
"style" :
|
"style" :
|
||||||
{
|
{
|
||||||
"navigationBarTitleText": "点餐",
|
"navigationBarTitleText": "点单",
|
||||||
"enablePullDownRefresh": true
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/menu/menu",
|
"pagePath": "pages/menu/menu",
|
||||||
"text": "点餐",
|
"text": "点单",
|
||||||
"iconPath": "static/images/tabBar/drink.png",
|
"iconPath": "static/images/tabBar/drink.png",
|
||||||
"selectedIconPath": "static/images/tabBar/drink-selected.png"
|
"selectedIconPath": "static/images/tabBar/drink-selected.png"
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
<view class="index-service__title">自取</view>
|
<view class="index-service__title">自取</view>
|
||||||
<view class="index-service__desc">下单免排队</view>
|
<view class="index-service__desc">下单免排队</view>
|
||||||
<view class="index-service__btn index-service__btn--orange">
|
<view class="index-service__btn index-service__btn--orange">
|
||||||
去下单 >
|
去下单 >
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<image
|
<image
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<view class="index-service__title">外卖</view>
|
<view class="index-service__title">外卖</view>
|
||||||
<view class="index-service__desc">美食送到家</view>
|
<view class="index-service__desc">美食送到家</view>
|
||||||
<view class="index-service__btn index-service__btn--gold">
|
<view class="index-service__btn index-service__btn--gold">
|
||||||
去下单 >
|
去下单 >
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<image
|
<image
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="index-extra__desc">可抵扣商品价格哦</view>
|
<view class="index-extra__desc">可抵扣商品价格哦</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="index-extra__link">去领个券 ></view>
|
<view class="index-extra__link">去领个券 ></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="index-extra index-extra--last" @tap="goScore">
|
<view class="index-extra index-extra--last" @tap="goScore">
|
||||||
<view class="index-extra__icon index-extra__icon--score">
|
<view class="index-extra__icon index-extra__icon--score">
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="index-extra__desc">进入积分商城兑换优惠券</view>
|
<view class="index-extra__desc">进入积分商城兑换优惠券</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="index-extra__link">逛一逛 ></view>
|
<view class="index-extra__link">逛一逛 ></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -147,7 +147,7 @@
|
|||||||
@tap="onCartPayTap"
|
@tap="onCartPayTap"
|
||||||
:disabled="cart.length > 0 && disabledPay"
|
:disabled="cart.length > 0 && disabledPay"
|
||||||
>
|
>
|
||||||
{{ !cart.length ? '去点餐' : (disabledPay ? `差${spread}元起送` : '去结算') }}
|
{{ !cart.length ? '去点单' : (disabledPay ? `差${spread}元起送` : '去结算') }}
|
||||||
</button>
|
</button>
|
||||||
</view>
|
</view>
|
||||||
<!-- 购物车栏 end -->
|
<!-- 购物车栏 end -->
|
||||||
@@ -390,25 +390,40 @@ const formatMoney = (n) => {
|
|||||||
return Math.round(x * 100) % 100 === 0 ? String(Math.round(x)) : x.toFixed(2)
|
return Math.round(x * 100) % 100 === 0 ? String(Math.round(x)) : x.toFixed(2)
|
||||||
}
|
}
|
||||||
const deliveryTipText = computed(() => {
|
const deliveryTipText = computed(() => {
|
||||||
if (!canShowDeliveryTip.value || !deliveryTipReady.value) return ''
|
const cartAmount = parseFloat(getCartGoodsPrice.value) || 0
|
||||||
|
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 fee = menuDeliveryFee.value
|
||||||
const freeAt = freeDeliveryAmount.value
|
const freeAt = freeDeliveryAmount.value
|
||||||
const cartAmount = parseFloat(getCartGoodsPrice.value) || 0
|
let suffix = ''
|
||||||
if (fee <= 0) {
|
if (underMin) {
|
||||||
return cartAmount > 0 ? '已免配送费' : (freeAt > 0
|
suffix = minOrderTip
|
||||||
? `另需配送费 0 元(满 ${formatMoney(freeAt)} 元免配送费)`
|
} else if (freeAt > 0 && fee > 0) {
|
||||||
: '')
|
|
||||||
}
|
|
||||||
if (cartAmount <= 0) {
|
if (cartAmount <= 0) {
|
||||||
return freeAt > 0
|
suffix = `满 ${formatMoney(freeAt)} 元免配送费`
|
||||||
? `另需配送费 ${formatMoney(fee)} 元(满 ${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)} 元`
|
: `另需配送费 ${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 filteredGoods = computed(() => {
|
||||||
const query = keyword.value.trim().toLowerCase()
|
const query = keyword.value.trim().toLowerCase()
|
||||||
|
|||||||
Reference in new issue
Block a user