From 130ef2c9496c1e17b31297072eec78e60ef6cd1e Mon Sep 17 00:00:00 2001
From: liu <2302563948@qq.com>
Date: Sat, 29 Aug 2026 13:52:57 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=91=E9=A2=9D=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/CartBall/index.less | 2 +-
src/components/PriceText/index.tsx | 8 ++-
src/pages/bill-detail/index.less | 6 --
src/pages/bill-detail/index.tsx | 49 ++++++++-------
src/pages/cart/index.less | 10 ++++
src/pages/cart/index.tsx | 20 +++----
src/pages/index/index.less | 3 +-
src/pages/index/index.tsx | 13 ++--
src/pages/order-list/index.tsx | 6 +-
src/pages/payment/index.tsx | 19 +-----
src/pages/product-detail/index.tsx | 12 ++--
src/pages/product/index.tsx | 95 +++++-------------------------
src/services/bill.ts | 2 +
src/types/cart.ts | 1 +
src/types/order.ts | 1 +
src/types/product.ts | 1 +
src/utils/request.ts | 4 +-
17 files changed, 93 insertions(+), 159 deletions(-)
diff --git a/src/components/CartBall/index.less b/src/components/CartBall/index.less
index 3f1cdb6..2c51e73 100644
--- a/src/components/CartBall/index.less
+++ b/src/components/CartBall/index.less
@@ -1,7 +1,7 @@
// 购物车悬浮球:右下角,底部避让自定义 tabBar(110rpx + 安全区)
.cart-ball {
position: fixed;
- right: 24rpx;
+ left: 24rpx;
bottom: calc(150rpx + env(safe-area-inset-bottom));
z-index: 998;
display: flex;
diff --git a/src/components/PriceText/index.tsx b/src/components/PriceText/index.tsx
index 99a5559..0b2f6ed 100644
--- a/src/components/PriceText/index.tsx
+++ b/src/components/PriceText/index.tsx
@@ -15,13 +15,15 @@ interface PriceTextProps {
* - block 独占一行(窄卡片:首页推荐、商品列表、购物车)
*/
mode?: 'inline' | 'block'
+ /** 单位 */
+ price_unit?: string | null
}
/**
* 商品价格:售价 + 零售价标注(小字)
* price=30、spec=15 → ¥30 零售价:¥2
*/
-export default function PriceText({ price, spec, className, mode = 'inline' }: PriceTextProps) {
+export default function PriceText({ price, spec, className, mode = 'inline', price_unit }: PriceTextProps) {
const retail = formatRetailPrice(price, spec)
// 窄卡片:大价格 / 零售价上下两行,避免与右侧按钮(+/步进器)挤压换行
@@ -30,7 +32,7 @@ export default function PriceText({ price, spec, className, mode = 'inline' }: P
¥{price}
{retail !== null && (
- 单价:¥{retail}
+ 单价:¥{retail} {price_unit}
)}
)
@@ -40,7 +42,7 @@ export default function PriceText({ price, spec, className, mode = 'inline' }: P
¥{price}
{retail !== null && (
- 单价:¥{retail}
+ 单价:¥{retail} {price_unit}
)}
)
diff --git a/src/pages/bill-detail/index.less b/src/pages/bill-detail/index.less
index 04c67e8..15fbfbd 100644
--- a/src/pages/bill-detail/index.less
+++ b/src/pages/bill-detail/index.less
@@ -147,12 +147,6 @@
flex-shrink: 0;
}
- &__qty {
- font-size: 24rpx;
- color: #969799;
- display: block;
- }
-
&__amount {
font-size: 28rpx;
color: #323233;
diff --git a/src/pages/bill-detail/index.tsx b/src/pages/bill-detail/index.tsx
index 2930d8c..ab8dc7a 100644
--- a/src/pages/bill-detail/index.tsx
+++ b/src/pages/bill-detail/index.tsx
@@ -5,8 +5,7 @@ import { Empty, Popup } from '@antmjs/vantui'
import { getBillDetailApi } from '@/services/bill'
import { getOrderDetailApi } from '@/services/order'
import { ORDER_STATUS_TEXT } from '@/types/order'
-import { formatSpec, resolveFileUrl } from '@/utils/format'
-import PriceText from '@/components/PriceText'
+import {formatRetailPrice, formatSpec, resolveFileUrl} from '@/utils/format'
import type { OrderDetail } from '@/types/order'
import type { BillDetail } from '@/services/bill'
import './index.less'
@@ -60,18 +59,9 @@ export default function BillDetailPage() {
const { bill, items, orders } = detail
- /** 附加金额:正=压筐附加,负=回筐抵扣(0 不带头符号) */
- const addedNum = Number(bill.added_amount)
- const addedLabel = addedNum < 0 ? '回筐抵扣' : '压筐附加'
- const addedText =
- addedNum < 0
- ? `-¥${Math.abs(addedNum).toFixed(2)}`
- : addedNum > 0
- ? `+¥${addedNum.toFixed(2)}`
- : '¥0.00'
/** 筐/托盘明细:正压负回,数量取绝对值(单价为出账时快照) */
- const boxPart = `${bill.box_num < 0 ? '回筐' : '压筐'} ${Math.abs(bill.box_num)}×¥${bill.box_price}`
- const trayPart = `${bill.tray_num < 0 ? '回托盘' : '压托盘'} ${Math.abs(bill.tray_num)}×¥${bill.tray_price}`
+ const boxTotalPrice = (Number(bill.box_price) * bill.box_num).toFixed(2)
+ const trayTotalPrice = (Number(bill.tray_price) * bill.tray_num).toFixed(2)
return (
@@ -124,7 +114,7 @@ export default function BillDetailPage() {
{/* ===== 金额构成 ===== */}
- 金额构成
+ 金额明细
商品金额
¥{bill.product_amount}
@@ -134,9 +124,21 @@ export default function BillDetailPage() {
¥{bill.delivery_fee}
- {addedLabel}({boxPart},{trayPart})
-
- {addedText}
+ 周转筐({bill.box_price} × {bill.box_num})
+
+ {Number(boxTotalPrice) < 0 ? `- ¥${boxTotalPrice}` : `¥${boxTotalPrice}`}
+
+
+
+ 周转托盘({bill.tray_price} × {bill.tray_num})
+
+ {Number(trayTotalPrice) < 0 ? `- ¥${trayTotalPrice}` : `¥${trayTotalPrice}`}
+
+
+
+ 售后
+
+ {Number(bill.after_sale) < 0 ? `- ¥${bill.after_sale}` : `¥${bill.after_sale}`}
@@ -148,7 +150,6 @@ export default function BillDetailPage() {
{/* ===== 商品明细(跨订单按商品合并) ===== */}
商品明细({items?.length ?? 0})
- 同一商品跨订单合并,单价为加权平均价
{(items ?? []).map(item => (
{!!item.image && (
@@ -162,13 +163,11 @@ export default function BillDetailPage() {
{item.product_name}
- {formatSpec(item.product_spec, item.unit)}{' '}
-
+ {formatSpec(item.product_spec, item.unit)}{' ¥'}{item.price}
- ×{item.quantity}
- ¥{item.amount}
+ ¥{item.price} × {item.quantity}
))}
@@ -216,11 +215,11 @@ export default function BillDetailPage() {
{item.product_name}
- {formatSpec(item.product_spec, item.unit)}{' '}
- × {item.quantity}
+ {formatSpec(item.product_spec, item.unit)}{' '}
+ 单价:{formatRetailPrice(item.price, item.product_spec)} {item.price_unit}
- ¥{item.amount}
+ ¥{item.price} × {item.quantity}
))}
diff --git a/src/pages/cart/index.less b/src/pages/cart/index.less
index bde7197..99d9679 100644
--- a/src/pages/cart/index.less
+++ b/src/pages/cart/index.less
@@ -88,6 +88,15 @@
white-space: nowrap;
}
+ &__spec-tag {
+ margin-left: 12rpx;
+ font-size: 24rpx;
+ color: #969799;
+ border-radius: 6rpx;
+ padding: 2rpx 8rpx;
+ flex-shrink: 0;
+ }
+
&__invalid-tag {
margin-left: 12rpx;
font-size: 20rpx;
@@ -167,6 +176,7 @@
padding: 16rpx 24rpx;
border-top: 1rpx solid #ebedf0;
box-sizing: border-box;
+ z-index: 99;
&__total {
flex: 1;
diff --git a/src/pages/cart/index.tsx b/src/pages/cart/index.tsx
index 32ee4d0..712846f 100644
--- a/src/pages/cart/index.tsx
+++ b/src/pages/cart/index.tsx
@@ -6,8 +6,7 @@ import useAuthStore from '@/stores/auth/useAuthStore'
import useCartStore from '@/stores/cart/useCartStore'
import { createOrderApi } from '@/services/order'
import { getStoreInfoApi } from '@/services/store'
-import PriceText from '@/components/PriceText'
-import { formatSpec } from '@/utils/format'
+import {formatRetailPrice, formatSpec} from '@/utils/format'
import type { CartItem } from '@/types/cart'
import type { StoreDetail } from '@/types/store'
import './index.less'
@@ -159,7 +158,7 @@ export default function CartPage() {
if (submitting) return
setSubmitting(true)
try {
- const res = await createOrderApi({
+ await createOrderApi({
items: purchasable.map(item => ({
product_id: item.product_id,
quantity: Number(qtyMap[item.id] ?? item.quantity),
@@ -221,13 +220,12 @@ export default function CartPage() {
{item.name}
{item.status === 0 && 已失效}
- {formatSpec(item.spec, item.unit)}
+
+ {formatSpec(item.spec, item.unit)}{' '}
+ 单价:{formatRetailPrice(item.price, item.spec)} {item.price_unit}
+
- {item.price !== null ? (
-
- ) : (
- 价格待定
- )}
+ ¥{item.price}
{item.status === 1 ? (
+
{loggedIn && hasInvalid && (
部分商品已下架或未设置您所在等级的价格,不可下单
@@ -262,7 +262,7 @@ export default function CartPage() {
{loggedIn && items.length > 0 && (
- 合计(可购{totalQuantity}件)
+ 合计{totalQuantity}件
¥{totalAmount}