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} - - )} - - {/* ========== 购物车悬浮球 ========== */} diff --git a/src/services/bill.ts b/src/services/bill.ts index 1066129..861c00b 100644 --- a/src/services/bill.ts +++ b/src/services/bill.ts @@ -44,6 +44,8 @@ export interface Bill { settlement_date: string /** 付款时间(已支付时非空) */ paid_at: string | null + /** 售后金额 */ + after_sale: string /** 付款备注 */ pay_remark: string /** 账单备注 */ diff --git a/src/types/cart.ts b/src/types/cart.ts index 0fca8ac..e7e1d8f 100644 --- a/src/types/cart.ts +++ b/src/types/cart.ts @@ -15,6 +15,7 @@ export interface CartItem { amount: string | null /** 1 可购 / 0 商品下架、缺失或未设等级价 */ status: number + price_unit: string } /** 购物车列表数据 */ diff --git a/src/types/order.ts b/src/types/order.ts index 3edf0da..f5b1879 100644 --- a/src/types/order.ts +++ b/src/types/order.ts @@ -85,6 +85,7 @@ export interface OrderItem { product_name: string product_spec: string unit: string + price_unit: string /** 下单时门店等级实际价快照 */ price: string quantity: number diff --git a/src/types/product.ts b/src/types/product.ts index 37d4d5a..898d969 100644 --- a/src/types/product.ts +++ b/src/types/product.ts @@ -27,6 +27,7 @@ export interface Product { content: string /** 当前门店等级的实际销售价(未登录/未绑店/未设等级为 null) */ price: string | null + price_unit: string | null images_arr: ProductImage[] /** 所属分类(详情接口 with 返回) */ category?: { id: number; name: string } | null diff --git a/src/utils/request.ts b/src/utils/request.ts index df6beb4..1093a8a 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -10,8 +10,8 @@ const LOGIN_PATH = '/pages/login/index' /** 默认请求超时(ms) */ const DEFAULT_TIMEOUT = 15000 /** 接口根地址(uploadFile 等原生请求同样使用) */ -// export const BASE_URL = "http://localhost:8000/index.php" -export const BASE_URL = "https://purchase.henanklkj.com/index.php" +export const BASE_URL = "http://localhost:8000/index.php" +// export const BASE_URL = "https://purchase.henanklkj.com/index.php" /** * HTTP 状态码 → 错误提示映射