「账单」包含在 Pro 里,开通会员后显示预览。
用法
import { ShopInvoice } from './ShopInvoice.jsx'
// Without onPay or onDownload, both finish after a short wait.
<ShopInvoice
locale="en"
currency="USD"
invoice={invoice} // { number, order, status: 'paid' | 'due' | 'overdue', issued, due, taxRate, delivery, card, link, note, from: { name, tagline, lines, logo: '/logo.svg' }, to }
items={lines} // [{ id, name, variant, price, qty }]
loading={!invoice}
error={loadError}
onRetry={reload}
onPay={async (amount) => (await api.payInvoice(invoice.number)).ok}
onDownload={() => api.downloadPdf(invoice.number)}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例账单的语言。 |
invoice | { number, order, status, lateDays?, issued, due, taxRate, delivery, card, link, note, from: { name, tagline, lines, logo?: string | ReactNode }, to: { name, lines } } | sample invoice | 账单信息。税费按 taxRate(0.08 表示 8%)对商品和运费计算。`from.logo` 是店铺标志,可传图片地址或你自己的元素;不传时显示 `from.name` 的首字母。 |
items | Array<{ id, name, variant, price, qty }> | sample lines | 账单明细。 |
status | 'paid' | 'due' | 'overdue' | invoice.status | 初始显示的状态;支付成功后变为已付款。 |
link / currency | string / string | invoice.link / by locale | 复制按钮复制的链接;ISO 货币代码。 |
loading / error | boolean / boolean | string | false | 显示骨架,或带重试按钮的错误提示(传字符串可替换说明)。 |
onPay / onDownload / onRetry | (total) => Promise<boolean | void> / () => Promise<boolean | void> / () => void | — | 支付账单(返回 false 显示支付失败);下载 PDF;出错后重新加载。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素 section 上。 |
装进你的项目
Pro 包含这个区块的完整源码。复制指令,让你的 Agent 把它安装到项目中。
ShopInvoice.jsxshop-invoice.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/rolling-number/ui/status-tag/ui/alert-banner/ui/success-check/ui/skeleton-shimmer/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。
