用户端修改:付款按钮,显示单价,订单的图片

This commit is contained in:
2026-07-22 13:02:52 +08:00
parent 5e33dd9847
commit b0f565103f
2 changed files with 104 additions and 28 deletions
+51 -10
View File
@@ -1,9 +1,10 @@
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { View, Text } from '@tarojs/components'; import { View, Text, Image } from '@tarojs/components';
import Taro, { usePullDownRefresh, useRouter } from '@tarojs/taro'; import Taro, { usePullDownRefresh, useRouter } from '@tarojs/taro';
import PageShell from '../../components/PageShell'; import PageShell from '../../components/PageShell';
import SubPageHeader from '../../components/SubPageHeader'; import SubPageHeader from '../../components/SubPageHeader';
import { request, toast } from '../../lib/api'; import { request, toast } from '../../lib/api';
import { buildPayUrl } from '../../lib/checkout-nav';
const TABS = [ const TABS = [
{ key: 'all', label: '全部订单' }, { key: 'all', label: '全部订单' },
@@ -30,6 +31,13 @@ function orderStatusLabel(tab: string, status?: string): string {
return STATUS_LABELS[status] || status; return STATUS_LABELS[status] || status;
} }
type OrderItem = {
productName?: string;
productImage?: string;
unitPrice?: number;
quantity?: number;
};
type OrderRow = { type OrderRow = {
id: string; id: string;
orderNo?: string; orderNo?: string;
@@ -37,7 +45,9 @@ type OrderRow = {
payAmount?: number; payAmount?: number;
productName?: string; productName?: string;
qty?: number; qty?: number;
createdAt?: string; quantity?: number;
originOrderId?: string | null;
items?: OrderItem[];
}; };
export default function OrdersPage() { export default function OrdersPage() {
@@ -71,6 +81,10 @@ export default function OrdersPage() {
void loadOrders().finally(() => Taro.stopPullDownRefresh()); void loadOrders().finally(() => Taro.stopPullDownRefresh());
}); });
function goPay(orderId: string) {
Taro.navigateTo({ url: buildPayUrl({ orderId }) });
}
return ( return (
<PageShell variant="sub" className="orders-page"> <PageShell variant="sub" className="orders-page">
<SubPageHeader title="我的订单" /> <SubPageHeader title="我的订单" />
@@ -89,7 +103,15 @@ export default function OrdersPage() {
{loading ? <View className="u-empty"></View> : null} {loading ? <View className="u-empty"></View> : null}
{!loading && orders.length === 0 ? <View className="u-empty"></View> : null} {!loading && orders.length === 0 ? <View className="u-empty"></View> : null}
{!loading && {!loading &&
orders.map((o) => ( orders.map((o) => {
const item = o.items?.[0];
const productName = item?.productName || o.productName || '杜康商品';
const productImage = (item?.productImage || '').trim();
const qty = item?.quantity ?? o.quantity ?? o.qty ?? 1;
const unitPrice = Number(item?.unitPrice ?? 0);
const canPay = o.status === 'PENDING_PAY' && !o.originOrderId;
return (
<View <View
key={o.id} key={o.id}
className="order-list-item" className="order-list-item"
@@ -102,22 +124,41 @@ export default function OrdersPage() {
</Text> </Text>
</View> </View>
<View className="order-list-body"> <View className="order-list-body">
<View className="order-list-thumb" /> <View className="order-list-thumb">
<View style={{ flex: 1 }}> {productImage ? (
<Text className="order-list-name">{o.productName || '杜康商品'}</Text> <Image className="order-list-thumb-img" src={productImage} mode="aspectFill" />
<Text className="order-list-meta"> ) : null}
{o.qty ?? 1} · {o.createdAt ? String(o.createdAt).slice(0, 10) : ''} </View>
</Text> <View style={{ flex: 1, minWidth: 0 }}>
<Text className="order-list-name">{productName}</Text>
<View className="order-list-meta-row">
<Text className="order-list-meta"> {qty}</Text>
<Text className="order-list-meta"> ¥{unitPrice.toFixed(2)}</Text>
</View>
</View> </View>
</View> </View>
<View className="order-list-footer"> <View className="order-list-footer">
<View className="order-list-pay-amount">
<Text className="order-list-meta"></Text> <Text className="order-list-meta"></Text>
<Text className="order-product-price"> <Text className="order-product-price">
¥{Number(o.payAmount ?? 0).toFixed(2)} ¥{Number(o.payAmount ?? 0).toFixed(2)}
</Text> </Text>
</View> </View>
{canPay ? (
<View
className="order-list-pay-btn"
onClick={(e) => {
e.stopPropagation();
goPay(o.id);
}}
>
</View> </View>
))} ) : null}
</View>
</View>
);
})}
</PageShell> </PageShell>
); );
} }
+35
View File
@@ -314,6 +314,13 @@
background: var(--color-surface-container); background: var(--color-surface-container);
margin-right: 12px; margin-right: 12px;
flex-shrink: 0; flex-shrink: 0;
overflow: hidden;
}
.order-list-thumb-img {
width: 100%;
height: 100%;
display: block;
} }
.order-list-name { .order-list-name {
@@ -323,6 +330,12 @@
margin-bottom: 4px; margin-bottom: 4px;
} }
.order-list-meta-row {
display: flex;
align-items: center;
gap: 12px;
}
.order-list-meta { .order-list-meta {
display: block; display: block;
font-size: 12px; font-size: 12px;
@@ -336,6 +349,28 @@
margin-top: 12px; margin-top: 12px;
padding-top: 12px; padding-top: 12px;
border-top: 1px solid var(--color-surface-container); border-top: 1px solid var(--color-surface-container);
gap: 12px;
}
.order-list-pay-amount {
display: flex;
align-items: baseline;
gap: 6px;
min-width: 0;
}
.order-list-pay-btn {
flex-shrink: 0;
height: 32px;
padding: 0 16px;
border-radius: 999px;
background: var(--color-heritage-red);
color: #fff;
font-size: 13px;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
} }
.pay-status { .pay-status {