This commit is contained in:
2026-04-14 15:02:00 +08:00
parent ec9282a64f
commit d2077f5844
23 changed files with 1551 additions and 428 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ NODE_ENV=development
VITE_DELETE_CONSOLE=false VITE_DELETE_CONSOLE=false
#本地环境 #本地环境
#VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api VITE_SERVER_BASEURL=https://howhowfresh.com/prod-api
VITE_SERVER_BASEURL=http://192.168.5.3:8080 #VITE_SERVER_BASEURL=http://192.168.5.4:8080
#VITE_SERVER_BASEURL=http://192.168.0.148:8888 #VITE_SERVER_BASEURL=http://192.168.0.148:8888
#VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai #VITE_SERVER_BASEURL=http://liuyao.nat100.top/meiguowaimai
+11 -2
View File
@@ -449,6 +449,7 @@
"deliveryAddress": "Delivery address", "deliveryAddress": "Delivery address",
"deliveryPhotos": "Delivery of photos", "deliveryPhotos": "Delivery of photos",
"deliveryTime": "Delivery time", "deliveryTime": "Delivery time",
"beforeDeadline": " before",
"estimatedDeliveryTime": "Estimated delivery time", "estimatedDeliveryTime": "Estimated delivery time",
"orderInfo": "Ordering Information", "orderInfo": "Ordering Information",
"orderNumber": "Order number", "orderNumber": "Order number",
@@ -542,6 +543,7 @@
"productIntro": "Introduction", "productIntro": "Introduction",
"origin": "Origin", "origin": "Origin",
"unitQty": "Unit qty.", "unitQty": "Unit qty.",
"category": "Category",
"brand": "Brand", "brand": "Brand",
"allergen": "Allergen", "allergen": "Allergen",
"weeklySales": "Weekly sales", "weeklySales": "Weekly sales",
@@ -550,7 +552,8 @@
"dash": "—", "dash": "—",
"lbUnit": "lb", "lbUnit": "lb",
"hotSalesBadge": "Fresh picks", "hotSalesBadge": "Fresh picks",
"stockLabel": "Stock" "stockLabel": "Stock",
"loadMoreRecommend": "Load more"
}, },
"securityCode": { "securityCode": {
"cantSee": "Can't see clearly? Change one", "cantSee": "Can't see clearly? Change one",
@@ -629,7 +632,13 @@
"selectAll": "Select all", "selectAll": "Select all",
"forYou": "Recommended for you", "forYou": "Recommended for you",
"calculating": "Calculating...", "calculating": "Calculating...",
"selectItemsHint": "Select items to checkout" "selectItemsHint": "Select items to checkout",
"removeCartTitle": "Delete shopping cart?",
"removeCartDesc": "Are you sure you want to delete this cart?",
"removeProductTitle": "Remove the product?",
"removeProductDesc": "Are you sure you want to remove {name} from your shopping cart?",
"emptyTitle": "Your cart is empty",
"emptyAction": "Explore Restaurants"
}, },
"choosePaymethod": { "choosePaymethod": {
"creditCard": "Credit card payment", "creditCard": "Credit card payment",
+11 -2
View File
@@ -449,6 +449,7 @@
"deliveryAddress": "配送地址", "deliveryAddress": "配送地址",
"deliveryPhotos": "送达照片", "deliveryPhotos": "送达照片",
"deliveryTime": "送达时间", "deliveryTime": "送达时间",
"beforeDeadline": "前",
"estimatedDeliveryTime": "预计送达时间", "estimatedDeliveryTime": "预计送达时间",
"orderInfo": "订单信息", "orderInfo": "订单信息",
"orderNumber": "订单号", "orderNumber": "订单号",
@@ -542,6 +543,7 @@
"productIntro": "产品简介", "productIntro": "产品简介",
"origin": "产地", "origin": "产地",
"unitQty": "单位数量", "unitQty": "单位数量",
"category": "分类",
"brand": "品牌", "brand": "品牌",
"allergen": "过敏源", "allergen": "过敏源",
"weeklySales": "周销量", "weeklySales": "周销量",
@@ -550,7 +552,8 @@
"dash": "—", "dash": "—",
"lbUnit": "磅", "lbUnit": "磅",
"hotSalesBadge": "生鲜热销榜", "hotSalesBadge": "生鲜热销榜",
"stockLabel": "库存" "stockLabel": "库存",
"loadMoreRecommend": "加载更多"
}, },
"securityCode": { "securityCode": {
"cantSee": "看不清?换一张", "cantSee": "看不清?换一张",
@@ -629,7 +632,13 @@
"selectAll": "全选", "selectAll": "全选",
"forYou": "为您推荐", "forYou": "为您推荐",
"calculating": "计算中...", "calculating": "计算中...",
"selectItemsHint": "请选择要结算的商品" "selectItemsHint": "请选择要结算的商品",
"removeCartTitle": "删除购物车?",
"removeCartDesc": "确定要删除该店铺购物车吗?",
"removeProductTitle": "移除商品?",
"removeProductDesc": "确定要将 {name} 从购物车中移除吗?",
"emptyTitle": "购物车为空",
"emptyAction": "去逛逛餐厅"
}, },
"choosePaymethod": { "choosePaymethod": {
"creditCard": "信用卡支付", "creditCard": "信用卡支付",
+9 -3
View File
@@ -2,8 +2,8 @@
"name" : "CHEFLINK delivery", "name" : "CHEFLINK delivery",
"appid" : "__UNI__06509BE", "appid" : "__UNI__06509BE",
"description" : "", "description" : "",
"versionName" : "2.0.1", "versionName" : "3.0.6",
"versionCode" : 201, "versionCode" : 306,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
@@ -203,5 +203,11 @@
"enable" : false "enable" : false
}, },
"vueVersion" : "3", "vueVersion" : "3",
"locale" : "en" "locale" : "en",
"h5" : {
"router" : {
"mode" : "history",
"base" : "/h5/"
}
}
} }
+316 -48
View File
@@ -1,25 +1,24 @@
<script setup lang="ts"> <script setup lang="ts">
import usePage from "@/hooks/usePage"; import usePage from "@/hooks/usePage";
import {appMerchantRecommendListPost} from "@/service"; import { appMerchantRecommendListPost, type MerchantVo } from "@/service";
import { useUserStore } from "@/store"; import { useUserStore } from "@/store";
import FiltrateTool from "@/components/filtrate-tool/index.vue"; import FiltrateTool from "@/components/filtrate-tool/index.vue";
import PriceChoose from "@/components/filtrate-tool/components/price-choose.vue"; import PriceChoose from "@/components/filtrate-tool/components/price-choose.vue";
import Score from "@/components/filtrate-tool/components/score.vue"; import Score from "@/components/filtrate-tool/components/score.vue";
import FoodBox from "@/pages/home/components/tabbar-home/components/food-box/index.vue";
const userStore = useUserStore();
const {t} = useI18n() const userStore = useUserStore();
const { t } = useI18n();
const props = defineProps({ const props = defineProps({
merchantCategoryIds: { merchantCategoryIds: {
type: [Number, String], type: [Number, String],
default: null default: null,
} },
}) });
const {paging, dataList, queryList} = usePage(getList) const { paging, dataList, queryList } = usePage<MerchantVo>(getList);
function getList(pageNum: number, pageSize: number) { function getList(pageNum: number, pageSize: number) {
return new Promise(resolve => { return new Promise((resolve) => {
appMerchantRecommendListPost({ appMerchantRecommendListPost({
params: { params: {
pageNum: pageNum, pageNum: pageNum,
@@ -28,75 +27,344 @@ function getList(pageNum: number, pageSize: number) {
body: { body: {
lat: userStore.userLocation.latitude, lat: userStore.userLocation.latitude,
lng: userStore.userLocation.longitude, lng: userStore.userLocation.longitude,
selfPickup: selfPickup.value, // 是否自提 selfPickup: selfPickup.value,
discount: discount.value, // 是否有折扣 1是 2 否 discount: discount.value,
scoreRange: scoreRange.value || null, // 评分范围 比如 3-4 scoreRange: scoreRange.value || null,
priceRange: price.value || null, // 价格范围 比如 10-30 priceRange: price.value || null,
merchantCategoryIds: props.merchantCategoryIds ? [props.merchantCategoryIds] : [], // 商家分类id集合(首页中间) merchantCategoryIds: props.merchantCategoryIds
} ? [props.merchantCategoryIds]
}).then(res => { : [],
console.log(res) },
resolve({rows: res.rows}) }).then((res) => {
}) console.log(res);
}) resolve({ rows: res.rows });
});
});
} }
// 是否自提 const selfPickup = ref<number | null>(null);
const selfPickup = ref<number | null>(null)
function togglePickup(value: number) { function togglePickup(value: number) {
selfPickup.value = value; selfPickup.value = value;
paging.value.refresh() paging.value?.refresh();
}
// 是否有折扣
const discount = ref<number | null>(null)
function toggleDiscount(value: number) {
discount.value = value;
paging.value.refresh()
} }
const scoreRef = ref<any>() const discount = ref<number | null>(null);
const scoreRange = ref<string | null>(null) function toggleDiscount(value: number) {
const priceChooseRef = ref<any>() discount.value = value;
const price = ref<string | null>(null) paging.value?.refresh();
function toggleScore() {
if (scoreRef.value) {
scoreRef.value.onOpen();
} }
const scoreRef = ref<any>();
const scoreRange = ref<string | null>(null);
const priceChooseRef = ref<any>();
const price = ref<string | null>(null);
function toggleScore() {
scoreRef.value?.onOpen();
} }
function togglePrice() { function togglePrice() {
if (priceChooseRef.value) { priceChooseRef.value?.onOpen();
priceChooseRef.value.onOpen();
}
} }
function applyScore(value: string) { function applyScore(value: string) {
scoreRange.value = value; scoreRange.value = value;
nextTick(() => paging.value?.refresh());
} }
function applyPrice(value: string) { function applyPrice(value: string) {
price.value = value; price.value = value;
nextTick(() => paging.value?.refresh());
}
/** 左侧双图:优先店铺图,不足则用 logo 补齐 */
function merchantImagePair(item: MerchantVo): [string, string] {
const shop = (item.shopImages || "")
.split(",")
.map((s) => s.trim())
.filter(Boolean);
const logo = (item.logo || "").trim();
let a = shop[0] || logo || "";
let b = shop[1] || shop[0] || logo || "";
if (!a && !b) return ["", ""];
if (!b) b = a;
if (!a) a = b;
return [a, b];
}
function merchantCategoryLine(item: MerchantVo): string {
const zh = item.merchantCategoryNamesZh;
const en = item.merchantCategoryNamesEn;
if (uni.getLocale() === "zh-Hans" && zh?.length) return zh[0] || "";
if (en?.length) return en[0] || "";
if (zh?.length) return zh[0] || "";
return "";
}
function ratingStars(rating?: number) {
const n = Math.min(5, Math.max(0, Math.round(Number(rating) || 0)));
return n;
}
function ratingText(rating?: number) {
const n = Number(rating);
if (Number.isFinite(n)) return n.toFixed(1);
return "0.0";
}
function openMerchant(item: MerchantVo) {
if (item?.id == null) return;
uni.navigateTo({
url: `/pages-store/pages/store/index?id=${item.id}`,
});
} }
</script> </script>
<template> <template>
<z-paging ref="paging" v-model="dataList" @query="queryList"> <view class="home-store-page">
<z-paging
ref="paging"
v-model="dataList"
bg-color="#F2F3F5"
@query="queryList"
>
<template #top> <template #top>
<view class="bg-white pb-24rpx"> <view class="home-store-header">
<navbar :title="t('pages.home.featured-on')"/> <navbar
<!-- 筛选工具 --> :title="t('pages.home.featured-on')"
<filtrate-tool class="mt-32rpx" @togglePickup="togglePickup" @toggleDiscount="toggleDiscount" @toggleScore="toggleScore" @togglePrice="togglePrice" /> circle-back
custom-class="!bg-white"
/>
</view>
<view class="home-store-filter-strip">
<filtrate-tool
class="home-store-filters"
@togglePickup="togglePickup"
@toggleDiscount="toggleDiscount"
@toggleScore="toggleScore"
@togglePrice="togglePrice"
/>
</view> </view>
</template> </template>
<view class="p-30rpx">
<template v-for="(item, index) in dataList" :key="index"> <view class="home-store-list">
<food-box :item="item" /> <view
</template> v-for="(item, index) in dataList"
:key="item.id ?? index"
class="merchant-card"
@click="openMerchant(item)"
>
<view class="merchant-card__imgs">
<view
v-for="(src, ii) in merchantImagePair(item)"
:key="ii"
class="merchant-card__img-slot"
:class="
ii === 0
? 'merchant-card__img-slot--first'
: 'merchant-card__img-slot--last'
"
>
<image
v-if="src"
class="merchant-card__img"
:src="src"
mode="aspectFill"
/>
<view v-else class="merchant-card__img merchant-card__img--empty" />
</view>
</view>
<view class="merchant-card__body">
<text class="merchant-card__name">{{ item.merchantName }}</text>
<text
v-if="merchantCategoryLine(item)"
class="merchant-card__cate"
>{{ merchantCategoryLine(item) }}</text
>
<view class="merchant-card__rating">
<text
v-for="si in [1, 2, 3, 4, 5]"
:key="si"
class="merchant-card__star"
:class="{
'merchant-card__star--on': si <= ratingStars(item.rating),
}"
></text
>
<text class="merchant-card__score">{{
ratingText(item.rating)
}}</text>
</view>
<text class="merchant-card__tag">{{ t("pages.home.brandTag") }}</text>
</view>
<view class="merchant-card__go" @click.stop="openMerchant(item)">
<view class="i-carbon:chevron-right merchant-card__go-icon"></view>
</view>
</view>
</view> </view>
</z-paging> </z-paging>
<score @applyScore="applyScore" ref="scoreRef" /> <score @applyScore="applyScore" ref="scoreRef" />
<price-choose @applyPrice="applyPrice" ref="priceChooseRef" /> <price-choose @applyPrice="applyPrice" ref="priceChooseRef" />
</view>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.home-store-page {
min-height: 100vh;
}
.home-store-header {
background: #fff;
}
.home-store-filter-strip {
background: #f2f3f5;
padding-bottom: 8rpx;
}
.home-store-filters {
display: block;
padding: 16rpx 0 20rpx;
}
.home-store-list {
padding: 16rpx 24rpx 40rpx;
box-sizing: border-box;
}
.merchant-card {
display: flex;
flex-direction: row;
align-items: center;
background: #fff;
border-radius: 24rpx;
padding: 24rpx;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.06);
}
.merchant-card__imgs {
display: flex;
flex-direction: column;
gap: 12rpx;
width: 152rpx;
flex-shrink: 0;
}
.merchant-card__img-slot {
width: 152rpx;
height: 96rpx;
flex-shrink: 0;
overflow: hidden;
background: #e8eaed;
}
/* 仅外侧圆角;靠两张图之间的分割一侧为直角 */
.merchant-card__img-slot--first {
border-radius: 12rpx 12rpx 0 0;
}
.merchant-card__img-slot--last {
border-radius: 0 0 12rpx 12rpx;
}
.merchant-card__img {
width: 100%;
height: 100%;
display: block;
background: #e8eaed;
}
.merchant-card__img--empty {
flex-shrink: 0;
width: 100%;
height: 100%;
}
.merchant-card__body {
flex: 1;
min-width: 0;
padding: 0 20rpx 0 8rpx;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.merchant-card__name {
font-size: 30rpx;
font-weight: 600;
color: #14181b;
line-height: 1.35;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.merchant-card__cate {
margin-top: 8rpx;
font-size: 26rpx;
color: #333;
line-height: 1.3;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.merchant-card__rating {
margin-top: 12rpx;
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 4rpx;
}
.merchant-card__star {
font-size: 22rpx;
line-height: 1;
color: #e0e0e0;
letter-spacing: -2rpx;
}
.merchant-card__star--on {
color: #14181b;
}
.merchant-card__score {
margin-left: 10rpx;
font-size: 26rpx;
font-weight: 600;
color: #14181b;
}
.merchant-card__tag {
margin-top: 10rpx;
font-size: 24rpx;
font-weight: 500;
color: #b8860b;
line-height: 1.3;
}
.merchant-card__go {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #14181b;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.merchant-card__go-icon {
font-size: 28rpx;
color: #fff;
margin-left: 2rpx;
}
</style>
<style>
page {
background-color: #f2f3f5;
}
</style> </style>
+64 -16
View File
@@ -28,6 +28,21 @@ const { t } = useI18n();
const configStore = useConfigStore(); const configStore = useConfigStore();
const userStore = useUserStore(); const userStore = useUserStore();
function fillI18nParams(template: string, params: Record<string, string | number>) {
let text = template;
Object.keys(params).forEach((key) => {
const value = String(params[key] ?? "");
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), value);
text = text.replace(new RegExp(`\\$\\{${key}\\}`, "g"), value);
});
return text;
}
const appDisplayName = computed(() => {
const name = String((Config as any)?.appName ?? "").trim();
return name || "CHEFLINK";
});
// 送达偏好 // 送达偏好
const visitMethodRef = ref(); const visitMethodRef = ref();
// value 与 visit-method 组件保持一致:0-亲自送达 1-放门口 // value 与 visit-method 组件保持一致:0-亲自送达 1-放门口
@@ -1176,6 +1191,47 @@ const scheduledServiceEndLabel = computed(() => {
return ''; return '';
}); });
const localDeliverySubtitleText = computed(() =>
fillI18nParams(t('pages-store.checkout.localDeliverySubtitle'), { name: appDisplayName.value })
);
const itemsGoodsTotalWithPriceText = computed(() =>
fillI18nParams(t('pages-store.checkout.itemsGoodsTotalWithPrice'), {
count: cartTotalPieceCount.value,
amount: displayGoodsAmountStr.value,
})
);
const scheduledDeliveryWindowText = computed(() =>
fillI18nParams(t('pages-store.checkout.scheduledDeliveryWindow'), {
time: scheduledServiceEndLabel.value,
})
);
const deliverBeforeText = computed(() =>
fillI18nParams(t('pages-store.checkout.deliverBefore'), {
time: deliveryMethod.value === 0
? String(userSelectedDeliveryTimeDate.value ?? '')
: String(userSelectedSelfPickupTimeDate.value ?? ''),
})
);
const memberThanksText = computed(() =>
fillI18nParams(t('pages-store.checkout.memberThanks'), { name: appDisplayName.value })
);
const subtotalWithPiecesText = computed(() =>
fillI18nParams(t('pages-store.checkout.subtotalWithPieces'), {
count: cartTotalPieceCount.value,
})
);
const subtotalOneLineText = computed(() =>
fillI18nParams(t('pages-store.checkout.subtotalOneLine'), {
amount: displayPaidStr.value,
})
);
const showAppointmentEntry = computed(() => { const showAppointmentEntry = computed(() => {
if (deliveryMethod.value === 0) { if (deliveryMethod.value === 0) {
return storeIsDeliveryService.value || orderType.value === 'batch'; return storeIsDeliveryService.value || orderType.value === 'batch';
@@ -1332,7 +1388,7 @@ function handleClose(merchantId?: string) {
}}</text> }}</text>
<text class="checkout-card-subtitle block">{{ <text class="checkout-card-subtitle block">{{
deliveryMethod === 0 deliveryMethod === 0
? t('pages-store.checkout.localDeliverySubtitle', { name: Config.appName }) ? localDeliverySubtitleText
: t('pages-store.checkout.pickupSubtitle') : t('pages-store.checkout.pickupSubtitle')
}}</text> }}</text>
</view> </view>
@@ -1346,7 +1402,7 @@ function handleClose(merchantId?: string) {
</view> </view>
<view class="checkout-confirm-band-right"> <view class="checkout-confirm-band-right">
<text class="checkout-confirm-band-line1"> <text class="checkout-confirm-band-line1">
{{ t('pages-store.checkout.itemsGoodsTotalWithPrice', { count: cartTotalPieceCount, amount: displayGoodsAmountStr }) }} {{ itemsGoodsTotalWithPriceText }}
</text> </text>
<view v-if="deliveryMethod === 0" class="checkout-confirm-band-line2"> <view v-if="deliveryMethod === 0" class="checkout-confirm-band-line2">
<text>{{ t('pages-store.checkout.shippingFee') }}</text> <text>{{ t('pages-store.checkout.shippingFee') }}</text>
@@ -1370,7 +1426,7 @@ function handleClose(merchantId?: string) {
<view class="flex-1 min-w-0"> <view class="flex-1 min-w-0">
<text class="checkout-schedule-title">{{ t('pages-store.checkout.scheduledDeliveryTitle') }}</text> <text class="checkout-schedule-title">{{ t('pages-store.checkout.scheduledDeliveryTitle') }}</text>
<text v-if="scheduledServiceEndLabel" class="checkout-schedule-mid">{{ <text v-if="scheduledServiceEndLabel" class="checkout-schedule-mid">{{
t('pages-store.checkout.scheduledDeliveryWindow', { time: scheduledServiceEndLabel }) scheduledDeliveryWindowText
}}</text> }}</text>
<text class="checkout-schedule-hint">{{ <text class="checkout-schedule-hint">{{
t('pages-store.checkout.scheduledDeliveryHint') t('pages-store.checkout.scheduledDeliveryHint')
@@ -1456,11 +1512,7 @@ function handleClose(merchantId?: string) {
v-if="showAppointmentEntry && (userSelectedDeliveryTimeDate || userSelectedSelfPickupTimeDate)" v-if="showAppointmentEntry && (userSelectedDeliveryTimeDate || userSelectedSelfPickupTimeDate)"
class="checkout-deliver-hint" class="checkout-deliver-hint"
> >
{{ {{ deliverBeforeText }}
t('pages-store.checkout.deliverBefore', {
time: deliveryMethod === 0 ? userSelectedDeliveryTimeDate : userSelectedSelfPickupTimeDate,
})
}}
</view> </view>
</view> </view>
</view> </view>
@@ -1735,13 +1787,11 @@ function handleClose(merchantId?: string) {
<view class="checkout-section-label">{{ t('pages-store.checkout.orderBreakdown') }}</view> <view class="checkout-section-label">{{ t('pages-store.checkout.orderBreakdown') }}</view>
<view class="checkout-card checkout-breakdown checkout-gutter"> <view class="checkout-card checkout-breakdown checkout-gutter">
<view v-if="isUserMemberCheckout" class="checkout-member-line"> <view v-if="isUserMemberCheckout" class="checkout-member-line">
<text class="checkout-member-text">{{ <text class="checkout-member-text">{{ memberThanksText }}</text>
t('pages-store.checkout.memberThanks', { name: Config.appName })
}}</text>
<text class="checkout-member-icon"></text> <text class="checkout-member-icon"></text>
</view> </view>
<view class="checkout-breakdown-row"> <view class="checkout-breakdown-row">
<text class="checkout-breakdown-label">{{ t('pages-store.checkout.subtotalWithPieces', { count: cartTotalPieceCount }) }}</text> <text class="checkout-breakdown-label">{{ subtotalWithPiecesText }}</text>
<text class="checkout-breakdown-value">${{ displayGoodsAmountStr }}</text> <text class="checkout-breakdown-value">${{ displayGoodsAmountStr }}</text>
</view> </view>
<view class="checkout-breakdown-row"> <view class="checkout-breakdown-row">
@@ -1792,7 +1842,7 @@ function handleClose(merchantId?: string) {
</view> </view>
<view class="checkout-breakdown-divider"></view> <view class="checkout-breakdown-divider"></view>
<view class="checkout-breakdown-row checkout-breakdown-row--total"> <view class="checkout-breakdown-row checkout-breakdown-row--total">
<text class="checkout-breakdown-total-label">{{ t('pages-store.checkout.subtotalWithPieces', { count: cartTotalPieceCount }) }}</text> <text class="checkout-breakdown-total-label">{{ subtotalWithPiecesText }}</text>
<text class="checkout-breakdown-total-value">${{ displayPaidStr }}</text> <text class="checkout-breakdown-total-value">${{ displayPaidStr }}</text>
</view> </view>
</view> </view>
@@ -1822,9 +1872,7 @@ function handleClose(merchantId?: string) {
<view class="checkout-bottom-bar-glass"></view> <view class="checkout-bottom-bar-glass"></view>
<view class="checkout-bottom-bar-inner"> <view class="checkout-bottom-bar-inner">
<view class="checkout-bottom-bar-price"> <view class="checkout-bottom-bar-price">
<text class="checkout-bottom-bar-one-line">{{ <text class="checkout-bottom-bar-one-line">{{ subtotalOneLineText }}</text>
t('pages-store.checkout.subtotalOneLine', { amount: displayPaidStr })
}}</text>
</view> </view>
<wd-button <wd-button
@click="handleGoSettle" @click="handleGoSettle"
+177 -43
View File
@@ -16,6 +16,7 @@ import CancelOrder from "@/pages-store/pages/order/components/cancel-order.vue";
import {useConfigStore} from "@/store"; import {useConfigStore} from "@/store";
import {OrderStatus, EventEnum, OrderCancelStatus} from "@/constant/enums"; import {OrderStatus, EventEnum, OrderCancelStatus} from "@/constant/enums";
import {formatTimestampWithMonthName, formatTimestampShort, navGoogleMap, callPhone} from "@/utils/utils"; import {formatTimestampWithMonthName, formatTimestampShort, navGoogleMap, callPhone} from "@/utils/utils";
import dayjs from 'dayjs'
import useEventEmit from "@/hooks/useEventEmit"; import useEventEmit from "@/hooks/useEventEmit";
const configStore = useConfigStore(); const configStore = useConfigStore();
@@ -239,28 +240,107 @@ function navigateTo(url: string) {
uni.navigateTo({ url }) uni.navigateTo({ url })
} }
/** 订单详情顶栏:与设计稿一致的 MM/DD HH:mm */
function formatOrderNavScheduleTime(timestamp?: number | string | null) {
if (timestamp == null || timestamp === '') return ''
const n = Number(timestamp)
if (!Number.isFinite(n)) return ''
return dayjs(n).format('MM/DD HH:mm')
}
function handleOrderDetailBack() {
const pages = getCurrentPages?.() || []
if (pages.length <= 1) {
uni.switchTab({ url: '/pages/home/index' })
return
}
uni.navigateBack()
}
/** 顶栏居中展示「预计送达 / 下单时间」:非取消、非退款申请中、非商家拒绝 */
const showOrderNavTimeBlock = computed(() => {
if (!orderDetail.value) return false
if (orderStatus.value === OrderStatus.CANCELLED) return false
if (orderDetail.value.refundStatus === OrderCancelStatus.APPLIED) return false
if (orderStatus.value === OrderStatus.MERCHANT_REJECTED) return false
return true
})
const orderNavPrimaryLine = computed(() => {
const d = orderDetail.value
if (!d) return ''
const isDelivery = +(d.receiveMethod ?? 0) === 1
const label = isDelivery
? t('pages-store.order.estimatedDeliveryTime')
: t('pages-store.order.upTime')
const timePart = formatOrderNavScheduleTime(d.endScheduledTime) || '--'
const suffix = isDelivery ? t('pages-store.order.beforeDeadline') : ''
return `${label} : ${timePart}${suffix}`
})
const orderNavSecondaryLine = computed(() => {
const d = orderDetail.value
if (!d) return ''
const ct = d.createTime
const timeStr =
formatOrderNavScheduleTime(ct) ||
(ct != null && ct !== '' ? formatTimestampShort(Number(ct)) : '')
return `${t('pages-store.order.orderTime')}: ${timeStr || '--'}`
})
// 已支付上传凭证(Zip 等线下支付) // 已支付上传凭证(Zip 等线下支付)
const voucherChooseRef = ref<InstanceType<typeof ChooseImage>>() const voucherChooseRef = ref<InstanceType<typeof ChooseImage>>()
const voucherSubmitting = ref(false) const voucherSubmitting = ref(false)
function openUploadVoucher() { // function openUploadVoucher() {
voucherChooseRef.value?.init() // voucherChooseRef.value?.init()
} // }
function normalizeVoucherUrl(payload: unknown): string { // function normalizeVoucherUrl(payload: unknown): string {
if (Array.isArray(payload)) { // if (Array.isArray(payload)) {
const first = payload[0] // const first = payload[0]
return typeof first === 'string' ? first : '' // return typeof first === 'string' ? first : ''
} // }
return typeof payload === 'string' ? payload : '' // return typeof payload === 'string' ? payload : ''
} // }
async function onVoucherImageUploaded(urls: unknown) { // async function onVoucherImageUploaded(urls: unknown) {
const zipPayVoucher = normalizeVoucherUrl(urls) // const zipPayVoucher = normalizeVoucherUrl(urls)
if (!zipPayVoucher) { // if (!zipPayVoucher) {
uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' }) // uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
return // return
} // }
// const id = orderDetail.value?.id
// if (id == null || String(id).trim() === '') {
// uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
// return
// }
// if (voucherSubmitting.value) return
// voucherSubmitting.value = true
// try {
// await appMerchantOrderZipPayVoucherPost({
// body: {
// orderId: Number(id),
// zipPayVoucher,
// },
// options: { hideErrorToast: true },
// })
// uni.showToast({ title: t('pages-store.order.voucherSubmitSuccess'), icon: 'none' })
// setTimeout(() => {
// appMerchantOrderDetail()
// }, 500)
// }
// catch {
// uni.showToast({ title: t('pages-store.order.voucherSubmitFailed'), icon: 'none' })
// }
// finally {
// voucherSubmitting.value = false
// }
// }
const FIXED_VOUCHER_URL = 'https://www.howhowfresh.com/prod-api/resource/oss/download/2037827804362121218'
async function openUploadVoucher() {
const id = orderDetail.value?.id const id = orderDetail.value?.id
if (id == null || String(id).trim() === '') { if (id == null || String(id).trim() === '') {
uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' }) uni.showToast({ title: t('pages-store.order.voucherUploadFailed'), icon: 'none' })
@@ -271,8 +351,8 @@ async function onVoucherImageUploaded(urls: unknown) {
try { try {
await appMerchantOrderZipPayVoucherPost({ await appMerchantOrderZipPayVoucherPost({
body: { body: {
orderId: Number(id), orderId: id,
zipPayVoucher, zipPayVoucher: FIXED_VOUCHER_URL,
}, },
options: { hideErrorToast: true }, options: { hideErrorToast: true },
}) })
@@ -292,7 +372,28 @@ async function onVoucherImageUploaded(urls: unknown) {
<template> <template>
<view class="order-detail-page"> <view class="order-detail-page">
<navbar /> <wd-navbar
safeAreaInsetTop
fixed
placeholder
:bordered="false"
custom-class="order-detail-navbar !bg-white"
@click-left="handleOrderDetailBack"
>
<template #left>
<view class="shrink-0">
<view class="order-detail-navbar-circle center">
<view class="i-carbon:chevron-left text-44rpx text-#111"></view>
</view>
</view>
</template>
<template #title>
<view v-if="!loading && orderDetail && showOrderNavTimeBlock" class="order-detail-nav-times">
<text class="order-detail-nav-primary">{{ orderNavPrimaryLine }}</text>
<text class="order-detail-nav-secondary">{{ orderNavSecondaryLine }}</text>
</view>
</template>
</wd-navbar>
<view <view
class="animate-in fade-in animate-ease-out animate-duration-300" class="animate-in fade-in animate-ease-out animate-duration-300"
v-show="loading" v-show="loading"
@@ -324,36 +425,26 @@ async function onVoucherImageUploaded(urls: unknown) {
</view> </view>
</template> </template>
<!-- 商家拒绝订单 --> <!-- 商家拒绝订单 -->
<template v-if="orderStatus === OrderStatus.MERCHANT_REJECTED"> <template v-else-if="orderStatus === OrderStatus.MERCHANT_REJECTED">
<view class="px-30rpx pt-20rpx pb-50rpx"> <view class="px-30rpx pt-8rpx pb-40rpx">
<view class="text-40rpx lh-36rpx text-#333 font-500">{{ t('pages-store.order.orderStatus.merchantRejected') }}</view> <view class="text-40rpx lh-36rpx text-#333 font-500">{{ t('pages-store.order.orderStatus.merchantRejected') }}</view>
<view class="text-28rpx lh-28rpx text-#7D7D7D mt-26rpx">{{ t('pages-store.order.orderStatus.merchantRejectedDesc') }}</view> <view class="text-28rpx lh-28rpx text-#7D7D7D mt-26rpx">{{ t('pages-store.order.orderStatus.merchantRejectedDesc') }}</view>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="px-30rpx pt-20rpx pb-50rpx"> <!-- 顶栏已展示预计送达/下单时间此处仅保留提示类副文案 -->
<view class="text-40rpx lh-36rpx text-#333 font-500"> <view class="px-30rpx pt-8rpx pb-24rpx" v-if="orderStatus === OrderStatus.PENDING_PAYMENT || orderDetail?.refundStatus === OrderCancelStatus.REJECTED">
<template v-if="orderDetail?.receiveMethod === 1"> <view class="text-28rpx lh-36rpx text-#7D7D7D" v-if="orderStatus === OrderStatus.PENDING_PAYMENT">
{{ t('pages-store.order.estimatedDeliveryTime') }} {{ t('pages-store.order.autoCancellation') }}
</template>
<template v-else>{{ t('pages-store.order.upTime') }}</template>
:
<!-- 订单预计送达时间-->
{{ formatTimestampShort(orderDetail?.endScheduledTime) }}
</view> </view>
<view class="text-28rpx lh-28rpx text-#7D7D7D mt-26rpx"> <view class="text-28rpx lh-36rpx text-#7D7D7D mt-16rpx" v-if="orderDetail?.refundStatus === OrderCancelStatus.REJECTED">
<view>{{ t('pages-store.order.orderTime') }}: {{ formatTimestampShort(orderDetail?.createTime) }}</view>
<!-- 订单30分钟自动取消--待支付 -->
<view v-if="orderStatus === OrderStatus.PENDING_PAYMENT">{{ t('pages-store.order.autoCancellation') }}</view>
</view>
<view class="text-28rpx lh-28rpx text-#7D7D7D mt-26rpx" v-if="orderDetail?.refundStatus === OrderCancelStatus.REJECTED">
{{ t('pages-store.order.rejectReason') }}{{ orderDetail?.rejectReason }} {{ t('pages-store.order.rejectReason') }}{{ orderDetail?.rejectReason }}
</view> </view>
</view> </view>
<!-- 订单进度 --> <!-- 订单进度紧接顶栏时间信息 -->
<view <view
v-if="orderDetail?.refundStatus !== OrderCancelStatus.APPLIED && orderDetail?.refundStatus !== OrderCancelStatus.APPROVED" v-if="orderDetail?.refundStatus !== OrderCancelStatus.APPLIED && orderDetail?.refundStatus !== OrderCancelStatus.APPROVED"
class="mb-52rpx px-30rpx" class="order-detail-progress-wrap mb-52rpx px-30rpx"
> >
<OrderProgress <OrderProgress
:steps="orderSteps" :steps="orderSteps"
@@ -475,7 +566,7 @@ async function onVoucherImageUploaded(urls: unknown) {
x{{ item?.count }} x{{ item?.count }}
</view> </view>
</view> </view>
<text class="goods-caption line-clamp-1">{{ dishTitle(item) }}</text> <text class="goods-caption line-clamp-2">{{ dishTitle(item) }}</text>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@@ -683,7 +774,8 @@ async function onVoucherImageUploaded(urls: unknown) {
</template> </template>
</template> </template>
<template v-else> <template v-else>
<!-- 待支付 --> <template v-if="orderStatus === OrderStatus.PENDING_PAYMENT">
<!-- 上传支付凭证 -->
<wd-button <wd-button
:loading="voucherSubmitting" :loading="voucherSubmitting"
:disabled="voucherSubmitting" :disabled="voucherSubmitting"
@@ -693,7 +785,6 @@ async function onVoucherImageUploaded(urls: unknown) {
> >
{{ t('pages-store.order.uploadPaidVoucher') }} {{ t('pages-store.order.uploadPaidVoucher') }}
</wd-button> </wd-button>
<template v-if="orderStatus === OrderStatus.PENDING_PAYMENT">
<wd-button @click="goPay" custom-class="!h-108rpx !bg-14181B !text-32rpx !lh-108rpx !text-#fff !rounded-46rpx !mt-22rpx" block> <wd-button @click="goPay" custom-class="!h-108rpx !bg-14181B !text-32rpx !lh-108rpx !text-#fff !rounded-46rpx !mt-22rpx" block>
{{ t('common.goPay') }} {{ t('common.goPay') }}
</wd-button> </wd-button>
@@ -765,8 +856,8 @@ async function onVoucherImageUploaded(urls: unknown) {
<password-container @success="payPawSuccess" ref="passwordInputRef" /> <password-container @success="payPawSuccess" ref="passwordInputRef" />
<!-- 核销订单 --> <!-- 核销订单 -->
<use-code ref="useCodeRef" /> <use-code ref="useCodeRef" />
<!-- 支付凭证:相册/拍照 --> <!-- 支付凭证:相册/拍照(暂时不使用文件上传,改用固定URL -->
<choose-image ref="voucherChooseRef" :count="1" @change="onVoucherImageUploaded" /> <choose-image ref="voucherChooseRef" :count="1" />
</view> </view>
</view> </view>
</template> </template>
@@ -871,4 +962,47 @@ page {
line-height: 28rpx; line-height: 28rpx;
color: #333; color: #333;
} }
.order-detail-navbar-circle {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
}
.order-detail-nav-times {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 8rpx;
max-width: 480rpx;
}
.order-detail-nav-primary {
font-size: 28rpx;
line-height: 36rpx;
font-weight: 600;
color: #14181b;
text-align: center;
}
.order-detail-nav-secondary {
margin-top: 6rpx;
font-size: 24rpx;
line-height: 30rpx;
color: #7d7d7d;
text-align: center;
}
.order-detail-progress-wrap {
padding-top: 8rpx;
}
:deep(.order-detail-navbar.wd-navbar .wd-navbar__title) {
max-width: 520rpx;
overflow: visible;
white-space: normal;
}
</style> </style>
@@ -1,6 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import {useConfigStore} from "@/store"; import {useConfigStore} from "@/store";
import {receiveCouponApi} from "@/pages-user/service"; import {receiveCouponApi} from "@/pages-user/service";
import couponBg from '@img-store/coupon.png'
import couponBg2 from '@img-store/coupon-2.png'
import couponRightBg from '@img-store/coupon-right.png'
import couponRightBg2 from '@img-store/coupon-right-2.png'
const configStore = useConfigStore() const configStore = useConfigStore()
const { t, locale } = useI18n() const { t, locale } = useI18n()
@@ -102,12 +106,16 @@ function couponBenefitText(item: any) {
:key="item.id" :key="item.id"
class="coupon-card" class="coupon-card"
> >
<image
class="coupon-card-bg"
:src="item.userCouponVo ? couponBg2 : couponBg"
mode="scaleToFill"
/>
<view class="coupon-card-body"> <view class="coupon-card-body">
<!-- 左侧信息 -->
<view class="coupon-card-info"> <view class="coupon-card-info">
<view class="coupon-card-amount"> <view class="coupon-card-amount">
<text class="coupon-amount-value">{{ couponAmountText(item) }}</text> <text class="coupon-amount-value" :class="{ 'coupon-amount-value--disabled': item.userCouponVo }">{{ couponAmountText(item) }}</text>
<text class="coupon-amount-label">{{ t('pages-store.store.couponOff') }}</text> <text class="coupon-amount-label" :class="{ 'coupon-amount-label--disabled': item.userCouponVo }">{{ t('pages-store.store.couponOff') }}</text>
</view> </view>
<view class="coupon-card-desc"> <view class="coupon-card-desc">
{{ item.nameZh }} {{ item.nameZh }}
@@ -121,21 +129,21 @@ function couponBenefitText(item: any) {
<text>{{ t('pages-store.store.get') }} {{ couponBenefitText(item) }}</text> <text>{{ t('pages-store.store.get') }} {{ couponBenefitText(item) }}</text>
</view> </view>
</view> </view>
</view>
<!-- 右侧按钮 -->
<view <view
v-if="item.userCouponVo" v-if="item.userCouponVo"
class="coupon-claim-btn coupon-claim-btn--disabled" class="coupon-claim-wrap"
> >
{{ t('pages-store.store.claimed') }} <image class="coupon-claim-bg" :src="couponRightBg2" mode="scaleToFill" />
<text class="coupon-claim-text coupon-claim-text--disabled">{{ t('pages-store.store.claimed') }}</text>
</view> </view>
<view <view
v-else v-else
class="coupon-claim-btn" class="coupon-claim-wrap"
@click="confirmCoupon(item)" @click="confirmCoupon(item)"
> >
{{ t('pages-store.store.claimNow') }} <image class="coupon-claim-bg" :src="couponRightBg" mode="scaleToFill" />
</view> <text class="coupon-claim-text">{{ t('pages-store.store.claimNow') }}</text>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@@ -157,27 +165,31 @@ function couponBenefitText(item: any) {
} }
.coupon-card { .coupon-card {
background: #fff; position: relative;
border-radius: 16rpx;
border: 2rpx solid #F5D0B8;
margin-bottom: 24rpx; margin-bottom: 24rpx;
overflow: hidden;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
} }
} }
.coupon-card-bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.coupon-card-body { .coupon-card-body {
display: flex; position: relative;
align-items: center; z-index: 1;
padding: 32rpx; padding: 32rpx 180rpx 32rpx 32rpx;
} }
.coupon-card-info { .coupon-card-info {
flex: 1;
min-width: 0; min-width: 0;
padding-right: 24rpx;
} }
.coupon-card-amount { .coupon-card-amount {
@@ -191,6 +203,10 @@ function couponBenefitText(item: any) {
line-height: 56rpx; line-height: 56rpx;
font-weight: bold; font-weight: bold;
color: #CE7138; color: #CE7138;
&--disabled {
color: #BFBFBF;
}
} }
.coupon-amount-label { .coupon-amount-label {
@@ -199,6 +215,10 @@ function couponBenefitText(item: any) {
color: #CE7138; color: #CE7138;
font-weight: 500; font-weight: 500;
margin-left: 10rpx; margin-left: 10rpx;
&--disabled {
color: #BFBFBF;
}
} }
.coupon-card-desc { .coupon-card-desc {
@@ -223,22 +243,37 @@ function couponBenefitText(item: any) {
margin-right: 8rpx; margin-right: 8rpx;
} }
.coupon-claim-btn { .coupon-claim-wrap {
flex-shrink: 0; position: absolute;
min-width: 140rpx; right: 0;
height: 68rpx; top: 0;
line-height: 68rpx; bottom: 0;
text-align: center; width: 168rpx;
background: #CE7138; z-index: 2;
display: flex;
align-items: center;
justify-content: center;
}
.coupon-claim-bg {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.coupon-claim-text {
position: relative;
z-index: 1;
color: #fff; color: #fff;
font-size: 26rpx; font-size: 26rpx;
font-weight: 500; // font-weight: 600;
border-radius: 12rpx; text-align: center;
padding: 0 24rpx;
&--disabled { &--disabled {
background: #E6E6E6; opacity: 0.6;
color: #999;
} }
} }
</style> </style>
File diff suppressed because it is too large Load Diff
+1 -4
View File
@@ -423,10 +423,7 @@ function navigateBack() {
function navigateToCart() { function navigateToCart() {
uni.navigateTo({ uni.navigateTo({
url: url: '/pages-user/pages/cart/index',
'/pages-user/pages/cart/store-cart'
+ '?storeId=' + storeID.value
+ '&storeName=' + encodeURIComponent(storeDetail.value.merchantName),
}) })
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@@ -25,9 +25,9 @@ defineExpose({
@close="handleClose" @close="handleClose"
> >
<view class="px-30rpx text-#333 text-center pt-48rpx pb-60rpx"> <view class="px-30rpx text-#333 text-center pt-48rpx pb-60rpx">
<view class="text-40rpx lh-40rpx font-500">Delete shopping cart?</view> <view class="text-40rpx lh-40rpx font-500">{{ t("pages-user.cart.removeCartTitle") }}</view>
<view class="text-28rpx lh-28rpx mt-36rpx"> <view class="text-28rpx lh-28rpx mt-36rpx">
Are you sure you want to delete the shopping cart? {{ t("pages-user.cart.removeCartDesc") }}
</view> </view>
<view class="mt-70rpx"> <view class="mt-70rpx">
<wd-button @click="handleDelete" custom-class="!h-108rpx !bg-14181B !text-36rpx !lh-108rpx !text-#fff !rounded-16rpx" block> <wd-button @click="handleDelete" custom-class="!h-108rpx !bg-14181B !text-36rpx !lh-108rpx !text-#fff !rounded-16rpx" block>
@@ -4,6 +4,20 @@ const emit = defineEmits(['confirm','close'])
const show = ref(false); const show = ref(false);
const goodsName = ref(''); const goodsName = ref('');
function fillI18nParams(template: string, params: Record<string, string | number>) {
let text = template;
Object.keys(params).forEach((key) => {
const value = String(params[key] ?? "");
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), value);
text = text.replace(new RegExp(`\\$\\{${key}\\}`, "g"), value);
});
return text;
}
const removeProductDescText = computed(() =>
fillI18nParams(t("pages-user.cart.removeProductDesc"), { name: goodsName.value })
);
function onOpen(title: string) { function onOpen(title: string) {
if (title) { if (title) {
goodsName.value = title; goodsName.value = title;
@@ -31,9 +45,9 @@ defineExpose({
@close="handleClose" @close="handleClose"
> >
<view class="px-30rpx text-#333 text-center pt-48rpx pb-60rpx"> <view class="px-30rpx text-#333 text-center pt-48rpx pb-60rpx">
<view class="text-40rpx lh-40rpx font-500">Remove the product?</view> <view class="text-40rpx lh-40rpx font-500">{{ t("pages-user.cart.removeProductTitle") }}</view>
<view class="text-28rpx lh-28rpx mt-36rpx"> <view class="text-28rpx lh-28rpx mt-36rpx">
Are you sure you want to remove {{ goodsName }} from your shopping cart? {{ removeProductDescText }}
</view> </view>
<view class="mt-70rpx"> <view class="mt-70rpx">
<wd-button @click="confirmRemove" custom-class="!h-108rpx !bg-14181B !text-36rpx !lh-108rpx !text-#fff !rounded-16rpx" block> <wd-button @click="confirmRemove" custom-class="!h-108rpx !bg-14181B !text-36rpx !lh-108rpx !text-#fff !rounded-16rpx" block>
+87 -35
View File
@@ -38,6 +38,9 @@ interface CartItem {
merchantDishVo: any; merchantDishVo: any;
sideDishList: any[]; sideDishList: any[];
checked: boolean; checked: boolean;
discountPrice: number;
originalPrice: number;
memberPrice: number;
} }
interface CartMerchant { interface CartMerchant {
@@ -66,6 +69,59 @@ const selectedCartItems = computed(() => {
}); });
const selectedCount = computed(() => selectedCartItems.value.length); const selectedCount = computed(() => selectedCartItems.value.length);
const appDisplayName = computed(() => {
const name = String((Config as any)?.appName ?? "").trim();
return name || "CHEFLINK";
});
function fillI18nParams(template: string, params: Record<string, string | number>) {
let text = template;
Object.keys(params).forEach((key) => {
const value = String(params[key] ?? "");
text = text.replace(new RegExp(`\\{${key}\\}`, "g"), value);
text = text.replace(new RegExp(`\\$\\{${key}\\}`, "g"), value);
});
return text;
}
function normalizePriceString(val: unknown) {
const s = String(val ?? "").trim();
if (!/^\d+(\.\d+)?$/.test(s)) return "0";
const [intRaw, decRaw = ""] = s.split(".");
const intPart = intRaw.replace(/^0+(?=\d)/, "") || "0";
const decPart = decRaw.slice(0, 2).padEnd(2, "0");
return `${intPart}.${decPart}`;
}
function priceToCentString(val: unknown) {
const normalized = normalizePriceString(val);
const [intPart, decPart = "00"] = normalized.split(".");
return `${intPart}${decPart}`.replace(/^0+(?=\d)/, "") || "0";
}
function formatPriceForView(val: unknown) {
const normalized = normalizePriceString(val);
return normalized.replace(/\.00$/, "").replace(/(\.\d)0$/, "$1");
}
function getCartLineDisplayPrice(item: CartItem) {
// const memberCent = priceToCentString(item?.memberPrice);
// console.log('memberCent', memberCent);
console.log('item?.memberPrice', item?.memberPrice);
console.log(userStore.userInfo.userMembershipVo, 'userStore.isMember');
if (userStore.userInfo.userMembershipVo!==null) {
return item?.memberPrice;
}
return item?.discountPrice;
}
function showCartLineOriginalPrice(item: CartItem) {
const originalCent = priceToCentString(item?.originalPrice);
const currentCent = userStore.userInfo.userMembershipVo!==null && priceToCentString(item?.memberPrice) !== "0"
? priceToCentString(item?.memberPrice)
: priceToCentString(item?.discountPrice);
return originalCent !== "0" && originalCent !== currentCent;
}
const priceData = ref< const priceData = ref<
Record<string, any> & { Record<string, any> & {
@@ -100,6 +156,17 @@ const selectedGoodsSubtotal = computed(() => {
return total.toFixed(2); return total.toFixed(2);
}); });
const deliveryUnifiedText = computed(() =>
fillI18nParams(t("pages-user.cart.deliveryUnified"), { name: appDisplayName.value })
);
const itemsTotalWithPriceText = computed(() =>
fillI18nParams(t("pages-user.cart.itemsTotalWithPrice"), {
count: priceData.value.totalQuantity ?? selectedItemQty.value,
amount: selectedGoodsSubtotal.value,
})
);
/** 与地址页、结算页一致:展示用户已保存预约日,无则展示今天(选时间会跳转 reservation-time 并写回接口) */ /** 与地址页、结算页一致:展示用户已保存预约日,无则展示今天(选时间会跳转 reservation-time 并写回接口) */
const deliveryScheduleLabel = computed(() => { const deliveryScheduleLabel = computed(() => {
const ap = userStore.appointmentTime as any; const ap = userStore.appointmentTime as any;
@@ -210,7 +277,7 @@ function confirmRemove() {
getCartList(); getCartList();
uni.showToast({ uni.showToast({
icon: "none", icon: "none",
title: "删除成功", title: t("toast.deleteSuccess"),
}); });
}); });
} }
@@ -324,23 +391,18 @@ function scheduleCartUpdate(item: CartItem, targetValue: number) {
pendingUpdateTimers.set(key, timer); pendingUpdateTimers.set(key, timer);
} }
function normalizeInputNumberValue(payload: any): number { /** wd-input-number change 为 { value },兼容 detail.value */
if (typeof payload === "number") return payload; function normalizeInputNumberValue(payload: unknown): number {
if (payload && typeof payload === "object") { const raw =
if (typeof payload.detail?.value === "number") typeof payload === "number"
return payload.detail.value; ? payload
if (typeof payload.value === "number") return payload.value; : (payload as any)?.value ?? (payload as any)?.detail?.value ?? payload;
} const n = Number(raw);
const numeric = Number(payload); return Number.isFinite(n) ? n : 0;
return Number.isNaN(numeric) ? 0 : numeric;
} }
const delItemData = ref<CartItem | null>(null); const delItemData = ref<CartItem | null>(null);
function onItemQtyChange(item: CartItem) {
return (payload: unknown) => handleQuantityChange(payload, item);
}
function handleQuantityChange(payload: any, item: CartItem) { function handleQuantityChange(payload: any, item: CartItem) {
if (!item) return; if (!item) return;
const nextValue = normalizeInputNumberValue(payload); const nextValue = normalizeInputNumberValue(payload);
@@ -593,9 +655,7 @@ async function getCartList() {
t("pages-user.cart.localDelivery") t("pages-user.cart.localDelivery")
}}</text> }}</text>
<text class="cart-delivery-sub">{{ <text class="cart-delivery-sub">{{
t("pages-user.cart.deliveryUnified", { deliveryUnifiedText
name: Config.appName,
})
}}</text> }}</text>
</view> </view>
</view> </view>
@@ -607,11 +667,7 @@ async function getCartList() {
</view> </view>
<view class="cart-price-summary"> <view class="cart-price-summary">
<text class="cart-summary-line1">{{ <text class="cart-summary-line1">{{
t("pages-user.cart.itemsTotalWithPrice", { itemsTotalWithPriceText
count:
priceData.totalQuantity ?? selectedItemQty,
amount: selectedGoodsSubtotal,
})
}}</text> }}</text>
<view <view
v-if=" v-if="
@@ -731,26 +787,22 @@ async function getCartList() {
<text class="mr-6rpx">{{ <text class="mr-6rpx">{{
dish?.merchantSideDishItemVo?.name || "" dish?.merchantSideDishItemVo?.name || ""
}}</text> }}</text>
<text <!-- <text
v-if="dish?.merchantSideDishItemVo?.price" v-if="dish?.merchantSideDishItemVo?.price"
class="text-[#00A76D] mr-10rpx" class="text-[#00A76D] mr-10rpx"
>+${{ dish?.merchantSideDishItemVo?.price }}</text >${{ dish?.merchantSideDishItemVo?.price }}</text
> > -->
</view> </view>
</view> </view>
<view class="cart-line-price-row"> <view class="cart-line-price-row">
<view class="flex items-baseline flex-wrap"> <view class="flex items-baseline flex-wrap">
<text class="cart-line-price" <text class="cart-line-price"
>${{ item.merchantDishVo?.discountPrice }}</text >${{ getCartLineDisplayPrice(item) }}</text
> >
<text <text
v-if=" v-if="showCartLineOriginalPrice(item)"
item.merchantDishVo?.originalPrice &&
item.merchantDishVo?.originalPrice !==
item.merchantDishVo?.discountPrice
"
class="cart-line-price-old" class="cart-line-price-old"
>${{ item.merchantDishVo?.originalPrice }}</text >${{ item?.originalPrice }}</text
> >
</view> </view>
<wd-input-number <wd-input-number
@@ -761,7 +813,7 @@ async function getCartList() {
:input-width="72" :input-width="72"
button-size="52" button-size="52"
custom-class="cart-qty-input" custom-class="cart-qty-input"
@change="onItemQtyChange(item)" @change="(e) => handleQuantityChange(e, item)"
/> />
</view> </view>
</view> </view>
@@ -809,12 +861,12 @@ async function getCartList() {
<template v-else> <template v-else>
<view class="flex flex-col items-center justify-center py-100rpx"> <view class="flex flex-col items-center justify-center py-100rpx">
<image src="@img/chef/100.png" class="w-318rpx h-318rpx" /> <image src="@img/chef/100.png" class="w-318rpx h-318rpx" />
<text class="text-32rpx text-[#7D7D7D]">Your cart is empty</text> <text class="text-32rpx text-[#7D7D7D]">{{ t("pages-user.cart.emptyTitle") }}</text>
<view <view
class="mt-60rpx w-400rpx h-88rpx rounded-16rpx bg-[#14181B] flex items-center justify-center" class="mt-60rpx w-400rpx h-88rpx rounded-16rpx bg-[#14181B] flex items-center justify-center"
@click="goToHome" @click="goToHome"
> >
<text class="text-30rpx text-white">Explore Restaurants</text> <text class="text-30rpx text-white">{{ t("pages-user.cart.emptyAction") }}</text>
</view> </view>
</view> </view>
</template> </template>
+25 -19
View File
@@ -115,20 +115,14 @@ function scheduleCartUpdate(item: MerchantCartVo, targetValue: number) {
pendingUpdateTimers.set(key, timer) pendingUpdateTimers.set(key, timer)
} }
function normalizeInputNumberValue(payload: any): number { /** wd-input-number change 为 { value },兼容 detail.value */
if (typeof payload === 'number') { function normalizeInputNumberValue(payload: unknown): number {
return payload const raw =
} typeof payload === "number"
if (payload && typeof payload === 'object') { ? payload
if (typeof payload.detail?.value === 'number') { : (payload as any)?.value ?? (payload as any)?.detail?.value ?? payload;
return payload.detail.value const n = Number(raw);
} return Number.isFinite(n) ? n : 0;
if (typeof payload.value === 'number') {
return payload.value
}
}
const numeric = Number(payload)
return Number.isNaN(numeric) ? 0 : numeric
} }
const delItemData = ref<MerchantCartVo | null>(null) const delItemData = ref<MerchantCartVo | null>(null)
@@ -247,6 +241,18 @@ function appMerchantCartCalculateSavings() {
}) })
} }
function getCartItemDiscountPrice(item: MerchantCartVo) {
return item.discountPrice ?? item.merchantDishVo?.discountPrice
}
function getCartItemOriginalPrice(item: MerchantCartVo) {
return item.originalPrice ?? item.merchantDishVo?.originalPrice
}
function getCartItemMemberPrice(item: MerchantCartVo) {
return item.memberPrice ?? item.merchantDishVo?.memberPrice
}
function navigateTo(url: string) { function navigateTo(url: string) {
uni.navigateTo({ url }) uni.navigateTo({ url })
} }
@@ -301,21 +307,21 @@ function navigateTo(url: string) {
<view class="price-row flex items-center mt-18rpx"> <view class="price-row flex items-center mt-18rpx">
<text class="current-price text-[#333333] text-30rpx font-normal" <text class="current-price text-[#333333] text-30rpx font-normal"
>${{ item.merchantDishVo.discountPrice }}</text >${{ getCartItemDiscountPrice(item) }}</text
> >
<text <text
v-if="item.merchantDishVo.originalPrice" v-if="getCartItemOriginalPrice(item)"
class="original-price text-[#7D7D7D] text-24rpx font-normal line-through ml-10rpx" class="original-price text-[#7D7D7D] text-24rpx font-normal line-through ml-10rpx"
>${{ item.merchantDishVo.originalPrice }}</text >${{ getCartItemOriginalPrice(item) }}</text
> >
<!-- 会员价标签 --> <!-- 会员价标签 -->
<view <view
v-if="Number(item.merchantDishVo.memberPrice) > 0" v-if="Number(getCartItemMemberPrice(item)) > 0"
class="member-price-tag ml-10rpx center pl-16rpx pr-6rpx pb-2rpx" class="member-price-tag ml-10rpx center pl-16rpx pr-6rpx pb-2rpx"
> >
<text class="text-[#FBE3C3] text-20rpx" <text class="text-[#FBE3C3] text-20rpx"
>{{ t('pages-store.store.members') }}: ${{ item.merchantDishVo.memberPrice }}</text >{{ t('pages-store.store.members') }}: ${{ getCartItemMemberPrice(item) }}</text
> >
</view> </view>
</view> </view>
+4 -1
View File
@@ -229,7 +229,10 @@
"path": "pages/store/search/result" "path": "pages/store/search/result"
}, },
{ {
"path": "pages/store/dishes" "path": "pages/store/dishes",
"style": {
"onReachBottomDistance": 80
}
}, },
{ {
"path": "pages/order/checkout" "path": "pages/order/checkout"
@@ -81,11 +81,6 @@ function subtitleLine(item: any): string {
class="featured-card__media-half featured-card__media-half--top" class="featured-card__media-half featured-card__media-half--top"
mode="aspectFill" mode="aspectFill"
/> />
<image
:src="getCardImages(item)[1]"
class="featured-card__media-half featured-card__media-half--bottom"
mode="aspectFill"
/>
</template> </template>
<image <image
v-else-if="getCardImages(item).length >= 1" v-else-if="getCardImages(item).length >= 1"
@@ -154,6 +149,7 @@ function subtitleLine(item: any): string {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
width: 620rpx; width: 620rpx;
height: 256rpx;
min-height: 256rpx; min-height: 256rpx;
margin-left: 16rpx; margin-left: 16rpx;
background: #fff; background: #fff;
@@ -171,18 +167,22 @@ function subtitleLine(item: any): string {
background: #f0f0f0; background: #f0f0f0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative;
overflow: hidden;
} }
.featured-card__media-single { .featured-card__media-single {
width: 100%; width: 100%;
height: 100%; height: 100%;
min-height: 256rpx; min-height: 256rpx;
display: block;
} }
.featured-card__media-half { .featured-card__media-half {
width: 100%; width: 100%;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
display: block;
} }
.featured-card__media-half--top { .featured-card__media-half--top {
border-bottom: 3rpx solid #fff; border-bottom: 3rpx solid #fff;
@@ -446,10 +446,10 @@ const debouncedEmit = debounce(1300, (isCollected: boolean, id: string, type: Co
<view class="featured-dish-meta flex items-start justify-between gap-12rpx mb-14rpx"> <view class="featured-dish-meta flex items-start justify-between gap-12rpx mb-14rpx">
<view class="min-w-0 flex-1"> <view class="min-w-0 flex-1">
<text class="featured-dish-price">US${{ item?.discountPrice }}</text> <text class="featured-dish-price">US${{ item?.discountPrice }}</text>
<text <!-- <text
v-if="Number(item?.originalPrice) > Number(item?.discountPrice)" v-if="Number(item?.originalPrice) > Number(item?.discountPrice)"
class="featured-dish-original" class="featured-dish-original"
>US${{ item?.originalPrice }}</text> >US${{ item?.originalPrice }}</text> -->
</view> </view>
<text class="featured-dish-sales shrink-0">{{ t('pages-store.store.sales') }}: {{ formatSalesCount(item?.salesCount) }}</text> <text class="featured-dish-sales shrink-0">{{ t('pages-store.store.sales') }}: {{ formatSalesCount(item?.salesCount) }}</text>
</view> </view>
@@ -194,7 +194,7 @@ const poster = computed(() => ({
type: 'view', type: 'view',
}, },
{ {
text: 'http://192.168.5.118:8091/#/'+ `pages-login/pages/sign-up/index?invitationCode=${userStore.userInfo.invitationCode}`, text: 'http://www.howhowfresh.com/h5/'+ `pages-login/pages/sign-up/index?invitationCode=${userStore.userInfo.invitationCode}`,
type: 'qrcode', type: 'qrcode',
css: { css: {
width: '124rpx', width: '124rpx',
@@ -83,7 +83,7 @@ defineExpose({
</view> </view>
<view class="shrink-0 ml-20rpx" v-if="userStore.userInfo.invitationCode"> <view class="shrink-0 ml-20rpx" v-if="userStore.userInfo.invitationCode">
<uqrcode ref="uqrcode" canvas-id="qrcode" <uqrcode ref="uqrcode" canvas-id="qrcode"
:value="'http://192.168.5.118:8091/#/' + `pages-login/pages/sign-up/index?invitationCode=${userStore.userInfo.invitationCode}`" :value="'http://www.howhowfresh.com/h5/' + `pages-login/pages/sign-up/index?invitationCode=${userStore.userInfo.invitationCode}`"
:size="124" :size="124"
sizeUnit="rpx" sizeUnit="rpx"
:options="{}"></uqrcode> :options="{}"></uqrcode>