Compare commits
67 Commits
847a3f0dc3
...
v3.4.10
| Author | SHA1 | Date | |
|---|---|---|---|
| fa0d928980 | |||
| c8ea5a3119 | |||
| 6f427cb553 | |||
| 89fd333702 | |||
| ab10431001 | |||
| e93e4b8f84 | |||
| d90847bad0 | |||
| ffa753707b | |||
| ac2f9f4793 | |||
| 3ba7b179e8 | |||
| 4e7079c221 | |||
| 3c19b7dd97 | |||
| a7d55b7293 | |||
| 7e3dc131ad | |||
| f09e00e16f | |||
| ff462bca9a | |||
| aa0e140fec | |||
| dc30932012 | |||
| f8d8e2d6d5 | |||
| 54fca99208 | |||
| 9859abba7e | |||
| 26472f8678 | |||
| c89560e4f8 | |||
| f3353bbce5 | |||
| 666bcb8633 | |||
| ffed560d43 | |||
| a7a0a54688 | |||
| 5199b495e0 | |||
| 04fd4d50d0 | |||
| 82b98aa4e3 | |||
| 2088a1ee19 | |||
| 7dffd40f3f | |||
| 021b9e0329 | |||
| 0304201e80 | |||
| fd05621660 | |||
| dd4362c397 | |||
| 2ebdb08a2f | |||
| 87515decb3 | |||
| 4a5b9eaffa | |||
| e06d9f4711 | |||
| 28ef916a22 | |||
| fa3484041e | |||
| 06cbcdeb9c | |||
| ebd8c07147 | |||
| 39e38aac7e | |||
| 87c4af7364 | |||
| 9f67221457 | |||
| 23587418c1 | |||
| daf534b4db | |||
| 0621ac18fb | |||
| 442f1ea842 | |||
| 8e25e23e81 | |||
| 118993a01f | |||
| a017a27b60 | |||
| 8f361981bf | |||
| 4bb6ae20cd | |||
| ad757e9ba8 | |||
| e63b57db19 | |||
| fb4432b307 | |||
| ab44515e8b | |||
| 78365d648c | |||
| e9eddbb26e | |||
| c00ca3620d | |||
| 4d76ee6d0e | |||
| 2dbe665bdc | |||
| 1bc3bec977 | |||
| 81a6e3674b |
@@ -30,4 +30,4 @@ chore(shared-types): add OrderStatus enum
|
|||||||
|
|
||||||
- **仅用户明确要求时** 才执行 git commit / push
|
- **仅用户明确要求时** 才执行 git commit / push
|
||||||
- 不 amend 已推送的 commit,不 force push main/master/dev
|
- 不 amend 已推送的 commit,不 force push main/master/dev
|
||||||
- 发版:`dev`→测试(staging),`main`→生产;用户只说「发布」默认发测试(见 dukang-release skill)
|
- 发版:`dev`→测试(staging),`main`→生产;用户只说「发布/发版」默认发**生产**(见 dukang-release skill);明确说「发测试」才发 staging
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ description: >-
|
|||||||
| `dev` | **staging 测试** | `/opt/dukang-staging` | 8190–8194 | `*-test.dukanghaoke.com` |
|
| `dev` | **staging 测试** | `/opt/dukang-staging` | 8190–8194 | `*-test.dukanghaoke.com` |
|
||||||
| `main` | **production 生产** | `/opt/dukang` | 8090–8094 | `*.dukanghaoke.com` |
|
| `main` | **production 生产** | `/opt/dukang` | 8090–8094 | `*.dukanghaoke.com` |
|
||||||
|
|
||||||
默认:`dev_jacy` → merge → `dev` → **发测试**。
|
默认:`dev_jacy` → merge → `dev` → merge → `main` → **发生产**。勿 force push `main`/`dev`。
|
||||||
生产:`dev` 验收通过 → merge → `main` → **发生产**。勿 force push `main`/`dev`。
|
|
||||||
|
|
||||||
用户只说「发布」且未指明生产时 → **发测试(staging)**。
|
> **团队约定(2026-08)**:用户说「发布 / 发版 / 直接发版」且**未特别强调**时 → **发生产(production)**。
|
||||||
用户说「发生产 / 上线生产」→ 用 `deploy-prod.sh`。
|
> 仅当用户明确说「发测试 / staging / 测试环境」时 → 发 staging。
|
||||||
|
|
||||||
|
用户说「发生产 / 上线生产 / 发版」→ 用 `deploy-prod.sh`。
|
||||||
|
用户说「发测试」→ 用 `deploy-staging.sh`。
|
||||||
|
|
||||||
## 标准流程(Windows)
|
## 标准流程(Windows)
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
| REQ-U-024 | 推广码 | 扫码归因;现场提货有码归码 |
|
| REQ-U-024 | 推广码 | 扫码归因;现场提货有码归码 |
|
||||||
| REQ-U-025 | 分享 | 微信商品分享+渠道参数 |
|
| REQ-U-025 | 分享 | 微信商品分享+渠道参数 |
|
||||||
| REQ-U-026 | 门店规则 | 附件一完整展示 |
|
| REQ-U-026 | 门店规则 | 附件一完整展示 |
|
||||||
|
| REQ-U-027 | 门店套餐 **3.4.10** | 门店详情展示生效套餐;套餐异议申诉入口 |
|
||||||
|
|
||||||
## 门店端 REQ-S
|
## 门店端 REQ-S
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
| REQ-S-018 | 权限 | §4.6 矩阵 |
|
| REQ-S-018 | 权限 | §4.6 矩阵 |
|
||||||
| REQ-S-019 | 多店选店 | 记住上次所选 |
|
| REQ-S-019 | 多店选店 | 记住上次所选 |
|
||||||
| REQ-S-020 | 待处理核销 | Wave 3 弱网单 |
|
| REQ-S-020 | 待处理核销 | Wave 3 弱网单 |
|
||||||
|
| REQ-S-021 | 门店套餐 **3.4.10** | 套餐列表/编辑/提审 |
|
||||||
|
|
||||||
## 合伙人端 REQ-P
|
## 合伙人端 REQ-P
|
||||||
|
|
||||||
@@ -89,6 +91,7 @@
|
|||||||
| REQ-P-024 | 负责人复核 | 待复核→待总部审 |
|
| REQ-P-024 | 负责人复核 | 待复核→待总部审 |
|
||||||
| REQ-P-025 | 合同同日 | 同日提交校验 |
|
| REQ-P-025 | 合同同日 | 同日提交校验 |
|
||||||
| REQ-P-026 | 我的仓库 | Wave 3 管仓只读 |
|
| REQ-P-026 | 我的仓库 | Wave 3 管仓只读 |
|
||||||
|
| REQ-P-027 | 门店套餐 **3.4.10** | 拓店套餐页;门店套餐列表/编辑/提审 |
|
||||||
|
|
||||||
## 总部端 REQ-H
|
## 总部端 REQ-H
|
||||||
|
|
||||||
@@ -122,3 +125,4 @@
|
|||||||
| REQ-H-022 | 签约主体 | 山西领势酒业 |
|
| REQ-H-022 | 签约主体 | 山西领势酒业 |
|
||||||
| REQ-H-023 | 热力图 | 腾讯位置服务 |
|
| REQ-H-023 | 热力图 | 腾讯位置服务 |
|
||||||
| REQ-H-024 | 结算异议 | 门店 3 日异议处理 |
|
| REQ-H-024 | 结算异议 | 门店 3 日异议处理 |
|
||||||
|
| REQ-H-025 | 门店套餐 **3.4.10** | 门店详情套餐 Tab 直存;套餐变更审核通过/驳回 |
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ node scripts/smoke-prev1.mjs
|
|||||||
pnpm lint && pnpm test
|
pnpm lint && pnpm test
|
||||||
```
|
```
|
||||||
|
|
||||||
Mock 验证码:`123456`。测试账号见 [`README.md`](./README.md)。
|
Mock 验证码:`999888`。测试账号见 [`README.md`](./README.md)。
|
||||||
|
|
||||||
> **端口冲突**:`h5-partner` 与 `admin-web` 同为 5175,勿同时 `dev:partner` + `dev:admin`。
|
> **端口冲突**:`h5-partner` 与 `admin-web` 同为 5175,勿同时 `dev:partner` + `dev:admin`。
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import LoginPage from './pages/LoginPage';
|
|||||||
import DashboardPage from './pages/DashboardPage';
|
import DashboardPage from './pages/DashboardPage';
|
||||||
import UsersPage from './pages/UsersPage';
|
import UsersPage from './pages/UsersPage';
|
||||||
import OrdersPage from './pages/OrdersPage';
|
import OrdersPage from './pages/OrdersPage';
|
||||||
|
import StorePackageAuditsPage from './pages/StorePackageAuditsPage';
|
||||||
import StoresPage from './pages/StoresPage';
|
import StoresPage from './pages/StoresPage';
|
||||||
|
import StoreRatingsPage from './pages/StoreRatingsPage';
|
||||||
import StoreAccountsPage from './pages/StoreAccountsPage';
|
import StoreAccountsPage from './pages/StoreAccountsPage';
|
||||||
import BenefitCouponsPage from './pages/BenefitCouponsPage';
|
import BenefitCouponsPage from './pages/BenefitCouponsPage';
|
||||||
import BenefitLedgersPage from './pages/BenefitLedgersPage';
|
import BenefitLedgersPage from './pages/BenefitLedgersPage';
|
||||||
@@ -36,6 +38,7 @@ import TicketsPage from './pages/TicketsPage';
|
|||||||
import SupportTicketsPage from './pages/SupportTicketsPage';
|
import SupportTicketsPage from './pages/SupportTicketsPage';
|
||||||
import InvoicesPage from './pages/InvoicesPage';
|
import InvoicesPage from './pages/InvoicesPage';
|
||||||
import UserLogsPage from './pages/UserLogsPage';
|
import UserLogsPage from './pages/UserLogsPage';
|
||||||
|
import DomainEventsPage from './pages/DomainEventsPage';
|
||||||
import HqLogsPage from './pages/HqLogsPage';
|
import HqLogsPage from './pages/HqLogsPage';
|
||||||
import ThirdPartyLogsPage from './pages/ThirdPartyLogsPage';
|
import ThirdPartyLogsPage from './pages/ThirdPartyLogsPage';
|
||||||
import StoreLogsPage from './pages/StoreLogsPage';
|
import StoreLogsPage from './pages/StoreLogsPage';
|
||||||
@@ -78,6 +81,8 @@ export default function App() {
|
|||||||
<Route path="/products" element={<ProductsPage />} />
|
<Route path="/products" element={<ProductsPage />} />
|
||||||
<Route path="/product-detail-templates" element={<ProductDetailTemplatesPage />} />
|
<Route path="/product-detail-templates" element={<ProductDetailTemplatesPage />} />
|
||||||
<Route path="/stores" element={<StoresPage />} />
|
<Route path="/stores" element={<StoresPage />} />
|
||||||
|
<Route path="/store-package-audits" element={<StorePackageAuditsPage />} />
|
||||||
|
<Route path="/store-ratings" element={<StoreRatingsPage />} />
|
||||||
<Route path="/store-categories" element={<StoreCategoriesPage />} />
|
<Route path="/store-categories" element={<StoreCategoriesPage />} />
|
||||||
<Route path="/store-accounts" element={<StoreAccountsPage />} />
|
<Route path="/store-accounts" element={<StoreAccountsPage />} />
|
||||||
<Route path="/store-media" element={<StoreMediaPage />} />
|
<Route path="/store-media" element={<StoreMediaPage />} />
|
||||||
@@ -94,11 +99,19 @@ export default function App() {
|
|||||||
<Route path="/redeem-pending" element={<PendingRedeemPage />} />
|
<Route path="/redeem-pending" element={<PendingRedeemPage />} />
|
||||||
<Route path="/redeem/debug" element={<RedeemDebugPage />} />
|
<Route path="/redeem/debug" element={<RedeemDebugPage />} />
|
||||||
<Route path="/finance/store-bills" element={<StoreBillsPage />} />
|
<Route path="/finance/store-bills" element={<StoreBillsPage />} />
|
||||||
|
<Route
|
||||||
|
path="/finance/store-withdrawals"
|
||||||
|
element={<Navigate to="/finance/store-bills?kind=WITHDRAW" replace />}
|
||||||
|
/>
|
||||||
<Route path="/finance/partner-bills" element={<PartnerBillsPage />} />
|
<Route path="/finance/partner-bills" element={<PartnerBillsPage />} />
|
||||||
<Route path="/finance/winery-bills" element={<WineryBillsPage />} />
|
<Route path="/finance/winery-bills" element={<WineryBillsPage />} />
|
||||||
<Route path="/finance/logistics-bills" element={<LogisticsBillsPage />} />
|
<Route path="/finance/logistics-bills" element={<LogisticsBillsPage />} />
|
||||||
<Route path="/store-bills" element={<Navigate to="/finance/store-bills" replace />} />
|
<Route path="/store-bills" element={<Navigate to="/finance/store-bills" replace />} />
|
||||||
<Route path="/store-payouts" element={<Navigate to="/finance/store-bills" replace />} />
|
<Route path="/store-payouts" element={<Navigate to="/finance/store-bills" replace />} />
|
||||||
|
<Route
|
||||||
|
path="/store-withdrawals"
|
||||||
|
element={<Navigate to="/finance/store-bills?kind=WITHDRAW" replace />}
|
||||||
|
/>
|
||||||
<Route path="/partner-bills" element={<Navigate to="/finance/partner-bills" replace />} />
|
<Route path="/partner-bills" element={<Navigate to="/finance/partner-bills" replace />} />
|
||||||
<Route path="/tickets" element={<TicketsPage />} />
|
<Route path="/tickets" element={<TicketsPage />} />
|
||||||
<Route path="/tickets/support" element={<SupportTicketsPage />} />
|
<Route path="/tickets/support" element={<SupportTicketsPage />} />
|
||||||
@@ -108,6 +121,7 @@ export default function App() {
|
|||||||
<Route path="/logs/partners" element={<PartnerLogsPage />} />
|
<Route path="/logs/partners" element={<PartnerLogsPage />} />
|
||||||
<Route path="/logs/hq" element={<HqLogsPage />} />
|
<Route path="/logs/hq" element={<HqLogsPage />} />
|
||||||
<Route path="/logs/third-party" element={<ThirdPartyLogsPage />} />
|
<Route path="/logs/third-party" element={<ThirdPartyLogsPage />} />
|
||||||
|
<Route path="/logs/domain-events" element={<DomainEventsPage />} />
|
||||||
<Route path="/deliveries" element={<DeliveriesPage />} />
|
<Route path="/deliveries" element={<DeliveriesPage />} />
|
||||||
<Route path="/deliveries/xiaofeixia" element={<XiaofeixiaTestPage />} />
|
<Route path="/deliveries/xiaofeixia" element={<XiaofeixiaTestPage />} />
|
||||||
<Route path="/hq-permissions" element={<HqPermissionsPage />} />
|
<Route path="/hq-permissions" element={<HqPermissionsPage />} />
|
||||||
|
|||||||
@@ -0,0 +1,217 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Alert, Button, Form, Input, InputNumber, Space, Typography, message } from 'antd';
|
||||||
|
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
||||||
|
import type { StorePackageItemDto } from '@dukang/shared-types';
|
||||||
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
|
||||||
|
type PackageRow = StorePackageItemDto;
|
||||||
|
|
||||||
|
function emptyRow(index = 0): PackageRow {
|
||||||
|
return { name: '', price: '0', dishes: '', usableTime: '', otherNotes: '', sortOrder: index };
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AdminStorePackagesSection({ storeId }: { storeId: string }) {
|
||||||
|
const [items, setItems] = useState<PackageRow[]>([emptyRow()]);
|
||||||
|
const [collapsed, setCollapsed] = useState<Record<number, boolean>>({});
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoading(true);
|
||||||
|
request<{ live: PackageRow[] }>(`/admin/stores/${storeId}/packages`)
|
||||||
|
.then((data) => {
|
||||||
|
setItems(
|
||||||
|
data.live?.length
|
||||||
|
? data.live.map((p, i) => ({ ...p, price: String(p.price), sortOrder: i }))
|
||||||
|
: [emptyRow()],
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((e) => message.error(e instanceof Error ? e.message : '加载套餐失败'))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [storeId]);
|
||||||
|
|
||||||
|
function updateAt(index: number, patch: Partial<PackageRow>) {
|
||||||
|
setItems((prev) => prev.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addRow() {
|
||||||
|
if (items.length >= STORE_PACKAGE_MAX_COUNT) return;
|
||||||
|
setItems((prev) => [...prev, emptyRow(prev.length)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAt(index: number) {
|
||||||
|
setItems((prev) => prev.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })));
|
||||||
|
setCollapsed((prev) => {
|
||||||
|
const next: Record<number, boolean> = {};
|
||||||
|
Object.entries(prev).forEach(([k, v]) => {
|
||||||
|
const i = Number(k);
|
||||||
|
if (i < index) next[i] = v;
|
||||||
|
else if (i > index) next[i - 1] = v;
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCollapse(index: number) {
|
||||||
|
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const filled = items
|
||||||
|
.map((item, index) => ({
|
||||||
|
name: item.name.trim(),
|
||||||
|
price: item.price.trim(),
|
||||||
|
dishes: item.dishes.trim(),
|
||||||
|
usableTime: item.usableTime?.trim() || null,
|
||||||
|
otherNotes: item.otherNotes?.trim() || null,
|
||||||
|
sortOrder: index,
|
||||||
|
}))
|
||||||
|
.filter((item) => item.name || item.dishes || item.price);
|
||||||
|
|
||||||
|
for (let i = 0; i < filled.length; i++) {
|
||||||
|
const item = filled[i];
|
||||||
|
if (!item.name) {
|
||||||
|
message.warning(`第 ${i + 1} 条套餐名称不能为空`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!item.dishes) {
|
||||||
|
message.warning(`第 ${i + 1} 条套餐菜品不能为空`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const price = Number(item.price);
|
||||||
|
if (!Number.isFinite(price) || price < 0) {
|
||||||
|
message.warning(`第 ${i + 1} 条套餐价格须为非负数字`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setSaving(true);
|
||||||
|
try {
|
||||||
|
await request(`/admin/stores/${storeId}/packages`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
packages: filled.map((p) => ({ ...p, price: Number(p.price).toFixed(2) })),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
message.success('套餐已保存并生效');
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '保存失败');
|
||||||
|
} finally {
|
||||||
|
setSaving(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <Typography.Text type="secondary">加载套餐中…</Typography.Text>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form layout="vertical" requiredMark={false}>
|
||||||
|
<Alert
|
||||||
|
type="info"
|
||||||
|
showIcon
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
message={`总部直存立即生效,无需审核。同一门店最多 ${STORE_PACKAGE_MAX_COUNT} 条套餐。`}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{items.map((item, index) => {
|
||||||
|
const isCollapsed = !!collapsed[index];
|
||||||
|
const displayName = item.name.trim() || `套餐 ${index + 1}`;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
style={{
|
||||||
|
marginBottom: 16,
|
||||||
|
padding: 16,
|
||||||
|
border: '1px solid #f0f0f0',
|
||||||
|
borderRadius: 8,
|
||||||
|
background: '#fafafa',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Space style={{ width: '100%', justifyContent: 'space-between', marginBottom: isCollapsed ? 0 : 12 }}>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
icon={isCollapsed ? <DownOutlined /> : <UpOutlined />}
|
||||||
|
onClick={() => toggleCollapse(index)}
|
||||||
|
style={{ paddingLeft: 0, height: 'auto' }}
|
||||||
|
>
|
||||||
|
<Typography.Title level={5} style={{ margin: 0 }}>
|
||||||
|
{displayName}
|
||||||
|
</Typography.Title>
|
||||||
|
</Button>
|
||||||
|
{items.length > 1 ? (
|
||||||
|
<Button type="link" danger onClick={() => removeAt(index)}>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
{!isCollapsed ? (
|
||||||
|
<>
|
||||||
|
<Form.Item label="套餐名称" required style={{ marginBottom: 12 }}>
|
||||||
|
<Input
|
||||||
|
placeholder="如:套餐A"
|
||||||
|
value={item.name}
|
||||||
|
onChange={(e) => updateAt(index, { name: e.target.value })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="价格(元)" required style={{ marginBottom: 12 }}>
|
||||||
|
<InputNumber
|
||||||
|
min={0}
|
||||||
|
precision={2}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
addonAfter="元"
|
||||||
|
placeholder="198"
|
||||||
|
value={item.price === '' ? undefined : Number(item.price)}
|
||||||
|
onChange={(v) => updateAt(index, { price: v != null ? String(v) : '' })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="菜品" required style={{ marginBottom: 12 }}>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={2}
|
||||||
|
placeholder="红烧肉、红烧鱼、油焖茄子"
|
||||||
|
value={item.dishes}
|
||||||
|
onChange={(e) => updateAt(index, { dishes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="使用时间" style={{ marginBottom: 12 }}>
|
||||||
|
<Input
|
||||||
|
placeholder="节假日除外"
|
||||||
|
value={item.usableTime || ''}
|
||||||
|
onChange={(e) => updateAt(index, { usableTime: e.target.value })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label="其他说明" style={{ marginBottom: 0 }}>
|
||||||
|
<Input
|
||||||
|
placeholder="不可叠加"
|
||||||
|
value={item.otherNotes || ''}
|
||||||
|
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
{items.length < STORE_PACKAGE_MAX_COUNT ? (
|
||||||
|
<Button onClick={addRow} style={{ marginBottom: 16 }}>
|
||||||
|
添加套餐
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Typography.Paragraph type="secondary" style={{ marginBottom: 12 }}>
|
||||||
|
修改后点击下方按钮保存,C 端将立即展示生效套餐。
|
||||||
|
</Typography.Paragraph>
|
||||||
|
|
||||||
|
<Button type="primary" loading={saving} onClick={() => void save()}>
|
||||||
|
保存套餐
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -51,6 +51,8 @@ const MENU_ITEMS: MenuProps['items'] = [
|
|||||||
label: '门店',
|
label: '门店',
|
||||||
children: [
|
children: [
|
||||||
{ key: '/stores', label: '门店列表' },
|
{ key: '/stores', label: '门店列表' },
|
||||||
|
{ key: '/store-package-audits', label: '套餐审核' },
|
||||||
|
{ key: '/store-ratings', label: '门店评价' },
|
||||||
{ key: '/store-categories', label: '门店分类' },
|
{ key: '/store-categories', label: '门店分类' },
|
||||||
{ key: '/store-accounts', label: '门店账户' },
|
{ key: '/store-accounts', label: '门店账户' },
|
||||||
{ key: '/store-media', label: '门店资源' },
|
{ key: '/store-media', label: '门店资源' },
|
||||||
@@ -120,6 +122,7 @@ const MENU_ITEMS: MenuProps['items'] = [
|
|||||||
{ key: '/logs/partners', label: '合伙人日志' },
|
{ key: '/logs/partners', label: '合伙人日志' },
|
||||||
{ key: '/logs/hq', label: 'HQ 操作日志' },
|
{ key: '/logs/hq', label: 'HQ 操作日志' },
|
||||||
{ key: '/logs/third-party', label: '第三方日志' },
|
{ key: '/logs/third-party', label: '第三方日志' },
|
||||||
|
{ key: '/logs/domain-events', label: '领域事件' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ key: '/hq-permissions', icon: <LockOutlined />, label: '权限分配' },
|
{ key: '/hq-permissions', icon: <LockOutlined />, label: '权限分配' },
|
||||||
@@ -145,6 +148,8 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
'/knowledge-bases': 'knowledge_bases',
|
'/knowledge-bases': 'knowledge_bases',
|
||||||
'stores-group': 'stores',
|
'stores-group': 'stores',
|
||||||
'/stores': 'stores',
|
'/stores': 'stores',
|
||||||
|
'/store-package-audits': 'stores',
|
||||||
|
'/store-ratings': 'stores',
|
||||||
'/store-categories': 'stores',
|
'/store-categories': 'stores',
|
||||||
'/store-accounts': 'stores',
|
'/store-accounts': 'stores',
|
||||||
'/store-media': 'stores',
|
'/store-media': 'stores',
|
||||||
@@ -155,6 +160,7 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
'/fulfillment-providers': 'partners',
|
'/fulfillment-providers': 'partners',
|
||||||
'finance-group': 'finance',
|
'finance-group': 'finance',
|
||||||
'/finance/store-bills': 'finance',
|
'/finance/store-bills': 'finance',
|
||||||
|
'/finance/store-withdrawals': 'finance',
|
||||||
'/finance/partner-bills': 'finance',
|
'/finance/partner-bills': 'finance',
|
||||||
'/finance/winery-bills': 'finance',
|
'/finance/winery-bills': 'finance',
|
||||||
'/finance/logistics-bills': 'finance',
|
'/finance/logistics-bills': 'finance',
|
||||||
@@ -177,6 +183,7 @@ function menuAllowed(key: string, permissionKeys: string[]): boolean {
|
|||||||
'/logs/partners': 'logs',
|
'/logs/partners': 'logs',
|
||||||
'/logs/hq': 'logs',
|
'/logs/hq': 'logs',
|
||||||
'/logs/third-party': 'logs',
|
'/logs/third-party': 'logs',
|
||||||
|
'/logs/domain-events': 'logs',
|
||||||
'/hq-permissions': 'hq_permissions',
|
'/hq-permissions': 'hq_permissions',
|
||||||
'/system-settings': 'system_settings_any',
|
'/system-settings': 'system_settings_any',
|
||||||
'/hq-accounts': 'hq_accounts',
|
'/hq-accounts': 'hq_accounts',
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ export type DashboardStats = {
|
|||||||
pendingBills?: number;
|
pendingBills?: number;
|
||||||
pendingPartnerDraftBills?: number;
|
pendingPartnerDraftBills?: number;
|
||||||
openTickets?: number;
|
openTickets?: number;
|
||||||
|
pendingStoreWithdrawals?: number;
|
||||||
|
overdueStoreWithdrawals?: number;
|
||||||
ordersByStatus: Array<{ status: string; count: number }>;
|
ordersByStatus: Array<{ status: string; count: number }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ export type StoreCreateForm = {
|
|||||||
bankAccountNo: string;
|
bankAccountNo: string;
|
||||||
bankBranch: string;
|
bankBranch: string;
|
||||||
settlementRate?: number;
|
settlementRate?: number;
|
||||||
|
visibilityWhitelistEnabled?: boolean;
|
||||||
|
visibilityPhones?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const PHONE_RE = /^1\d{10}$/;
|
const PHONE_RE = /^1\d{10}$/;
|
||||||
|
|||||||
@@ -1,45 +1,12 @@
|
|||||||
export type UserLogCategory =
|
export {
|
||||||
| 'login'
|
USER_LOG_CATEGORY_OPTIONS,
|
||||||
| 'browse_product'
|
resolveUserLogCategory,
|
||||||
| 'order'
|
eventNamesForUserLogCategory,
|
||||||
| 'pay'
|
type UserLogCategory,
|
||||||
| 'wechat_auth'
|
} from '@dukang/shared-types';
|
||||||
| 'browse_store'
|
|
||||||
| 'redeem'
|
|
||||||
| 'profile';
|
|
||||||
|
|
||||||
const USER_LOG_EVENT_CATEGORIES: Record<UserLogCategory, readonly string[]> = {
|
import { USER_LOG_CATEGORY_OPTIONS } from '@dukang/shared-types';
|
||||||
login: ['login_success', 'sms_login', 'sms_send', 'sms_verify_fail'],
|
|
||||||
browse_product: ['home_view', 'product_click', 'product_detail_view'],
|
|
||||||
order: ['order_confirm_view', 'order_submit'],
|
|
||||||
pay: ['pay_success', 'pay_fail'],
|
|
||||||
wechat_auth: ['wechat_login', 'wechat_phone', 'wechat_location', 'wechat_album'],
|
|
||||||
browse_store: ['store_list_view', 'store_detail_view'],
|
|
||||||
redeem: ['benefit_redeem_start', 'benefit_redeem_success'],
|
|
||||||
profile: ['profile_update', 'bind_phone'],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const USER_LOG_CATEGORY_OPTIONS: Array<{ value: UserLogCategory | ''; label: string }> = [
|
export const USER_LOG_CATEGORY_LABELS: Record<string, string> = Object.fromEntries(
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: 'login', label: '登录' },
|
|
||||||
{ value: 'browse_product', label: '浏览商品' },
|
|
||||||
{ value: 'order', label: '下单' },
|
|
||||||
{ value: 'pay', label: '支付' },
|
|
||||||
{ value: 'wechat_auth', label: '微信授权' },
|
|
||||||
{ value: 'browse_store', label: '浏览门店' },
|
|
||||||
{ value: 'redeem', label: '核销' },
|
|
||||||
{ value: 'profile', label: '信息修改' },
|
|
||||||
];
|
|
||||||
|
|
||||||
export function resolveUserLogCategory(eventName: string): UserLogCategory | null {
|
|
||||||
for (const [category, events] of Object.entries(USER_LOG_EVENT_CATEGORIES) as Array<
|
|
||||||
[UserLogCategory, readonly string[]]
|
|
||||||
>) {
|
|
||||||
if (events.includes(eventName)) return category;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const USER_LOG_CATEGORY_LABELS = Object.fromEntries(
|
|
||||||
USER_LOG_CATEGORY_OPTIONS.filter((o) => o.value).map((o) => [o.value, o.label]),
|
USER_LOG_CATEGORY_OPTIONS.filter((o) => o.value).map((o) => [o.value, o.label]),
|
||||||
) as Record<string, string>;
|
);
|
||||||
|
|||||||
@@ -717,6 +717,26 @@ export default function DashboardPage() {
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
<Col xs={24} sm={12} lg={8}>
|
||||||
|
<Card
|
||||||
|
loading={loading}
|
||||||
|
title="待审门店提现"
|
||||||
|
extra={<Link to="/finance/store-bills?kind=WITHDRAW">去处理</Link>}
|
||||||
|
>
|
||||||
|
<Statistic
|
||||||
|
value={stats?.pendingStoreWithdrawals ?? 0}
|
||||||
|
suffix="笔"
|
||||||
|
valueStyle={{
|
||||||
|
color: (stats?.overdueStoreWithdrawals ?? 0) > 0 ? '#cf1322' : (stats?.pendingStoreWithdrawals ?? 0) > 0 ? '#fa8c16' : undefined,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
{(stats?.overdueStoreWithdrawals ?? 0) > 0
|
||||||
|
? `超时未审 ${stats?.overdueStoreWithdrawals} 笔(FIN-003)`
|
||||||
|
: '工作日 T+0 审完'}
|
||||||
|
</Typography.Text>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
<Col xs={24} sm={12} lg={8}>
|
<Col xs={24} sm={12} lg={8}>
|
||||||
<Card loading={loading} title="待处理工单">
|
<Card loading={loading} title="待处理工单">
|
||||||
<Statistic value={stats?.openTickets ?? 0} suffix="个" />
|
<Statistic value={stats?.openTickets ?? 0} suffix="个" />
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
import { Card, Descriptions, Drawer, Select, Space, Table, Tag } from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { fmtTime } from '../lib/constants';
|
||||||
|
|
||||||
|
type Row = {
|
||||||
|
id: string;
|
||||||
|
eventType: string;
|
||||||
|
refType: string;
|
||||||
|
refId: string;
|
||||||
|
status?: string | null;
|
||||||
|
param1?: string | null;
|
||||||
|
param2?: string | null;
|
||||||
|
param3?: string | null;
|
||||||
|
remark?: string | null;
|
||||||
|
createdAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const EVENT_OPTIONS = [
|
||||||
|
{ value: '', label: '全部领域事件' },
|
||||||
|
{ value: 'ORDER_STATUS', label: '订单状态' },
|
||||||
|
{ value: 'BENEFIT_LEDGER', label: '权益流水' },
|
||||||
|
{ value: 'STORE_AUDIT', label: '门店审核' },
|
||||||
|
{ value: 'TICKET_COLLAB', label: '工单协作' },
|
||||||
|
{ value: 'PROMO_TOUCH', label: '推广触达' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function DomainEventsPage() {
|
||||||
|
const [params, setParams] = useSearchParams();
|
||||||
|
const eventType = params.get('eventType') ?? '';
|
||||||
|
const refType = params.get('refType') ?? '';
|
||||||
|
const refId = params.get('refId') ?? '';
|
||||||
|
const [data, setData] = useState<{ items: Row[]; total: number; page: number; pageSize: number } | null>(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [detail, setDetail] = useState<Row | null>(null);
|
||||||
|
|
||||||
|
const load = useCallback(() => {
|
||||||
|
setLoading(true);
|
||||||
|
const q = new URLSearchParams();
|
||||||
|
if (eventType) q.set('eventType', eventType);
|
||||||
|
if (refType) q.set('refType', refType);
|
||||||
|
if (refId) q.set('refId', refId);
|
||||||
|
q.set('page', params.get('page') ?? '1');
|
||||||
|
q.set('pageSize', '20');
|
||||||
|
request<{ items: Row[]; total: number; page: number; pageSize: number }>(
|
||||||
|
`/admin/logs/domain-events?${q.toString()}`,
|
||||||
|
)
|
||||||
|
.then(setData)
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [eventType, refType, refId, params]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
|
const columns: ColumnsType<Row> = [
|
||||||
|
{ title: '时间', dataIndex: 'createdAt', width: 170, render: (v) => fmtTime(v) },
|
||||||
|
{ title: '类型', dataIndex: 'eventType', width: 130, render: (v) => <Tag>{v}</Tag> },
|
||||||
|
{ title: '关联', render: (_, r) => `${r.refType} #${r.refId}` },
|
||||||
|
{ title: '状态', dataIndex: 'status', width: 100 },
|
||||||
|
{ title: '摘要', render: (_, r) => r.param1 || r.remark || '—' },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 80,
|
||||||
|
render: (_, r) => (
|
||||||
|
<a
|
||||||
|
onClick={async () => {
|
||||||
|
setDetail(await request<Row>(`/admin/logs/domain-events/${r.id}`));
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
详情
|
||||||
|
</a>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card title="领域事件">
|
||||||
|
<Space wrap style={{ marginBottom: 16 }}>
|
||||||
|
<Select
|
||||||
|
style={{ width: 180 }}
|
||||||
|
value={eventType}
|
||||||
|
options={EVENT_OPTIONS}
|
||||||
|
onChange={(v) => {
|
||||||
|
const next = new URLSearchParams(params);
|
||||||
|
if (v) next.set('eventType', v);
|
||||||
|
else next.delete('eventType');
|
||||||
|
next.set('page', '1');
|
||||||
|
setParams(next);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={data?.items ?? []}
|
||||||
|
pagination={{
|
||||||
|
current: data?.page ?? 1,
|
||||||
|
pageSize: data?.pageSize ?? 20,
|
||||||
|
total: data?.total ?? 0,
|
||||||
|
onChange: (p) => {
|
||||||
|
const next = new URLSearchParams(params);
|
||||||
|
next.set('page', String(p));
|
||||||
|
setParams(next);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Drawer open={!!detail} title="事件详情" width={520} onClose={() => setDetail(null)}>
|
||||||
|
{detail && (
|
||||||
|
<Descriptions column={1} size="small">
|
||||||
|
<Descriptions.Item label="ID">{detail.id}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="类型">{detail.eventType}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="关联">{`${detail.refType} #${detail.refId}`}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="param1">{detail.param1}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="param2">{detail.param2}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="param3">{detail.param3}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="备注">{detail.remark}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="时间">{fmtTime(detail.createdAt)}</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
)}
|
||||||
|
</Drawer>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Button, Card, Form, Input, Tabs, message, Typography } from 'antd';
|
import { Button, Card, Form, Input, Tabs, message, Typography } from 'antd';
|
||||||
|
import { MOCK_SMS_FIXED_CODE } from '@dukang/shared-types';
|
||||||
import { saveAuth, request } from '../lib/api';
|
import { saveAuth, request } from '../lib/api';
|
||||||
|
|
||||||
type LoginResult = { accessToken: string; refreshToken: string };
|
type LoginResult = { accessToken: string; refreshToken: string };
|
||||||
@@ -117,14 +118,14 @@ export default function LoginPage() {
|
|||||||
form={smsForm}
|
form={smsForm}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
onFinish={onSmsFinish}
|
onFinish={onSmsFinish}
|
||||||
initialValues={{ phone: '13600000001', code: '123456' }}
|
initialValues={{ phone: '13600000001', code: MOCK_SMS_FIXED_CODE }}
|
||||||
>
|
>
|
||||||
<Form.Item name="phone" label="手机号" rules={[{ required: true, message: '请输入手机号' }]}>
|
<Form.Item name="phone" label="手机号" rules={[{ required: true, message: '请输入手机号' }]}>
|
||||||
<Input placeholder="13600000001" maxLength={11} />
|
<Input placeholder="13600000001" maxLength={11} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="code" label="验证码" rules={[{ required: true, message: '请输入验证码' }]}>
|
<Form.Item name="code" label="验证码" rules={[{ required: true, message: '请输入验证码' }]}>
|
||||||
<Input
|
<Input
|
||||||
placeholder="123456"
|
placeholder={MOCK_SMS_FIXED_CODE}
|
||||||
addonAfter={
|
addonAfter={
|
||||||
<Button type="link" size="small" disabled={codeCooldown > 0} onClick={() => void sendCode()}>
|
<Button type="link" size="small" disabled={codeCooldown > 0} onClick={() => void sendCode()}>
|
||||||
{codeCooldown > 0 ? `${codeCooldown}s` : '获取验证码'}
|
{codeCooldown > 0 ? `${codeCooldown}s` : '获取验证码'}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
|||||||
import {
|
import {
|
||||||
Button, Card, Col, Form, Input, InputNumber, Row, Space, Tabs, Typography, message,
|
Button, Card, Col, Form, Input, InputNumber, Row, Space, Tabs, Typography, message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
|
import { MOCK_SMS_FIXED_CODE } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
|
||||||
type ApiResult = Record<string, unknown>;
|
type ApiResult = Record<string, unknown>;
|
||||||
@@ -255,7 +256,7 @@ export default function RedeemDebugPage() {
|
|||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="code" label="验证码" rules={[{ required: true }]}>
|
<Form.Item name="code" label="验证码" rules={[{ required: true }]}>
|
||||||
<Input placeholder="Mock 默认 123456" />
|
<Input placeholder={`Mock 默认 ${MOCK_SMS_FIXED_CODE}`} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Button
|
<Button
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -335,7 +336,7 @@ export default function RedeemDebugPage() {
|
|||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="code" label="核销确认验证码" rules={[{ required: true }]}>
|
<Form.Item name="code" label="核销确认验证码" rules={[{ required: true }]}>
|
||||||
<Input placeholder="Mock 默认 123456" />
|
<Input placeholder={`Mock 默认 ${MOCK_SMS_FIXED_CODE}`} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
@@ -1,12 +1,18 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Button, Descriptions, Drawer, Form, Input, Table, Typography } from 'antd';
|
import { Button, Descriptions, Drawer, Form, Input, Select, Table, Tag, Typography } from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import { REDEEM_CHANNEL_LABELS, type RedeemChannel } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { fmtTime } from '../lib/constants';
|
import { fmtTime } from '../lib/constants';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: string; redeemNo: string; amount: number; settleAmount: number; createdAt: string;
|
id: string;
|
||||||
|
redeemNo: string;
|
||||||
|
amount: number;
|
||||||
|
settleAmount: number;
|
||||||
|
channel?: RedeemChannel;
|
||||||
|
createdAt: string;
|
||||||
user?: { userNo: string; phone: string | null };
|
user?: { userNo: string; phone: string | null };
|
||||||
store?: { name: string; cityName: string };
|
store?: { name: string; cityName: string };
|
||||||
coupon?: { couponNo: string };
|
coupon?: { couponNo: string };
|
||||||
@@ -21,6 +27,7 @@ export default function RedeemRecordsPage() {
|
|||||||
const qs = new URLSearchParams();
|
const qs = new URLSearchParams();
|
||||||
if (filters.redeemNo) qs.set('redeemNo', filters.redeemNo);
|
if (filters.redeemNo) qs.set('redeemNo', filters.redeemNo);
|
||||||
if (filters.storeId) qs.set('storeId', filters.storeId);
|
if (filters.storeId) qs.set('storeId', filters.storeId);
|
||||||
|
if (filters.channel) qs.set('channel', filters.channel);
|
||||||
return qs;
|
return qs;
|
||||||
},
|
},
|
||||||
[filters],
|
[filters],
|
||||||
@@ -30,6 +37,19 @@ export default function RedeemRecordsPage() {
|
|||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const columns: ColumnsType<Row> = [
|
||||||
{ title: '核销号', dataIndex: 'redeemNo', width: 180 },
|
{ title: '核销号', dataIndex: 'redeemNo', width: 180 },
|
||||||
|
{
|
||||||
|
title: '方式',
|
||||||
|
dataIndex: 'channel',
|
||||||
|
width: 110,
|
||||||
|
render: (v: RedeemChannel | undefined) => {
|
||||||
|
const channel = v === 'PHONE' ? 'PHONE' : 'SCAN';
|
||||||
|
return (
|
||||||
|
<Tag color={channel === 'PHONE' ? 'purple' : 'blue'}>
|
||||||
|
{REDEEM_CHANNEL_LABELS[channel]}
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
{ title: '用户', dataIndex: ['user', 'userNo'], width: 110 },
|
{ title: '用户', dataIndex: ['user', 'userNo'], width: 110 },
|
||||||
{ title: '门店', dataIndex: ['store', 'name'] },
|
{ title: '门店', dataIndex: ['store', 'name'] },
|
||||||
{ title: '核销额', dataIndex: 'amount', width: 90, render: (v) => `¥${v}` },
|
{ title: '核销额', dataIndex: 'amount', width: 90, render: (v) => `¥${v}` },
|
||||||
@@ -37,12 +57,19 @@ export default function RedeemRecordsPage() {
|
|||||||
{ title: '券号', dataIndex: ['coupon', 'couponNo'], width: 160 },
|
{ title: '券号', dataIndex: ['coupon', 'couponNo'], width: 160 },
|
||||||
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '操作', width: 80,
|
title: '操作',
|
||||||
|
width: 80,
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Button type="link" size="small" onClick={async () => {
|
<Button
|
||||||
setDetail(await request(`/admin/redeem-records/${row.id}`));
|
type="link"
|
||||||
setDrawerOpen(true);
|
size="small"
|
||||||
}}>详情</Button>
|
onClick={async () => {
|
||||||
|
setDetail(await request(`/admin/redeem-records/${row.id}`));
|
||||||
|
setDrawerOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
详情
|
||||||
|
</Button>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -50,16 +77,65 @@ export default function RedeemRecordsPage() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Typography.Title level={4}>核销记录</Typography.Title>
|
<Typography.Title level={4}>核销记录</Typography.Title>
|
||||||
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
|
<Form
|
||||||
<Form.Item name="redeemNo" label="核销号"><Input allowClear /></Form.Item>
|
form={form}
|
||||||
<Form.Item name="storeId" label="门店ID"><Input allowClear /></Form.Item>
|
layout="inline"
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
onFinish={(v) => {
|
||||||
|
setFilters(v);
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Form.Item name="redeemNo" label="核销号">
|
||||||
|
<Input allowClear />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="storeId" label="门店ID">
|
||||||
|
<Input allowClear />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="channel" label="方式">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
style={{ width: 140 }}
|
||||||
|
options={[
|
||||||
|
{ value: 'SCAN', label: '扫码核销' },
|
||||||
|
{ value: 'PHONE', label: '手机号核销' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item>
|
||||||
|
<Button type="primary" htmlType="submit">
|
||||||
|
查询
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Table rowKey="id" loading={loading} columns={columns} dataSource={data?.items ?? []} scroll={{ x: 1000 }}
|
<Table
|
||||||
pagination={{ current: page, pageSize, total: data?.total ?? 0, showSizeChanger: true, onChange: (p, ps) => { setPage(p); setPageSize(ps); } }} />
|
rowKey="id"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={data?.items ?? []}
|
||||||
|
scroll={{ x: 1100 }}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize,
|
||||||
|
total: data?.total ?? 0,
|
||||||
|
showSizeChanger: true,
|
||||||
|
onChange: (p, ps) => {
|
||||||
|
setPage(p);
|
||||||
|
setPageSize(ps);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Drawer title="核销详情" width={520} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
<Drawer title="核销详情" width={520} open={drawerOpen} onClose={() => setDrawerOpen(false)}>
|
||||||
{detail && (
|
{detail && (
|
||||||
<Descriptions column={1} bordered size="small">
|
<Descriptions column={1} bordered size="small">
|
||||||
<Descriptions.Item label="核销号">{String(detail.redeemNo)}</Descriptions.Item>
|
<Descriptions.Item label="核销号">{String(detail.redeemNo)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="方式">
|
||||||
|
{
|
||||||
|
REDEEM_CHANNEL_LABELS[
|
||||||
|
(detail.channel === 'PHONE' ? 'PHONE' : 'SCAN') as RedeemChannel
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="核销额">¥{String(detail.amount)}</Descriptions.Item>
|
<Descriptions.Item label="核销额">¥{String(detail.amount)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="结算额">¥{String(detail.settleAmount)}</Descriptions.Item>
|
<Descriptions.Item label="结算额">¥{String(detail.settleAmount)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="时间">{fmtTime(String(detail.createdAt))}</Descriptions.Item>
|
<Descriptions.Item label="时间">{fmtTime(String(detail.createdAt))}</Descriptions.Item>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
@@ -6,6 +7,7 @@ import {
|
|||||||
Descriptions,
|
Descriptions,
|
||||||
Drawer,
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
|
Input,
|
||||||
Modal,
|
Modal,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
@@ -17,44 +19,61 @@ import {
|
|||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import type { Dayjs } from 'dayjs';
|
import type { Dayjs } from 'dayjs';
|
||||||
|
import {
|
||||||
|
STORE_SETTLEMENT_KIND_LABELS,
|
||||||
|
STORE_SETTLEMENT_STATUS_LABELS,
|
||||||
|
storeSettlementStatusLabel,
|
||||||
|
type StoreSettlementKind,
|
||||||
|
type StoreSettlementStatus,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
import { downloadExcelCsv } from '../lib/exportExcel';
|
import { downloadExcelCsv } from '../lib/exportExcel';
|
||||||
import { useAdminList } from '../lib/useAdminList';
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
|
kind: StoreSettlementKind;
|
||||||
id: string;
|
id: string;
|
||||||
billNo: string;
|
billNo: string;
|
||||||
billDate: string;
|
amount: number;
|
||||||
redeemCount: number;
|
status: StoreSettlementStatus;
|
||||||
redeemAmount: number;
|
date: string;
|
||||||
settlementRate: number;
|
overdue?: boolean;
|
||||||
payoutAmount: number;
|
redeemCount?: number | null;
|
||||||
status: string;
|
redeemAmount?: number | null;
|
||||||
paidAt?: string | null;
|
settlementRate?: number | null;
|
||||||
store?: { id: string; name: string; cityName: string; phone?: string };
|
payoutCount?: number | null;
|
||||||
|
store?: { id: string; name: string; cityName: string; phone?: string | null };
|
||||||
};
|
};
|
||||||
|
|
||||||
type StoreOption = { id: string; name: string; phone: string };
|
type StoreOption = { id: string; name: string; phone: string };
|
||||||
|
|
||||||
const STATUS_LABELS: Record<string, string> = {
|
|
||||||
UNPAID: '未打款',
|
|
||||||
PAID: '已打款',
|
|
||||||
};
|
|
||||||
|
|
||||||
const STATUS_COLORS: Record<string, string> = {
|
const STATUS_COLORS: Record<string, string> = {
|
||||||
UNPAID: 'red',
|
UNPAID: 'red',
|
||||||
PAID: 'green',
|
PAID: 'green',
|
||||||
|
PENDING_REVIEW: 'orange',
|
||||||
|
REJECTED: 'red',
|
||||||
|
};
|
||||||
|
|
||||||
|
const KIND_COLORS: Record<StoreSettlementKind, string> = {
|
||||||
|
T1_BILL: 'blue',
|
||||||
|
WITHDRAW: 'purple',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function StoreBillsPage() {
|
export default function StoreBillsPage() {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const initialKind = searchParams.get('kind') === 'WITHDRAW' ? 'WITHDRAW' : '';
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [filters, setFilters] = useState<Record<string, string>>({});
|
const [filters, setFilters] = useState<Record<string, string>>({
|
||||||
|
kind: initialKind,
|
||||||
|
status: initialKind === 'WITHDRAW' ? 'PENDING_REVIEW' : '',
|
||||||
|
});
|
||||||
const [stores, setStores] = useState<StoreOption[]>([]);
|
const [stores, setStores] = useState<StoreOption[]>([]);
|
||||||
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
||||||
'/admin/store-bills',
|
'/admin/store-settlements',
|
||||||
() => {
|
() => {
|
||||||
const qs = new URLSearchParams();
|
const qs = new URLSearchParams();
|
||||||
|
if (filters.kind) qs.set('kind', filters.kind);
|
||||||
if (filters.status) qs.set('status', filters.status);
|
if (filters.status) qs.set('status', filters.status);
|
||||||
if (filters.storeId) qs.set('storeId', filters.storeId);
|
if (filters.storeId) qs.set('storeId', filters.storeId);
|
||||||
if (filters.dateFrom) qs.set('dateFrom', filters.dateFrom);
|
if (filters.dateFrom) qs.set('dateFrom', filters.dateFrom);
|
||||||
@@ -64,21 +83,38 @@ export default function StoreBillsPage() {
|
|||||||
[filters],
|
[filters],
|
||||||
);
|
);
|
||||||
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
|
const [detailKind, setDetailKind] = useState<StoreSettlementKind | null>(null);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const [exporting, setExporting] = useState(false);
|
const [exporting, setExporting] = useState(false);
|
||||||
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
|
const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
|
||||||
const [batchLoading, setBatchLoading] = useState(false);
|
const [batchLoading, setBatchLoading] = useState(false);
|
||||||
|
const [overdueSummary, setOverdueSummary] = useState<{
|
||||||
|
pendingCount: number;
|
||||||
|
overdueCount: number;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
kind: filters.kind || undefined,
|
||||||
|
status: filters.status || undefined,
|
||||||
|
});
|
||||||
|
}, [filters.kind, filters.status, form]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void request<Paginated<StoreOption>>(`/admin/stores?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
void request<Paginated<StoreOption>>(`/admin/stores?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
.then((res) => setStores(res.items))
|
.then((res) => setStores(res.items))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
void request<{ pendingCount: number; overdueCount: number }>(
|
||||||
|
'/admin/store-withdrawals/overdue-summary',
|
||||||
|
)
|
||||||
|
.then(setOverdueSummary)
|
||||||
|
.catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function confirmPay(ids: string[], amountHint?: number) {
|
function confirmPay(ids: string[], amountHint?: number) {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认打款?',
|
title: '确认打款?',
|
||||||
content: `将确认 ${ids.length} 笔门店对账单${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。`,
|
content: `将确认 ${ids.length} 笔 T+1 门店对账单${amountHint != null ? `,合计约 ¥${amountHint.toFixed(2)}` : ''}。此操作不可撤销。`,
|
||||||
okText: '确认打款',
|
okText: '确认打款',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
@@ -102,9 +138,75 @@ export default function StoreBillsPage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openDetail(id: string) {
|
function approveWithdraw(id: string) {
|
||||||
const d = await request<Record<string, unknown>>(`/admin/store-bills/${id}`);
|
let paymentRef = '';
|
||||||
|
Modal.confirm({
|
||||||
|
title: '审核通过并标记已结算?',
|
||||||
|
content: (
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
okText: '通过并结算',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: async () => {
|
||||||
|
await request(`/admin/store-withdrawals/${id}/approve`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ paymentRef: paymentRef.trim() || undefined }),
|
||||||
|
});
|
||||||
|
message.success('已通过并标记已结算');
|
||||||
|
setDrawerOpen(false);
|
||||||
|
reload();
|
||||||
|
void request<{ pendingCount: number; overdueCount: number }>(
|
||||||
|
'/admin/store-withdrawals/overdue-summary',
|
||||||
|
)
|
||||||
|
.then(setOverdueSummary)
|
||||||
|
.catch(() => {});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function rejectWithdraw(id: string) {
|
||||||
|
let reason = '';
|
||||||
|
Modal.confirm({
|
||||||
|
title: '驳回提现申请?',
|
||||||
|
content: (
|
||||||
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
placeholder="请填写驳回理由"
|
||||||
|
onChange={(e) => {
|
||||||
|
reason = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
okText: '确认驳回',
|
||||||
|
okButtonProps: { danger: true },
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: async () => {
|
||||||
|
if (!reason.trim()) {
|
||||||
|
message.error('请填写驳回理由');
|
||||||
|
throw new Error('reason required');
|
||||||
|
}
|
||||||
|
await request(`/admin/store-withdrawals/${id}/reject`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ reason: reason.trim() }),
|
||||||
|
});
|
||||||
|
message.success('已驳回');
|
||||||
|
setDrawerOpen(false);
|
||||||
|
reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openDetail(row: Row) {
|
||||||
|
const path =
|
||||||
|
row.kind === 'WITHDRAW' ? `/admin/store-withdrawals/${row.id}` : `/admin/store-bills/${row.id}`;
|
||||||
|
const d = await request<Record<string, unknown>>(path);
|
||||||
setDetail(d);
|
setDetail(d);
|
||||||
|
setDetailKind(row.kind);
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,88 +220,134 @@ export default function StoreBillsPage() {
|
|||||||
if (filters.dateTo) qs.set('dateTo', filters.dateTo);
|
if (filters.dateTo) qs.set('dateTo', filters.dateTo);
|
||||||
const result = await request<{ csv: string; count: number }>(`/admin/store-bills/export?${qs}`);
|
const result = await request<{ csv: string; count: number }>(`/admin/store-bills/export?${qs}`);
|
||||||
downloadExcelCsv(result.csv, `门店对账单_${filters.dateFrom || 'all'}_${filters.dateTo || 'all'}.csv`);
|
downloadExcelCsv(result.csv, `门店对账单_${filters.dateFrom || 'all'}_${filters.dateTo || 'all'}.csv`);
|
||||||
message.success(`已导出 ${result.count} 条`);
|
message.success(`已导出 ${result.count} 条 T+1 账单`);
|
||||||
} finally {
|
} finally {
|
||||||
setExporting(false);
|
setExporting(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const summary = data?.summary;
|
const summary = data?.summary;
|
||||||
const selectedRows = (data?.items ?? []).filter((r) => selectedKeys.includes(r.id));
|
const selectedRows = (data?.items ?? []).filter(
|
||||||
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.payoutAmount), 0);
|
(r) =>
|
||||||
|
selectedKeys.includes(`${r.kind}-${r.id}`) &&
|
||||||
|
r.kind === 'T1_BILL' &&
|
||||||
|
r.status === 'UNPAID',
|
||||||
|
);
|
||||||
|
const selectedAmount = selectedRows.reduce((s, r) => s + Number(r.amount), 0);
|
||||||
|
|
||||||
const columns: ColumnsType<Row> = [
|
const columns: ColumnsType<Row> = [
|
||||||
{ title: '账单号', dataIndex: 'billNo', width: 170, ellipsis: true },
|
|
||||||
{
|
{
|
||||||
title: '账单日',
|
title: '类型',
|
||||||
dataIndex: 'billDate',
|
dataIndex: 'kind',
|
||||||
width: 110,
|
width: 100,
|
||||||
render: (v) => String(v || '').slice(0, 10),
|
render: (k: StoreSettlementKind) => (
|
||||||
|
<Tag color={KIND_COLORS[k]}>{STORE_SETTLEMENT_KIND_LABELS[k] ?? k}</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '单号',
|
||||||
|
dataIndex: 'billNo',
|
||||||
|
width: 180,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (v, row) => (
|
||||||
|
<Space>
|
||||||
|
<span>{v}</span>
|
||||||
|
{row.overdue ? <Tag color="magenta">超时</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '日期',
|
||||||
|
dataIndex: 'date',
|
||||||
|
width: 160,
|
||||||
|
render: (v, row) => (row.kind === 'T1_BILL' ? String(v || '').slice(0, 10) : fmtTime(v)),
|
||||||
},
|
},
|
||||||
{ title: '门店', dataIndex: ['store', 'name'], width: 140, ellipsis: true },
|
{ title: '门店', dataIndex: ['store', 'name'], width: 140, ellipsis: true },
|
||||||
{ title: '登录手机', dataIndex: ['store', 'phone'], width: 120, render: (v) => v || '—' },
|
{ title: '登录手机', dataIndex: ['store', 'phone'], width: 120, render: (v) => v || '—' },
|
||||||
{ title: '城市', dataIndex: ['store', 'cityName'], width: 90 },
|
{ title: '城市', dataIndex: ['store', 'cityName'], width: 90 },
|
||||||
{ title: '核销笔数', dataIndex: 'redeemCount', width: 90 },
|
|
||||||
{
|
{
|
||||||
title: '核销金额',
|
title: '笔数',
|
||||||
dataIndex: 'redeemAmount',
|
width: 80,
|
||||||
width: 110,
|
render: (_, row) =>
|
||||||
render: (v) => `¥${Number(v).toFixed(2)}`,
|
row.kind === 'T1_BILL' ? (row.redeemCount ?? '—') : (row.payoutCount ?? '—'),
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '结算比例',
|
|
||||||
dataIndex: 'settlementRate',
|
|
||||||
width: 90,
|
|
||||||
render: (v) => `${Math.round(Number(v) * 100)}%`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '应付金额',
|
title: '应付金额',
|
||||||
dataIndex: 'payoutAmount',
|
dataIndex: 'amount',
|
||||||
width: 110,
|
width: 110,
|
||||||
render: (v) => `¥${Number(v).toFixed(2)}`,
|
render: (v) => `¥${Number(v).toFixed(2)}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'status',
|
dataIndex: 'status',
|
||||||
width: 90,
|
width: 100,
|
||||||
render: (s) => <Tag color={STATUS_COLORS[s] || 'default'}>{STATUS_LABELS[s] || s}</Tag>,
|
render: (s: string, row) => (
|
||||||
|
<Tag color={STATUS_COLORS[s] || 'default'}>{storeSettlementStatusLabel(row.kind, s)}</Tag>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
width: 160,
|
width: 200,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Space size={0}>
|
<Space size={0}>
|
||||||
<Button type="link" size="small" onClick={() => void openDetail(row.id)}>
|
<Button type="link" size="small" onClick={() => void openDetail(row)}>
|
||||||
明细
|
明细
|
||||||
</Button>
|
</Button>
|
||||||
{row.status === 'UNPAID' && (
|
{row.kind === 'T1_BILL' && row.status === 'UNPAID' && (
|
||||||
<Button type="link" size="small" onClick={() => confirmPay([row.id], Number(row.payoutAmount))}>
|
<Button type="link" size="small" onClick={() => confirmPay([row.id], Number(row.amount))}>
|
||||||
确认打款
|
确认打款
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{row.kind === 'WITHDRAW' && row.status === 'PENDING_REVIEW' && (
|
||||||
|
<>
|
||||||
|
<Button type="link" size="small" onClick={() => approveWithdraw(row.id)}>
|
||||||
|
通过
|
||||||
|
</Button>
|
||||||
|
<Button type="link" size="small" danger onClick={() => rejectWithdraw(row.id)}>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const withdrawDetailItems =
|
||||||
|
(detail?.items as Array<Record<string, unknown>> | undefined) ?? [];
|
||||||
|
const storeAccount = detail?.storeAccount as
|
||||||
|
| {
|
||||||
|
name?: string;
|
||||||
|
phone?: string;
|
||||||
|
bankAccountName?: string;
|
||||||
|
bankAccountNo?: string;
|
||||||
|
bankBranch?: string;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
<Space direction="vertical" size={0} style={{ marginBottom: 16 }}>
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
门店对账单
|
门店账单
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
<Typography.Text type="secondary">
|
<Typography.Text type="secondary">
|
||||||
按核销日汇总(每日 8:00 自动出账);未打款红色、已打款绿色
|
含 T+1 自动出账与门店手动提现;按类型筛选,详情与审核动作沿用原接口
|
||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
|
{overdueSummary && overdueSummary.overdueCount > 0 ? (
|
||||||
|
<Typography.Text type="danger">
|
||||||
|
手动提现超时未审 {overdueSummary.overdueCount} 笔(待审共 {overdueSummary.pendingCount})
|
||||||
|
</Typography.Text>
|
||||||
|
) : null}
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
{summary && (
|
{summary && (
|
||||||
<Card size="small" style={{ marginBottom: 16 }}>
|
<Card size="small" style={{ marginBottom: 16 }}>
|
||||||
<Space size="large" wrap>
|
<Space size="large" wrap>
|
||||||
<Statistic title="账单数" value={summary.count} />
|
<Statistic title="记录数" value={summary.count} />
|
||||||
<Statistic title="核销金额合计" value={summary.redeemAmount ?? 0} prefix="¥" precision={2} />
|
<Statistic title="核销金额合计" value={summary.redeemAmount ?? 0} prefix="¥" precision={2} />
|
||||||
<Statistic title="应付合计" value={summary.payoutAmount ?? 0} prefix="¥" precision={2} />
|
<Statistic title="应付合计" value={summary.payoutAmount ?? summary.totalAmount ?? 0} prefix="¥" precision={2} />
|
||||||
</Space>
|
</Space>
|
||||||
</Card>
|
</Card>
|
||||||
)}
|
)}
|
||||||
@@ -208,16 +356,37 @@ export default function StoreBillsPage() {
|
|||||||
form={form}
|
form={form}
|
||||||
layout="inline"
|
layout="inline"
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
onFinish={(v: { storeId?: string; status?: string; range?: [Dayjs, Dayjs] }) => {
|
initialValues={{
|
||||||
|
kind: filters.kind || undefined,
|
||||||
|
status: filters.status || undefined,
|
||||||
|
}}
|
||||||
|
onFinish={(v: {
|
||||||
|
kind?: string;
|
||||||
|
storeId?: string;
|
||||||
|
status?: string;
|
||||||
|
range?: [Dayjs, Dayjs];
|
||||||
|
}) => {
|
||||||
setFilters({
|
setFilters({
|
||||||
|
kind: v.kind || '',
|
||||||
storeId: v.storeId || '',
|
storeId: v.storeId || '',
|
||||||
status: v.status || '',
|
status: v.status || '',
|
||||||
dateFrom: v.range?.[0] ? v.range[0].format('YYYY-MM-DD') : '',
|
dateFrom: v.range?.[0] ? v.range[0].format('YYYY-MM-DD') : '',
|
||||||
dateTo: v.range?.[1] ? v.range[1].format('YYYY-MM-DD') : '',
|
dateTo: v.range?.[1] ? v.range[1].format('YYYY-MM-DD') : '',
|
||||||
});
|
});
|
||||||
setPage(1);
|
setPage(1);
|
||||||
|
setSelectedKeys([]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Form.Item name="kind" label="类型">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
style={{ width: 140 }}
|
||||||
|
options={Object.entries(STORE_SETTLEMENT_KIND_LABELS).map(([value, label]) => ({
|
||||||
|
value,
|
||||||
|
label,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item name="storeId" label="门店">
|
<Form.Item name="storeId" label="门店">
|
||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
@@ -232,10 +401,16 @@ export default function StoreBillsPage() {
|
|||||||
<Select
|
<Select
|
||||||
allowClear
|
allowClear
|
||||||
style={{ width: 120 }}
|
style={{ width: 120 }}
|
||||||
options={Object.entries(STATUS_LABELS).map(([value, label]) => ({ value, label }))}
|
options={Object.entries(STORE_SETTLEMENT_STATUS_LABELS).map(([value, label]) => ({
|
||||||
|
value,
|
||||||
|
label:
|
||||||
|
value === 'PAID'
|
||||||
|
? '已打款/已结算'
|
||||||
|
: label,
|
||||||
|
}))}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="range" label="账单日">
|
<Form.Item name="range" label="日期">
|
||||||
<DatePicker.RangePicker />
|
<DatePicker.RangePicker />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
@@ -249,6 +424,7 @@ export default function StoreBillsPage() {
|
|||||||
form.resetFields();
|
form.resetFields();
|
||||||
setFilters({});
|
setFilters({});
|
||||||
setPage(1);
|
setPage(1);
|
||||||
|
setSelectedKeys([]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
重置
|
重置
|
||||||
@@ -256,33 +432,36 @@ export default function StoreBillsPage() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button loading={exporting} onClick={() => void exportExcel()}>
|
<Button loading={exporting} onClick={() => void exportExcel()}>
|
||||||
导出 Excel
|
导出 T+1 Excel
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
disabled={!selectedKeys.length}
|
disabled={!selectedRows.length}
|
||||||
loading={batchLoading}
|
loading={batchLoading}
|
||||||
onClick={() => confirmPay(selectedKeys.map(String), selectedAmount)}
|
onClick={() => confirmPay(selectedRows.map((r) => r.id), selectedAmount)}
|
||||||
>
|
>
|
||||||
批量确认打款 ({selectedKeys.length})
|
批量确认打款 ({selectedRows.length})
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey={(r) => `${r.kind}-${r.id}`}
|
||||||
className="admin-table-nowrap"
|
className="admin-table-nowrap"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data?.items ?? []}
|
dataSource={data?.items ?? []}
|
||||||
|
rowClassName={(row) => (row.overdue ? 'ant-table-row-selected' : '')}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
selectedRowKeys: selectedKeys,
|
selectedRowKeys: selectedKeys,
|
||||||
onChange: setSelectedKeys,
|
onChange: setSelectedKeys,
|
||||||
getCheckboxProps: (r) => ({ disabled: r.status !== 'UNPAID' }),
|
getCheckboxProps: (r) => ({
|
||||||
|
disabled: !(r.kind === 'T1_BILL' && r.status === 'UNPAID'),
|
||||||
|
}),
|
||||||
}}
|
}}
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 1300 }}
|
||||||
pagination={{
|
pagination={{
|
||||||
current: page,
|
current: page,
|
||||||
pageSize,
|
pageSize,
|
||||||
@@ -295,14 +474,25 @@ export default function StoreBillsPage() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Drawer title="门店对账单明细" open={drawerOpen} onClose={() => setDrawerOpen(false)} width={520}>
|
<Drawer
|
||||||
{detail && (
|
title={detailKind === 'WITHDRAW' ? '手动提现明细' : 'T+1 对账单明细'}
|
||||||
|
open={drawerOpen}
|
||||||
|
onClose={() => setDrawerOpen(false)}
|
||||||
|
width={detailKind === 'WITHDRAW' ? 640 : 520}
|
||||||
|
>
|
||||||
|
{detail && detailKind === 'T1_BILL' && (
|
||||||
<>
|
<>
|
||||||
<Descriptions column={1} size="small" bordered>
|
<Descriptions column={1} size="small" bordered>
|
||||||
<Descriptions.Item label="账单号">{String(detail.billNo)}</Descriptions.Item>
|
<Descriptions.Item label="账单号">{String(detail.billNo)}</Descriptions.Item>
|
||||||
<Descriptions.Item label="账单日">{String(detail.billDate || '').slice(0, 10)}</Descriptions.Item>
|
<Descriptions.Item label="账单日">
|
||||||
<Descriptions.Item label="应付">¥{Number(detail.payoutAmount ?? 0).toFixed(2)}</Descriptions.Item>
|
{String(detail.billDate || '').slice(0, 10)}
|
||||||
<Descriptions.Item label="状态">{STATUS_LABELS[String(detail.status)] || String(detail.status)}</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="应付">
|
||||||
|
¥{Number(detail.payoutAmount ?? 0).toFixed(2)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="状态">
|
||||||
|
{storeSettlementStatusLabel('T1_BILL', String(detail.status))}
|
||||||
|
</Descriptions.Item>
|
||||||
<Descriptions.Item label="打款时间">
|
<Descriptions.Item label="打款时间">
|
||||||
{detail.paidAt ? fmtTime(String(detail.paidAt)) : '—'}
|
{detail.paidAt ? fmtTime(String(detail.paidAt)) : '—'}
|
||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
@@ -318,7 +508,8 @@ export default function StoreBillsPage() {
|
|||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
title: '核销单号',
|
title: '核销单号',
|
||||||
render: (_, r) => String((r.redeemRecord as { redeemNo?: string })?.redeemNo || '—'),
|
render: (_, r) =>
|
||||||
|
String((r.redeemRecord as { redeemNo?: string })?.redeemNo || '—'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '金额',
|
title: '金额',
|
||||||
@@ -334,6 +525,83 @@ export default function StoreBillsPage() {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail && detailKind === 'WITHDRAW' && (
|
||||||
|
<>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="提现单号">{String(detail.withdrawNo)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="金额">
|
||||||
|
¥{Number(detail.amount ?? 0).toFixed(2)}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="状态">
|
||||||
|
{storeSettlementStatusLabel('WITHDRAW', String(detail.status))}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="申请时间">
|
||||||
|
{detail.appliedAt ? fmtTime(String(detail.appliedAt)) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="驳回理由">
|
||||||
|
{detail.rejectReason ? String(detail.rejectReason) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="打款凭证">
|
||||||
|
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
{storeAccount ? (
|
||||||
|
<>
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
收款账户
|
||||||
|
</Typography.Title>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="户名">
|
||||||
|
{storeAccount.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="账号">
|
||||||
|
{storeAccount.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户行">
|
||||||
|
{storeAccount.bankBranch || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
提现明细
|
||||||
|
</Typography.Title>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey="id"
|
||||||
|
pagination={false}
|
||||||
|
dataSource={withdrawDetailItems}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: '核销单号',
|
||||||
|
render: (_, r) => {
|
||||||
|
const payout = r.storePayout as
|
||||||
|
| { redeemRecord?: { redeemNo?: string }; payoutAmount?: number }
|
||||||
|
| undefined;
|
||||||
|
return String(payout?.redeemRecord?.redeemNo || '—');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '应付',
|
||||||
|
render: (_, r) => {
|
||||||
|
const payout = r.storePayout as { payoutAmount?: number } | undefined;
|
||||||
|
return `¥${Number(payout?.payoutAmount ?? 0).toFixed(2)}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
{String(detail.status) === 'PENDING_REVIEW' ? (
|
||||||
|
<Space style={{ marginTop: 16 }}>
|
||||||
|
<Button type="primary" onClick={() => approveWithdraw(String(detail.id))}>
|
||||||
|
通过
|
||||||
|
</Button>
|
||||||
|
<Button danger onClick={() => rejectWithdraw(String(detail.id))}>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,331 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Drawer,
|
||||||
|
Input,
|
||||||
|
Modal,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
message,
|
||||||
|
} from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import type {
|
||||||
|
StorePackageAuditDetailDto,
|
||||||
|
StorePackageChangeRequestDto,
|
||||||
|
StorePackageItemDto,
|
||||||
|
StorePackageViewDto,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
|
import { STORE_PACKAGE_CHANGE_STATUS_LABELS } from '@dukang/shared-types';
|
||||||
|
import { request, type Paginated } from '../lib/api';
|
||||||
|
import { fmtTime } from '../lib/constants';
|
||||||
|
|
||||||
|
function packageKey(pkg: StorePackageItemDto | StorePackageViewDto, index: number) {
|
||||||
|
const name = String(pkg.name ?? '').trim();
|
||||||
|
return name ? `name:${name}` : `idx:${index}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function diffPackages(live: StorePackageViewDto[], proposed: StorePackageItemDto[]) {
|
||||||
|
const liveMap = new Map(live.map((p, i) => [packageKey(p, i), p]));
|
||||||
|
const proposedMap = new Map(proposed.map((p, i) => [packageKey(p, i), p]));
|
||||||
|
const keys = new Set([...liveMap.keys(), ...proposedMap.keys()]);
|
||||||
|
const rows: Array<{
|
||||||
|
key: string;
|
||||||
|
change: 'added' | 'removed' | 'changed' | 'unchanged';
|
||||||
|
live?: StorePackageViewDto;
|
||||||
|
proposed?: StorePackageItemDto;
|
||||||
|
}> = [];
|
||||||
|
|
||||||
|
for (const key of keys) {
|
||||||
|
const l = liveMap.get(key);
|
||||||
|
const p = proposedMap.get(key);
|
||||||
|
if (l && !p) {
|
||||||
|
rows.push({ key, change: 'removed', live: l });
|
||||||
|
} else if (!l && p) {
|
||||||
|
rows.push({ key, change: 'added', proposed: p });
|
||||||
|
} else if (l && p) {
|
||||||
|
const changed =
|
||||||
|
l.price !== p.price ||
|
||||||
|
l.dishes !== p.dishes ||
|
||||||
|
(l.usableTime ?? '') !== (p.usableTime ?? '') ||
|
||||||
|
(l.otherNotes ?? '') !== (p.otherNotes ?? '');
|
||||||
|
rows.push({ key, change: changed ? 'changed' : 'unchanged', live: l, proposed: p });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CHANGE_LABELS = {
|
||||||
|
added: { text: '新增', color: 'green' },
|
||||||
|
removed: { text: '删除', color: 'red' },
|
||||||
|
changed: { text: '变更', color: 'orange' },
|
||||||
|
unchanged: { text: '未变', color: 'default' },
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export default function StorePackageAuditsPage() {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [items, setItems] = useState<StorePackageChangeRequestDto[]>([]);
|
||||||
|
const [total, setTotal] = useState(0);
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [status, setStatus] = useState<string>('PENDING');
|
||||||
|
const [rejectOpen, setRejectOpen] = useState(false);
|
||||||
|
const [rejectReason, setRejectReason] = useState('');
|
||||||
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
|
const [detailOpen, setDetailOpen] = useState(false);
|
||||||
|
const [detailLoading, setDetailLoading] = useState(false);
|
||||||
|
const [detail, setDetail] = useState<StorePackageAuditDetailDto | null>(null);
|
||||||
|
|
||||||
|
async function reload(nextPage = page, nextStatus = status) {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const qs = new URLSearchParams({
|
||||||
|
page: String(nextPage),
|
||||||
|
pageSize: '20',
|
||||||
|
});
|
||||||
|
if (nextStatus) qs.set('status', nextStatus);
|
||||||
|
const data = await request<Paginated<StorePackageChangeRequestDto>>(
|
||||||
|
`/admin/store-package-audits?${qs}`,
|
||||||
|
);
|
||||||
|
setItems(data.items);
|
||||||
|
setTotal(data.total);
|
||||||
|
setPage(data.page);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '加载失败');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void reload(1, status);
|
||||||
|
}, [status]);
|
||||||
|
|
||||||
|
async function openDetail(id: string) {
|
||||||
|
setDetailOpen(true);
|
||||||
|
setDetailLoading(true);
|
||||||
|
setDetail(null);
|
||||||
|
try {
|
||||||
|
const data = await request<StorePackageAuditDetailDto>(`/admin/store-package-audits/${id}`);
|
||||||
|
setDetail(data);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '加载详情失败');
|
||||||
|
setDetailOpen(false);
|
||||||
|
} finally {
|
||||||
|
setDetailLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function audit(id: string, action: 'APPROVE' | 'REJECT', reason?: string) {
|
||||||
|
try {
|
||||||
|
await request(`/admin/store-package-audits/${id}/audit`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(
|
||||||
|
action === 'REJECT' ? { action, rejectReason: reason } : { action },
|
||||||
|
),
|
||||||
|
});
|
||||||
|
message.success(action === 'APPROVE' ? '已通过' : '已驳回');
|
||||||
|
setDetailOpen(false);
|
||||||
|
void reload(page, status);
|
||||||
|
} catch (e) {
|
||||||
|
message.error(e instanceof Error ? e.message : '操作失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const diffRows = detail ? diffPackages(detail.livePackages ?? [], detail.packages ?? []) : [];
|
||||||
|
|
||||||
|
const diffColumns: ColumnsType<(typeof diffRows)[number]> = [
|
||||||
|
{
|
||||||
|
title: '变更',
|
||||||
|
dataIndex: 'change',
|
||||||
|
width: 72,
|
||||||
|
render: (v: keyof typeof CHANGE_LABELS) => {
|
||||||
|
const meta = CHANGE_LABELS[v];
|
||||||
|
return <Tag color={meta.color}>{meta.text}</Tag>;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '当前线上',
|
||||||
|
render: (_, row) =>
|
||||||
|
row.live ? (
|
||||||
|
<div>
|
||||||
|
<div><strong>{row.live.name}</strong> · ¥{row.live.price}</div>
|
||||||
|
<Typography.Text type="secondary">{row.live.dishes}</Typography.Text>
|
||||||
|
{row.live.usableTime ? (
|
||||||
|
<div><Typography.Text type="secondary">可用:{row.live.usableTime}</Typography.Text></div>
|
||||||
|
) : null}
|
||||||
|
{row.live.otherNotes ? (
|
||||||
|
<div><Typography.Text type="secondary">备注:{row.live.otherNotes}</Typography.Text></div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
'—'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '申请变更',
|
||||||
|
render: (_, row) =>
|
||||||
|
row.proposed ? (
|
||||||
|
<div>
|
||||||
|
<div><strong>{row.proposed.name}</strong> · ¥{row.proposed.price}</div>
|
||||||
|
<Typography.Text type="secondary">{row.proposed.dishes}</Typography.Text>
|
||||||
|
{row.proposed.usableTime ? (
|
||||||
|
<div><Typography.Text type="secondary">可用:{row.proposed.usableTime}</Typography.Text></div>
|
||||||
|
) : null}
|
||||||
|
{row.proposed.otherNotes ? (
|
||||||
|
<div><Typography.Text type="secondary">备注:{row.proposed.otherNotes}</Typography.Text></div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
'—'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const columns: ColumnsType<StorePackageChangeRequestDto> = [
|
||||||
|
{ title: '门店', dataIndex: 'storeName', render: (_, row) => row.storeName || row.storeId },
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
render: (v: StorePackageChangeRequestDto['status']) => (
|
||||||
|
<Tag>{STORE_PACKAGE_CHANGE_STATUS_LABELS[v] ?? v}</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '套餐数',
|
||||||
|
render: (_, row) => row.packages?.length ?? 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '提交方',
|
||||||
|
render: (_, row) => (row.submitterType === 'PARTNER' ? '合伙人' : '门店'),
|
||||||
|
},
|
||||||
|
{ title: '提交时间', dataIndex: 'createdAt', render: (v) => fmtTime(String(v)) },
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
render: (_, row) => (
|
||||||
|
<Space>
|
||||||
|
<Button type="link" onClick={() => void openDetail(row.id)}>
|
||||||
|
查看变更
|
||||||
|
</Button>
|
||||||
|
{row.status === 'PENDING' ? (
|
||||||
|
<>
|
||||||
|
<Button type="link" onClick={() => void audit(row.id, 'APPROVE')}>
|
||||||
|
通过
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
onClick={() => {
|
||||||
|
setActiveId(row.id);
|
||||||
|
setRejectReason('');
|
||||||
|
setRejectOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
row.rejectReason || null
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography.Title level={4}>套餐变更审核</Typography.Title>
|
||||||
|
<Space style={{ marginBottom: 16 }}>
|
||||||
|
{(['PENDING', 'APPROVED', 'REJECTED', ''] as const).map((s) => (
|
||||||
|
<Button key={s || 'all'} type={status === s ? 'primary' : 'default'} onClick={() => setStatus(s)}>
|
||||||
|
{s ? STORE_PACKAGE_CHANGE_STATUS_LABELS[s as keyof typeof STORE_PACKAGE_CHANGE_STATUS_LABELS] : '全部'}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={items}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
total,
|
||||||
|
pageSize: 20,
|
||||||
|
onChange: (p) => void reload(p, status),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Drawer
|
||||||
|
title={detail ? `${detail.storeName || detail.storeId} · 套餐变更` : '套餐变更详情'}
|
||||||
|
width={720}
|
||||||
|
open={detailOpen}
|
||||||
|
onClose={() => setDetailOpen(false)}
|
||||||
|
extra={
|
||||||
|
detail?.status === 'PENDING' ? (
|
||||||
|
<Space>
|
||||||
|
<Button onClick={() => void audit(detail.id, 'APPROVE')}>通过</Button>
|
||||||
|
<Button
|
||||||
|
danger
|
||||||
|
onClick={() => {
|
||||||
|
setActiveId(detail.id);
|
||||||
|
setRejectReason('');
|
||||||
|
setRejectOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{detailLoading ? (
|
||||||
|
<Typography.Text type="secondary">加载中…</Typography.Text>
|
||||||
|
) : detail ? (
|
||||||
|
<>
|
||||||
|
<Space style={{ marginBottom: 16 }}>
|
||||||
|
<Tag>{STORE_PACKAGE_CHANGE_STATUS_LABELS[detail.status]}</Tag>
|
||||||
|
<Typography.Text type="secondary">
|
||||||
|
提交方:{detail.submitterType === 'PARTNER' ? '合伙人' : '门店'} · {fmtTime(detail.createdAt)}
|
||||||
|
</Typography.Text>
|
||||||
|
</Space>
|
||||||
|
{detail.rejectReason ? (
|
||||||
|
<Typography.Paragraph type="danger">驳回原因:{detail.rejectReason}</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
线上 {detail.livePackages?.length ?? 0} 条 → 申请 {detail.packages?.length ?? 0} 条
|
||||||
|
</Typography.Paragraph>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey="key"
|
||||||
|
columns={diffColumns}
|
||||||
|
dataSource={diffRows}
|
||||||
|
pagination={false}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</Drawer>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="驳回套餐变更"
|
||||||
|
open={rejectOpen}
|
||||||
|
onCancel={() => setRejectOpen(false)}
|
||||||
|
onOk={() => {
|
||||||
|
if (!activeId) return;
|
||||||
|
if (!rejectReason.trim()) {
|
||||||
|
message.warning('请填写驳回原因');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void audit(activeId, 'REJECT', rejectReason.trim());
|
||||||
|
setRejectOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
value={rejectReason}
|
||||||
|
placeholder="驳回原因"
|
||||||
|
onChange={(e) => setRejectReason(e.target.value)}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Button, Form, Input, Table, Typography } from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
import { fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
|
||||||
|
type Row = {
|
||||||
|
id: string;
|
||||||
|
serviceScore: number;
|
||||||
|
envScore: number;
|
||||||
|
createdAt: string;
|
||||||
|
redeemNo: string;
|
||||||
|
redeemAmount: number;
|
||||||
|
store?: { id: string; name: string; cityName?: string };
|
||||||
|
user?: { userNo: string; phone: string | null; nickname: string | null };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function StoreRatingsPage() {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
|
const initialStoreId = searchParams.get('storeId') || '';
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const [filters, setFilters] = useState<Record<string, string>>({
|
||||||
|
...(initialStoreId ? { storeId: initialStoreId } : {}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data, loading, page, pageSize, setPage, setPageSize } = useAdminList<Row>(
|
||||||
|
'/admin/store-ratings',
|
||||||
|
() => {
|
||||||
|
const qs = new URLSearchParams();
|
||||||
|
if (filters.storeId) qs.set('storeId', filters.storeId);
|
||||||
|
if (filters.redeemNo) qs.set('redeemNo', filters.redeemNo);
|
||||||
|
return qs;
|
||||||
|
},
|
||||||
|
[filters],
|
||||||
|
);
|
||||||
|
|
||||||
|
const columns: ColumnsType<Row> = [
|
||||||
|
{ title: '核销号', dataIndex: 'redeemNo', width: 180 },
|
||||||
|
{
|
||||||
|
title: '门店',
|
||||||
|
dataIndex: ['store', 'name'],
|
||||||
|
render: (v, row) => (row.store?.cityName ? `${v}(${row.store.cityName})` : v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户',
|
||||||
|
width: 140,
|
||||||
|
render: (_, row) => row.user?.phone || row.user?.userNo || '-',
|
||||||
|
},
|
||||||
|
{ title: '核销额', dataIndex: 'redeemAmount', width: 90, render: (v) => `¥${v}` },
|
||||||
|
{ title: '服务分', dataIndex: 'serviceScore', width: 80 },
|
||||||
|
{ title: '环境分', dataIndex: 'envScore', width: 80 },
|
||||||
|
{ title: '评价时间', dataIndex: 'createdAt', width: 170, render: fmtTime },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
||||||
|
门店评价
|
||||||
|
</Typography.Title>
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="inline"
|
||||||
|
style={{ marginBottom: 16 }}
|
||||||
|
initialValues={filters}
|
||||||
|
onFinish={(v) => {
|
||||||
|
setFilters({
|
||||||
|
storeId: v.storeId || '',
|
||||||
|
redeemNo: v.redeemNo || '',
|
||||||
|
});
|
||||||
|
setPage(1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Form.Item name="storeId" label="门店ID">
|
||||||
|
<Input allowClear placeholder="storeId" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="redeemNo" label="核销号">
|
||||||
|
<Input allowClear />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item>
|
||||||
|
<Button type="primary" htmlType="submit">
|
||||||
|
查询
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={data?.items ?? []}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize,
|
||||||
|
total: data?.total ?? 0,
|
||||||
|
showSizeChanger: true,
|
||||||
|
onChange: (p, ps) => {
|
||||||
|
setPage(p);
|
||||||
|
setPageSize(ps);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,394 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
DatePicker,
|
||||||
|
Descriptions,
|
||||||
|
Drawer,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Table,
|
||||||
|
Tag,
|
||||||
|
Typography,
|
||||||
|
message,
|
||||||
|
} from 'antd';
|
||||||
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
import { STORE_WITHDRAW_STATUS_LABELS, type StoreWithdrawStatus } from '@dukang/shared-types';
|
||||||
|
import { request, type Paginated } from '../lib/api';
|
||||||
|
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||||
|
import { useAdminList } from '../lib/useAdminList';
|
||||||
|
|
||||||
|
type Row = {
|
||||||
|
id: string;
|
||||||
|
withdrawNo: string;
|
||||||
|
amount: number;
|
||||||
|
payoutCount: number;
|
||||||
|
status: StoreWithdrawStatus;
|
||||||
|
appliedAt: string;
|
||||||
|
reviewedAt?: string | null;
|
||||||
|
paidAt?: string | null;
|
||||||
|
paymentRef?: string | null;
|
||||||
|
rejectReason?: string | null;
|
||||||
|
overdue?: boolean;
|
||||||
|
store?: { id: string; name: string; cityName: string; phone?: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
type StoreOption = { id: string; name: string; phone: string };
|
||||||
|
|
||||||
|
const STATUS_COLORS: Record<string, string> = {
|
||||||
|
PENDING_REVIEW: 'orange',
|
||||||
|
REJECTED: 'red',
|
||||||
|
PAID: 'green',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function StoreWithdrawalsPage() {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const [filters, setFilters] = useState<Record<string, string>>({ status: 'PENDING_REVIEW' });
|
||||||
|
const [stores, setStores] = useState<StoreOption[]>([]);
|
||||||
|
const { data, loading, page, pageSize, setPage, setPageSize, reload } = useAdminList<Row>(
|
||||||
|
'/admin/store-withdrawals',
|
||||||
|
() => {
|
||||||
|
const qs = new URLSearchParams();
|
||||||
|
if (filters.status) qs.set('status', filters.status);
|
||||||
|
if (filters.storeId) qs.set('storeId', filters.storeId);
|
||||||
|
if (filters.dateFrom) qs.set('dateFrom', filters.dateFrom);
|
||||||
|
if (filters.dateTo) qs.set('dateTo', filters.dateTo);
|
||||||
|
return qs;
|
||||||
|
},
|
||||||
|
[filters],
|
||||||
|
);
|
||||||
|
const [detail, setDetail] = useState<Record<string, unknown> | null>(null);
|
||||||
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
|
const [overdueSummary, setOverdueSummary] = useState<{
|
||||||
|
pendingCount: number;
|
||||||
|
overdueCount: number;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void request<Paginated<StoreOption>>(`/admin/stores?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||||
|
.then((res) => setStores(res.items))
|
||||||
|
.catch(() => {});
|
||||||
|
void request<{ pendingCount: number; overdueCount: number }>(
|
||||||
|
'/admin/store-withdrawals/overdue-summary',
|
||||||
|
)
|
||||||
|
.then(setOverdueSummary)
|
||||||
|
.catch(() => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function openDetail(id: string) {
|
||||||
|
const d = await request<Record<string, unknown>>(`/admin/store-withdrawals/${id}`);
|
||||||
|
setDetail(d);
|
||||||
|
setDrawerOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function approve(id: string) {
|
||||||
|
let paymentRef = '';
|
||||||
|
Modal.confirm({
|
||||||
|
title: '审核通过并标记已结算?',
|
||||||
|
content: (
|
||||||
|
<Input
|
||||||
|
placeholder="打款凭证号(可选)"
|
||||||
|
onChange={(e) => {
|
||||||
|
paymentRef = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
okText: '通过并结算',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: async () => {
|
||||||
|
await request(`/admin/store-withdrawals/${id}/approve`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ paymentRef: paymentRef.trim() || undefined }),
|
||||||
|
});
|
||||||
|
message.success('已通过并标记已结算');
|
||||||
|
setDrawerOpen(false);
|
||||||
|
reload();
|
||||||
|
void request<{ pendingCount: number; overdueCount: number }>(
|
||||||
|
'/admin/store-withdrawals/overdue-summary',
|
||||||
|
)
|
||||||
|
.then(setOverdueSummary)
|
||||||
|
.catch(() => {});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reject(id: string) {
|
||||||
|
let reason = '';
|
||||||
|
Modal.confirm({
|
||||||
|
title: '驳回提现申请?',
|
||||||
|
content: (
|
||||||
|
<Input.TextArea
|
||||||
|
rows={3}
|
||||||
|
placeholder="请填写驳回理由"
|
||||||
|
onChange={(e) => {
|
||||||
|
reason = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
okText: '确认驳回',
|
||||||
|
okButtonProps: { danger: true },
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: async () => {
|
||||||
|
if (!reason.trim()) {
|
||||||
|
message.error('请填写驳回理由');
|
||||||
|
throw new Error('reason required');
|
||||||
|
}
|
||||||
|
await request(`/admin/store-withdrawals/${id}/reject`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ reason: reason.trim() }),
|
||||||
|
});
|
||||||
|
message.success('已驳回');
|
||||||
|
setDrawerOpen(false);
|
||||||
|
reload();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns: ColumnsType<Row> = [
|
||||||
|
{
|
||||||
|
title: '提现单号',
|
||||||
|
dataIndex: 'withdrawNo',
|
||||||
|
width: 180,
|
||||||
|
render: (v, row) => (
|
||||||
|
<Space>
|
||||||
|
<Typography.Link onClick={() => void openDetail(row.id)}>{v}</Typography.Link>
|
||||||
|
{row.overdue ? <Tag color="magenta">超时</Tag> : null}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '门店',
|
||||||
|
dataIndex: ['store', 'name'],
|
||||||
|
width: 160,
|
||||||
|
render: (_, row) => (
|
||||||
|
<div>
|
||||||
|
<div>{row.store?.name || '—'}</div>
|
||||||
|
<Typography.Text type="secondary" style={{ fontSize: 12 }}>
|
||||||
|
{row.store?.cityName} {row.store?.phone}
|
||||||
|
</Typography.Text>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '金额',
|
||||||
|
dataIndex: 'amount',
|
||||||
|
width: 110,
|
||||||
|
render: (v) => `¥${Number(v).toFixed(2)}`,
|
||||||
|
},
|
||||||
|
{ title: '明细笔数', dataIndex: 'payoutCount', width: 90 },
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'status',
|
||||||
|
width: 100,
|
||||||
|
render: (v: StoreWithdrawStatus) => (
|
||||||
|
<Tag color={STATUS_COLORS[v]}>{STORE_WITHDRAW_STATUS_LABELS[v] ?? v}</Tag>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '申请时间',
|
||||||
|
dataIndex: 'appliedAt',
|
||||||
|
width: 170,
|
||||||
|
render: (v) => fmtTime(v),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'actions',
|
||||||
|
width: 180,
|
||||||
|
fixed: 'right',
|
||||||
|
render: (_, row) => (
|
||||||
|
<Space>
|
||||||
|
<Button size="small" onClick={() => void openDetail(row.id)}>
|
||||||
|
详情
|
||||||
|
</Button>
|
||||||
|
{row.status === 'PENDING_REVIEW' ? (
|
||||||
|
<>
|
||||||
|
<Button size="small" type="primary" onClick={() => approve(row.id)}>
|
||||||
|
通过
|
||||||
|
</Button>
|
||||||
|
<Button size="small" danger onClick={() => reject(row.id)}>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const detailItems = (detail?.items as Array<Record<string, unknown>> | undefined) ?? [];
|
||||||
|
const storeAccount = detail?.storeAccount as
|
||||||
|
| {
|
||||||
|
name?: string;
|
||||||
|
phone?: string;
|
||||||
|
bankAccountName?: string;
|
||||||
|
bankAccountNo?: string;
|
||||||
|
bankBranch?: string;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography.Title level={4} style={{ marginTop: 0 }}>
|
||||||
|
门店提现审
|
||||||
|
</Typography.Title>
|
||||||
|
{overdueSummary ? (
|
||||||
|
<Typography.Paragraph type="secondary">
|
||||||
|
待审 {overdueSummary.pendingCount} 笔
|
||||||
|
{overdueSummary.overdueCount > 0 ? (
|
||||||
|
<Typography.Text type="danger">
|
||||||
|
{' '}
|
||||||
|
· 超时未审 {overdueSummary.overdueCount} 笔(FIN-003)
|
||||||
|
</Typography.Text>
|
||||||
|
) : null}
|
||||||
|
</Typography.Paragraph>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="inline"
|
||||||
|
style={{ marginBottom: 16, gap: 8 }}
|
||||||
|
initialValues={{ status: 'PENDING_REVIEW' }}
|
||||||
|
onFinish={(v) => {
|
||||||
|
const range = v.range as [Dayjs, Dayjs] | undefined;
|
||||||
|
setFilters({
|
||||||
|
status: v.status || '',
|
||||||
|
storeId: v.storeId || '',
|
||||||
|
dateFrom: range?.[0]?.format('YYYY-MM-DD') || '',
|
||||||
|
dateTo: range?.[1]?.format('YYYY-MM-DD') || '',
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Form.Item name="status" label="状态">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
style={{ width: 140 }}
|
||||||
|
options={[
|
||||||
|
{ value: 'PENDING_REVIEW', label: '待审核' },
|
||||||
|
{ value: 'PAID', label: '已结算' },
|
||||||
|
{ value: 'REJECTED', label: '已驳回' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="storeId" label="门店">
|
||||||
|
<Select
|
||||||
|
allowClear
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
|
style={{ width: 220 }}
|
||||||
|
options={stores.map((s) => ({
|
||||||
|
value: s.id,
|
||||||
|
label: `${s.name} (${s.phone})`,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="range" label="申请日">
|
||||||
|
<DatePicker.RangePicker />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item>
|
||||||
|
<Button type="primary" htmlType="submit">
|
||||||
|
查询
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
<Table
|
||||||
|
rowKey="id"
|
||||||
|
loading={loading}
|
||||||
|
columns={columns}
|
||||||
|
dataSource={data?.items ?? []}
|
||||||
|
scroll={{ x: 1100 }}
|
||||||
|
rowClassName={(row) => (row.overdue ? 'ant-table-row-selected' : '')}
|
||||||
|
pagination={{
|
||||||
|
current: page,
|
||||||
|
pageSize,
|
||||||
|
total: data?.total ?? 0,
|
||||||
|
showSizeChanger: true,
|
||||||
|
onChange: (p, ps) => {
|
||||||
|
setPage(p);
|
||||||
|
setPageSize(ps);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Drawer
|
||||||
|
title="提现详情"
|
||||||
|
width={640}
|
||||||
|
open={drawerOpen}
|
||||||
|
onClose={() => setDrawerOpen(false)}
|
||||||
|
extra={
|
||||||
|
detail?.status === 'PENDING_REVIEW' ? (
|
||||||
|
<Space>
|
||||||
|
<Button type="primary" onClick={() => approve(String(detail.id))}>
|
||||||
|
通过
|
||||||
|
</Button>
|
||||||
|
<Button danger onClick={() => reject(String(detail.id))}>
|
||||||
|
驳回
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{detail ? (
|
||||||
|
<>
|
||||||
|
<Descriptions column={1} size="small" bordered>
|
||||||
|
<Descriptions.Item label="提现单号">{String(detail.withdrawNo)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="状态">
|
||||||
|
<Tag color={STATUS_COLORS[String(detail.status)]}>
|
||||||
|
{STORE_WITHDRAW_STATUS_LABELS[detail.status as StoreWithdrawStatus] ??
|
||||||
|
String(detail.status)}
|
||||||
|
</Tag>
|
||||||
|
{detail.overdue ? <Tag color="magenta">超时</Tag> : null}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="金额">¥{Number(detail.amount).toFixed(2)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="明细笔数">{String(detail.payoutCount)}</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="申请时间">{fmtTime(String(detail.appliedAt))}</Descriptions.Item>
|
||||||
|
{detail.rejectReason ? (
|
||||||
|
<Descriptions.Item label="驳回理由">{String(detail.rejectReason)}</Descriptions.Item>
|
||||||
|
) : null}
|
||||||
|
{detail.paymentRef ? (
|
||||||
|
<Descriptions.Item label="打款凭证">{String(detail.paymentRef)}</Descriptions.Item>
|
||||||
|
) : null}
|
||||||
|
<Descriptions.Item label="收款户名">
|
||||||
|
{storeAccount?.bankAccountName || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="收款账号">
|
||||||
|
{storeAccount?.bankAccountNo || '—'}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="开户行">{storeAccount?.bankBranch || '—'}</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
|
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 24 }}>
|
||||||
|
关联结算明细
|
||||||
|
</Typography.Title>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey={(r) => String((r as { id?: string }).id)}
|
||||||
|
pagination={false}
|
||||||
|
dataSource={detailItems}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: '核销单号',
|
||||||
|
render: (_, r) => {
|
||||||
|
const payout = (r as { storePayout?: { redeemRecord?: { redeemNo?: string } } })
|
||||||
|
.storePayout;
|
||||||
|
return payout?.redeemRecord?.redeemNo || '—';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '结算额',
|
||||||
|
render: (_, r) => {
|
||||||
|
const payout = (r as { storePayout?: { payoutAmount?: number } }).storePayout;
|
||||||
|
return `¥${Number(payout?.payoutAmount ?? 0).toFixed(2)}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</Drawer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
Steps,
|
Steps,
|
||||||
|
Switch,
|
||||||
Table,
|
Table,
|
||||||
Tabs,
|
Tabs,
|
||||||
Tag,
|
Tag,
|
||||||
@@ -20,6 +21,7 @@ import {
|
|||||||
message,
|
message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
|
import type { FormInstance } from 'antd/es/form';
|
||||||
import { FilePdfOutlined, LinkOutlined, EnvironmentOutlined } from '@ant-design/icons';
|
import { FilePdfOutlined, LinkOutlined, EnvironmentOutlined } from '@ant-design/icons';
|
||||||
import { request, type Paginated } from '../lib/api';
|
import { request, type Paginated } from '../lib/api';
|
||||||
import {
|
import {
|
||||||
@@ -39,6 +41,7 @@ import { resolveRegionBinding } from '../lib/china-region';
|
|||||||
import ChinaRegionCascader from '../components/ChinaRegionCascader';
|
import ChinaRegionCascader from '../components/ChinaRegionCascader';
|
||||||
import OssUpload from '../components/OssUpload';
|
import OssUpload from '../components/OssUpload';
|
||||||
import TencentLocPickerModal from '../components/TencentLocPickerModal';
|
import TencentLocPickerModal from '../components/TencentLocPickerModal';
|
||||||
|
import AdminStorePackagesSection from '../components/AdminStorePackagesSection';
|
||||||
|
|
||||||
const CREATE_STEPS = [
|
const CREATE_STEPS = [
|
||||||
{ title: '基本信息' },
|
{ title: '基本信息' },
|
||||||
@@ -274,6 +277,89 @@ function StoreAuditMediaSection({ detail }: { detail: Record<string, unknown> })
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserPickRow = { id: string; phone?: string | null; nickname?: string | null; userNo?: string | null };
|
||||||
|
|
||||||
|
function StoreVisibilityWhitelistFields({ form }: { form: FormInstance }) {
|
||||||
|
const [userOptions, setUserOptions] = useState<UserPickRow[]>([]);
|
||||||
|
const [userSearching, setUserSearching] = useState(false);
|
||||||
|
const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
|
async function searchUsers(keyword: string) {
|
||||||
|
const q = keyword.trim();
|
||||||
|
if (searchTimer.current) clearTimeout(searchTimer.current);
|
||||||
|
if (!q) {
|
||||||
|
setUserOptions([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
searchTimer.current = setTimeout(() => {
|
||||||
|
void (async () => {
|
||||||
|
setUserSearching(true);
|
||||||
|
try {
|
||||||
|
const qs = new URLSearchParams({ page: '1', pageSize: '20', phone: q });
|
||||||
|
const res = await request<{ items: UserPickRow[] }>(`/admin/users?${qs}`);
|
||||||
|
setUserOptions((res.items ?? []).filter((u) => !!u.phone));
|
||||||
|
} catch {
|
||||||
|
setUserOptions([]);
|
||||||
|
} finally {
|
||||||
|
setUserSearching(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
const enabled = Form.useWatch('visibilityWhitelistEnabled', form);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Form.Item
|
||||||
|
name="visibilityWhitelistEnabled"
|
||||||
|
label="可见白名单"
|
||||||
|
valuePropName="checked"
|
||||||
|
extra="开启后仅名单内手机号在 C 端可见,用于在线测试"
|
||||||
|
>
|
||||||
|
<Switch checkedChildren="开" unCheckedChildren="关" />
|
||||||
|
</Form.Item>
|
||||||
|
{enabled ? (
|
||||||
|
<>
|
||||||
|
<Form.Item
|
||||||
|
name="visibilityPhones"
|
||||||
|
label="白名单手机号"
|
||||||
|
rules={[{ required: true, message: '请至少添加一个手机号' }]}
|
||||||
|
extra="可直接输入多个手机号回车添加,或从下方用户库选择"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
mode="tags"
|
||||||
|
tokenSeparators={[',', ' ', ',', ';', ';']}
|
||||||
|
placeholder="输入手机号后回车"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="从用户库添加">
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
filterOption={false}
|
||||||
|
placeholder="按手机号搜索用户"
|
||||||
|
loading={userSearching}
|
||||||
|
options={userOptions.map((u) => ({
|
||||||
|
value: u.phone!,
|
||||||
|
label: `${u.phone}${u.nickname ? ` · ${u.nickname}` : ''}${u.userNo ? `(${u.userNo})` : ''}`,
|
||||||
|
}))}
|
||||||
|
onSearch={searchUsers}
|
||||||
|
onSelect={(phone: string) => {
|
||||||
|
const cur = (form.getFieldValue('visibilityPhones') as string[] | undefined) ?? [];
|
||||||
|
if (!cur.includes(phone)) {
|
||||||
|
form.setFieldsValue({ visibilityPhones: [...cur, phone] });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
notFoundContent={userSearching ? '搜索中…' : '输入手机号搜索'}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type StoreRow = {
|
type StoreRow = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -287,6 +373,8 @@ type StoreRow = {
|
|||||||
intro: string | null;
|
intro: string | null;
|
||||||
coverUrl: string | null;
|
coverUrl: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
visibilityWhitelistEnabled?: boolean;
|
||||||
|
visibilityPhones?: string[];
|
||||||
cityRef?: { name: string; code: string };
|
cityRef?: { name: string; code: string };
|
||||||
partner?: { companyName: string };
|
partner?: { companyName: string };
|
||||||
account?: {
|
account?: {
|
||||||
@@ -504,6 +592,10 @@ export default function StoresPage() {
|
|||||||
bankAccountName: account?.bankAccountName || undefined,
|
bankAccountName: account?.bankAccountName || undefined,
|
||||||
bankAccountNo: account?.bankAccountNo || undefined,
|
bankAccountNo: account?.bankAccountNo || undefined,
|
||||||
bankBranch: account?.bankBranch || undefined,
|
bankBranch: account?.bankBranch || undefined,
|
||||||
|
visibilityWhitelistEnabled: !!d.visibilityWhitelistEnabled,
|
||||||
|
visibilityPhones: Array.isArray(d.visibilityPhones)
|
||||||
|
? (d.visibilityPhones as string[])
|
||||||
|
: [],
|
||||||
});
|
});
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
@@ -543,6 +635,10 @@ export default function StoresPage() {
|
|||||||
bankAccountName: v.bankAccountName ?? null,
|
bankAccountName: v.bankAccountName ?? null,
|
||||||
bankAccountNo: v.bankAccountNo ?? null,
|
bankAccountNo: v.bankAccountNo ?? null,
|
||||||
bankBranch: v.bankBranch ?? null,
|
bankBranch: v.bankBranch ?? null,
|
||||||
|
visibilityWhitelistEnabled: !!v.visibilityWhitelistEnabled,
|
||||||
|
visibilityPhones: ((v.visibilityPhones as string[] | undefined) ?? [])
|
||||||
|
.map((p) => String(p || '').replace(/\D/g, '').trim())
|
||||||
|
.filter(Boolean),
|
||||||
...(hasCoords
|
...(hasCoords
|
||||||
? { latitude: Number(v.latitude), longitude: Number(v.longitude) }
|
? { latitude: Number(v.latitude), longitude: Number(v.longitude) }
|
||||||
: {}),
|
: {}),
|
||||||
@@ -632,6 +728,8 @@ export default function StoresPage() {
|
|||||||
openTime2: undefined,
|
openTime2: undefined,
|
||||||
closeTime2: undefined,
|
closeTime2: undefined,
|
||||||
avgPrice: undefined,
|
avgPrice: undefined,
|
||||||
|
visibilityWhitelistEnabled: false,
|
||||||
|
visibilityPhones: [],
|
||||||
});
|
});
|
||||||
setCreateStep(0);
|
setCreateStep(0);
|
||||||
setCreateError('');
|
setCreateError('');
|
||||||
@@ -713,6 +811,10 @@ export default function StoresPage() {
|
|||||||
bankAccountNo: values.bankAccountNo.replace(/\s/g, ''),
|
bankAccountNo: values.bankAccountNo.replace(/\s/g, ''),
|
||||||
bankBranch: values.bankBranch.trim(),
|
bankBranch: values.bankBranch.trim(),
|
||||||
settlementRate: Number(values.settlementRate ?? 60) / 100,
|
settlementRate: Number(values.settlementRate ?? 60) / 100,
|
||||||
|
visibilityWhitelistEnabled: !!values.visibilityWhitelistEnabled,
|
||||||
|
visibilityPhones: (values.visibilityPhones ?? [])
|
||||||
|
.map((p: string) => String(p || '').replace(/\D/g, '').trim())
|
||||||
|
.filter(Boolean),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
message.success('门店已创建');
|
message.success('门店已创建');
|
||||||
@@ -766,13 +868,23 @@ export default function StoresPage() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ title: '开城合伙人', dataIndex: ['partner', 'companyName'], width: 120 },
|
{ title: '开城合伙人', dataIndex: ['partner', 'companyName'], width: 120 },
|
||||||
|
{
|
||||||
|
title: '可见',
|
||||||
|
dataIndex: 'visibilityWhitelistEnabled',
|
||||||
|
width: 90,
|
||||||
|
render: (v, row) =>
|
||||||
|
v ? <Tag color="orange">限{row.visibilityPhones?.length ?? 0}人</Tag> : <Tag>公开</Tag>,
|
||||||
|
},
|
||||||
{ title: '介绍', dataIndex: 'intro', width: 160, ellipsis: true, render: (v) => v || '—' },
|
{ title: '介绍', dataIndex: 'intro', width: 160, ellipsis: true, render: (v) => v || '—' },
|
||||||
{ title: '店长', dataIndex: ['account', 'name'], width: 90, render: (v) => v || '—' },
|
{ title: '店长', dataIndex: ['account', 'name'], width: 90, render: (v) => v || '—' },
|
||||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||||
{
|
{
|
||||||
title: '操作', width: 80,
|
title: '操作', width: 140,
|
||||||
render: (_, row) => (
|
render: (_, row) => (
|
||||||
<Button type="link" size="small" onClick={() => void openStoreDetail(row)}>详情</Button>
|
<Space size={0}>
|
||||||
|
<Button type="link" size="small" onClick={() => void openStoreDetail(row)}>详情</Button>
|
||||||
|
<Button type="link" size="small" onClick={() => navigate(`/store-ratings?storeId=${row.id}`)}>评价</Button>
|
||||||
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -1056,6 +1168,7 @@ export default function StoresPage() {
|
|||||||
<Input type="time" style={{ width: 140 }} />
|
<Input type="time" style={{ width: 140 }} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Space>
|
</Space>
|
||||||
|
<StoreVisibilityWhitelistFields form={editForm} />
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -1102,6 +1215,11 @@ export default function StoresPage() {
|
|||||||
label: '审核材料',
|
label: '审核材料',
|
||||||
children: <StoreAuditMediaSection detail={detail} />,
|
children: <StoreAuditMediaSection detail={detail} />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'packages',
|
||||||
|
label: '套餐',
|
||||||
|
children: <AdminStorePackagesSection storeId={String(detail.id)} />,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
@@ -1276,6 +1394,7 @@ export default function StoresPage() {
|
|||||||
>
|
>
|
||||||
<Input.TextArea rows={3} placeholder="选填,最多1000字" showCount maxLength={1000} />
|
<Input.TextArea rows={3} placeholder="选填,最多1000字" showCount maxLength={1000} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<StoreVisibilityWhitelistFields form={createForm} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: createStep === 1 ? 'block' : 'none' }}>
|
<div style={{ display: createStep === 1 ? 'block' : 'none' }}>
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Paragraph type="secondary">
|
||||||
@@ -1285,14 +1404,20 @@ export default function StoresPage() {
|
|||||||
<OssUpload bizType="STORE_TITLE" mediaType="IMAGE" />
|
<OssUpload bizType="STORE_TITLE" mediaType="IMAGE" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Typography.Text strong>环境照片</Typography.Text>
|
<Typography.Text strong>环境照片</Typography.Text>
|
||||||
|
<Typography.Paragraph type="secondary" style={{ marginTop: 4 }}>
|
||||||
|
至少 3 张,可继续添加
|
||||||
|
</Typography.Paragraph>
|
||||||
<Form.List name="envPhotoUrls">
|
<Form.List name="envPhotoUrls">
|
||||||
{(fields) => (
|
{(fields, { add }) => (
|
||||||
<div style={{ marginTop: 8 }}>
|
<div style={{ marginTop: 8 }}>
|
||||||
{fields.map((field, index) => (
|
{fields.map((field, index) => (
|
||||||
<Form.Item key={field.key} name={field.name} label={`环境图 ${index + 1}`}>
|
<Form.Item key={field.key} name={field.name} label={`环境图 ${index + 1}`}>
|
||||||
<OssUpload bizType="STORE_ENV" mediaType="IMAGE" />
|
<OssUpload bizType="STORE_ENV" mediaType="IMAGE" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))}
|
))}
|
||||||
|
<Button type="dashed" onClick={() => add('')} block>
|
||||||
|
添加环境照片
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ export default function TicketsPage() {
|
|||||||
{ value: 'RESHIPMENT', label: '破损补发' },
|
{ value: 'RESHIPMENT', label: '破损补发' },
|
||||||
{ value: 'DAMAGE_RETURN', label: '破损退货' },
|
{ value: 'DAMAGE_RETURN', label: '破损退货' },
|
||||||
{ value: 'RETURN_REFUND', label: '退货退款' },
|
{ value: 'RETURN_REFUND', label: '退货退款' },
|
||||||
|
{ value: 'PACKAGE_DISPUTE', label: '套餐异议' },
|
||||||
{ value: 'ALERT', label: '异常' },
|
{ value: 'ALERT', label: '异常' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
message,
|
message,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { ColumnsType } from 'antd/es/table';
|
import type { ColumnsType } from 'antd/es/table';
|
||||||
import { USER_SOURCE_TYPE_LABELS, type UserSourceType } from '@dukang/shared-types';
|
import { USER_SOURCE_TYPE_LABELS, resolveUserLogCategory, type UserSourceType } from '@dukang/shared-types';
|
||||||
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
||||||
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||||
|
|
||||||
@@ -30,6 +30,14 @@ type UserOrderRow = {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type UserBehaviorLog = {
|
||||||
|
id: string;
|
||||||
|
eventName: string;
|
||||||
|
clientApp?: string | null;
|
||||||
|
createdAt: string;
|
||||||
|
extraJson?: Record<string, unknown> | null;
|
||||||
|
};
|
||||||
|
|
||||||
type UserDetail = AdminUserRow & {
|
type UserDetail = AdminUserRow & {
|
||||||
wxUnionId?: string | null;
|
wxUnionId?: string | null;
|
||||||
cityPref?: Record<string, unknown> | null;
|
cityPref?: Record<string, unknown> | null;
|
||||||
@@ -72,6 +80,7 @@ export default function UsersPage() {
|
|||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [pageSize, setPageSize] = useState(20);
|
const [pageSize, setPageSize] = useState(20);
|
||||||
const [detail, setDetail] = useState<UserDetail | null>(null);
|
const [detail, setDetail] = useState<UserDetail | null>(null);
|
||||||
|
const [behaviorLogs, setBehaviorLogs] = useState<UserBehaviorLog[]>([]);
|
||||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||||
const [deleteConfirm, setDeleteConfirm] = useState('');
|
const [deleteConfirm, setDeleteConfirm] = useState('');
|
||||||
@@ -123,8 +132,14 @@ export default function UsersPage() {
|
|||||||
}, [location.state, location.pathname, navigate]);
|
}, [location.state, location.pathname, navigate]);
|
||||||
|
|
||||||
async function openDetail(id: string) {
|
async function openDetail(id: string) {
|
||||||
const res = await request<UserDetail>(`/admin/users/${id}`);
|
const [res, logs] = await Promise.all([
|
||||||
|
request<UserDetail>(`/admin/users/${id}`),
|
||||||
|
request<{ items: UserBehaviorLog[] }>(`/admin/logs/users?userId=${id}&pageSize=50`).catch(
|
||||||
|
() => ({ items: [] as UserBehaviorLog[] }),
|
||||||
|
),
|
||||||
|
]);
|
||||||
setDetail(res);
|
setDetail(res);
|
||||||
|
setBehaviorLogs(logs.items ?? []);
|
||||||
setDrawerOpen(true);
|
setDrawerOpen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,6 +452,28 @@ export default function UsersPage() {
|
|||||||
</Descriptions.Item>
|
</Descriptions.Item>
|
||||||
</Descriptions>
|
</Descriptions>
|
||||||
|
|
||||||
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
|
行为时间线(最近 {behaviorLogs.length} 条)
|
||||||
|
</Typography.Title>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
rowKey="id"
|
||||||
|
pagination={false}
|
||||||
|
scroll={{ y: 200 }}
|
||||||
|
dataSource={behaviorLogs}
|
||||||
|
locale={{ emptyText: '暂无行为日志' }}
|
||||||
|
columns={[
|
||||||
|
{ title: '时间', dataIndex: 'createdAt', width: 160, render: (v) => fmtTime(v) },
|
||||||
|
{
|
||||||
|
title: '分类',
|
||||||
|
width: 100,
|
||||||
|
render: (_, r) => resolveUserLogCategory(r.eventName) ?? '—',
|
||||||
|
},
|
||||||
|
{ title: '事件', dataIndex: 'eventName' },
|
||||||
|
{ title: '端', dataIndex: 'clientApp', width: 90 },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||||
全部订单({detail.orders?.length ?? 0})
|
全部订单({detail.orders?.length ?? 0})
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"lint": "echo ok"
|
"lint": "echo ok"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@dukang/client-logging": "workspace:*",
|
||||||
"@dukang/shared-types": "workspace:*",
|
"@dukang/shared-types": "workspace:*",
|
||||||
"@dukang/shared-ui": "workspace:*",
|
"@dukang/shared-ui": "workspace:*",
|
||||||
"@dukang/weixin-sdk": "workspace:*",
|
"@dukang/weixin-sdk": "workspace:*",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import SubAccountLayout from './layouts/SubAccountLayout';
|
|||||||
import HomePage from './pages/HomePage';
|
import HomePage from './pages/HomePage';
|
||||||
import StoreListPage from './pages/StoreListPage';
|
import StoreListPage from './pages/StoreListPage';
|
||||||
import StoreDetailPage from './pages/StoreDetailPage';
|
import StoreDetailPage from './pages/StoreDetailPage';
|
||||||
|
import StorePackagesPage from './pages/StorePackagesPage';
|
||||||
import StoreCreatePage from './pages/StoreCreatePage';
|
import StoreCreatePage from './pages/StoreCreatePage';
|
||||||
import OrderListPage from './pages/OrderListPage';
|
import OrderListPage from './pages/OrderListPage';
|
||||||
import OrderDetailPage from './pages/OrderDetailPage';
|
import OrderDetailPage from './pages/OrderDetailPage';
|
||||||
@@ -31,6 +32,7 @@ function PrimaryRoutes() {
|
|||||||
<Route path="/center" element={<CenterPage />} />
|
<Route path="/center" element={<CenterPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/stores/new" element={<StoreCreatePage />} />
|
<Route path="/stores/new" element={<StoreCreatePage />} />
|
||||||
|
<Route path="/stores/:id/packages" element={<StorePackagesPage />} />
|
||||||
<Route path="/center/bills" element={<BillsPage />} />
|
<Route path="/center/bills" element={<BillsPage />} />
|
||||||
<Route path="/center/settlement" element={<SettlementPage />} />
|
<Route path="/center/settlement" element={<SettlementPage />} />
|
||||||
<Route path="/center/staff" element={<StaffListPage />} />
|
<Route path="/center/staff" element={<StaffListPage />} />
|
||||||
@@ -68,6 +70,7 @@ function SubAccountRoutes() {
|
|||||||
{!isWarehouse && (
|
{!isWarehouse && (
|
||||||
<>
|
<>
|
||||||
<Route path="/stores/new" element={<StoreCreatePage />} />
|
<Route path="/stores/new" element={<StoreCreatePage />} />
|
||||||
|
<Route path="/stores/:id/packages" element={<StorePackagesPage />} />
|
||||||
<Route path="/stores/:id" element={<StoreDetailPage />} />
|
<Route path="/stores/:id" element={<StoreDetailPage />} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import type { PackageFormItem } from '../lib/storePackages';
|
||||||
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
|
import { emptyPackage } from '../lib/storePackages';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
items: PackageFormItem[];
|
||||||
|
onChange: (items: PackageFormItem[]) => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
/** 嵌入拓店流程时不重复外层卡片边距 */
|
||||||
|
embedded?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function StorePackagesForm({ items, onChange, disabled, embedded }: Props) {
|
||||||
|
const [collapsed, setCollapsed] = useState<Record<number, boolean>>({});
|
||||||
|
|
||||||
|
function updateAt(index: number, patch: Partial<PackageFormItem>) {
|
||||||
|
const next = items.map((item, i) => (i === index ? { ...item, ...patch } : item));
|
||||||
|
onChange(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem() {
|
||||||
|
if (items.length >= STORE_PACKAGE_MAX_COUNT) return;
|
||||||
|
onChange([...items, emptyPackage(items.length)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAt(index: number) {
|
||||||
|
onChange(items.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })));
|
||||||
|
setCollapsed((prev) => {
|
||||||
|
const next: Record<number, boolean> = {};
|
||||||
|
Object.entries(prev).forEach(([k, v]) => {
|
||||||
|
const i = Number(k);
|
||||||
|
if (i < index) next[i] = v;
|
||||||
|
else if (i > index) next[i - 1] = v;
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCollapse(index: number) {
|
||||||
|
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = items.length ? items : [emptyPackage(0)];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`partner-packages-form${embedded ? ' partner-packages-form--embedded' : ''}`}>
|
||||||
|
{list.map((item, index) => {
|
||||||
|
const isCollapsed = !!collapsed[index];
|
||||||
|
const displayName = item.name.trim() || `套餐 ${index + 1}`;
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
key={index}
|
||||||
|
className={`partner-form-card partner-packages-item${isCollapsed ? ' partner-packages-item--collapsed' : ''}`}
|
||||||
|
style={embedded ? { marginLeft: 0, marginRight: 0 } : undefined}
|
||||||
|
>
|
||||||
|
<div className="partner-packages-item-head">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-packages-toggle"
|
||||||
|
onClick={() => toggleCollapse(index)}
|
||||||
|
aria-expanded={!isCollapsed}
|
||||||
|
aria-label={isCollapsed ? '展开套餐' : '收起套餐'}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined">
|
||||||
|
{isCollapsed ? 'expand_more' : 'expand_less'}
|
||||||
|
</span>
|
||||||
|
<span className="headline-md">{displayName}</span>
|
||||||
|
</button>
|
||||||
|
{!disabled && list.length > 1 ? (
|
||||||
|
<button type="button" className="partner-packages-remove" onClick={() => removeAt(index)}>
|
||||||
|
删除
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!isCollapsed ? (
|
||||||
|
<>
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>套餐名称 <span className="text-primary">*</span></label>
|
||||||
|
<div className="partner-field-input">
|
||||||
|
<span className="material-symbols-outlined">restaurant</span>
|
||||||
|
<input
|
||||||
|
placeholder="如:套餐A"
|
||||||
|
value={item.name}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { name: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>价格(元) <span className="text-primary">*</span></label>
|
||||||
|
<div className="partner-field-input">
|
||||||
|
<span className="material-symbols-outlined">payments</span>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
step={0.01}
|
||||||
|
placeholder="198"
|
||||||
|
value={item.price}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { price: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>菜品 <span className="text-primary">*</span></label>
|
||||||
|
<textarea
|
||||||
|
rows={3}
|
||||||
|
placeholder="红烧肉、红烧鱼、油焖茄子"
|
||||||
|
value={item.dishes}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { dishes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>使用时间</label>
|
||||||
|
<div className="partner-field-input">
|
||||||
|
<span className="material-symbols-outlined">schedule</span>
|
||||||
|
<input
|
||||||
|
placeholder="节假日除外"
|
||||||
|
value={item.usableTime || ''}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { usableTime: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="partner-field">
|
||||||
|
<label>其他说明</label>
|
||||||
|
<div className="partner-field-input">
|
||||||
|
<span className="material-symbols-outlined">info</span>
|
||||||
|
<input
|
||||||
|
placeholder="不可叠加"
|
||||||
|
value={item.otherNotes || ''}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
{!disabled && list.length < STORE_PACKAGE_MAX_COUNT ? (
|
||||||
|
<button type="button" className="partner-packages-add" onClick={addItem}>
|
||||||
|
<span className="material-symbols-outlined">add_circle</span>
|
||||||
|
添加套餐
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { createPartnerTracker } from '@dukang/client-logging';
|
||||||
|
import { apiBase } from './api';
|
||||||
|
|
||||||
|
const tracker = createPartnerTracker({
|
||||||
|
apiBase,
|
||||||
|
clientApp: 'PARTNER_H5',
|
||||||
|
getToken: () => localStorage.getItem('partnerAccessToken'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export function trackPartner(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.track(eventName, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trackPartnerPageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.trackPageView(eventName, params);
|
||||||
|
}
|
||||||
@@ -29,6 +29,8 @@ export type StoreDraftForm = {
|
|||||||
bankAccountName: string;
|
bankAccountName: string;
|
||||||
bankAccountNo: string;
|
bankAccountNo: string;
|
||||||
bankBranch: string;
|
bankBranch: string;
|
||||||
|
/** 门店套餐(拓店第 4 步,可空) */
|
||||||
|
packages: import('@dukang/shared-types').StorePackageItemDto[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StoreDraft = {
|
export type StoreDraft = {
|
||||||
@@ -68,6 +70,7 @@ export const defaultStoreForm = (): StoreDraftForm => ({
|
|||||||
bankAccountName: '',
|
bankAccountName: '',
|
||||||
bankAccountNo: '',
|
bankAccountNo: '',
|
||||||
bankBranch: '',
|
bankBranch: '',
|
||||||
|
packages: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
const TIME_RE = /^([01]\d|2[0-3]):([0-5]\d)$/;
|
||||||
@@ -79,12 +82,18 @@ function timeToMinutes(hhmm: string): number {
|
|||||||
return h * 60 + m;
|
return h * 60 + m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const MIN_ENV_PHOTO_COUNT = 3;
|
||||||
|
|
||||||
export function normalizeStringArray(urls: unknown, minLen: number): string[] {
|
export function normalizeStringArray(urls: unknown, minLen: number): string[] {
|
||||||
const arr = Array.isArray(urls) ? urls.map((u) => String(u ?? '')) : [];
|
const arr = Array.isArray(urls) ? urls.map((u) => String(u ?? '')) : [];
|
||||||
while (arr.length < minLen) arr.push('');
|
while (arr.length < minLen) arr.push('');
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addEnvPhotoSlot(urls: string[]): string[] {
|
||||||
|
return [...urls, ''];
|
||||||
|
}
|
||||||
|
|
||||||
export function normalizeStoreDraftForm(raw: Partial<StoreDraftForm> | null | undefined): StoreDraftForm {
|
export function normalizeStoreDraftForm(raw: Partial<StoreDraftForm> | null | undefined): StoreDraftForm {
|
||||||
const base = defaultStoreForm();
|
const base = defaultStoreForm();
|
||||||
if (!raw) return base;
|
if (!raw) return base;
|
||||||
@@ -101,7 +110,17 @@ export function normalizeStoreDraftForm(raw: Partial<StoreDraftForm> | null | un
|
|||||||
openTime2: String(raw.openTime2 ?? base.openTime2),
|
openTime2: String(raw.openTime2 ?? base.openTime2),
|
||||||
closeTime2: String(raw.closeTime2 ?? base.closeTime2),
|
closeTime2: String(raw.closeTime2 ?? base.closeTime2),
|
||||||
avgPrice: String(raw.avgPrice ?? base.avgPrice),
|
avgPrice: String(raw.avgPrice ?? base.avgPrice),
|
||||||
envPhotoUrls: normalizeStringArray(raw.envPhotoUrls, 3),
|
envPhotoUrls: normalizeStringArray(raw.envPhotoUrls, MIN_ENV_PHOTO_COUNT),
|
||||||
|
packages: Array.isArray(raw.packages)
|
||||||
|
? raw.packages.map((p, i) => ({
|
||||||
|
name: String((p as { name?: string }).name ?? ''),
|
||||||
|
price: String((p as { price?: string | number }).price ?? ''),
|
||||||
|
dishes: String((p as { dishes?: string }).dishes ?? ''),
|
||||||
|
usableTime: (p as { usableTime?: string }).usableTime ?? '',
|
||||||
|
otherNotes: (p as { otherNotes?: string }).otherNotes ?? '',
|
||||||
|
sortOrder: i,
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,13 +221,14 @@ export function validateStoreStep2(
|
|||||||
): string | null {
|
): string | null {
|
||||||
if (!form.coverUrl.trim()) return '请上传门头照';
|
if (!form.coverUrl.trim()) return '请上传门头照';
|
||||||
const envCount = form.envPhotoUrls.filter((u) => u.trim()).length;
|
const envCount = form.envPhotoUrls.filter((u) => u.trim()).length;
|
||||||
if (envCount < 3) return '请上传至少 3 张环境照片';
|
if (envCount < MIN_ENV_PHOTO_COUNT) return `请上传至少 ${MIN_ENV_PHOTO_COUNT} 张环境照片`;
|
||||||
if (!form.contractUrl.trim()) return '请上传签约合同';
|
if (!form.contractUrl.trim()) return '请上传签约合同';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function patchEnvPhotoAt(urls: string[], index: number, url: string): string[] {
|
export function patchEnvPhotoAt(urls: string[], index: number, url: string): string[] {
|
||||||
const envPhotoUrls = normalizeStringArray(urls, 3);
|
const envPhotoUrls = [...urls];
|
||||||
|
while (envPhotoUrls.length <= index) envPhotoUrls.push('');
|
||||||
envPhotoUrls[index] = url;
|
envPhotoUrls[index] = url;
|
||||||
return envPhotoUrls;
|
return envPhotoUrls;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import type { StorePackageItemDto } from '@dukang/shared-types';
|
||||||
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
|
|
||||||
|
export type PackageFormItem = StorePackageItemDto;
|
||||||
|
|
||||||
|
export function emptyPackage(index = 0): PackageFormItem {
|
||||||
|
return {
|
||||||
|
name: '',
|
||||||
|
price: '',
|
||||||
|
dishes: '',
|
||||||
|
usableTime: '',
|
||||||
|
otherNotes: '',
|
||||||
|
sortOrder: index,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormItem[] {
|
||||||
|
return raw
|
||||||
|
.map((item, index) => ({
|
||||||
|
name: item.name.trim(),
|
||||||
|
price: item.price.trim(),
|
||||||
|
dishes: item.dishes.trim(),
|
||||||
|
usableTime: item.usableTime?.trim() || '',
|
||||||
|
otherNotes: item.otherNotes?.trim() || '',
|
||||||
|
sortOrder: index,
|
||||||
|
}))
|
||||||
|
.filter((item) => item.name || item.price || item.dishes || item.usableTime || item.otherNotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
||||||
|
const filled = normalizePackageFormItems(items);
|
||||||
|
if (filled.length > STORE_PACKAGE_MAX_COUNT) {
|
||||||
|
return `套餐最多 ${STORE_PACKAGE_MAX_COUNT} 条`;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < filled.length; i++) {
|
||||||
|
const item = filled[i];
|
||||||
|
if (!item.name) return `第 ${i + 1} 条套餐名称不能为空`;
|
||||||
|
const price = Number(item.price);
|
||||||
|
if (!Number.isFinite(price) || price < 0) return `第 ${i + 1} 条套餐价格须为非负数字`;
|
||||||
|
if (!item.dishes) return `第 ${i + 1} 条套餐菜品不能为空`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatPackagePrice(price: string | number) {
|
||||||
|
const n = typeof price === 'number' ? price : Number(price);
|
||||||
|
if (!Number.isFinite(n)) return String(price);
|
||||||
|
return n % 1 === 0 ? String(n) : n.toFixed(2);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { trackPartnerPageView } from './analytics';
|
||||||
|
|
||||||
|
export function usePartnerPageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
const fired = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (fired.current) return;
|
||||||
|
fired.current = true;
|
||||||
|
trackPartnerPageView(eventName, params);
|
||||||
|
}, [eventName, params]);
|
||||||
|
}
|
||||||
@@ -5,11 +5,16 @@ import { getRouterBasename } from '@dukang/weixin-sdk';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
import { PartnerSessionProvider } from './contexts/PartnerSessionContext';
|
import { PartnerSessionProvider } from './contexts/PartnerSessionContext';
|
||||||
import { PartnerToastProvider } from './contexts/PartnerToastContext';
|
import { PartnerToastProvider } from './contexts/PartnerToastContext';
|
||||||
import { installClientErrorReporting } from './lib/client-error';
|
import { installClientErrorReporting } from '@dukang/client-logging';
|
||||||
|
import { apiBase } from './lib/api';
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
import './styles/legal.css';
|
import './styles/legal.css';
|
||||||
|
|
||||||
installClientErrorReporting();
|
installClientErrorReporting({
|
||||||
|
apiBase,
|
||||||
|
clientApp: 'PARTNER_H5',
|
||||||
|
getToken: () => localStorage.getItem('partnerAccessToken'),
|
||||||
|
});
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
|||||||
import type { PartnerBillDto } from '@dukang/shared-types';
|
import type { PartnerBillDto } from '@dukang/shared-types';
|
||||||
import { isLoggedIn, request } from '../lib/api';
|
import { isLoggedIn, request } from '../lib/api';
|
||||||
import { toastError, toastSuccess } from '../lib/toast';
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function fmtMoney(n: number) {
|
function fmtMoney(n: number) {
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
@@ -25,6 +26,7 @@ function canConfirm(status: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function BillsPage() {
|
export default function BillsPage() {
|
||||||
|
usePartnerPageView('partner_bills_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [bills, setBills] = useState<PartnerBillDto[]>([]);
|
const [bills, setBills] = useState<PartnerBillDto[]>([]);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import type { PartnerLeaderboardEntry } from '@dukang/shared-types';
|
import type { PartnerLeaderboardEntry } from '@dukang/shared-types';
|
||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
import { isLoggedIn, request } from '../lib/api';
|
import { isLoggedIn, request } from '../lib/api';
|
||||||
import { fetchPartnerLeaderboard } from '../lib/leaderboard';
|
import { fetchPartnerLeaderboard } from '../lib/leaderboard';
|
||||||
import {
|
import {
|
||||||
@@ -137,6 +138,7 @@ function LeaderboardPreview({ entries }: { entries: PartnerLeaderboardEntry[] })
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
|
usePartnerPageView('partner_home_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
const navKind = getPartnerNavKind(account);
|
const navKind = getPartnerNavKind(account);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
|||||||
import { fetchPartnerLeaderboard } from '../lib/leaderboard';
|
import { fetchPartnerLeaderboard } from '../lib/leaderboard';
|
||||||
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
||||||
import { isPrimaryAccount } from '../lib/partnerAccess';
|
import { isPrimaryAccount } from '../lib/partnerAccess';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
const PERIOD_TABS: { key: PartnerLeaderboardPeriod; label: string }[] = [
|
const PERIOD_TABS: { key: PartnerLeaderboardPeriod; label: string }[] = [
|
||||||
{ key: 'month', label: '本月' },
|
{ key: 'month', label: '本月' },
|
||||||
@@ -26,6 +27,7 @@ function periodSubLabel(period: PartnerLeaderboardPeriod): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function LeaderboardPage() {
|
export default function LeaderboardPage() {
|
||||||
|
usePartnerPageView('partner_leaderboard_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
const showStaffFab = isPrimaryAccount(account);
|
const showStaffFab = isPrimaryAccount(account);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { toastError, toastSuccess } from '../lib/toast';
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
const TIMELINE = [
|
const TIMELINE = [
|
||||||
{ key: 'confirm', label: '待确认' },
|
{ key: 'confirm', label: '待确认' },
|
||||||
@@ -36,6 +37,7 @@ function canShip(status: string) {
|
|||||||
|
|
||||||
export default function OrderDetailPage() {
|
export default function OrderDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
usePartnerPageView('partner_order_detail_view', id ? { orderId: id } : undefined);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [order, setOrder] = useState<Record<string, unknown> | null>(null);
|
const [order, setOrder] = useState<Record<string, unknown> | null>(null);
|
||||||
const [shipping, setShipping] = useState(false);
|
const [shipping, setShipping] = useState(false);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
|||||||
import { isLoggedIn, request } from '../lib/api';
|
import { isLoggedIn, request } from '../lib/api';
|
||||||
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
||||||
import { hasWarehouseAccess } from '../lib/partnerAccess';
|
import { hasWarehouseAccess } from '../lib/partnerAccess';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type DateFilter = 'today' | '7d' | '30d';
|
type DateFilter = 'today' | '7d' | '30d';
|
||||||
type StatusFilter = 'ALL' | 'PENDING_SHIP' | 'SHIPPING' | 'COMPLETED' | 'ABNORMAL';
|
type StatusFilter = 'ALL' | 'PENDING_SHIP' | 'SHIPPING' | 'COMPLETED' | 'ABNORMAL';
|
||||||
@@ -44,6 +45,7 @@ type OrdersResponse = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function OrderListPage({ tabRoot = false }: OrderListPageProps) {
|
export default function OrderListPage({ tabRoot = false }: OrderListPageProps) {
|
||||||
|
usePartnerPageView('partner_order_list_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
const warehouseOk = hasWarehouseAccess(account);
|
const warehouseOk = hasWarehouseAccess(account);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export default function ProxyOrderDetailPage() {
|
|||||||
const [payMethod, setPayMethod] = useState<ProxyPayMethod>('NATIVE');
|
const [payMethod, setPayMethod] = useState<ProxyPayMethod>('NATIVE');
|
||||||
const [codeUrl, setCodeUrl] = useState<string | null>(null);
|
const [codeUrl, setCodeUrl] = useState<string | null>(null);
|
||||||
const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);
|
const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);
|
||||||
|
const [cancelling, setCancelling] = useState(false);
|
||||||
const pollRef = useRef<number | null>(null);
|
const pollRef = useRef<number | null>(null);
|
||||||
|
|
||||||
function stopPoll() {
|
function stopPoll() {
|
||||||
@@ -77,7 +78,12 @@ export default function ProxyOrderDetailPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
void request<PartnerProxyOrderListItem>('PARTNER_H5', `/partner/proxy-orders/${id}`)
|
void request<PartnerProxyOrderListItem>('PARTNER_H5', `/partner/proxy-orders/${id}`)
|
||||||
.then(setOrder)
|
.then((data) => {
|
||||||
|
setOrder(data);
|
||||||
|
if (data.proxyPayMethod) {
|
||||||
|
setPayMethod(data.proxyPayMethod);
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch((e) => setError(e instanceof Error ? e.message : '加载失败'));
|
.catch((e) => setError(e instanceof Error ? e.message : '加载失败'));
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
@@ -129,6 +135,15 @@ export default function ProxyOrderDetailPage() {
|
|||||||
|
|
||||||
async function startPay(method: ProxyPayMethod) {
|
async function startPay(method: ProxyPayMethod) {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
const locked = order?.proxyPayMethod;
|
||||||
|
if (locked && locked !== method) {
|
||||||
|
setPayMsg(
|
||||||
|
locked === 'JSAPI'
|
||||||
|
? '该订单已发起微信代付,请先取消支付后重新下单'
|
||||||
|
: '该订单已生成收款码,请先取消支付后重新下单',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setPaying(true);
|
setPaying(true);
|
||||||
setPayMsg('');
|
setPayMsg('');
|
||||||
setPayMethod(method);
|
setPayMethod(method);
|
||||||
@@ -166,12 +181,14 @@ export default function ProxyOrderDetailPage() {
|
|||||||
|
|
||||||
if (pay.mode === 'native' && pay.codeUrl) {
|
if (pay.mode === 'native' && pay.codeUrl) {
|
||||||
setCodeUrl(pay.codeUrl);
|
setCodeUrl(pay.codeUrl);
|
||||||
|
setOrder((prev) => (prev ? { ...prev, proxyPayMethod: method } : prev));
|
||||||
startPoll(id);
|
startPoll(id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pay.mode === 'jsapi' && pay.prepay) {
|
if (pay.mode === 'jsapi' && pay.prepay) {
|
||||||
setCodeUrl(null);
|
setCodeUrl(null);
|
||||||
|
setOrder((prev) => (prev ? { ...prev, proxyPayMethod: method } : prev));
|
||||||
await invokeWechatPay(pay.prepay, {
|
await invokeWechatPay(pay.prepay, {
|
||||||
apiBase: '/api/v1',
|
apiBase: '/api/v1',
|
||||||
clientApp: 'PARTNER_H5',
|
clientApp: 'PARTNER_H5',
|
||||||
@@ -191,14 +208,27 @@ export default function ProxyOrderDetailPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const autoPayStartedRef = useRef(false);
|
async function cancelPay() {
|
||||||
useEffect(() => {
|
if (!id) return;
|
||||||
if (!id || !unpaid || autoPayStartedRef.current) return;
|
setCancelling(true);
|
||||||
autoPayStartedRef.current = true;
|
setPayMsg('');
|
||||||
void startPay('NATIVE');
|
stopPoll();
|
||||||
// 仅首次进入未支付详情时自动拉收款码
|
try {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
await request('PARTNER_H5', `/partner/proxy-orders/${id}/cancel-pay`, {
|
||||||
}, [id, unpaid]);
|
method: 'POST',
|
||||||
|
body: '{}',
|
||||||
|
});
|
||||||
|
toastSuccess('已取消支付,可重新下单并选择其他支付方式');
|
||||||
|
navigate('/center/proxy-orders');
|
||||||
|
} catch (e) {
|
||||||
|
setPayMsg(e instanceof Error ? e.message : '取消失败');
|
||||||
|
toastError(e instanceof Error ? e.message : '取消失败');
|
||||||
|
} finally {
|
||||||
|
setCancelling(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const lockedPayMethod = order?.proxyPayMethod ?? null;
|
||||||
|
|
||||||
const img = order?.imageResource?.url || '';
|
const img = order?.imageResource?.url || '';
|
||||||
const isOnSite = String(order?.deliveryType || '').toUpperCase() === 'ON_SITE_PICKUP';
|
const isOnSite = String(order?.deliveryType || '').toUpperCase() === 'ON_SITE_PICKUP';
|
||||||
@@ -285,6 +315,7 @@ export default function ProxyOrderDetailPage() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`partner-proxy-mode-tab${payMethod === 'NATIVE' ? ' is-active' : ''}`}
|
className={`partner-proxy-mode-tab${payMethod === 'NATIVE' ? ' is-active' : ''}`}
|
||||||
|
disabled={!!lockedPayMethod && lockedPayMethod !== 'NATIVE'}
|
||||||
onClick={() => void startPay('NATIVE')}
|
onClick={() => void startPay('NATIVE')}
|
||||||
>
|
>
|
||||||
收款码
|
收款码
|
||||||
@@ -292,11 +323,21 @@ export default function ProxyOrderDetailPage() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`partner-proxy-mode-tab${payMethod === 'JSAPI' ? ' is-active' : ''}`}
|
className={`partner-proxy-mode-tab${payMethod === 'JSAPI' ? ' is-active' : ''}`}
|
||||||
|
disabled={!!lockedPayMethod && lockedPayMethod !== 'JSAPI'}
|
||||||
onClick={() => void startPay('JSAPI')}
|
onClick={() => void startPay('JSAPI')}
|
||||||
>
|
>
|
||||||
微信代付
|
微信代付
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{lockedPayMethod ? (
|
||||||
|
<p className="label-md text-muted" style={{ marginTop: 8 }}>
|
||||||
|
已选择{lockedPayMethod === 'NATIVE' ? '收款码' : '微信代付'},切换方式请先取消支付
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="label-md text-muted" style={{ marginTop: 8 }}>
|
||||||
|
请选择支付方式并点击下方按钮发起支付
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
{payMethod === 'NATIVE' ? (
|
{payMethod === 'NATIVE' ? (
|
||||||
<div style={{ textAlign: 'center', marginTop: 16 }}>
|
<div style={{ textAlign: 'center', marginTop: 16 }}>
|
||||||
@@ -338,6 +379,16 @@ export default function ProxyOrderDetailPage() {
|
|||||||
{payMsg}
|
{payMsg}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-block"
|
||||||
|
style={{ marginTop: 16 }}
|
||||||
|
disabled={cancelling || paying}
|
||||||
|
onClick={() => void cancelPay()}
|
||||||
|
>
|
||||||
|
{cancelling ? '取消中…' : '取消支付'}
|
||||||
|
</button>
|
||||||
</section>
|
</section>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import type {
|
|||||||
ProxyOrderPayResponse,
|
ProxyOrderPayResponse,
|
||||||
ProxyPayMethod,
|
ProxyPayMethod,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function fmtMoney(n: number) {
|
function fmtMoney(n: number) {
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
@@ -46,6 +47,7 @@ function initialDraft(): ProxyOrderDraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ProxyOrderPage() {
|
export default function ProxyOrderPage() {
|
||||||
|
usePartnerPageView('partner_proxy_order_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const draft0 = useMemo(() => initialDraft(), []);
|
const draft0 = useMemo(() => initialDraft(), []);
|
||||||
@@ -70,6 +72,8 @@ export default function ProxyOrderPage() {
|
|||||||
const [codeUrl, setCodeUrl] = useState<string | null>(null);
|
const [codeUrl, setCodeUrl] = useState<string | null>(null);
|
||||||
const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);
|
const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);
|
||||||
const [paying, setPaying] = useState(false);
|
const [paying, setPaying] = useState(false);
|
||||||
|
const [cancelling, setCancelling] = useState(false);
|
||||||
|
const [lockedPayMethod, setLockedPayMethod] = useState<ProxyPayMethod | null>(null);
|
||||||
const pollRef = useRef<number | null>(null);
|
const pollRef = useRef<number | null>(null);
|
||||||
|
|
||||||
const region = useMemo(() => parseRegionCodes(regionCodes), [regionCodes]);
|
const region = useMemo(() => parseRegionCodes(regionCodes), [regionCodes]);
|
||||||
@@ -234,8 +238,17 @@ export default function ProxyOrderPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startPay(orderId: string, method: ProxyPayMethod) {
|
async function startPay(orderId: string, method: ProxyPayMethod) {
|
||||||
|
if (lockedPayMethod && lockedPayMethod !== method) {
|
||||||
|
setMsg(
|
||||||
|
lockedPayMethod === 'JSAPI'
|
||||||
|
? '该订单已发起微信代付,请先取消支付后重新下单'
|
||||||
|
: '该订单已生成收款码,请先取消支付后重新下单',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setPaying(true);
|
setPaying(true);
|
||||||
setMsg('');
|
setMsg('');
|
||||||
|
setPayMethod(method);
|
||||||
try {
|
try {
|
||||||
if (method === 'JSAPI') {
|
if (method === 'JSAPI') {
|
||||||
if (!isWechatEnv()) {
|
if (!isWechatEnv()) {
|
||||||
@@ -266,11 +279,14 @@ export default function ProxyOrderPage() {
|
|||||||
|
|
||||||
if (pay.mode === 'native' && pay.codeUrl) {
|
if (pay.mode === 'native' && pay.codeUrl) {
|
||||||
setCodeUrl(pay.codeUrl);
|
setCodeUrl(pay.codeUrl);
|
||||||
|
setLockedPayMethod(method);
|
||||||
startPoll(orderId);
|
startPoll(orderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pay.mode === 'jsapi' && pay.prepay) {
|
if (pay.mode === 'jsapi' && pay.prepay) {
|
||||||
|
setCodeUrl(null);
|
||||||
|
setLockedPayMethod(method);
|
||||||
await invokeWechatPay(pay.prepay, {
|
await invokeWechatPay(pay.prepay, {
|
||||||
apiBase: '/api/v1',
|
apiBase: '/api/v1',
|
||||||
clientApp: 'PARTNER_H5',
|
clientApp: 'PARTNER_H5',
|
||||||
@@ -289,6 +305,40 @@ export default function ProxyOrderPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function cancelPay(orderId: string) {
|
||||||
|
setCancelling(true);
|
||||||
|
setMsg('');
|
||||||
|
stopPoll();
|
||||||
|
try {
|
||||||
|
await request('PARTNER_H5', `/partner/proxy-orders/${orderId}/cancel-pay`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: '{}',
|
||||||
|
});
|
||||||
|
toastSuccess('已取消支付,可重新下单并选择其他支付方式');
|
||||||
|
setStep('form');
|
||||||
|
setCreated(null);
|
||||||
|
setCodeUrl(null);
|
||||||
|
setLockedPayMethod(null);
|
||||||
|
} catch (e) {
|
||||||
|
setMsg(e instanceof Error ? e.message : '取消失败');
|
||||||
|
} finally {
|
||||||
|
setCancelling(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function switchPayMethod(method: ProxyPayMethod) {
|
||||||
|
if (lockedPayMethod && lockedPayMethod !== method) {
|
||||||
|
setMsg(
|
||||||
|
lockedPayMethod === 'JSAPI'
|
||||||
|
? '该订单已发起微信代付,请先取消支付后重新下单'
|
||||||
|
: '该订单已生成收款码,请先取消支付后重新下单',
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPayMethod(method);
|
||||||
|
setMsg('');
|
||||||
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setMsg('');
|
setMsg('');
|
||||||
const err = validateForm();
|
const err = validateForm();
|
||||||
@@ -322,6 +372,7 @@ export default function ProxyOrderPage() {
|
|||||||
setCreated(order);
|
setCreated(order);
|
||||||
setStep('pay');
|
setStep('pay');
|
||||||
setCodeUrl(null);
|
setCodeUrl(null);
|
||||||
|
setLockedPayMethod(null);
|
||||||
await startPay(order.id, payMethod);
|
await startPay(order.id, payMethod);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMsg(e instanceof Error ? e.message : '下单失败');
|
setMsg(e instanceof Error ? e.message : '下单失败');
|
||||||
@@ -359,24 +410,25 @@ export default function ProxyOrderPage() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`partner-proxy-mode-tab${payMethod === 'NATIVE' ? ' is-active' : ''}`}
|
className={`partner-proxy-mode-tab${payMethod === 'NATIVE' ? ' is-active' : ''}`}
|
||||||
onClick={() => {
|
disabled={!!lockedPayMethod && lockedPayMethod !== 'NATIVE'}
|
||||||
setPayMethod('NATIVE');
|
onClick={() => switchPayMethod('NATIVE')}
|
||||||
void startPay(created.id, 'NATIVE');
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
收款码
|
收款码
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={`partner-proxy-mode-tab${payMethod === 'JSAPI' ? ' is-active' : ''}`}
|
className={`partner-proxy-mode-tab${payMethod === 'JSAPI' ? ' is-active' : ''}`}
|
||||||
onClick={() => {
|
disabled={!!lockedPayMethod && lockedPayMethod !== 'JSAPI'}
|
||||||
setPayMethod('JSAPI');
|
onClick={() => switchPayMethod('JSAPI')}
|
||||||
void startPay(created.id, 'JSAPI');
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
微信代付
|
微信代付
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{lockedPayMethod ? (
|
||||||
|
<p className="label-md text-muted" style={{ marginTop: 8 }}>
|
||||||
|
已选择{lockedPayMethod === 'NATIVE' ? '收款码' : '微信代付'},切换方式请先取消支付
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{payMethod === 'NATIVE' ? (
|
{payMethod === 'NATIVE' ? (
|
||||||
@@ -419,6 +471,16 @@ export default function ProxyOrderPage() {
|
|||||||
{msg}
|
{msg}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-block"
|
||||||
|
style={{ marginTop: 16 }}
|
||||||
|
disabled={cancelling || paying}
|
||||||
|
onClick={() => void cancelPay(created.id)}
|
||||||
|
>
|
||||||
|
{cancelling ? '取消中…' : '取消支付'}
|
||||||
|
</button>
|
||||||
</>
|
</>
|
||||||
) : loadingOptions ? (
|
) : loadingOptions ? (
|
||||||
<p className="label-md text-muted">加载商品…</p>
|
<p className="label-md text-muted">加载商品…</p>
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import {
|
|||||||
type PartnerStaffItem,
|
type PartnerStaffItem,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
import { deletePartnerStaff, listPartnerStaff, updatePartnerStaff } from '../lib/staff';
|
import { deletePartnerStaff, listPartnerStaff, updatePartnerStaff } from '../lib/staff';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
export default function StaffListPage() {
|
export default function StaffListPage() {
|
||||||
|
usePartnerPageView('partner_staff_list_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [staff, setStaff] = useState<PartnerStaffItem[]>([]);
|
const [staff, setStaff] = useState<PartnerStaffItem[]>([]);
|
||||||
const [q, setQ] = useState('');
|
const [q, setQ] = useState('');
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
|||||||
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
||||||
|
|
||||||
import TencentLocPickerOverlay from '../components/TencentLocPickerOverlay';
|
import TencentLocPickerOverlay from '../components/TencentLocPickerOverlay';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
||||||
@@ -40,12 +41,13 @@ import {
|
|||||||
validateStoreStep3,
|
validateStoreStep3,
|
||||||
|
|
||||||
patchEnvPhotoAt,
|
patchEnvPhotoAt,
|
||||||
|
addEnvPhotoSlot,
|
||||||
|
MIN_ENV_PHOTO_COUNT,
|
||||||
} from '../lib/storeDraft';
|
} from '../lib/storeDraft';
|
||||||
|
import StorePackagesForm from '../components/StorePackagesForm';
|
||||||
|
import { normalizePackageFormItems, validatePackageFormItems } from '../lib/storePackages';
|
||||||
|
|
||||||
|
const STEPS = ['基本信息', '照片上传', '结算资质', '门店套餐'] as const;
|
||||||
|
|
||||||
const STEPS = ['基本信息', '照片上传', '结算资质'] as const;
|
|
||||||
|
|
||||||
type StoreCategoryNode = {
|
type StoreCategoryNode = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -77,6 +79,8 @@ function isPhoneValidationMessage(message: string) {
|
|||||||
|
|
||||||
export default function StoreCreatePage() {
|
export default function StoreCreatePage() {
|
||||||
|
|
||||||
|
usePartnerPageView('partner_store_create_view');
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
@@ -102,6 +106,7 @@ export default function StoreCreatePage() {
|
|||||||
const [categoryTree, setCategoryTree] = useState<StoreCategoryNode[]>([]);
|
const [categoryTree, setCategoryTree] = useState<StoreCategoryNode[]>([]);
|
||||||
|
|
||||||
const [mapPickerOpen, setMapPickerOpen] = useState(false);
|
const [mapPickerOpen, setMapPickerOpen] = useState(false);
|
||||||
|
const [stepErrorModal, setStepErrorModal] = useState<string | null>(null);
|
||||||
|
|
||||||
const draftSaveDisabledRef = useRef(false);
|
const draftSaveDisabledRef = useRef(false);
|
||||||
|
|
||||||
@@ -109,9 +114,14 @@ export default function StoreCreatePage() {
|
|||||||
setSubmitError(message);
|
setSubmitError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reportStepError(message: string) {
|
||||||
|
setSubmitError(message);
|
||||||
|
setStepErrorModal(message);
|
||||||
|
}
|
||||||
|
|
||||||
const stepFromUrl = Number(params.get('step') || 0);
|
const stepFromUrl = Number(params.get('step') || 0);
|
||||||
|
|
||||||
const step = stepFromUrl >= 1 && stepFromUrl <= 3 ? stepFromUrl : (saved?.step ?? 1);
|
const step = stepFromUrl >= 1 && stepFromUrl <= 4 ? stepFromUrl : (saved?.step ?? 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -301,7 +311,7 @@ export default function StoreCreatePage() {
|
|||||||
const msg = validateStoreStep1(form);
|
const msg = validateStoreStep1(form);
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
reportFormError(msg);
|
reportStepError(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,19 +322,32 @@ export default function StoreCreatePage() {
|
|||||||
const msg = validateStoreStep2(form);
|
const msg = validateStoreStep2(form);
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
reportFormError(msg);
|
reportStepError(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (step === 3) {
|
||||||
|
const msg = validateStoreStep3(form);
|
||||||
|
if (msg) {
|
||||||
|
if (isPhoneValidationMessage(msg)) {
|
||||||
|
setFieldErrors({ phone: msg });
|
||||||
|
reportStepError(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reportStepError(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
goStep(step + 1);
|
goStep(step + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function submit() {
|
async function submit(skipPackages = false) {
|
||||||
|
|
||||||
const msg = validateStoreStep3(form);
|
const msg = validateStoreStep3(form);
|
||||||
|
|
||||||
@@ -337,6 +360,15 @@ export default function StoreCreatePage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const packagesToSubmit = skipPackages ? [] : form.packages || [];
|
||||||
|
if (!skipPackages) {
|
||||||
|
const pkgMsg = validatePackageFormItems(packagesToSubmit);
|
||||||
|
if (pkgMsg) {
|
||||||
|
reportFormError(pkgMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const step1Msg = validateStoreStep1(form);
|
const step1Msg = validateStoreStep1(form);
|
||||||
|
|
||||||
if (step1Msg) {
|
if (step1Msg) {
|
||||||
@@ -472,6 +504,15 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
draftSaveDisabledRef.current = true;
|
draftSaveDisabledRef.current = true;
|
||||||
clearAllStoreDrafts(accountId);
|
clearAllStoreDrafts(accountId);
|
||||||
|
const packages = normalizePackageFormItems(packagesToSubmit);
|
||||||
|
if (packages.length) {
|
||||||
|
await request('PARTNER_H5', `/partner/stores/${result.store.id}/packages`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({
|
||||||
|
packages: packages.map((p) => ({ ...p, price: Number(p.price).toFixed(2) })),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
setForm(defaultStoreForm());
|
setForm(defaultStoreForm());
|
||||||
setFieldErrors({});
|
setFieldErrors({});
|
||||||
setSubmitError('');
|
setSubmitError('');
|
||||||
@@ -496,7 +537,7 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const progress = step === 1 ? 0 : step === 2 ? 50 : 100;
|
const progress = step === 1 ? 0 : step === 2 ? 33 : step === 3 ? 66 : 100;
|
||||||
|
|
||||||
const nextDisabled = submitting;
|
const nextDisabled = submitting;
|
||||||
|
|
||||||
@@ -919,7 +960,7 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
<h3 className="headline-md">环境照片 <span className="text-primary">*</span></h3>
|
<h3 className="headline-md">环境照片 <span className="text-primary">*</span></h3>
|
||||||
|
|
||||||
<p className="label-md text-muted" style={{ margin: '4px 0 12px' }}>至少 3 张,展示店内整洁环境</p>
|
<p className="label-md text-muted" style={{ margin: '4px 0 12px' }}>至少 {MIN_ENV_PHOTO_COUNT} 张,展示店内整洁环境</p>
|
||||||
|
|
||||||
<div className="partner-upload-grid">
|
<div className="partner-upload-grid">
|
||||||
|
|
||||||
@@ -945,6 +986,17 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-btn-outline"
|
||||||
|
style={{ width: '100%', marginTop: 12 }}
|
||||||
|
onClick={() =>
|
||||||
|
setForm((prev) => ({ ...prev, envPhotoUrls: addEnvPhotoSlot(prev.envPhotoUrls) }))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
添加环境照片
|
||||||
|
</button>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
@@ -1096,6 +1148,26 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{step === 4 && (
|
||||||
|
<>
|
||||||
|
<section className="partner-form-card">
|
||||||
|
<div className="partner-section-title">
|
||||||
|
<div className="partner-section-bar" />
|
||||||
|
<h2 className="headline-md">门店套餐</h2>
|
||||||
|
</div>
|
||||||
|
<p className="label-md text-muted" style={{ marginBottom: 16 }}>
|
||||||
|
可选填写;提交后将进入总部审核。也可在最后一页点击「跳过」。
|
||||||
|
</p>
|
||||||
|
<StorePackagesForm
|
||||||
|
items={form.packages?.length ? form.packages : [{ name: '', price: '', dishes: '', usableTime: '', otherNotes: '', sortOrder: 0 }]}
|
||||||
|
onChange={(packages) => setForm((prev) => ({ ...prev, packages }))}
|
||||||
|
disabled={submitting}
|
||||||
|
embedded
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<footer className="partner-sticky-footer">
|
<footer className="partner-sticky-footer">
|
||||||
@@ -1110,7 +1182,7 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{step < 3 ? (
|
{step < 4 ? (
|
||||||
|
|
||||||
<button type="button" className="partner-btn-primary" onClick={() => void handleNext()} disabled={nextDisabled}>
|
<button type="button" className="partner-btn-primary" onClick={() => void handleNext()} disabled={nextDisabled}>
|
||||||
|
|
||||||
@@ -1122,16 +1194,37 @@ export default function StoreCreatePage() {
|
|||||||
|
|
||||||
) : (
|
) : (
|
||||||
|
|
||||||
<button type="button" className="partner-btn-primary" onClick={() => void submit()} disabled={submitting}>
|
<>
|
||||||
|
<button type="button" className="partner-btn-outline" onClick={() => void submit(true)} disabled={submitting}>
|
||||||
|
跳过
|
||||||
|
</button>
|
||||||
|
<button type="button" className="partner-btn-primary" onClick={() => void submit(false)} disabled={submitting}>
|
||||||
|
|
||||||
{submitting ? '提交中…' : '提交'}
|
{submitting ? '提交中…' : '提交'}
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
|
</>
|
||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
{stepErrorModal ? (
|
||||||
|
<div className="partner-ship-modal-backdrop" role="presentation" onClick={() => setStepErrorModal(null)}>
|
||||||
|
<div className="partner-ship-modal" role="dialog" aria-modal="true" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<h3 className="headline-md" style={{ marginBottom: 8 }}>请完善信息</h3>
|
||||||
|
<p className="body-md text-muted" style={{ lineHeight: 1.6, whiteSpace: 'pre-wrap' }}>
|
||||||
|
{stepErrorModal}
|
||||||
|
</p>
|
||||||
|
<div className="partner-ship-actions">
|
||||||
|
<button type="button" className="partner-btn-primary" onClick={() => setStepErrorModal(null)}>
|
||||||
|
我知道了
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<TencentLocPickerOverlay
|
<TencentLocPickerOverlay
|
||||||
open={mapPickerOpen}
|
open={mapPickerOpen}
|
||||||
onClose={() => setMapPickerOpen(false)}
|
onClose={() => setMapPickerOpen(false)}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { request } from '../lib/api';
|
|||||||
import { toastError, toastSuccess } from '../lib/toast';
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
import { usePartnerSession } from '../contexts/PartnerSessionContext';
|
||||||
import { canManagePartnerStore } from '../lib/partnerAccess';
|
import { canManagePartnerStore } from '../lib/partnerAccess';
|
||||||
import { normalizeStringArray, patchEnvPhotoAt } from '../lib/storeDraft';
|
import { MIN_ENV_PHOTO_COUNT, normalizeStringArray, patchEnvPhotoAt, addEnvPhotoSlot } from '../lib/storeDraft';
|
||||||
import OssUploadField from '../components/OssUploadField';
|
import OssUploadField from '../components/OssUploadField';
|
||||||
import TencentLocPickerOverlay from '../components/TencentLocPickerOverlay';
|
import TencentLocPickerOverlay from '../components/TencentLocPickerOverlay';
|
||||||
import {
|
import {
|
||||||
@@ -16,9 +16,9 @@ import {
|
|||||||
storeStatusPillClass,
|
storeStatusPillClass,
|
||||||
type StoreStatusValue,
|
type StoreStatusValue,
|
||||||
} from '../lib/storeStatus';
|
} from '../lib/storeStatus';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
const STATUS_OPTIONS: StoreStatusValue[] = ['OPEN', 'PAUSED', 'CLOSED'];
|
const STATUS_OPTIONS: StoreStatusValue[] = ['OPEN', 'PAUSED', 'CLOSED'];
|
||||||
const ENV_SLOT_COUNT = 3;
|
|
||||||
|
|
||||||
function uniqueEnvUrls(urls: string[]): string[] {
|
function uniqueEnvUrls(urls: string[]): string[] {
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
@@ -34,6 +34,7 @@ function uniqueEnvUrls(urls: string[]): string[] {
|
|||||||
|
|
||||||
export default function StoreDetailPage() {
|
export default function StoreDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
usePartnerPageView('partner_store_detail_view', id ? { storeId: id } : undefined);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
const canMutate = canManagePartnerStore(account);
|
const canMutate = canManagePartnerStore(account);
|
||||||
@@ -81,7 +82,7 @@ export default function StoreDetailPage() {
|
|||||||
.map((m) => String(m.url || '')),
|
.map((m) => String(m.url || '')),
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
setEnvPhotoUrls(normalizeStringArray(envFromMedia, ENV_SLOT_COUNT));
|
setEnvPhotoUrls(normalizeStringArray(envFromMedia, MIN_ENV_PHOTO_COUNT));
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -196,8 +197,8 @@ export default function StoreDetailPage() {
|
|||||||
setActionError('请上传门头照');
|
setActionError('请上传门头照');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nextEnv.length < ENV_SLOT_COUNT) {
|
if (nextEnv.length < MIN_ENV_PHOTO_COUNT) {
|
||||||
setActionError(`请上传至少 ${ENV_SLOT_COUNT} 张环境照片`);
|
setActionError(`请上传至少 ${MIN_ENV_PHOTO_COUNT} 张环境照片`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMediaSaving(true);
|
setMediaSaving(true);
|
||||||
@@ -277,6 +278,18 @@ export default function StoreDetailPage() {
|
|||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{canMutate && !auditPending && status !== 'CLOSED' && (
|
||||||
|
<section className="partner-form-card" style={{ margin: '0 0 16px' }}>
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
|
<h3 className="label-md text-muted" style={{ textTransform: 'uppercase', letterSpacing: '0.1em' }}>门店套餐</h3>
|
||||||
|
<button type="button" className="partner-btn-outline" onClick={() => navigate(`/stores/${id}/packages`)}>
|
||||||
|
编辑套餐
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p className="label-md text-muted" style={{ marginTop: 8 }}>维护可核销套餐信息,提交后由总部审核。</p>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
|
|
||||||
{canMutate && (
|
{canMutate && (
|
||||||
<section className="partner-form-card" style={{ margin: '0 0 16px' }}>
|
<section className="partner-form-card" style={{ margin: '0 0 16px' }}>
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||||
@@ -388,7 +401,7 @@ export default function StoreDetailPage() {
|
|||||||
<h3 className="headline-md" style={{ borderLeft: '4px solid var(--color-heritage-red)', paddingLeft: 12 }}>店内环境</h3>
|
<h3 className="headline-md" style={{ borderLeft: '4px solid var(--color-heritage-red)', paddingLeft: 12 }}>店内环境</h3>
|
||||||
<span className="label-md text-muted">
|
<span className="label-md text-muted">
|
||||||
{canMutate && !readOnly
|
{canMutate && !readOnly
|
||||||
? `需 ${ENV_SLOT_COUNT} 张 · 已选 ${uniqueEnvUrls(envPhotoUrls).length} 张`
|
? `至少 ${MIN_ENV_PHOTO_COUNT} 张 · 已选 ${uniqueEnvUrls(envPhotoUrls).length} 张`
|
||||||
: envPhotos.length
|
: envPhotos.length
|
||||||
? `已上传 ${envPhotos.length} 张`
|
? `已上传 ${envPhotos.length} 张`
|
||||||
: '暂无照片'}
|
: '暂无照片'}
|
||||||
@@ -408,6 +421,14 @@ export default function StoreDetailPage() {
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-btn-outline"
|
||||||
|
style={{ width: '100%', marginTop: 12 }}
|
||||||
|
onClick={() => setEnvPhotoUrls((prev) => addEnvPhotoSlot(prev))}
|
||||||
|
>
|
||||||
|
添加环境照片
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="partner-btn-outline"
|
className="partner-btn-outline"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
storeStatusPillClass,
|
storeStatusPillClass,
|
||||||
type StoreStatusValue,
|
type StoreStatusValue,
|
||||||
} from '../lib/storeStatus';
|
} from '../lib/storeStatus';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type StatusFilter = 'ALL' | StoreStatusValue | 'PENDING_AUDIT' | 'REJECTED';
|
type StatusFilter = 'ALL' | StoreStatusValue | 'PENDING_AUDIT' | 'REJECTED';
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ const FILTERS: { key: StatusFilter; label: string }[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function StoreListPage() {
|
export default function StoreListPage() {
|
||||||
|
usePartnerPageView('partner_store_list_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const { account } = usePartnerSession();
|
const { account } = usePartnerSession();
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import type { StorePackagesResponse } from '@dukang/shared-types';
|
||||||
|
import StorePackagesForm from '../components/StorePackagesForm';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { toastError, toastSuccess } from '../lib/toast';
|
||||||
|
import {
|
||||||
|
emptyPackage,
|
||||||
|
normalizePackageFormItems,
|
||||||
|
validatePackageFormItems,
|
||||||
|
type PackageFormItem,
|
||||||
|
} from '../lib/storePackages';
|
||||||
|
|
||||||
|
export default function StorePackagesPage() {
|
||||||
|
const { id } = useParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [items, setItems] = useState<PackageFormItem[]>([emptyPackage()]);
|
||||||
|
const [pending, setPending] = useState<StorePackagesResponse['pendingRequest']>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!id) return;
|
||||||
|
setLoading(true);
|
||||||
|
request<StorePackagesResponse>('PARTNER_H5', `/partner/stores/${id}/packages`)
|
||||||
|
.then((data) => {
|
||||||
|
const base = data.pendingRequest?.packages?.length
|
||||||
|
? data.pendingRequest.packages
|
||||||
|
: data.live?.length
|
||||||
|
? data.live
|
||||||
|
: [emptyPackage()];
|
||||||
|
setItems(base.map((p, i) => ({ ...p, price: String(p.price), sortOrder: i })));
|
||||||
|
setPending(data.pendingRequest ?? null);
|
||||||
|
})
|
||||||
|
.catch((e) => setError(e instanceof Error ? e.message : '加载失败'))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
async function submitAudit() {
|
||||||
|
if (!id) return;
|
||||||
|
const msg = validatePackageFormItems(items);
|
||||||
|
if (msg) {
|
||||||
|
toastError(msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pending?.status === 'PENDING') {
|
||||||
|
toastError('已有套餐变更审核中,请等待总部处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSubmitting(true);
|
||||||
|
try {
|
||||||
|
const packages = normalizePackageFormItems(items).map((p) => ({
|
||||||
|
...p,
|
||||||
|
price: Number(p.price).toFixed(2),
|
||||||
|
}));
|
||||||
|
await request('PARTNER_H5', `/partner/stores/${id}/packages`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({ packages }),
|
||||||
|
});
|
||||||
|
toastSuccess('已提交审核');
|
||||||
|
navigate(`/stores/${id}`);
|
||||||
|
} catch (e) {
|
||||||
|
toastError(e instanceof Error ? e.message : '提交失败');
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="partner-detail-page partner-home--flush-top">
|
||||||
|
<main style={{ padding: '24px 20px' }}>
|
||||||
|
<p className="label-md text-muted">加载中…</p>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="partner-page-sticky partner-home--flush-top">
|
||||||
|
<header className="partner-packages-page-header">
|
||||||
|
<button type="button" className="partner-packages-back" onClick={() => navigate(`/stores/${id}`)}>
|
||||||
|
<span className="material-symbols-outlined">arrow_back</span>
|
||||||
|
</button>
|
||||||
|
<h1 className="headline-md">门店套餐</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main className="partner-packages-page-main">
|
||||||
|
{error ? <p className="partner-form-error" role="alert">{error}</p> : null}
|
||||||
|
|
||||||
|
{pending?.status === 'PENDING' ? (
|
||||||
|
<div className="partner-info-banner">
|
||||||
|
<span className="material-symbols-outlined" style={{ color: 'var(--color-heritage-red)' }}>hourglass_top</span>
|
||||||
|
<p className="body-md">套餐变更审核中,C 端仍展示上一版生效套餐。</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{pending?.status === 'REJECTED' && pending.rejectReason ? (
|
||||||
|
<div className="partner-info-banner" style={{ background: 'rgba(180,35,24,0.06)', borderColor: 'rgba(180,35,24,0.15)' }}>
|
||||||
|
<span className="material-symbols-outlined" style={{ color: 'var(--color-heritage-red)' }}>error</span>
|
||||||
|
<p className="body-md">上次驳回:{pending.rejectReason}</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<section className="partner-form-card">
|
||||||
|
<div className="partner-section-title">
|
||||||
|
<div className="partner-section-bar" />
|
||||||
|
<h2 className="headline-md">套餐信息</h2>
|
||||||
|
</div>
|
||||||
|
<p className="label-md text-muted" style={{ marginBottom: 16 }}>
|
||||||
|
提交后将由总部审核,通过后 C 端展示生效套餐。
|
||||||
|
</p>
|
||||||
|
<StorePackagesForm
|
||||||
|
items={items}
|
||||||
|
onChange={setItems}
|
||||||
|
disabled={pending?.status === 'PENDING' || submitting}
|
||||||
|
embedded
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer className="partner-sticky-footer">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-btn-outline"
|
||||||
|
onClick={() => navigate(`/stores/${id}`)}
|
||||||
|
disabled={submitting}
|
||||||
|
>
|
||||||
|
返回
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="partner-btn-primary"
|
||||||
|
disabled={submitting || pending?.status === 'PENDING'}
|
||||||
|
onClick={() => void submitAudit()}
|
||||||
|
>
|
||||||
|
{submitting ? '提交中…' : '提交审核'}
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import type { PartnerWeeklyReportResponse } from '@dukang/shared-types';
|
|||||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
import { fetchPartnerWeeklyReport } from '../lib/weeklyReport';
|
import { fetchPartnerWeeklyReport } from '../lib/weeklyReport';
|
||||||
|
import { usePartnerPageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function fmtMoney(n: number) {
|
function fmtMoney(n: number) {
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 0 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 0 });
|
||||||
@@ -15,6 +16,7 @@ function fmtGrowth(n: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function WeeklyReportPage() {
|
export default function WeeklyReportPage() {
|
||||||
|
usePartnerPageView('partner_weekly_report_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [selectedStart, setSelectedStart] = useState<string | undefined>();
|
const [selectedStart, setSelectedStart] = useState<string | undefined>();
|
||||||
const [data, setData] = useState<PartnerWeeklyReportResponse | null>(null);
|
const [data, setData] = useState<PartnerWeeklyReportResponse | null>(null);
|
||||||
|
|||||||
@@ -3634,3 +3634,107 @@ header:has(> .app-page-title:only-child),
|
|||||||
border: none !important;
|
border: none !important;
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── 门店套餐 ─── */
|
||||||
|
.partner-packages-page-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 12px var(--space-page) 8px;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-bottom: 1px solid rgba(226, 190, 188, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-back {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-page-main {
|
||||||
|
padding-bottom: 88px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-form--embedded .partner-packages-item {
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
box-shadow: none;
|
||||||
|
border: 1px solid rgba(226, 190, 188, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-form--embedded .partner-packages-item:last-of-type {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-item-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: var(--space-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-item--collapsed .partner-packages-item-head {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-toggle .material-symbols-outlined {
|
||||||
|
font-size: 20px;
|
||||||
|
color: var(--color-on-surface-variant, #666);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-toggle .headline-md {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-remove {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-heritage-red);
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-add {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
width: calc(100% - var(--space-page) * 2);
|
||||||
|
margin: 0 var(--space-page) var(--space-md);
|
||||||
|
min-height: 48px;
|
||||||
|
border: 1px dashed rgba(166, 29, 36, 0.35);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: rgba(166, 29, 36, 0.04);
|
||||||
|
color: var(--color-heritage-red);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-add .material-symbols-outlined {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.partner-packages-form:not(.partner-packages-form--embedded) .partner-packages-item {
|
||||||
|
margin-left: var(--space-page);
|
||||||
|
margin-right: var(--space-page);
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"lint": "echo ok"
|
"lint": "echo ok"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@dukang/client-logging": "workspace:*",
|
||||||
"@dukang/shared-ui": "workspace:*",
|
"@dukang/shared-ui": "workspace:*",
|
||||||
"@dukang/shared-types": "workspace:*",
|
"@dukang/shared-types": "workspace:*",
|
||||||
"@dukang/weixin-sdk": "workspace:*",
|
"@dukang/weixin-sdk": "workspace:*",
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import RecordsPage from './pages/RecordsPage';
|
|||||||
import StatusPage from './pages/StatusPage';
|
import StatusPage from './pages/StatusPage';
|
||||||
import MinePage from './pages/MinePage';
|
import MinePage from './pages/MinePage';
|
||||||
import StaffPage from './pages/StaffPage';
|
import StaffPage from './pages/StaffPage';
|
||||||
|
import WithdrawPage from './pages/WithdrawPage';
|
||||||
|
import PackagesPage from './pages/PackagesPage';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
@@ -22,6 +24,8 @@ export default function App() {
|
|||||||
<Route path="/legal/privacy-policy" element={<LegalPage docId="privacy-policy" />} />
|
<Route path="/legal/privacy-policy" element={<LegalPage docId="privacy-policy" />} />
|
||||||
<Route path="/select-store" element={<SelectStorePage />} />
|
<Route path="/select-store" element={<SelectStorePage />} />
|
||||||
<Route path="/staff" element={<StaffPage />} />
|
<Route path="/staff" element={<StaffPage />} />
|
||||||
|
<Route path="/withdraw" element={<WithdrawPage />} />
|
||||||
|
<Route path="/packages" element={<PackagesPage />} />
|
||||||
<Route path="/redeem" element={<RedeemConfirmPage />} />
|
<Route path="/redeem" element={<RedeemConfirmPage />} />
|
||||||
<Route path="/redeem/phone" element={<PhoneRedeemPage />} />
|
<Route path="/redeem/phone" element={<PhoneRedeemPage />} />
|
||||||
<Route path="/redeem/success" element={<RedeemSuccessPage />} />
|
<Route path="/redeem/success" element={<RedeemSuccessPage />} />
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
|
import { emptyPackage, type PackageFormItem } from '../lib/storePackages';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
items: PackageFormItem[];
|
||||||
|
onChange: (items: PackageFormItem[]) => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ShopPackagesForm({ items, onChange, disabled }: Props) {
|
||||||
|
const [collapsed, setCollapsed] = useState<Record<number, boolean>>({});
|
||||||
|
|
||||||
|
function updateAt(index: number, patch: Partial<PackageFormItem>) {
|
||||||
|
onChange(items.map((item, i) => (i === index ? { ...item, ...patch } : item)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function addItem() {
|
||||||
|
if (items.length >= STORE_PACKAGE_MAX_COUNT) return;
|
||||||
|
onChange([...items, emptyPackage(items.length)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAt(index: number) {
|
||||||
|
onChange(items.filter((_, i) => i !== index).map((item, i) => ({ ...item, sortOrder: i })));
|
||||||
|
setCollapsed((prev) => {
|
||||||
|
const next: Record<number, boolean> = {};
|
||||||
|
Object.entries(prev).forEach(([k, v]) => {
|
||||||
|
const i = Number(k);
|
||||||
|
if (i < index) next[i] = v;
|
||||||
|
else if (i > index) next[i - 1] = v;
|
||||||
|
});
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCollapse(index: number) {
|
||||||
|
setCollapsed((prev) => ({ ...prev, [index]: !prev[index] }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = items.length ? items : [emptyPackage(0)];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="shop-packages-form">
|
||||||
|
{list.map((item, index) => {
|
||||||
|
const isCollapsed = !!collapsed[index];
|
||||||
|
const displayName = item.name.trim() || `套餐 ${index + 1}`;
|
||||||
|
return (
|
||||||
|
<section key={index} className={`shop-packages-card${isCollapsed ? ' shop-packages-card--collapsed' : ''}`}>
|
||||||
|
<div className="shop-packages-card-head">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-packages-toggle"
|
||||||
|
onClick={() => toggleCollapse(index)}
|
||||||
|
aria-expanded={!isCollapsed}
|
||||||
|
aria-label={isCollapsed ? '展开套餐' : '收起套餐'}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined">
|
||||||
|
{isCollapsed ? 'expand_more' : 'expand_less'}
|
||||||
|
</span>
|
||||||
|
<span className="shop-packages-card-title">{displayName}</span>
|
||||||
|
</button>
|
||||||
|
{!disabled && list.length > 1 ? (
|
||||||
|
<button type="button" className="shop-packages-remove" onClick={() => removeAt(index)}>
|
||||||
|
删除
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!isCollapsed ? (
|
||||||
|
<>
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">套餐名称 *</span>
|
||||||
|
<input
|
||||||
|
className="shop-packages-input"
|
||||||
|
placeholder="如:套餐A"
|
||||||
|
value={item.name}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { name: e.target.value })}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">价格(元) *</span>
|
||||||
|
<input
|
||||||
|
className="shop-packages-input"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
step={0.01}
|
||||||
|
placeholder="198"
|
||||||
|
value={item.price}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { price: e.target.value })}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">菜品 *</span>
|
||||||
|
<textarea
|
||||||
|
className="shop-packages-textarea"
|
||||||
|
rows={3}
|
||||||
|
placeholder="红烧肉、红烧鱼、油焖茄子"
|
||||||
|
value={item.dishes}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { dishes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">使用时间</span>
|
||||||
|
<input
|
||||||
|
className="shop-packages-input"
|
||||||
|
placeholder="节假日除外"
|
||||||
|
value={item.usableTime || ''}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { usableTime: e.target.value })}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="shop-packages-field">
|
||||||
|
<span className="shop-packages-label">其他说明</span>
|
||||||
|
<input
|
||||||
|
className="shop-packages-input"
|
||||||
|
placeholder="不可叠加"
|
||||||
|
value={item.otherNotes || ''}
|
||||||
|
disabled={disabled}
|
||||||
|
onChange={(e) => updateAt(index, { otherNotes: e.target.value })}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
{!disabled && list.length < STORE_PACKAGE_MAX_COUNT ? (
|
||||||
|
<button type="button" className="shop-packages-add" onClick={addItem}>
|
||||||
|
<span className="material-symbols-outlined">add_circle</span>
|
||||||
|
添加套餐
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { createStoreTracker } from '@dukang/client-logging';
|
||||||
|
import { apiBase } from './api';
|
||||||
|
|
||||||
|
const tracker = createStoreTracker({
|
||||||
|
apiBase,
|
||||||
|
clientApp: 'SHOP_H5',
|
||||||
|
getToken: () => localStorage.getItem('shopAccessToken'),
|
||||||
|
getStoreId: () => {
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem('shopSession');
|
||||||
|
if (!raw) return null;
|
||||||
|
const parsed = JSON.parse(raw) as { storeId?: string };
|
||||||
|
return parsed.storeId ?? null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function trackStore(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.track(eventName, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trackStorePageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.trackPageView(eventName, params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import type { StorePackageItemDto } from '@dukang/shared-types';
|
||||||
|
import { STORE_PACKAGE_MAX_COUNT } from '@dukang/shared-types';
|
||||||
|
|
||||||
|
export type PackageFormItem = StorePackageItemDto;
|
||||||
|
|
||||||
|
export function emptyPackage(index = 0): PackageFormItem {
|
||||||
|
return {
|
||||||
|
name: '',
|
||||||
|
price: '',
|
||||||
|
dishes: '',
|
||||||
|
usableTime: '',
|
||||||
|
otherNotes: '',
|
||||||
|
sortOrder: index,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizePackageFormItems(raw: PackageFormItem[]): PackageFormItem[] {
|
||||||
|
return raw
|
||||||
|
.map((item, index) => ({
|
||||||
|
name: item.name.trim(),
|
||||||
|
price: item.price.trim(),
|
||||||
|
dishes: item.dishes.trim(),
|
||||||
|
usableTime: item.usableTime?.trim() || '',
|
||||||
|
otherNotes: item.otherNotes?.trim() || '',
|
||||||
|
sortOrder: index,
|
||||||
|
}))
|
||||||
|
.filter((item) => item.name || item.price || item.dishes || item.usableTime || item.otherNotes);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function validatePackageFormItems(items: PackageFormItem[]): string | null {
|
||||||
|
const filled = normalizePackageFormItems(items);
|
||||||
|
if (filled.length > STORE_PACKAGE_MAX_COUNT) {
|
||||||
|
return `套餐最多 ${STORE_PACKAGE_MAX_COUNT} 条`;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < filled.length; i++) {
|
||||||
|
const item = filled[i];
|
||||||
|
if (!item.name) return `第 ${i + 1} 条套餐名称不能为空`;
|
||||||
|
const price = Number(item.price);
|
||||||
|
if (!Number.isFinite(price) || price < 0) return `第 ${i + 1} 条套餐价格须为非负数字`;
|
||||||
|
if (!item.dishes) return `第 ${i + 1} 条套餐菜品不能为空`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { trackStorePageView } from './analytics';
|
||||||
|
|
||||||
|
export function useStorePageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
const fired = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (fired.current) return;
|
||||||
|
fired.current = true;
|
||||||
|
trackStorePageView(eventName, params);
|
||||||
|
}, [eventName, params]);
|
||||||
|
}
|
||||||
@@ -3,12 +3,17 @@ import ReactDOM from 'react-dom/client';
|
|||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { getRouterBasename } from '@dukang/weixin-sdk';
|
import { getRouterBasename } from '@dukang/weixin-sdk';
|
||||||
import { StoreSessionProvider } from './contexts/StoreSessionContext';
|
import { StoreSessionProvider } from './contexts/StoreSessionContext';
|
||||||
import { installClientErrorReporting } from './lib/client-error';
|
import { installClientErrorReporting } from '@dukang/client-logging';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
import { apiBase } from './lib/api';
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
import './styles/legal.css';
|
import './styles/legal.css';
|
||||||
|
|
||||||
installClientErrorReporting();
|
installClientErrorReporting({
|
||||||
|
apiBase,
|
||||||
|
clientApp: 'SHOP_H5',
|
||||||
|
getToken: () => localStorage.getItem('shopAccessToken'),
|
||||||
|
});
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
||||||
import { stripOAuthParamsFromLocation } from '@dukang/weixin-sdk';
|
import { stripOAuthParamsFromLocation } from '@dukang/weixin-sdk';
|
||||||
import WechatScanAuthModal from '../components/WechatScanAuthModal';
|
import WechatScanAuthModal from '../components/WechatScanAuthModal';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
import { trackStore } from '../lib/analytics';
|
||||||
|
|
||||||
const PENDING_SCAN_KEY = 'shop_pending_scan';
|
const PENDING_SCAN_KEY = 'shop_pending_scan';
|
||||||
|
|
||||||
@@ -27,12 +29,13 @@ function formatScanError(e: unknown): string {
|
|||||||
return '微信 JSSDK 签名校验失败:请确认公众号已配置 JS 接口安全域名,并刷新页面后重试';
|
return '微信 JSSDK 签名校验失败:请确认公众号已配置 JS 接口安全域名,并刷新页面后重试';
|
||||||
}
|
}
|
||||||
if (/offline verifying|权限验证中|接口未就绪/i.test(msg)) {
|
if (/offline verifying|权限验证中|接口未就绪/i.test(msg)) {
|
||||||
return `${msg}(可在 URL 后加 ?wxdebug=1 开启 JSSDK 调试查看详情)`;
|
return '微信权限校验尚未完成,请等待 1~2 秒后再次点击扫码(首次绑定微信时较常见)';
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
|
useStorePageView('store_home_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { applySession } = useStoreSession();
|
const { applySession } = useStoreSession();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
@@ -73,7 +76,8 @@ export default function HomePage() {
|
|||||||
};
|
};
|
||||||
}, [loadDashboard]);
|
}, [loadDashboard]);
|
||||||
|
|
||||||
async function runScan() {
|
async function runScan(opts?: { postAuthWarmup?: boolean }) {
|
||||||
|
trackStore('store_redeem_scan_start');
|
||||||
if (!isWechatEnv()) {
|
if (!isWechatEnv()) {
|
||||||
setScanMsg('请在微信内打开门店端进行扫码核销');
|
setScanMsg('请在微信内打开门店端进行扫码核销');
|
||||||
return;
|
return;
|
||||||
@@ -81,8 +85,14 @@ export default function HomePage() {
|
|||||||
setScanning(true);
|
setScanning(true);
|
||||||
setScanMsg('');
|
setScanMsg('');
|
||||||
try {
|
try {
|
||||||
|
// 授权回跳后强制重签,避免沿用带 code 的旧签名态
|
||||||
|
if (opts?.postAuthWarmup) {
|
||||||
|
weixinSdk.reset();
|
||||||
|
}
|
||||||
await weixinSdk.init();
|
await weixinSdk.init();
|
||||||
const raw = await weixinSdk.scanQrCode();
|
const raw = await weixinSdk.scanQrCode(
|
||||||
|
opts?.postAuthWarmup ? { postAuthWarmup: true } : undefined,
|
||||||
|
);
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
void loadDashboard();
|
void loadDashboard();
|
||||||
return;
|
return;
|
||||||
@@ -111,12 +121,14 @@ export default function HomePage() {
|
|||||||
}
|
}
|
||||||
setAuthModalOpen(false);
|
setAuthModalOpen(false);
|
||||||
setAuthError('');
|
setAuthError('');
|
||||||
|
// 先清 OAuth 参数再扫,保证 JSSDK 签名 URL 与当前页一致
|
||||||
stripOAuthParamsFromLocation();
|
stripOAuthParamsFromLocation();
|
||||||
setSearchParams({}, { replace: true });
|
setSearchParams({}, { replace: true });
|
||||||
const shouldScan = sessionStorage.getItem(PENDING_SCAN_KEY) === '1';
|
const shouldScan = sessionStorage.getItem(PENDING_SCAN_KEY) === '1';
|
||||||
sessionStorage.removeItem(PENDING_SCAN_KEY);
|
sessionStorage.removeItem(PENDING_SCAN_KEY);
|
||||||
if (shouldScan) {
|
if (shouldScan) {
|
||||||
window.setTimeout(() => void runScan(), 0);
|
// OAuth 回跳后微信权限离线校验未完成;稍候再扫,失败可再点一次
|
||||||
|
window.setTimeout(() => void runScan({ postAuthWarmup: true }), 400);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -182,6 +194,9 @@ export default function HomePage() {
|
|||||||
<div className="shop-home-stat">
|
<div className="shop-home-stat">
|
||||||
<p className="shop-home-stat-label">今日核销笔数</p>
|
<p className="shop-home-stat-label">今日核销笔数</p>
|
||||||
<p className="shop-home-stat-value">{Number(dash?.todayCount || 0)}</p>
|
<p className="shop-home-stat-value">{Number(dash?.todayCount || 0)}</p>
|
||||||
|
<p className="shop-home-stat-sub">
|
||||||
|
扫码 {Number(dash?.todayScanCount || 0)} · 手机号 {Number(dash?.todayPhoneCount || 0)}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="shop-home-stat">
|
<div className="shop-home-stat">
|
||||||
<p className="shop-home-stat-label">今日到账金额</p>
|
<p className="shop-home-stat-label">今日到账金额</p>
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import {
|
|||||||
handleShopWechatLoginResult,
|
handleShopWechatLoginResult,
|
||||||
} from '../lib/wechat-auth';
|
} from '../lib/wechat-auth';
|
||||||
import { isWechatEnv } from '../lib/weixin';
|
import { isWechatEnv } from '../lib/weixin';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
export default function MinePage() {
|
export default function MinePage() {
|
||||||
|
useStorePageView('store_mine_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
const { resetSession, store: sessionStore, applySession } = useStoreSession();
|
const { resetSession, store: sessionStore, applySession } = useStoreSession();
|
||||||
@@ -141,6 +143,16 @@ export default function MinePage() {
|
|||||||
切换门店
|
切换门店
|
||||||
</button>
|
</button>
|
||||||
) : null}
|
) : null}
|
||||||
|
<button type="button" className="shop-mine-action" onClick={() => navigate('/withdraw')}>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>account_balance_wallet</span>
|
||||||
|
结算提现
|
||||||
|
</button>
|
||||||
|
{profile?.isPrimary ? (
|
||||||
|
<button type="button" className="shop-mine-action" onClick={() => navigate('/packages')}>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>restaurant_menu</span>
|
||||||
|
门店套餐
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
{profile?.isPrimary ? (
|
{profile?.isPrimary ? (
|
||||||
<button type="button" className="shop-mine-action" onClick={() => navigate('/staff')}>
|
<button type="button" className="shop-mine-action" onClick={() => navigate('/staff')}>
|
||||||
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>group</span>
|
<span className="material-symbols-outlined" style={{ fontSize: 20 }}>group</span>
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import type { StorePackagesResponse } from '@dukang/shared-types';
|
||||||
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
|
import ShopPackagesForm from '../components/ShopPackagesForm';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
import {
|
||||||
|
emptyPackage,
|
||||||
|
normalizePackageFormItems,
|
||||||
|
validatePackageFormItems,
|
||||||
|
type PackageFormItem,
|
||||||
|
} from '../lib/storePackages';
|
||||||
|
|
||||||
|
export default function PackagesPage() {
|
||||||
|
useStorePageView('store_packages_view');
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [items, setItems] = useState<PackageFormItem[]>([emptyPackage()]);
|
||||||
|
const [pending, setPending] = useState<StorePackagesResponse['pendingRequest']>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [msg, setMsg] = useState('');
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const data = await request<StorePackagesResponse>('SHOP_H5', '/shop/store/packages');
|
||||||
|
const base = data.pendingRequest?.packages?.length
|
||||||
|
? data.pendingRequest.packages
|
||||||
|
: data.live?.length
|
||||||
|
? data.live
|
||||||
|
: [emptyPackage()];
|
||||||
|
setItems(base.map((p, i) => ({ ...p, price: String(p.price), sortOrder: i })));
|
||||||
|
setPending(data.pendingRequest ?? null);
|
||||||
|
setMsg('');
|
||||||
|
} catch (e) {
|
||||||
|
setMsg(e instanceof Error ? e.message : '加载失败');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void load();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function submitAudit() {
|
||||||
|
const validationMsg = validatePackageFormItems(items);
|
||||||
|
if (validationMsg) {
|
||||||
|
setMsg(validationMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pending?.status === 'PENDING') {
|
||||||
|
setMsg('已有套餐变更审核中,请等待总部处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSubmitting(true);
|
||||||
|
setMsg('');
|
||||||
|
try {
|
||||||
|
const packages = normalizePackageFormItems(items).map((p) => ({
|
||||||
|
...p,
|
||||||
|
price: Number(p.price).toFixed(2),
|
||||||
|
}));
|
||||||
|
await request('SHOP_H5', '/shop/store/packages', {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify({ packages }),
|
||||||
|
});
|
||||||
|
setMsg('已提交审核,请等待总部处理');
|
||||||
|
await load();
|
||||||
|
} catch (e) {
|
||||||
|
setMsg(e instanceof Error ? e.message : '提交失败');
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const disabled = pending?.status === 'PENDING' || submitting;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PullToRefresh onRefresh={load} className="shop-records-page shop-packages-page">
|
||||||
|
<header className="shop-records-header" style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-withdraw-back"
|
||||||
|
onClick={() => navigate('/mine')}
|
||||||
|
aria-label="返回"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: 22 }}>
|
||||||
|
arrow_back
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<h1 className="app-page-title" style={{ margin: 0 }}>
|
||||||
|
门店套餐
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div className="shop-records-main">
|
||||||
|
{loading ? <p className="shop-records-empty">加载中…</p> : null}
|
||||||
|
|
||||||
|
{!loading && pending?.status === 'PENDING' ? (
|
||||||
|
<section className="shop-packages-notice">
|
||||||
|
<span className="material-symbols-outlined shop-fill-icon" style={{ fontSize: 18 }}>
|
||||||
|
hourglass_top
|
||||||
|
</span>
|
||||||
|
<p>套餐变更审核中,用户端仍展示上一版生效套餐。</p>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{!loading && pending?.status === 'REJECTED' && pending.rejectReason ? (
|
||||||
|
<section className="shop-packages-notice shop-packages-notice--warn">
|
||||||
|
<span className="material-symbols-outlined shop-fill-icon" style={{ fontSize: 18 }}>
|
||||||
|
error
|
||||||
|
</span>
|
||||||
|
<p>上次驳回:{pending.rejectReason}</p>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{!loading ? (
|
||||||
|
<>
|
||||||
|
<p className="shop-packages-intro">
|
||||||
|
维护门店可核销套餐信息,提交后由总部审核通过后在用户端展示。
|
||||||
|
</p>
|
||||||
|
<ShopPackagesForm items={items} onChange={setItems} disabled={disabled} />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{msg ? <p className="shop-withdraw-msg">{msg}</p> : null}
|
||||||
|
|
||||||
|
{!loading ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-withdraw-btn"
|
||||||
|
style={{ marginTop: 16 }}
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={() => void submitAudit()}
|
||||||
|
>
|
||||||
|
{submitting ? '提交中…' : '提交审核'}
|
||||||
|
</button>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</PullToRefresh>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,12 +2,14 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import type { RedeemPhoneDirectPrepareResult } from '@dukang/shared-types';
|
import type { RedeemPhoneDirectPrepareResult } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function formatAmount(n: number) {
|
function formatAmount(n: number) {
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PhoneRedeemPage() {
|
export default function PhoneRedeemPage() {
|
||||||
|
useStorePageView('store_phone_redeem_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [phone, setPhone] = useState('');
|
const [phone, setPhone] = useState('');
|
||||||
const [amount, setAmount] = useState('');
|
const [amount, setAmount] = useState('');
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
|
import { REDEEM_CHANNEL_LABELS, type RedeemChannel, type RedeemStatsDto } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type RangeKey = 'today' | '7d' | '30d';
|
type RangeKey = 'today' | '7d' | '30d';
|
||||||
type StatusFilter = 'all' | 'pending' | 'paid';
|
type StatusFilter = 'all' | 'pending' | 'paid';
|
||||||
@@ -23,32 +25,60 @@ function inRange(dateStr: string, range: RangeKey) {
|
|||||||
return d >= start;
|
return d >= start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function channelLabel(channel: unknown): string {
|
||||||
|
const key = channel === 'PHONE' ? 'PHONE' : 'SCAN';
|
||||||
|
return REDEEM_CHANNEL_LABELS[key];
|
||||||
|
}
|
||||||
|
|
||||||
export default function RecordsPage() {
|
export default function RecordsPage() {
|
||||||
|
useStorePageView('store_records_view');
|
||||||
const [records, setRecords] = useState<Array<Record<string, unknown>>>([]);
|
const [records, setRecords] = useState<Array<Record<string, unknown>>>([]);
|
||||||
const [range, setRange] = useState<RangeKey>('today');
|
const [range, setRange] = useState<RangeKey>('today');
|
||||||
const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');
|
const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');
|
||||||
const [storeName, setStoreName] = useState('');
|
const [storeName, setStoreName] = useState('');
|
||||||
|
const [statsOpen, setStatsOpen] = useState(false);
|
||||||
|
const [statsLoading, setStatsLoading] = useState(false);
|
||||||
|
const [stats, setStats] = useState<RedeemStatsDto | null>(null);
|
||||||
|
|
||||||
const loadRecords = useCallback(() => {
|
const loadRecords = useCallback(() => {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
request<{ list: Array<Record<string, unknown>> }>('SHOP_H5', '/shop/redeem/records').then((d) => {
|
request<{ list: Array<Record<string, unknown>> }>('SHOP_H5', '/shop/redeem/records?pageSize=200').then(
|
||||||
setRecords(d.list || []);
|
(d) => {
|
||||||
}),
|
setRecords(d.list || []);
|
||||||
|
},
|
||||||
|
),
|
||||||
request<Record<string, unknown>>('SHOP_H5', '/shop/store')
|
request<Record<string, unknown>>('SHOP_H5', '/shop/store')
|
||||||
.then((s) => setStoreName(String(s.name || '')))
|
.then((s) => setStoreName(String(s.name || '')))
|
||||||
.catch(() => {}),
|
.catch(() => {}),
|
||||||
]);
|
]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const loadStats = useCallback(async (r: RangeKey) => {
|
||||||
|
setStatsLoading(true);
|
||||||
|
try {
|
||||||
|
const data = await request<RedeemStatsDto>('SHOP_H5', `/shop/redeem/stats?range=${r}`);
|
||||||
|
setStats(data);
|
||||||
|
} catch {
|
||||||
|
setStats(null);
|
||||||
|
} finally {
|
||||||
|
setStatsLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void loadRecords();
|
void loadRecords();
|
||||||
}, [loadRecords]);
|
}, [loadRecords]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (statsOpen) void loadStats(range);
|
||||||
|
}, [statsOpen, range, loadStats]);
|
||||||
|
|
||||||
const filtered = useMemo(() => {
|
const filtered = useMemo(() => {
|
||||||
return records.filter((r) => {
|
return records.filter((r) => {
|
||||||
if (!inRange(String(r.createdAt), range)) return false;
|
if (!inRange(String(r.createdAt), range)) return false;
|
||||||
if (statusFilter === 'all') return true;
|
if (statusFilter === 'all') return true;
|
||||||
const isPaid = Boolean(r.paidAt);
|
const payout = r.payout as { paidAt?: string | null; status?: string } | undefined;
|
||||||
|
const isPaid = Boolean(payout?.paidAt) || payout?.status === 'PAID' || Boolean(r.paidAt);
|
||||||
if (statusFilter === 'paid') return isPaid;
|
if (statusFilter === 'paid') return isPaid;
|
||||||
return !isPaid;
|
return !isPaid;
|
||||||
});
|
});
|
||||||
@@ -70,11 +100,13 @@ export default function RecordsPage() {
|
|||||||
<div className="shop-records-main">
|
<div className="shop-records-main">
|
||||||
<nav className="shop-records-filters">
|
<nav className="shop-records-filters">
|
||||||
<div className="shop-records-range-tabs">
|
<div className="shop-records-range-tabs">
|
||||||
{([
|
{(
|
||||||
['today', '今日'],
|
[
|
||||||
['7d', '近7日'],
|
['today', '今日'],
|
||||||
['30d', '近30日'],
|
['7d', '近7日'],
|
||||||
] as const).map(([key, label]) => (
|
['30d', '近30日'],
|
||||||
|
] as const
|
||||||
|
).map(([key, label]) => (
|
||||||
<button
|
<button
|
||||||
key={key}
|
key={key}
|
||||||
type="button"
|
type="button"
|
||||||
@@ -85,21 +117,35 @@ export default function RecordsPage() {
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="shop-records-status-chips">
|
<div className="shop-records-status-row">
|
||||||
{([
|
<div className="shop-records-status-chips">
|
||||||
['all', '全部'],
|
{(
|
||||||
['pending', '待打款'],
|
[
|
||||||
['paid', '已打款'],
|
['all', '全部'],
|
||||||
] as const).map(([key, label]) => (
|
['pending', '待打款'],
|
||||||
<button
|
['paid', '已打款'],
|
||||||
key={key}
|
] as const
|
||||||
type="button"
|
).map(([key, label]) => (
|
||||||
className={`shop-records-chip${statusFilter === key ? ' active' : ''}`}
|
<button
|
||||||
onClick={() => setStatusFilter(key)}
|
key={key}
|
||||||
>
|
type="button"
|
||||||
{label}
|
className={`shop-records-chip${statusFilter === key ? ' active' : ''}`}
|
||||||
</button>
|
onClick={() => setStatusFilter(key)}
|
||||||
))}
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-records-stats-btn"
|
||||||
|
onClick={() => setStatsOpen(true)}
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>
|
||||||
|
bar_chart
|
||||||
|
</span>
|
||||||
|
统计
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@@ -115,7 +161,10 @@ export default function RecordsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className="shop-records-summary-note">
|
<p className="shop-records-summary-note">
|
||||||
<span className="material-symbols-outlined shop-fill-icon" style={{ fontSize: 16, color: 'var(--color-success-green)' }}>
|
<span
|
||||||
|
className="material-symbols-outlined shop-fill-icon"
|
||||||
|
style={{ fontSize: 16, color: 'var(--color-success-green)' }}
|
||||||
|
>
|
||||||
check_circle
|
check_circle
|
||||||
</span>
|
</span>
|
||||||
结算比例: {summary.rate}% (按{summary.rate / 10}折结算)
|
结算比例: {summary.rate}% (按{summary.rate / 10}折结算)
|
||||||
@@ -134,17 +183,32 @@ export default function RecordsPage() {
|
|||||||
{filtered.map((r) => {
|
{filtered.map((r) => {
|
||||||
const amount = Number(r.amount || 0);
|
const amount = Number(r.amount || 0);
|
||||||
const settle = Number(r.settleAmount || 0);
|
const settle = Number(r.settleAmount || 0);
|
||||||
const paid = Boolean(r.paidAt);
|
const payout = r.payout as { paidAt?: string | null; status?: string } | undefined;
|
||||||
|
const paid = Boolean(payout?.paidAt) || payout?.status === 'PAID' || Boolean(r.paidAt);
|
||||||
|
const paidAt = payout?.paidAt || (typeof r.paidAt === 'string' ? r.paidAt : null);
|
||||||
|
const channel = (r.channel === 'PHONE' ? 'PHONE' : 'SCAN') as RedeemChannel;
|
||||||
return (
|
return (
|
||||||
<article key={String(r.id)} className="shop-record-card">
|
<article key={String(r.id)} className="shop-record-card">
|
||||||
<div className="shop-record-card-top">
|
<div className="shop-record-card-top">
|
||||||
<div>
|
<div>
|
||||||
<div className="shop-record-order">
|
<div className="shop-record-order">
|
||||||
<span className="shop-record-time" style={{ margin: 0 }}>订单号</span>
|
<span className="shop-record-time" style={{ margin: 0 }}>
|
||||||
|
订单号
|
||||||
|
</span>
|
||||||
<span>{r.redeemNo ? String(r.redeemNo) : '—'}</span>
|
<span>{r.redeemNo ? String(r.redeemNo) : '—'}</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="shop-record-time">
|
<p className="shop-record-time">
|
||||||
核销时间: {new Date(String(r.createdAt)).toLocaleString('zh-CN', { hour12: false }).slice(0, 16)}
|
核销时间:{' '}
|
||||||
|
{new Date(String(r.createdAt))
|
||||||
|
.toLocaleString('zh-CN', { hour12: false })
|
||||||
|
.slice(0, 16)}
|
||||||
|
</p>
|
||||||
|
<p className="shop-record-channel">
|
||||||
|
<span
|
||||||
|
className={`shop-record-channel-tag${channel === 'PHONE' ? ' phone' : ''}`}
|
||||||
|
>
|
||||||
|
{channelLabel(channel)}
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span className={`shop-record-badge ${paid ? 'paid' : 'pending'}`}>
|
<span className={`shop-record-badge ${paid ? 'paid' : 'pending'}`}>
|
||||||
@@ -162,10 +226,16 @@ export default function RecordsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="shop-record-footer">
|
<div className="shop-record-footer">
|
||||||
<p>{paid ? `打款时间: ${new Date(String(r.createdAt)).toLocaleDateString('zh-CN')}` : '预计打款: T+1工作日'}</p>
|
<p>
|
||||||
|
{paid
|
||||||
|
? `打款时间: ${paidAt ? new Date(String(paidAt)).toLocaleDateString('zh-CN') : '—'}`
|
||||||
|
: '预计打款: T+1工作日'}
|
||||||
|
</p>
|
||||||
{storeName && (
|
{storeName && (
|
||||||
<span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
<span style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||||
<span className="material-symbols-outlined" style={{ fontSize: 12 }}>restaurant</span>
|
<span className="material-symbols-outlined" style={{ fontSize: 12 }}>
|
||||||
|
restaurant
|
||||||
|
</span>
|
||||||
{storeName}
|
{storeName}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -183,6 +253,80 @@ export default function RecordsPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{statsOpen && (
|
||||||
|
<div className="shop-stats-overlay" role="dialog" aria-modal="true" aria-label="核销方式统计">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-stats-backdrop"
|
||||||
|
aria-label="关闭"
|
||||||
|
onClick={() => setStatsOpen(false)}
|
||||||
|
/>
|
||||||
|
<div className="shop-stats-sheet">
|
||||||
|
<div className="shop-stats-sheet-head">
|
||||||
|
<h2>核销方式统计</h2>
|
||||||
|
<button type="button" className="shop-stats-close" onClick={() => setStatsOpen(false)}>
|
||||||
|
<span className="material-symbols-outlined">close</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p className="shop-stats-range-hint">
|
||||||
|
统计区间:{range === 'today' ? '今日' : range === '7d' ? '近7日' : '近30日'}(与上方筛选同步)
|
||||||
|
</p>
|
||||||
|
{statsLoading ? (
|
||||||
|
<p className="shop-records-empty">加载中…</p>
|
||||||
|
) : !stats ? (
|
||||||
|
<p className="shop-records-empty">统计加载失败</p>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className="shop-stats-total">
|
||||||
|
<div>
|
||||||
|
<p className="shop-records-summary-label">合计笔数</p>
|
||||||
|
<p className="shop-stats-total-value">{stats.totalCount}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="shop-records-summary-label">核销总额</p>
|
||||||
|
<p className="shop-stats-total-value">¥{formatMoney(stats.totalAmount)}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="shop-records-summary-label">到账总额</p>
|
||||||
|
<p className="shop-stats-total-value">¥{formatMoney(stats.totalSettleAmount)}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="shop-stats-channel-list">
|
||||||
|
{stats.byChannel.map((b) => (
|
||||||
|
<div key={b.channel} className="shop-stats-channel-card">
|
||||||
|
<div className="shop-stats-channel-title">
|
||||||
|
<span
|
||||||
|
className={`shop-record-channel-tag${b.channel === 'PHONE' ? ' phone' : ''}`}
|
||||||
|
>
|
||||||
|
{REDEEM_CHANNEL_LABELS[b.channel]}
|
||||||
|
</span>
|
||||||
|
<strong>{b.count} 笔</strong>
|
||||||
|
</div>
|
||||||
|
<div className="shop-stats-channel-row">
|
||||||
|
<span>核销额</span>
|
||||||
|
<span>¥{formatMoney(b.amount)}</span>
|
||||||
|
</div>
|
||||||
|
<div className="shop-stats-channel-row">
|
||||||
|
<span>到账额</span>
|
||||||
|
<span>¥{formatMoney(b.settleAmount)}</span>
|
||||||
|
</div>
|
||||||
|
<div className="shop-stats-bar">
|
||||||
|
<div
|
||||||
|
className={`shop-stats-bar-fill${b.channel === 'PHONE' ? ' phone' : ''}`}
|
||||||
|
style={{
|
||||||
|
width: `${stats.totalCount > 0 ? Math.round((b.count / stats.totalCount) * 100) : 0}%`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</PullToRefresh>
|
</PullToRefresh>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
|
|||||||
import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel';
|
import WeakNetFallbackPanel from '../components/WeakNetFallbackPanel';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { reportRedeemFailure } from '../lib/redeem-failure';
|
import { reportRedeemFailure } from '../lib/redeem-failure';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
function formatAmount(n: number) {
|
function formatAmount(n: number) {
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
@@ -17,6 +18,7 @@ type Preview = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function RedeemConfirmPage() {
|
export default function RedeemConfirmPage() {
|
||||||
|
useStorePageView('store_redeem_confirm_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const [token, setToken] = useState('');
|
const [token, setToken] = useState('');
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { STORE_STAFF_ROLE_LABELS, type StoreStaffRole } from '@dukang/shared-typ
|
|||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||||
import { getStoreProfile, request } from '../lib/api';
|
import { getStoreProfile, request } from '../lib/api';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type StaffItem = {
|
type StaffItem = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -23,6 +24,7 @@ function maskPhone(phone: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function StaffPage() {
|
export default function StaffPage() {
|
||||||
|
useStorePageView('store_staff_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { store } = useStoreSession();
|
const { store } = useStoreSession();
|
||||||
const profile = store ?? getStoreProfile();
|
const profile = store ?? getStoreProfile();
|
||||||
|
|||||||
@@ -0,0 +1,236 @@
|
|||||||
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
STORE_WITHDRAW_STATUS_LABELS,
|
||||||
|
type StoreWithdrawRequestDto,
|
||||||
|
type StoreWithdrawStatus,
|
||||||
|
type StoreWithdrawSummaryDto,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
|
import { request } from '../lib/api';
|
||||||
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
|
type StatusFilter = 'all' | StoreWithdrawStatus;
|
||||||
|
|
||||||
|
function formatMoney(n: number) {
|
||||||
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function WithdrawPage() {
|
||||||
|
useStorePageView('store_withdraw_view');
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [summary, setSummary] = useState<StoreWithdrawSummaryDto | null>(null);
|
||||||
|
const [items, setItems] = useState<StoreWithdrawRequestDto[]>([]);
|
||||||
|
const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [msg, setMsg] = useState('');
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
const [summaryRes, listRes] = await Promise.all([
|
||||||
|
request<StoreWithdrawSummaryDto>('SHOP_H5', '/shop/withdraw/summary'),
|
||||||
|
request<{ items: StoreWithdrawRequestDto[] }>('SHOP_H5', '/shop/withdraw/requests?pageSize=50'),
|
||||||
|
]);
|
||||||
|
setSummary(summaryRes);
|
||||||
|
setItems(listRes.items || []);
|
||||||
|
} catch (e) {
|
||||||
|
setMsg(e instanceof Error ? e.message : '加载失败');
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
|
const filtered = useMemo(() => {
|
||||||
|
if (statusFilter === 'all') return items;
|
||||||
|
return items.filter((r) => r.status === statusFilter);
|
||||||
|
}, [items, statusFilter]);
|
||||||
|
|
||||||
|
async function applyWithdraw() {
|
||||||
|
if (!summary || submitting) return;
|
||||||
|
if (!summary.isPrimary) {
|
||||||
|
setMsg('仅主账号可申请提现');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(summary.availableAmount > 0)) {
|
||||||
|
setMsg('暂无可提未出账余额');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ok = window.confirm(
|
||||||
|
`确认申请提现 ¥${formatMoney(summary.availableAmount)}?\n审核通过后将打款至入驻收款账户。`,
|
||||||
|
);
|
||||||
|
if (!ok) return;
|
||||||
|
setSubmitting(true);
|
||||||
|
setMsg('');
|
||||||
|
try {
|
||||||
|
await request('SHOP_H5', '/shop/withdraw', {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({}),
|
||||||
|
});
|
||||||
|
setMsg('提现申请已提交,请等待总部审核');
|
||||||
|
await load();
|
||||||
|
} catch (e) {
|
||||||
|
setMsg(e instanceof Error ? e.message : '提现申请失败');
|
||||||
|
} finally {
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const canApply =
|
||||||
|
!!summary?.isPrimary &&
|
||||||
|
summary.availableAmount > 0 &&
|
||||||
|
!summary.hasPendingRequest &&
|
||||||
|
summary.hasBankAccount &&
|
||||||
|
!submitting;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PullToRefresh onRefresh={load} className="shop-records-page shop-withdraw-page">
|
||||||
|
<header className="shop-records-header" style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-withdraw-back"
|
||||||
|
onClick={() => navigate(-1)}
|
||||||
|
aria-label="返回"
|
||||||
|
>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: 22 }}>
|
||||||
|
arrow_back
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<h1 className="app-page-title" style={{ margin: 0 }}>
|
||||||
|
结算提现
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div className="shop-records-main">
|
||||||
|
<section className="shop-records-summary">
|
||||||
|
<div className="shop-records-summary-grid">
|
||||||
|
<div>
|
||||||
|
<p className="shop-records-summary-label">可提未出账余额</p>
|
||||||
|
<p className="shop-records-summary-value">
|
||||||
|
¥ {formatMoney(summary?.availableAmount ?? 0)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="shop-records-summary-label">今日剩余额度</p>
|
||||||
|
<p className="shop-records-summary-value">
|
||||||
|
¥ {formatMoney(summary?.remainingDailyLimit ?? 0)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="shop-records-summary-note">
|
||||||
|
<span
|
||||||
|
className="material-symbols-outlined shop-fill-icon"
|
||||||
|
style={{ fontSize: 16, color: 'var(--color-success-green)' }}
|
||||||
|
>
|
||||||
|
info
|
||||||
|
</span>
|
||||||
|
单日上限 ¥{formatMoney(summary?.dailyLimit ?? 5000)}
|
||||||
|
{summary?.hasPendingRequest ? ' · 已有待审核申请' : ''}
|
||||||
|
{!summary?.hasBankAccount ? ' · 请先完善收款账户' : ''}
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{summary && !summary.isPrimary ? (
|
||||||
|
<p className="shop-records-empty">仅主账号可申请提现,店员可查看记录</p>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="shop-withdraw-btn"
|
||||||
|
disabled={!canApply}
|
||||||
|
onClick={() => void applyWithdraw()}
|
||||||
|
>
|
||||||
|
{submitting ? '提交中…' : '申请提现'}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{msg ? <p className="shop-withdraw-msg">{msg}</p> : null}
|
||||||
|
|
||||||
|
<nav className="shop-records-filters" style={{ marginTop: 16 }}>
|
||||||
|
<div className="shop-records-status-chips">
|
||||||
|
{(
|
||||||
|
[
|
||||||
|
['all', '全部'],
|
||||||
|
['PENDING_REVIEW', '待审核'],
|
||||||
|
['PAID', '已结算'],
|
||||||
|
['REJECTED', '已驳回'],
|
||||||
|
] as const
|
||||||
|
).map(([key, label]) => (
|
||||||
|
<button
|
||||||
|
key={key}
|
||||||
|
type="button"
|
||||||
|
className={`shop-records-chip${statusFilter === key ? ' active' : ''}`}
|
||||||
|
onClick={() => setStatusFilter(key)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="shop-records-list-head">
|
||||||
|
<h3 className="shop-records-list-title">提现记录</h3>
|
||||||
|
<span className="shop-records-list-count">共 {filtered.length} 笔</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{filtered.length === 0 ? (
|
||||||
|
<p className="shop-records-empty">暂无提现记录</p>
|
||||||
|
) : (
|
||||||
|
<div className="shop-records-list">
|
||||||
|
{filtered.map((r) => {
|
||||||
|
const status = r.status as StoreWithdrawStatus;
|
||||||
|
const badgeClass =
|
||||||
|
status === 'PAID' ? 'paid' : status === 'REJECTED' ? 'rejected' : 'pending';
|
||||||
|
return (
|
||||||
|
<article key={r.id} className="shop-record-card">
|
||||||
|
<div className="shop-record-card-top">
|
||||||
|
<div>
|
||||||
|
<div className="shop-record-order">
|
||||||
|
<span className="shop-record-time" style={{ margin: 0 }}>
|
||||||
|
单号
|
||||||
|
</span>
|
||||||
|
<span>{r.withdrawNo}</span>
|
||||||
|
</div>
|
||||||
|
<p className="shop-record-time">
|
||||||
|
申请时间:{' '}
|
||||||
|
{new Date(r.appliedAt)
|
||||||
|
.toLocaleString('zh-CN', { hour12: false })
|
||||||
|
.slice(0, 16)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span className={`shop-record-badge ${badgeClass}`}>
|
||||||
|
{STORE_WITHDRAW_STATUS_LABELS[status] ?? status}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="shop-record-amounts">
|
||||||
|
<div>
|
||||||
|
<p className="shop-record-amount-label">提现金额</p>
|
||||||
|
<p className="shop-record-amount-value red">¥{formatMoney(Number(r.amount))}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="shop-record-amount-label">明细笔数</p>
|
||||||
|
<p className="shop-record-amount-value">{r.payoutCount} 笔</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{status === 'REJECTED' && r.rejectReason ? (
|
||||||
|
<div className="shop-record-footer">
|
||||||
|
<p>驳回原因: {r.rejectReason}</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
{status === 'PAID' && r.paidAt ? (
|
||||||
|
<div className="shop-record-footer">
|
||||||
|
<p>
|
||||||
|
结算时间:{' '}
|
||||||
|
{new Date(r.paidAt).toLocaleString('zh-CN', { hour12: false }).slice(0, 16)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</PullToRefresh>
|
||||||
|
);
|
||||||
|
}
|
||||||
+366
-1
@@ -587,6 +587,12 @@
|
|||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-home-stat-sub {
|
||||||
|
margin-top: 6px;
|
||||||
|
font-size: 11px;
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
.shop-home-scan {
|
.shop-home-scan {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -1549,18 +1555,42 @@
|
|||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-records-status-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-records-status-chips {
|
.shop-records-status-chips {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
padding: 8px 16px;
|
padding: 0;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop-records-status-chips::-webkit-scrollbar {
|
.shop-records-status-chips::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-records-stats-btn {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
border: 1px solid var(--color-primary);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-primary);
|
||||||
|
border-radius: var(--radius-full);
|
||||||
|
padding: 4px 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-records-chip {
|
.shop-records-chip {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -1578,6 +1608,142 @@
|
|||||||
color: var(--color-on-primary);
|
color: var(--color-on-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-record-channel {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-record-channel-tag {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 4px 8px;
|
||||||
|
border-radius: var(--radius-full);
|
||||||
|
background: rgba(59, 130, 246, 0.12);
|
||||||
|
color: #1d4ed8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-record-channel-tag.phone {
|
||||||
|
background: rgba(168, 85, 247, 0.12);
|
||||||
|
color: #7e22ce;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 80;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-backdrop {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border: none;
|
||||||
|
background: rgba(0, 0, 0, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-sheet {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 480px;
|
||||||
|
max-height: 78vh;
|
||||||
|
overflow: auto;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-radius: 16px 16px 0 0;
|
||||||
|
padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
|
||||||
|
box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-sheet-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-sheet-head h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-close {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 4px;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-range-hint {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-on-surface-variant);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-total {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--color-surface-container-low, #f5f5f4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-total-value {
|
||||||
|
margin: 4px 0 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-channel-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-channel-card {
|
||||||
|
border: 1px solid var(--color-surface-container-highest);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-channel-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-channel-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-on-surface-variant);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-bar {
|
||||||
|
margin-top: 8px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--color-surface-container-highest);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-bar-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: #3b82f6;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-stats-bar-fill.phone {
|
||||||
|
background: #a855f7;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-records-main {
|
.shop-records-main {
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
@@ -1714,6 +1880,205 @@
|
|||||||
color: var(--color-aged-amber);
|
color: var(--color-aged-amber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shop-record-badge.rejected {
|
||||||
|
background: rgba(180, 35, 24, 0.1);
|
||||||
|
color: var(--color-error-red, #b42318);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-withdraw-back {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 4px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-withdraw-btn {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 12px;
|
||||||
|
height: 44px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--color-primary, #8b1a1a);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-withdraw-btn:disabled {
|
||||||
|
opacity: 0.45;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-withdraw-msg {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--color-aged-amber);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ─── 门店套餐 ─── */
|
||||||
|
.shop-packages-page .shop-records-main {
|
||||||
|
padding-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-intro {
|
||||||
|
margin: 0 0 12px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--color-subtle-gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-notice {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: rgba(46, 125, 50, 0.08);
|
||||||
|
border: 1px solid rgba(46, 125, 50, 0.15);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-notice--warn {
|
||||||
|
background: rgba(180, 35, 24, 0.06);
|
||||||
|
border-color: rgba(180, 35, 24, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-notice p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-card {
|
||||||
|
background: var(--color-card);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-card-head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-card--collapsed .shop-packages-card-head {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-toggle {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
padding: 0;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-toggle .material-symbols-outlined {
|
||||||
|
font-size: 20px;
|
||||||
|
color: var(--color-on-surface-variant, #666);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-card-title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-remove {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-heritage-red);
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-field:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--color-subtle-gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-input,
|
||||||
|
.shop-packages-textarea {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 12px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--color-surface-container-low, #fafafa);
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-textarea {
|
||||||
|
resize: vertical;
|
||||||
|
min-height: 72px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-input:focus,
|
||||||
|
.shop-packages-textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--color-heritage-red);
|
||||||
|
box-shadow: 0 0 0 1px rgba(166, 29, 36, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-input:disabled,
|
||||||
|
.shop-packages-textarea:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-add {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 48px;
|
||||||
|
border: 1px dashed rgba(166, 29, 36, 0.35);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: rgba(166, 29, 36, 0.04);
|
||||||
|
color: var(--color-heritage-red);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shop-packages-add .material-symbols-outlined {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.shop-record-amounts {
|
.shop-record-amounts {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"lint": "echo ok"
|
"lint": "echo ok"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@dukang/client-logging": "workspace:*",
|
||||||
"@dukang/shared-types": "workspace:*",
|
"@dukang/shared-types": "workspace:*",
|
||||||
"@dukang/shared-ui": "workspace:*",
|
"@dukang/shared-ui": "workspace:*",
|
||||||
"@dukang/weixin-sdk": "workspace:*",
|
"@dukang/weixin-sdk": "workspace:*",
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
|
import { createUserTracker, getSessionId } from '@dukang/client-logging';
|
||||||
import { apiBase } from './api';
|
import { apiBase } from './api';
|
||||||
|
|
||||||
export function track(eventName: string, params?: Record<string, unknown>) {
|
const tracker = createUserTracker({
|
||||||
const token = localStorage.getItem('accessToken');
|
apiBase,
|
||||||
if (!token) return;
|
clientApp: 'USER_H5',
|
||||||
|
});
|
||||||
|
|
||||||
void fetch(`${apiBase}/analytics/events`, {
|
export { getSessionId };
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
export function track(eventName: string, params?: Record<string, unknown>) {
|
||||||
'Content-Type': 'application/json',
|
tracker.track(eventName, params);
|
||||||
Authorization: `Bearer ${token}`,
|
}
|
||||||
'X-Client-App': 'USER_H5',
|
|
||||||
},
|
export function trackPageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
body: JSON.stringify({ events: [{ eventName, params }] }),
|
tracker.trackPageView(eventName, params);
|
||||||
}).catch(() => {});
|
}
|
||||||
|
|
||||||
|
export function initUserAnalytics() {
|
||||||
|
tracker.trackSessionStart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { trackPageView } from './analytics';
|
||||||
|
|
||||||
|
export function usePageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
const fired = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (fired.current) return;
|
||||||
|
fired.current = true;
|
||||||
|
trackPageView(eventName, params);
|
||||||
|
}, [eventName, params]);
|
||||||
|
}
|
||||||
@@ -2,10 +2,16 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import { getRouterBasename } from '@dukang/weixin-sdk';
|
import { getRouterBasename } from '@dukang/weixin-sdk';
|
||||||
|
import { installClientErrorReporting } from '@dukang/client-logging';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
import { initUserAnalytics } from './lib/analytics';
|
||||||
|
import { apiBase } from './lib/api';
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
import './styles/legal.css';
|
import './styles/legal.css';
|
||||||
|
|
||||||
|
installClientErrorReporting({ apiBase, clientApp: 'USER_H5' });
|
||||||
|
initUserAnalytics();
|
||||||
|
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<BrowserRouter basename={getRouterBasename()}>
|
<BrowserRouter basename={getRouterBasename()}>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { request } from '../lib/api';
|
|||||||
import { buildAddressListUrl, readCheckoutContext } from '../lib/navigation';
|
import { buildAddressListUrl, readCheckoutContext } from '../lib/navigation';
|
||||||
import { DEFAULT_REGION, formatRegion } from '../lib/region-data';
|
import { DEFAULT_REGION, formatRegion } from '../lib/region-data';
|
||||||
import { normalizePhoneInput, validateMobilePhone } from '../lib/phone';
|
import { normalizePhoneInput, validateMobilePhone } from '../lib/phone';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type AddressForm = {
|
type AddressForm = {
|
||||||
receiverName: string;
|
receiverName: string;
|
||||||
@@ -21,6 +22,7 @@ export default function AddressEditPage() {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
const isEdit = Boolean(id);
|
const isEdit = Boolean(id);
|
||||||
|
usePageView('address_edit', { mode: isEdit ? 'edit' : 'create' });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [pickerOpen, setPickerOpen] = useState(false);
|
const [pickerOpen, setPickerOpen] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import SubPageHeader from '../components/SubPageHeader';
|
|||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { useUserSession } from '../contexts/UserSessionContext';
|
import { useUserSession } from '../contexts/UserSessionContext';
|
||||||
import { buildAddressEditUrl, buildAddressListUrl, buildOrderConfirmUrl, hasCheckoutContext, readCheckoutContext } from '../lib/navigation';
|
import { buildAddressEditUrl, buildAddressListUrl, buildOrderConfirmUrl, hasCheckoutContext, readCheckoutContext } from '../lib/navigation';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type Address = {
|
type Address = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -25,6 +26,7 @@ function formatAddress(a: Address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function AddressListPage() {
|
export default function AddressListPage() {
|
||||||
|
usePageView('address_list_view');
|
||||||
const { profile } = useUserSession();
|
const { profile } = useUserSession();
|
||||||
const [list, setList] = useState<Address[]>([]);
|
const [list, setList] = useState<Address[]>([]);
|
||||||
const [pendingAddress, setPendingAddress] = useState<Address | null>(null);
|
const [pendingAddress, setPendingAddress] = useState<Address | null>(null);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { TICKET_TYPE_LABELS, type TicketTypeDto } from '@dukang/shared-types';
|
import { TICKET_TYPE_LABELS, type TicketTypeDto } from '@dukang/shared-types';
|
||||||
import SubPageHeader from '../components/SubPageHeader';
|
import SubPageHeader from '../components/SubPageHeader';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type TicketRow = {
|
type TicketRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -23,6 +24,7 @@ const STATUS_LABEL: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function AfterSaleListPage() {
|
export default function AfterSaleListPage() {
|
||||||
|
usePageView('after_sale_list_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [items, setItems] = useState<TicketRow[]>([]);
|
const [items, setItems] = useState<TicketRow[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import {
|
|||||||
import SubPageHeader from '../components/SubPageHeader';
|
import SubPageHeader from '../components/SubPageHeader';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
import { uploadFileToOss } from '../lib/upload';
|
import { uploadFileToOss } from '../lib/upload';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
import { track } from '../lib/analytics';
|
||||||
|
|
||||||
type OrderRow = {
|
type OrderRow = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -21,6 +23,7 @@ type OrderRow = {
|
|||||||
const STEPS = ['类型', '订单', '凭证', '完成'] as const;
|
const STEPS = ['类型', '订单', '凭证', '完成'] as const;
|
||||||
|
|
||||||
export default function AfterSalePage() {
|
export default function AfterSalePage() {
|
||||||
|
usePageView('after_sale_apply');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
const presetOrderId = params.get('orderId') || '';
|
const presetOrderId = params.get('orderId') || '';
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
export default function BenefitDetailPage() {
|
export default function BenefitDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
usePageView('benefit_detail_view', { couponId: id });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [data, setData] = useState<{ coupon: Record<string, unknown>; ledgers: Array<Record<string, unknown>> } | null>(null);
|
const [data, setData] = useState<{ coupon: Record<string, unknown>; ledgers: Array<Record<string, unknown>> } | null>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react';
|
|||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import BrandLogo from '@dukang/shared-ui/BrandLogo';
|
import BrandLogo from '@dukang/shared-ui/BrandLogo';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type BenefitSummary = {
|
type BenefitSummary = {
|
||||||
totalBalance: number;
|
totalBalance: number;
|
||||||
@@ -44,6 +45,7 @@ function buildRedeemUrl(coupon?: CouponItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function BenefitPage() {
|
export default function BenefitPage() {
|
||||||
|
usePageView('benefit_page_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const listRef = useRef<HTMLElement>(null);
|
const listRef = useRef<HTMLElement>(null);
|
||||||
const [summary, setSummary] = useState<BenefitSummary | null>(null);
|
const [summary, setSummary] = useState<BenefitSummary | null>(null);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { buildOrderAddressSelectUrl } from '../lib/navigation';
|
|||||||
import { STITCH_ORDER_PRODUCT_IMAGE } from '../lib/order-images';
|
import { STITCH_ORDER_PRODUCT_IMAGE } from '../lib/order-images';
|
||||||
import { handleShareButtonClick } from '../lib/wechat-share';
|
import { handleShareButtonClick } from '../lib/wechat-share';
|
||||||
import ContactCustomerSheet from '../components/ContactCustomerSheet';
|
import ContactCustomerSheet from '../components/ContactCustomerSheet';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type OrderItem = {
|
type OrderItem = {
|
||||||
productName: string;
|
productName: string;
|
||||||
@@ -131,6 +132,7 @@ function fullReceiverAddress(order: Order) {
|
|||||||
|
|
||||||
export default function OrderDetailPage() {
|
export default function OrderDetailPage() {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
usePageView('order_detail_view', { orderId: id });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [order, setOrder] = useState<Order | null>(null);
|
const [order, setOrder] = useState<Order | null>(null);
|
||||||
const [showCs, setShowCs] = useState(false);
|
const [showCs, setShowCs] = useState(false);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import PageHeader from '@dukang/shared-ui/PageHeader';
|
|||||||
import AppImage from '@dukang/shared-ui/AppImage';
|
import AppImage from '@dukang/shared-ui/AppImage';
|
||||||
import OrderStatusTabs from '@dukang/shared-ui/OrderStatusTabs';
|
import OrderStatusTabs from '@dukang/shared-ui/OrderStatusTabs';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
const TABS = [
|
const TABS = [
|
||||||
{ key: 'all', label: '全部' },
|
{ key: 'all', label: '全部' },
|
||||||
@@ -36,6 +37,7 @@ function orderStatusLabel(order: Record<string, unknown>) {
|
|||||||
export default function OrderListPage() {
|
export default function OrderListPage() {
|
||||||
const [params, setParams] = useSearchParams();
|
const [params, setParams] = useSearchParams();
|
||||||
const tab = params.get('tab') || 'all';
|
const tab = params.get('tab') || 'all';
|
||||||
|
usePageView('order_list_view', { tab });
|
||||||
const [data, setData] = useState<{ list: Array<Record<string, unknown>> }>({ list: [] });
|
const [data, setData] = useState<{ list: Array<Record<string, unknown>> }>({ list: [] });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import {
|
|||||||
} from '../lib/pay-wechat';
|
} from '../lib/pay-wechat';
|
||||||
import { applyWechatLoginResult, handleWechatAuthCallback } from '../lib/wechat-auth';
|
import { applyWechatLoginResult, handleWechatAuthCallback } from '../lib/wechat-auth';
|
||||||
import { isWechatEnv } from '../lib/weixin';
|
import { isWechatEnv } from '../lib/weixin';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
import { track } from '../lib/analytics';
|
||||||
|
|
||||||
function sleep(ms: number) {
|
function sleep(ms: number) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
@@ -32,6 +34,7 @@ async function waitOrderPaid(orderId: string, maxAttempts = 15) {
|
|||||||
export default function PayPage() {
|
export default function PayPage() {
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
const orderId = params.get('orderId') || '';
|
const orderId = params.get('orderId') || '';
|
||||||
|
usePageView('pay_page_view', { orderId });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [authLoading, setAuthLoading] = useState(false);
|
const [authLoading, setAuthLoading] = useState(false);
|
||||||
@@ -161,6 +164,11 @@ export default function PayPage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setMsg(e instanceof Error ? e.message : '支付失败');
|
setMsg(e instanceof Error ? e.message : '支付失败');
|
||||||
|
track('pay_fail', {
|
||||||
|
orderId,
|
||||||
|
failReason: e instanceof Error ? e.message : '支付失败',
|
||||||
|
pagePath: '/pay',
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,10 @@ export default function ProductDetailPage() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="product-detail-buy-btn"
|
className="product-detail-buy-btn"
|
||||||
onClick={() => navigate(`/order/confirm?productId=${id}&qty=2`)}
|
onClick={() => {
|
||||||
|
track('product_click', { refType: 'PRODUCT', refId: id, productId: id });
|
||||||
|
navigate(`/order/confirm?productId=${id}&qty=2`);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
立即购买
|
立即购买
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { REDEEM_TOKEN_TTL_SECONDS } from '@dukang/shared-types';
|
import { REDEEM_TOKEN_TTL_SECONDS } from '@dukang/shared-types';
|
||||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
export default function RedeemCodePage() {
|
export default function RedeemCodePage() {
|
||||||
|
usePageView('redeem_code_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const token = sessionStorage.getItem('redeemToken') || '';
|
const token = sessionStorage.getItem('redeemToken') || '';
|
||||||
const amount = sessionStorage.getItem('redeemAmount') || '0';
|
const amount = sessionStorage.getItem('redeemAmount') || '0';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
import { REDEEM_TOKEN_TTL_SECONDS } from '@dukang/shared-types';
|
import { REDEEM_TOKEN_TTL_SECONDS } from '@dukang/shared-types';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
const POLL_INTERVAL_MS = 2500;
|
const POLL_INTERVAL_MS = 2500;
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ function formatTimer(seconds: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function RedeemPage() {
|
export default function RedeemPage() {
|
||||||
|
usePageView('benefit_redeem_start');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const couponId = searchParams.get('couponId') ?? undefined;
|
const couponId = searchParams.get('couponId') ?? undefined;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useMemo, useState } from 'react';
|
|||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
import { usePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
type RedeemRecord = {
|
type RedeemRecord = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -46,6 +47,7 @@ function StarRating({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function RedeemSuccessPage() {
|
export default function RedeemSuccessPage() {
|
||||||
|
usePageView('redeem_success_view');
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [serviceScore, setServiceScore] = useState(5);
|
const [serviceScore, setServiceScore] = useState(5);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
loginHqWithWechat,
|
loginHqWithWechat,
|
||||||
} from '../../lib/wechat';
|
} from '../../lib/wechat';
|
||||||
import { isWechatEnv } from '../../lib/weixin';
|
import { isWechatEnv } from '../../lib/weixin';
|
||||||
|
import { MOCK_SMS_FIXED_CODE } from '@dukang/shared-types';
|
||||||
import { WECHAT_INAPP_REQUIRED_MSG } from '@dukang/weixin-sdk';
|
import { WECHAT_INAPP_REQUIRED_MSG } from '@dukang/weixin-sdk';
|
||||||
import { clearHqAccountCache } from '../../lib/session';
|
import { clearHqAccountCache } from '../../lib/session';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@@ -41,7 +42,7 @@ function WechatIcon() {
|
|||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const remembered = loadRememberedPhone();
|
const remembered = loadRememberedPhone();
|
||||||
const [phone, setPhone] = useState(remembered.phone || DEMO_PHONE);
|
const [phone, setPhone] = useState(remembered.phone || DEMO_PHONE);
|
||||||
const [code, setCode] = useState('123456');
|
const [code, setCode] = useState(MOCK_SMS_FIXED_CODE);
|
||||||
const [rememberAccount, setRememberAccount] = useState(remembered.remember);
|
const [rememberAccount, setRememberAccount] = useState(remembered.remember);
|
||||||
const [agreed, setAgreed] = useState(false);
|
const [agreed, setAgreed] = useState(false);
|
||||||
const [cooldown, setCooldown] = useState(0);
|
const [cooldown, setCooldown] = useState(0);
|
||||||
@@ -103,7 +104,7 @@ export default function LoginPage() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { phone, scene: 'HQ_LOGIN' },
|
data: { phone, scene: 'HQ_LOGIN' },
|
||||||
});
|
});
|
||||||
toast('验证码已发送(Mock:123456)', 'success');
|
toast(`验证码已发送(Mock:${MOCK_SMS_FIXED_CODE})`, 'success');
|
||||||
setCooldown(60);
|
setCooldown(60);
|
||||||
const t = setInterval(() => {
|
const t = setInterval(() => {
|
||||||
setCooldown((s) => {
|
setCooldown((s) => {
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ export default defineConfig(async () => ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
h5: {
|
h5: {
|
||||||
// 生产发版由 remote-release 注入 TARO_H5_PUBLIC_PATH=/user/、TARO_H5_ROUTER_BASENAME=/user
|
// staging:user-test.dukanghaoke.com 根路径;生产:remote-release 注入 /user/
|
||||||
// 本地预览勿强制 basename,否则静态托管下易白屏
|
|
||||||
publicPath: process.env.TARO_H5_PUBLIC_PATH || '/',
|
publicPath: process.env.TARO_H5_PUBLIC_PATH || '/',
|
||||||
...(process.env.TARO_H5_ROUTER_BASENAME
|
...(process.env.TARO_H5_ROUTER_BASENAME
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.24.4",
|
"@babel/runtime": "^7.24.4",
|
||||||
|
"@dukang/client-logging": "workspace:*",
|
||||||
"@dukang/shared-types": "workspace:*",
|
"@dukang/shared-types": "workspace:*",
|
||||||
"@dukang/shared-ui": "workspace:*",
|
"@dukang/shared-ui": "workspace:*",
|
||||||
"@dukang/weixin-sdk": "workspace:*",
|
"@dukang/weixin-sdk": "workspace:*",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import './lib/intl-polyfill';
|
||||||
import './lib/text-encoding-polyfill';
|
import './lib/text-encoding-polyfill';
|
||||||
import { PropsWithChildren, useRef } from 'react';
|
import { PropsWithChildren, useRef } from 'react';
|
||||||
import Taro, { useDidShow } from '@tarojs/taro';
|
import Taro, { useDidShow } from '@tarojs/taro';
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||||
|
import { View, Text } from '@tarojs/components';
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
|
|
||||||
|
type StoreRedeemMarqueeProps = {
|
||||||
|
lines: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const FLY_SPEED = 56;
|
||||||
|
const MIN_FLY_MS = 2400;
|
||||||
|
const PAUSE_MIN_MS = 1000;
|
||||||
|
const PAUSE_MAX_MS = 5000;
|
||||||
|
const TICK_MS = 16;
|
||||||
|
/** 全文滚出视口后,再向左多走 10px */
|
||||||
|
const EXTRA_AFTER_EXIT_PX = 10;
|
||||||
|
|
||||||
|
function estimateTextWidth(text: string): number {
|
||||||
|
let w = 0;
|
||||||
|
for (const ch of text) {
|
||||||
|
w += /[^\x00-\xff]/.test(ch) ? 12 : 7;
|
||||||
|
}
|
||||||
|
return Math.max(Math.ceil(w), 80);
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomPauseMs() {
|
||||||
|
return PAUSE_MIN_MS + Math.floor(Math.random() * (PAUSE_MAX_MS - PAUSE_MIN_MS + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 容器宽兜底(不依赖 DOM 测量,小程序首帧即可用) */
|
||||||
|
function getBoxWidthFallback(): number {
|
||||||
|
try {
|
||||||
|
const sys = Taro.getSystemInfoSync();
|
||||||
|
const screenW = Number(sys.windowWidth || sys.screenWidth || 375);
|
||||||
|
// 与 section 同宽:左右 var(--space-page)
|
||||||
|
return Math.max(220, Math.floor(screenW - 32));
|
||||||
|
} catch {
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function measureBoxWidth(selector: string, fallback: number): Promise<number> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
Taro.nextTick(() => {
|
||||||
|
try {
|
||||||
|
const page = Taro.getCurrentInstance().page;
|
||||||
|
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
|
||||||
|
query
|
||||||
|
.select(selector)
|
||||||
|
.boundingClientRect()
|
||||||
|
.exec((res) => {
|
||||||
|
const w = Number(res?.[0]?.width || 0);
|
||||||
|
resolve(w > 8 ? Math.ceil(w) : fallback);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
resolve(fallback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function measureTextWidth(selector: string, text: string): Promise<number> {
|
||||||
|
const fallback = estimateTextWidth(text);
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
Taro.nextTick(() => {
|
||||||
|
try {
|
||||||
|
const page = Taro.getCurrentInstance().page;
|
||||||
|
const query = page ? Taro.createSelectorQuery().in(page) : Taro.createSelectorQuery();
|
||||||
|
query
|
||||||
|
.select(selector)
|
||||||
|
.boundingClientRect()
|
||||||
|
.exec((res) => {
|
||||||
|
const w = Number(res?.[0]?.width || 0);
|
||||||
|
if (w > 8 && w < fallback * 3) resolve(Math.ceil(w));
|
||||||
|
else resolve(fallback);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
resolve(fallback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核销走马灯:单条从右向左位移飞出,间隔 1~5 秒随机再播下一条。
|
||||||
|
*
|
||||||
|
* 小程序注意:
|
||||||
|
* - 不用 useReady(子组件内不触发 → opacity 永远 0)
|
||||||
|
* - 不用 Text + transform(支持差),改用 View + left
|
||||||
|
* - 字宽用估算,避免屏外元素测宽失败
|
||||||
|
*/
|
||||||
|
export default function StoreRedeemMarquee({ lines }: StoreRedeemMarqueeProps) {
|
||||||
|
const items = useMemo(
|
||||||
|
() =>
|
||||||
|
lines
|
||||||
|
.map((s) => String(s || '').trim())
|
||||||
|
.filter(Boolean),
|
||||||
|
[lines],
|
||||||
|
);
|
||||||
|
|
||||||
|
const rootIdRef = useRef(`smr${Math.random().toString(36).slice(2, 10)}`);
|
||||||
|
const textIdRef = useRef(`smt${Math.random().toString(36).slice(2, 10)}`);
|
||||||
|
const indexRef = useRef(0);
|
||||||
|
const boxWidthRef = useRef(getBoxWidthFallback());
|
||||||
|
const itemsKey = items.join('\n');
|
||||||
|
|
||||||
|
const [displayIndex, setDisplayIndex] = useState(0);
|
||||||
|
const [leftPx, setLeftPx] = useState(() => boxWidthRef.current);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!items.length) return;
|
||||||
|
|
||||||
|
let cancelled = false;
|
||||||
|
const waiters = new Set<ReturnType<typeof setTimeout>>();
|
||||||
|
let tickTimer: ReturnType<typeof setInterval> | undefined;
|
||||||
|
|
||||||
|
const sleep = (ms: number) =>
|
||||||
|
new Promise<void>((resolve) => {
|
||||||
|
const id = setTimeout(() => {
|
||||||
|
waiters.delete(id);
|
||||||
|
resolve();
|
||||||
|
}, ms);
|
||||||
|
waiters.add(id);
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearTick = () => {
|
||||||
|
if (tickTimer) {
|
||||||
|
clearInterval(tickTimer);
|
||||||
|
tickTimer = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fly = (from: number, to: number, durationMs: number) =>
|
||||||
|
new Promise<void>((resolve) => {
|
||||||
|
const began = Date.now();
|
||||||
|
setLeftPx(from);
|
||||||
|
clearTick();
|
||||||
|
tickTimer = setInterval(() => {
|
||||||
|
if (cancelled) {
|
||||||
|
clearTick();
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const t = Math.min(1, (Date.now() - began) / durationMs);
|
||||||
|
setLeftPx(from + (to - from) * t);
|
||||||
|
if (t >= 1) {
|
||||||
|
clearTick();
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
}, TICK_MS);
|
||||||
|
});
|
||||||
|
|
||||||
|
const loop = async () => {
|
||||||
|
indexRef.current = 0;
|
||||||
|
setDisplayIndex(0);
|
||||||
|
|
||||||
|
const measured = await measureBoxWidth(`#${rootIdRef.current}`, boxWidthRef.current);
|
||||||
|
boxWidthRef.current = measured;
|
||||||
|
if (cancelled) return;
|
||||||
|
|
||||||
|
while (!cancelled && items.length) {
|
||||||
|
const idx = indexRef.current % items.length;
|
||||||
|
const text = items[idx];
|
||||||
|
const box = boxWidthRef.current;
|
||||||
|
|
||||||
|
setDisplayIndex(idx);
|
||||||
|
|
||||||
|
const from = box;
|
||||||
|
setLeftPx(from);
|
||||||
|
await sleep(48);
|
||||||
|
if (cancelled) break;
|
||||||
|
|
||||||
|
const textW = await measureTextWidth(`#${textIdRef.current}`, text);
|
||||||
|
// 全文 left 边缘移出容器左边界后再走 10px
|
||||||
|
const to = -(textW + EXTRA_AFTER_EXIT_PX);
|
||||||
|
const distance = from - to;
|
||||||
|
const durationMs = Math.max(MIN_FLY_MS, Math.round((distance / FLY_SPEED) * 1000));
|
||||||
|
|
||||||
|
await sleep(32);
|
||||||
|
if (cancelled) break;
|
||||||
|
|
||||||
|
await fly(from, to, durationMs);
|
||||||
|
if (cancelled) break;
|
||||||
|
|
||||||
|
await sleep(randomPauseMs());
|
||||||
|
if (cancelled) break;
|
||||||
|
|
||||||
|
indexRef.current = (idx + 1) % items.length;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void loop();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
clearTick();
|
||||||
|
waiters.forEach(clearTimeout);
|
||||||
|
waiters.clear();
|
||||||
|
};
|
||||||
|
}, [itemsKey, items]);
|
||||||
|
|
||||||
|
if (!items.length) return null;
|
||||||
|
|
||||||
|
const current = items[displayIndex] || items[0];
|
||||||
|
const innerStyle: CSSProperties = { left: `${leftPx}px` };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View id={rootIdRef.current} className="store-detail-marquee">
|
||||||
|
<View className="store-detail-marquee-inner" style={innerStyle}>
|
||||||
|
<Text id={textIdRef.current} className="store-detail-marquee-text">
|
||||||
|
{current}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import Taro from '@tarojs/taro';
|
||||||
|
import { createUserTracker, getSessionId } from '@dukang/client-logging';
|
||||||
|
import { API_BASE, CLIENT_APP, getToken } from './api';
|
||||||
|
|
||||||
|
function currentPagePath(): string | undefined {
|
||||||
|
try {
|
||||||
|
const pages = Taro.getCurrentPages();
|
||||||
|
const cur = pages[pages.length - 1] as { route?: string; $taroPath?: string } | undefined;
|
||||||
|
return cur?.$taroPath || cur?.route || undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tracker = createUserTracker({
|
||||||
|
apiBase: API_BASE,
|
||||||
|
clientApp: CLIENT_APP,
|
||||||
|
getToken,
|
||||||
|
getPagePath: currentPagePath,
|
||||||
|
postJson: ({ url, headers, body }) => {
|
||||||
|
void Taro.request({ url, method: 'POST', header: headers, data: body }).catch(() => {});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { getSessionId };
|
||||||
|
|
||||||
|
export function track(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.track(eventName, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trackPageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
tracker.trackPageView(eventName, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initUserAnalytics() {
|
||||||
|
tracker.trackSessionStart();
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import Taro from '@tarojs/taro';
|
|||||||
import { ClientApp } from '@dukang/shared-types';
|
import { ClientApp } from '@dukang/shared-types';
|
||||||
import { forceReloadAfterAccountMerge } from './auth-nav';
|
import { forceReloadAfterAccountMerge } from './auth-nav';
|
||||||
import { resetStoresSessionBootstrap } from './stores-session';
|
import { resetStoresSessionBootstrap } from './stores-session';
|
||||||
|
import { resetHomeCatalogBootstrap } from './home-catalog-session';
|
||||||
|
|
||||||
function resolveApiBase(): string {
|
function resolveApiBase(): string {
|
||||||
const origin =
|
const origin =
|
||||||
@@ -57,8 +58,9 @@ export function isLoggedIn(): boolean {
|
|||||||
|
|
||||||
export function logout() {
|
export function logout() {
|
||||||
clearAuth();
|
clearAuth();
|
||||||
// 主动退出才重置门店「当次登录」会话;401 清 token 不要打断门店筛选
|
// 主动退出才重置门店/首页「当次登录」会话;401 清 token 不要打断筛选
|
||||||
resetStoresSessionBootstrap();
|
resetStoresSessionBootstrap();
|
||||||
|
resetHomeCatalogBootstrap();
|
||||||
Taro.reLaunch({ url: '/pages/home/index' });
|
Taro.reLaunch({ url: '/pages/home/index' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/** 格式化为 Asia/Shanghai:2026-08-03 15:14:30(不依赖 Intl,兼容微信小程序) */
|
||||||
|
export function formatShanghaiDateTime(input?: string | Date | null): string {
|
||||||
|
if (input == null || input === '') return '—';
|
||||||
|
if (typeof input === 'string') {
|
||||||
|
const s = input.trim();
|
||||||
|
if (/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(s)) {
|
||||||
|
return s.slice(0, 19).replace('T', ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const d = input instanceof Date ? input : new Date(input);
|
||||||
|
if (Number.isNaN(d.getTime())) return '—';
|
||||||
|
// 用 UTC 读数 + 固定东八区偏移,避免依赖 Intl / 设备时区 API 差异
|
||||||
|
const sh = new Date(d.getTime() + 8 * 60 * 60 * 1000);
|
||||||
|
const p = (n: number) => String(n).padStart(2, '0');
|
||||||
|
return `${sh.getUTCFullYear()}-${p(sh.getUTCMonth() + 1)}-${p(sh.getUTCDate())} ${p(sh.getUTCHours())}:${p(sh.getUTCMinutes())}:${p(sh.getUTCSeconds())}`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* 首页商品列表「当次登录」会话 —— 切 tab 不重复拉商品;
|
||||||
|
* 城市 / 登录态变化或下拉刷新时再请求。logout 时 clear。
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Taro from '@tarojs/taro';
|
||||||
|
|
||||||
|
export type HomeCatalogCache = {
|
||||||
|
cityCode: string;
|
||||||
|
authKey: string;
|
||||||
|
products: unknown[];
|
||||||
|
};
|
||||||
|
|
||||||
|
type HomeSession = {
|
||||||
|
bootstrapped: boolean;
|
||||||
|
cache: HomeCatalogCache | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'dukang_home_catalog_session_v1';
|
||||||
|
|
||||||
|
let memory: HomeSession | null = null;
|
||||||
|
|
||||||
|
function emptySession(): HomeSession {
|
||||||
|
return { bootstrapped: false, cache: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
function readSession(): HomeSession {
|
||||||
|
if (memory) return memory;
|
||||||
|
try {
|
||||||
|
const raw = Taro.getStorageSync(STORAGE_KEY);
|
||||||
|
if (!raw) {
|
||||||
|
memory = emptySession();
|
||||||
|
return memory;
|
||||||
|
}
|
||||||
|
const parsed = (typeof raw === 'string' ? JSON.parse(raw) : raw) as Partial<HomeSession>;
|
||||||
|
memory = {
|
||||||
|
bootstrapped: !!parsed.bootstrapped,
|
||||||
|
cache: (parsed.cache as HomeCatalogCache | null) ?? null,
|
||||||
|
};
|
||||||
|
return memory;
|
||||||
|
} catch {
|
||||||
|
memory = emptySession();
|
||||||
|
return memory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeSession(next: HomeSession) {
|
||||||
|
memory = next;
|
||||||
|
try {
|
||||||
|
Taro.setStorageSync(STORAGE_KEY, JSON.stringify(next));
|
||||||
|
} catch {
|
||||||
|
/* ignore quota */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isHomeCatalogBootstrapped(): boolean {
|
||||||
|
return readSession().bootstrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getHomeCatalogCache(): HomeCatalogCache | null {
|
||||||
|
return readSession().cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setHomeCatalogCache(cache: HomeCatalogCache): void {
|
||||||
|
writeSession({ bootstrapped: true, cache });
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resetHomeCatalogBootstrap(): void {
|
||||||
|
memory = emptySession();
|
||||||
|
try {
|
||||||
|
Taro.removeStorageSync(STORAGE_KEY);
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
* 微信小程序基础库无 Intl。业务代码已避免依赖,此处仅作兜底,
|
||||||
|
* 防止旧包 / 依赖偶发 `new Intl.DateTimeFormat` 直接白屏。
|
||||||
|
*/
|
||||||
|
function pad(n: number) {
|
||||||
|
return String(n).padStart(2, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
function shanghaiParts(date: Date) {
|
||||||
|
const sh = new Date(date.getTime() + 8 * 60 * 60 * 1000);
|
||||||
|
return {
|
||||||
|
year: String(sh.getUTCFullYear()),
|
||||||
|
month: pad(sh.getUTCMonth() + 1),
|
||||||
|
day: pad(sh.getUTCDate()),
|
||||||
|
hour: pad(sh.getUTCHours()),
|
||||||
|
minute: pad(sh.getUTCMinutes()),
|
||||||
|
second: pad(sh.getUTCSeconds()),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function installIntlStub() {
|
||||||
|
const root = (typeof globalThis !== 'undefined'
|
||||||
|
? globalThis
|
||||||
|
: typeof global !== 'undefined'
|
||||||
|
? global
|
||||||
|
: typeof wx !== 'undefined'
|
||||||
|
? wx
|
||||||
|
: {}) as typeof globalThis & { Intl?: typeof Intl };
|
||||||
|
|
||||||
|
if (typeof root.Intl !== 'undefined' && typeof root.Intl.DateTimeFormat === 'function') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MiniDateTimeFormat {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
constructor(_locales?: string | string[], _options?: Record<string, unknown>) {}
|
||||||
|
|
||||||
|
format(date?: Date | number) {
|
||||||
|
const d = date instanceof Date ? date : new Date(date ?? Date.now());
|
||||||
|
if (Number.isNaN(d.getTime())) return '';
|
||||||
|
const p = shanghaiParts(d);
|
||||||
|
return `${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}:${p.second}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
formatToParts(date?: Date | number) {
|
||||||
|
const d = date instanceof Date ? date : new Date(date ?? Date.now());
|
||||||
|
if (Number.isNaN(d.getTime())) return [];
|
||||||
|
const p = shanghaiParts(d);
|
||||||
|
return [
|
||||||
|
{ type: 'year', value: p.year },
|
||||||
|
{ type: 'literal', value: '-' },
|
||||||
|
{ type: 'month', value: p.month },
|
||||||
|
{ type: 'literal', value: '-' },
|
||||||
|
{ type: 'day', value: p.day },
|
||||||
|
{ type: 'literal', value: ' ' },
|
||||||
|
{ type: 'hour', value: p.hour },
|
||||||
|
{ type: 'literal', value: ':' },
|
||||||
|
{ type: 'minute', value: p.minute },
|
||||||
|
{ type: 'literal', value: ':' },
|
||||||
|
{ type: 'second', value: p.second },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
root.Intl = {
|
||||||
|
DateTimeFormat: MiniDateTimeFormat,
|
||||||
|
} as unknown as typeof Intl;
|
||||||
|
}
|
||||||
|
|
||||||
|
installIntlStub();
|
||||||
|
|
||||||
|
export {};
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/** 金额展示(不依赖 Intl / toLocaleString,兼容微信小程序) */
|
||||||
|
export function formatMoney(amount: number | string): string {
|
||||||
|
const n = typeof amount === 'number' ? amount : Number(amount);
|
||||||
|
if (!Number.isFinite(n)) return '0.00';
|
||||||
|
const fixed = n.toFixed(2);
|
||||||
|
const [intPart, dec] = fixed.split('.');
|
||||||
|
const withComma = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
return `${withComma}.${dec}`;
|
||||||
|
}
|
||||||
@@ -106,6 +106,8 @@ export function tabNavContentStyle(metrics: NavBarMetrics): Record<string, strin
|
|||||||
/** 子页/内页顶栏:标题全屏居中,内容区单独留白 */
|
/** 子页/内页顶栏:标题全屏居中,内容区单独留白 */
|
||||||
export function subPageNavBarStyle(metrics: NavBarMetrics): Record<string, string | number> {
|
export function subPageNavBarStyle(metrics: NavBarMetrics): Record<string, string | number> {
|
||||||
const pagePad = 20;
|
const pagePad = 20;
|
||||||
|
// 标题两侧取「右侧避让胶囊」宽度,保证相对屏幕视觉居中
|
||||||
|
const titlePad = Math.max(metrics.navBarPaddingRight, 72);
|
||||||
return {
|
return {
|
||||||
paddingTop: `${metrics.statusBarHeight}px`,
|
paddingTop: `${metrics.statusBarHeight}px`,
|
||||||
height: `${metrics.navBarHeight}px`,
|
height: `${metrics.navBarHeight}px`,
|
||||||
@@ -113,7 +115,7 @@ export function subPageNavBarStyle(metrics: NavBarMetrics): Record<string, strin
|
|||||||
'--nav-content-height': `${metrics.navContentHeight}px`,
|
'--nav-content-height': `${metrics.navContentHeight}px`,
|
||||||
'--nav-status-bar-height': `${metrics.statusBarHeight}px`,
|
'--nav-status-bar-height': `${metrics.statusBarHeight}px`,
|
||||||
'--nav-padding-left': `${pagePad}px`,
|
'--nav-padding-left': `${pagePad}px`,
|
||||||
'--nav-padding-right': `${metrics.navBarPaddingRight}px`,
|
'--nav-padding-right': `${titlePad}px`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/** 商品履约能力(与 HQ / 交易硬闸一致) */
|
||||||
|
|
||||||
|
export type FulfillmentFlags = {
|
||||||
|
allowOnlinePurchase?: boolean | null;
|
||||||
|
allowOnSitePickup?: boolean | null;
|
||||||
|
allowCrossCityDelivery?: boolean | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 未返回时默认允许线上(存量商品) */
|
||||||
|
export function canBuyOnline(p: FulfillmentFlags): boolean {
|
||||||
|
return p.allowOnlinePurchase !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 仅显式开启才展示现场取货 */
|
||||||
|
export function canPickupOnSite(p: FulfillmentFlags): boolean {
|
||||||
|
return p.allowOnSitePickup === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canCrossCity(p: FulfillmentFlags): boolean {
|
||||||
|
return p.allowCrossCityDelivery !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function normalizeFulfillmentFlags<T extends FulfillmentFlags>(p: T): T {
|
||||||
|
return {
|
||||||
|
...p,
|
||||||
|
allowOnlinePurchase: canBuyOnline(p),
|
||||||
|
allowOnSitePickup: canPickupOnSite(p),
|
||||||
|
allowCrossCityDelivery: canCrossCity(p),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 与交易侧一致:收货市 ≠ 开城市且 ≠ 郑州 → 跨城 */
|
||||||
|
export function isCrossCityAddress(
|
||||||
|
addressCity: string | null | undefined,
|
||||||
|
openCityName: string | null | undefined,
|
||||||
|
): boolean {
|
||||||
|
const addr = (addressCity || '').trim();
|
||||||
|
const open = (openCityName || '').trim();
|
||||||
|
if (!addr) return false;
|
||||||
|
if (addr === '郑州市') return false;
|
||||||
|
if (open && addr === open) return false;
|
||||||
|
// 尚无开城信息时,非郑州地址先按可能跨城处理(由预览接口最终裁定)
|
||||||
|
if (!open) return addr !== '郑州市';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -22,6 +22,8 @@ export type StoresSessionCategory = {
|
|||||||
export type StoresListCache = {
|
export type StoresListCache = {
|
||||||
cityKey: string;
|
cityKey: string;
|
||||||
cityCode: string;
|
cityCode: string;
|
||||||
|
/** 登录态指纹:token 变化时需重新拉取(白名单) */
|
||||||
|
authKey: string;
|
||||||
listRegion: StoresSessionRegion;
|
listRegion: StoresSessionRegion;
|
||||||
items: unknown[];
|
items: unknown[];
|
||||||
filterRegion: StoresSessionRegion;
|
filterRegion: StoresSessionRegion;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { trackPageView } from './analytics';
|
||||||
|
|
||||||
|
export function usePageView(eventName: string, params?: Record<string, unknown>) {
|
||||||
|
const fired = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (fired.current) return;
|
||||||
|
fired.current = true;
|
||||||
|
trackPageView(eventName, params);
|
||||||
|
}, [eventName, params]);
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ import { useCallback, useMemo, useState } from 'react';
|
|||||||
import { View, Text, Image } from '@tarojs/components';
|
import { View, Text, Image } from '@tarojs/components';
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
||||||
import PageShell from '../../components/PageShell';
|
import PageShell from '../../components/PageShell';
|
||||||
import ShareNavButton from '../../components/ShareNavButton';
|
|
||||||
import WechatShareReady from '../../components/WechatShareReady';
|
import WechatShareReady from '../../components/WechatShareReady';
|
||||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||||
import { goLogin } from '../../lib/auth-nav';
|
import { goLogin } from '../../lib/auth-nav';
|
||||||
@@ -13,6 +12,7 @@ import {
|
|||||||
DEFAULT_SHARE_TITLE,
|
DEFAULT_SHARE_TITLE,
|
||||||
toWeappShareMessage,
|
toWeappShareMessage,
|
||||||
} from '../../lib/wechat-share';
|
} from '../../lib/wechat-share';
|
||||||
|
import { formatMoney } from '../../lib/money';
|
||||||
import iconBenefit from '../../assets/tabbar/benefit-active.png';
|
import iconBenefit from '../../assets/tabbar/benefit-active.png';
|
||||||
|
|
||||||
type BenefitSummary = {
|
type BenefitSummary = {
|
||||||
@@ -31,9 +31,13 @@ type CouponItem = {
|
|||||||
sourceProduct: string;
|
sourceProduct: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function formatMoney(amount: number) {
|
type RedeemHistoryItem = {
|
||||||
return amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
id: string;
|
||||||
}
|
redeemNo: string;
|
||||||
|
amount: number;
|
||||||
|
storeName: string;
|
||||||
|
createdAt: string;
|
||||||
|
};
|
||||||
|
|
||||||
function usagePercent(coupon: CouponItem) {
|
function usagePercent(coupon: CouponItem) {
|
||||||
const total = Number(coupon.totalAmount);
|
const total = Number(coupon.totalAmount);
|
||||||
@@ -46,11 +50,13 @@ export default function BenefitPage() {
|
|||||||
const [loggedIn, setLoggedIn] = useState(() => isLoggedIn());
|
const [loggedIn, setLoggedIn] = useState(() => isLoggedIn());
|
||||||
const [summary, setSummary] = useState<BenefitSummary | null>(null);
|
const [summary, setSummary] = useState<BenefitSummary | null>(null);
|
||||||
const [coupons, setCoupons] = useState<CouponItem[]>([]);
|
const [coupons, setCoupons] = useState<CouponItem[]>([]);
|
||||||
|
const [redeemHistory, setRedeemHistory] = useState<RedeemHistoryItem[]>([]);
|
||||||
const [tab, setTab] = useState<'available' | 'history'>('available');
|
const [tab, setTab] = useState<'available' | 'history'>('available');
|
||||||
|
|
||||||
const resetGuestState = useCallback(() => {
|
const resetGuestState = useCallback(() => {
|
||||||
setSummary(null);
|
setSummary(null);
|
||||||
setCoupons([]);
|
setCoupons([]);
|
||||||
|
setRedeemHistory([]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const loadBenefit = useCallback(() => {
|
const loadBenefit = useCallback(() => {
|
||||||
@@ -58,10 +64,17 @@ export default function BenefitPage() {
|
|||||||
return Promise.all([
|
return Promise.all([
|
||||||
request<BenefitSummary>('/benefit/summary'),
|
request<BenefitSummary>('/benefit/summary'),
|
||||||
request<CouponItem[]>('/benefit/coupons'),
|
request<CouponItem[]>('/benefit/coupons'),
|
||||||
|
request<{ list?: RedeemHistoryItem[] } | RedeemHistoryItem[]>('/redeem/records?page=1&pageSize=50'),
|
||||||
])
|
])
|
||||||
.then(([s, list]) => {
|
.then(([s, list, records]) => {
|
||||||
setSummary(s);
|
setSummary(s);
|
||||||
setCoupons(Array.isArray(list) ? list : []);
|
setCoupons(Array.isArray(list) ? list : []);
|
||||||
|
const hist = Array.isArray(records)
|
||||||
|
? records
|
||||||
|
: Array.isArray(records?.list)
|
||||||
|
? records.list
|
||||||
|
: [];
|
||||||
|
setRedeemHistory(hist);
|
||||||
})
|
})
|
||||||
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'));
|
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'));
|
||||||
}, []);
|
}, []);
|
||||||
@@ -89,8 +102,6 @@ export default function BenefitPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const available = coupons.filter((c) => c.status === 'ACTIVE' && c.balance > 0);
|
const available = coupons.filter((c) => c.status === 'ACTIVE' && c.balance > 0);
|
||||||
const history = coupons.filter((c) => c.status === 'USED_UP' || c.status === 'VOID');
|
|
||||||
const visible = tab === 'available' ? available : history;
|
|
||||||
|
|
||||||
const sharePayload = useMemo(
|
const sharePayload = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -123,9 +134,6 @@ export default function BenefitPage() {
|
|||||||
<View className="benefit-header-city-pin" />
|
<View className="benefit-header-city-pin" />
|
||||||
<Text>郑州市</Text>
|
<Text>郑州市</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className="benefit-header__share page-nav-bar__right-slot">
|
|
||||||
<ShareNavButton payload={sharePayload} />
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -180,26 +188,26 @@ export default function BenefitPage() {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{visible.length === 0 ? (
|
{tab === 'available' ? (
|
||||||
<View className="u-empty">{tab === 'available' ? '暂无可用权益' : '暂无历史记录'}</View>
|
available.length === 0 ? (
|
||||||
) : (
|
<View className="u-empty">暂无可用权益</View>
|
||||||
visible.map((c) => (
|
) : (
|
||||||
<View key={c.id} className="benefit-coupon">
|
available.map((c) => (
|
||||||
<View className="benefit-coupon-notch" />
|
<View key={c.id} className="benefit-coupon">
|
||||||
<View className="benefit-coupon-notch benefit-coupon-notch--right" />
|
<View className="benefit-coupon-notch" />
|
||||||
<View className="benefit-coupon-head">
|
<View className="benefit-coupon-notch benefit-coupon-notch--right" />
|
||||||
<Text className="benefit-coupon-name">{c.sourceProduct || '好客权益'}</Text>
|
<View className="benefit-coupon-head">
|
||||||
<Text className="benefit-coupon-balance">¥{formatMoney(c.balance)}</Text>
|
<Text className="benefit-coupon-name">{c.sourceProduct || '好客权益'}</Text>
|
||||||
</View>
|
<Text className="benefit-coupon-balance">¥{formatMoney(c.balance)}</Text>
|
||||||
<Text className="benefit-coupon-no">NO. {c.couponNo}</Text>
|
</View>
|
||||||
<View className="benefit-progress">
|
<Text className="benefit-coupon-no">NO. {c.couponNo}</Text>
|
||||||
<View className="benefit-progress-bar" style={{ width: `${usagePercent(c)}%` }} />
|
<View className="benefit-progress">
|
||||||
</View>
|
<View className="benefit-progress-bar" style={{ width: `${usagePercent(c)}%` }} />
|
||||||
<View className="benefit-coupon-footer">
|
</View>
|
||||||
<Text className="benefit-coupon-meta">
|
<View className="benefit-coupon-footer">
|
||||||
已用 ¥{formatMoney(c.usedAmount)} / 总额 ¥{formatMoney(c.totalAmount)}
|
<Text className="benefit-coupon-meta">
|
||||||
</Text>
|
已用 ¥{formatMoney(c.usedAmount)} / 总额 ¥{formatMoney(c.totalAmount)}
|
||||||
{tab === 'available' ? (
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
className="benefit-coupon-btn"
|
className="benefit-coupon-btn"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -210,7 +218,26 @@ export default function BenefitPage() {
|
|||||||
>
|
>
|
||||||
立即核销
|
立即核销
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
</View>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)
|
||||||
|
) : redeemHistory.length === 0 ? (
|
||||||
|
<View className="u-empty">暂无核销记录</View>
|
||||||
|
) : (
|
||||||
|
redeemHistory.map((r) => (
|
||||||
|
<View key={r.id} className="benefit-coupon">
|
||||||
|
<View className="benefit-coupon-notch" />
|
||||||
|
<View className="benefit-coupon-notch benefit-coupon-notch--right" />
|
||||||
|
<View className="benefit-coupon-head">
|
||||||
|
<Text className="benefit-coupon-name">{r.storeName || '门店核销'}</Text>
|
||||||
|
<Text className="benefit-coupon-balance">-¥{formatMoney(Number(r.amount))}</Text>
|
||||||
|
</View>
|
||||||
|
<Text className="benefit-coupon-no">NO. {r.redeemNo}</Text>
|
||||||
|
<View className="benefit-coupon-footer">
|
||||||
|
<Text className="benefit-coupon-meta">
|
||||||
|
{r.createdAt ? String(r.createdAt).slice(0, 19).replace('T', ' ') : '-'}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -13,17 +13,27 @@ import CouponBadge from '../../components/CouponBadge';
|
|||||||
import WechatShareReady from '../../components/WechatShareReady';
|
import WechatShareReady from '../../components/WechatShareReady';
|
||||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||||
import { goLogin } from '../../lib/auth-nav';
|
import { goLogin } from '../../lib/auth-nav';
|
||||||
import { isLoggedIn, request, toast } from '../../lib/api';
|
import { getToken, isLoggedIn, request, toast } from '../../lib/api';
|
||||||
|
import {
|
||||||
|
getHomeCatalogCache,
|
||||||
|
isHomeCatalogBootstrapped,
|
||||||
|
setHomeCatalogCache,
|
||||||
|
} from '../../lib/home-catalog-session';
|
||||||
import { ensurePayReady } from '../../lib/pay-ready';
|
import { ensurePayReady } from '../../lib/pay-ready';
|
||||||
import { capturePromoSceneAndTouchScan } from '../../lib/promo';
|
import { capturePromoSceneAndTouchScan } from '../../lib/promo';
|
||||||
import { getProductMainImage } from '../../lib/product-images';
|
import { getProductMainImage } from '../../lib/product-images';
|
||||||
|
import {
|
||||||
|
canBuyOnline,
|
||||||
|
canPickupOnSite,
|
||||||
|
normalizeFulfillmentFlags,
|
||||||
|
} from '../../lib/product-fulfillment';
|
||||||
import { getCityCodeForCatalog, resolveUserCity } from '../../lib/user-location';
|
import { getCityCodeForCatalog, resolveUserCity } from '../../lib/user-location';
|
||||||
import {
|
import {
|
||||||
DEFAULT_SHARE_DESC,
|
DEFAULT_SHARE_DESC,
|
||||||
DEFAULT_SHARE_TITLE,
|
DEFAULT_SHARE_TITLE,
|
||||||
toWeappShareMessage,
|
toWeappShareMessage,
|
||||||
} from '../../lib/wechat-share';
|
} from '../../lib/wechat-share';
|
||||||
|
import { trackPageView } from '../../lib/analytics';
|
||||||
type Product = {
|
type Product = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -39,22 +49,6 @@ type Product = {
|
|||||||
allowCrossCityDelivery?: boolean;
|
allowCrossCityDelivery?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type FulfillmentFilter = 'ALL' | 'ONLINE' | 'CROSS_CITY' | 'ON_SITE';
|
|
||||||
|
|
||||||
const FULFILLMENT_FILTERS: Array<{ key: FulfillmentFilter; label: string }> = [
|
|
||||||
{ key: 'ALL', label: '全部' },
|
|
||||||
{ key: 'ONLINE', label: '线上' },
|
|
||||||
{ key: 'CROSS_CITY', label: '跨城' },
|
|
||||||
{ key: 'ON_SITE', label: '现场' },
|
|
||||||
];
|
|
||||||
|
|
||||||
function matchFulfillmentFilter(p: Product, filter: FulfillmentFilter): boolean {
|
|
||||||
if (filter === 'ALL') return true;
|
|
||||||
if (filter === 'ONLINE') return p.allowOnlinePurchase !== false;
|
|
||||||
if (filter === 'CROSS_CITY') return p.allowCrossCityDelivery !== false;
|
|
||||||
return !!p.allowOnSitePickup;
|
|
||||||
}
|
|
||||||
|
|
||||||
type MiniHomeConfig = {
|
type MiniHomeConfig = {
|
||||||
banners: string[];
|
banners: string[];
|
||||||
footerUrl: string | null;
|
footerUrl: string | null;
|
||||||
@@ -77,7 +71,6 @@ function aromaSectionId(key: AromaKey) {
|
|||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const [activeAroma, setActiveAroma] = useState<AromaKey>('QINGXIANG');
|
const [activeAroma, setActiveAroma] = useState<AromaKey>('QINGXIANG');
|
||||||
const [fulfillmentFilter, setFulfillmentFilter] = useState<FulfillmentFilter>('ALL');
|
|
||||||
const [products, setProducts] = useState<Product[]>([]);
|
const [products, setProducts] = useState<Product[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [displayCity, setDisplayCity] = useState('郑州市');
|
const [displayCity, setDisplayCity] = useState('郑州市');
|
||||||
@@ -87,6 +80,10 @@ export default function HomePage() {
|
|||||||
const scrollLockTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const scrollLockTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const lastScrollSyncAtRef = useRef(0);
|
const lastScrollSyncAtRef = useRef(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
trackPageView('home_view', { pagePath: '/pages/home/index', cityCode });
|
||||||
|
}, [cityCode]);
|
||||||
|
|
||||||
const loadMiniHome = useCallback(() => {
|
const loadMiniHome = useCallback(() => {
|
||||||
return request<{ miniHome?: MiniHomeConfig }>('/common/client-config')
|
return request<{ miniHome?: MiniHomeConfig }>('/common/client-config')
|
||||||
.then((cfg) => {
|
.then((cfg) => {
|
||||||
@@ -104,31 +101,60 @@ export default function HomePage() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const applyProductList = useCallback((list: Product[], nextCode: string, authKey: string) => {
|
||||||
|
const normalized = Array.isArray(list) ? list.map((p) => normalizeFulfillmentFlags(p)) : [];
|
||||||
|
setProducts(normalized);
|
||||||
|
setHomeCatalogCache({ cityCode: nextCode, authKey, products: normalized });
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const fetchProducts = useCallback(
|
||||||
|
(nextCode: string, authKey: string) => {
|
||||||
|
setLoading(true);
|
||||||
|
return request<Product[]>(`/catalog/products?cityCode=${encodeURIComponent(nextCode)}`)
|
||||||
|
.then((list) => applyProductList(list, nextCode, authKey))
|
||||||
|
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'))
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
},
|
||||||
|
[applyProductList],
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首次进入 / 城市或登录态变化:拉商品。
|
||||||
|
* 同次再切 tab:只同步选中态,不重复请求(对齐门店页)。
|
||||||
|
*/
|
||||||
useDidShow(() => {
|
useDidShow(() => {
|
||||||
syncTabBarSelected(0);
|
syncTabBarSelected(0);
|
||||||
void capturePromoSceneAndTouchScan();
|
void capturePromoSceneAndTouchScan();
|
||||||
void loadMiniHome();
|
void loadMiniHome();
|
||||||
void resolveUserCity().then((resolved) => {
|
|
||||||
|
const authKey = getToken() || '';
|
||||||
|
void (async () => {
|
||||||
|
const resolved = await resolveUserCity();
|
||||||
|
const nextCode = getCityCodeForCatalog(resolved);
|
||||||
setDisplayCity(resolved.displayCity);
|
setDisplayCity(resolved.displayCity);
|
||||||
setCityCode(getCityCodeForCatalog(resolved));
|
setCityCode(nextCode);
|
||||||
});
|
|
||||||
|
const cache = getHomeCatalogCache();
|
||||||
|
if (
|
||||||
|
isHomeCatalogBootstrapped() &&
|
||||||
|
cache &&
|
||||||
|
cache.cityCode === nextCode &&
|
||||||
|
cache.authKey === authKey &&
|
||||||
|
Array.isArray(cache.products)
|
||||||
|
) {
|
||||||
|
setProducts(cache.products as Product[]);
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await fetchProducts(nextCode, authKey);
|
||||||
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
const loadProducts = useCallback(() => {
|
|
||||||
setLoading(true);
|
|
||||||
return request<Product[]>(`/catalog/products?cityCode=${encodeURIComponent(cityCode)}`)
|
|
||||||
.then((list) => setProducts(Array.isArray(list) ? list : []))
|
|
||||||
.catch((e) => toast(e instanceof Error ? e.message : '加载失败'))
|
|
||||||
.finally(() => setLoading(false));
|
|
||||||
}, [cityCode]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
void loadProducts();
|
|
||||||
}, [loadProducts]);
|
|
||||||
|
|
||||||
usePullDownRefresh(() => {
|
usePullDownRefresh(() => {
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
|
const authKey = getToken() || '';
|
||||||
const resolved = await resolveUserCity();
|
const resolved = await resolveUserCity();
|
||||||
setDisplayCity(resolved.displayCity);
|
setDisplayCity(resolved.displayCity);
|
||||||
const nextCode = getCityCodeForCatalog(resolved);
|
const nextCode = getCityCodeForCatalog(resolved);
|
||||||
@@ -138,7 +164,11 @@ export default function HomePage() {
|
|||||||
request<Product[]>(`/catalog/products?cityCode=${encodeURIComponent(nextCode)}`),
|
request<Product[]>(`/catalog/products?cityCode=${encodeURIComponent(nextCode)}`),
|
||||||
loadMiniHome(),
|
loadMiniHome(),
|
||||||
]);
|
]);
|
||||||
setProducts(Array.isArray(list) ? list : []);
|
applyProductList(
|
||||||
|
Array.isArray(list) ? list : [],
|
||||||
|
nextCode,
|
||||||
|
authKey,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast(e instanceof Error ? e.message : '加载失败');
|
toast(e instanceof Error ? e.message : '加载失败');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -147,7 +177,6 @@ export default function HomePage() {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
function openProductDetail(id: string) {
|
function openProductDetail(id: string) {
|
||||||
Taro.navigateTo({ url: `/pages/product-detail/index?id=${id}` });
|
Taro.navigateTo({ url: `/pages/product-detail/index?id=${id}` });
|
||||||
}
|
}
|
||||||
@@ -163,23 +192,30 @@ export default function HomePage() {
|
|||||||
Taro.navigateTo({ url: returnPath });
|
Taro.navigateTo({ url: returnPath });
|
||||||
}
|
}
|
||||||
|
|
||||||
const filteredProducts = useMemo(
|
|
||||||
() => products.filter((p) => matchFulfillmentFilter(p, fulfillmentFilter)),
|
|
||||||
[products, fulfillmentFilter],
|
|
||||||
);
|
|
||||||
|
|
||||||
const productsByAroma = useMemo(() => {
|
const productsByAroma = useMemo(() => {
|
||||||
const map: Record<AromaKey, Product[]> = {
|
const map: Record<AromaKey, Product[]> = {
|
||||||
QINGXIANG: [],
|
QINGXIANG: [],
|
||||||
JIANGXIANG: [],
|
JIANGXIANG: [],
|
||||||
NONGXIANG: [],
|
NONGXIANG: [],
|
||||||
};
|
};
|
||||||
for (const p of filteredProducts) {
|
for (const p of products) {
|
||||||
const key = p.aromaType as AromaKey;
|
const key = p.aromaType as AromaKey;
|
||||||
if (key in map) map[key].push(p);
|
if (key in map) map[key].push(p);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}, [filteredProducts]);
|
}, [products]);
|
||||||
|
|
||||||
|
const visibleAromaTabs = useMemo(
|
||||||
|
() => AROMA_TABS.filter((t) => productsByAroma[t.key].length > 0),
|
||||||
|
[productsByAroma],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (loading || visibleAromaTabs.length === 0) return;
|
||||||
|
if (!visibleAromaTabs.some((t) => t.key === activeAroma)) {
|
||||||
|
setActiveAroma(visibleAromaTabs[0].key);
|
||||||
|
}
|
||||||
|
}, [loading, visibleAromaTabs, activeAroma]);
|
||||||
|
|
||||||
const banners = miniHome.banners;
|
const banners = miniHome.banners;
|
||||||
const footerUrl = miniHome.footerUrl;
|
const footerUrl = miniHome.footerUrl;
|
||||||
@@ -227,18 +263,18 @@ export default function HomePage() {
|
|||||||
if (now - lastScrollSyncAtRef.current < 80) return;
|
if (now - lastScrollSyncAtRef.current < 80) return;
|
||||||
lastScrollSyncAtRef.current = now;
|
lastScrollSyncAtRef.current = now;
|
||||||
const query = Taro.createSelectorQuery();
|
const query = Taro.createSelectorQuery();
|
||||||
AROMA_TABS.forEach((t) => {
|
visibleAromaTabs.forEach((t) => {
|
||||||
query.select(`#${aromaSectionId(t.key)}`).boundingClientRect();
|
query.select(`#${aromaSectionId(t.key)}`).boundingClientRect();
|
||||||
});
|
});
|
||||||
query.exec((rects) => {
|
query.exec((rects) => {
|
||||||
if (!Array.isArray(rects) || rects.length === 0) return;
|
if (!Array.isArray(rects) || rects.length === 0) return;
|
||||||
let next: AromaKey = AROMA_TABS[0].key;
|
let next: AromaKey = visibleAromaTabs[0]?.key ?? AROMA_TABS[0].key;
|
||||||
for (let i = 0; i < AROMA_TABS.length; i++) {
|
for (let i = 0; i < visibleAromaTabs.length; i++) {
|
||||||
const rect = rects[i] as { top?: number } | null;
|
const rect = rects[i] as { top?: number } | null;
|
||||||
if (!rect || rect.top == null) continue;
|
if (!rect || rect.top == null) continue;
|
||||||
// 区块顶进入导航下方一带时视为当前香型
|
// 区块顶进入导航下方一带时视为当前香型
|
||||||
if (rect.top <= AROMA_NAV_OFFSET_PX + 24) {
|
if (rect.top <= AROMA_NAV_OFFSET_PX + 24) {
|
||||||
next = AROMA_TABS[i].key;
|
next = visibleAromaTabs[i].key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setActiveAroma((prev) => (prev === next ? prev : next));
|
setActiveAroma((prev) => (prev === next ? prev : next));
|
||||||
@@ -268,7 +304,7 @@ export default function HomePage() {
|
|||||||
<CouponBadge amount={p.benefitDisplay ?? p.price} label="好客权益" />
|
<CouponBadge amount={p.benefitDisplay ?? p.price} label="好客权益" />
|
||||||
</View>
|
</View>
|
||||||
<View className="home-product-actions">
|
<View className="home-product-actions">
|
||||||
{p.allowOnSitePickup ? (
|
{canPickupOnSite(p) ? (
|
||||||
<Text
|
<Text
|
||||||
className="home-pickup-btn"
|
className="home-pickup-btn"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -279,7 +315,7 @@ export default function HomePage() {
|
|||||||
现场取货
|
现场取货
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
{p.allowOnlinePurchase !== false ? (
|
{canBuyOnline(p) ? (
|
||||||
<Text
|
<Text
|
||||||
className="home-buy-btn"
|
className="home-buy-btn"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@@ -322,7 +358,7 @@ export default function HomePage() {
|
|||||||
|
|
||||||
<View className="home-aroma-nav">
|
<View className="home-aroma-nav">
|
||||||
<View className="home-aroma-tabs">
|
<View className="home-aroma-tabs">
|
||||||
{AROMA_TABS.map((t) => (
|
{visibleAromaTabs.map((t) => (
|
||||||
<Text
|
<Text
|
||||||
key={t.key}
|
key={t.key}
|
||||||
className={`home-aroma-tab${activeAroma === t.key ? ' home-aroma-tab--active' : ''}`}
|
className={`home-aroma-tab${activeAroma === t.key ? ' home-aroma-tab--active' : ''}`}
|
||||||
@@ -335,38 +371,19 @@ export default function HomePage() {
|
|||||||
<Text className="home-aroma-city">{displayCity}</Text>
|
<Text className="home-aroma-city">{displayCity}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="home-fulfillment-filters">
|
|
||||||
{FULFILLMENT_FILTERS.map((f) => (
|
|
||||||
<Text
|
|
||||||
key={f.key}
|
|
||||||
className={`home-fulfillment-chip${fulfillmentFilter === f.key ? ' home-fulfillment-chip--active' : ''}`}
|
|
||||||
onClick={() => setFulfillmentFilter(f.key)}
|
|
||||||
>
|
|
||||||
{f.label}
|
|
||||||
</Text>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View className="home-product-list">
|
<View className="home-product-list">
|
||||||
{loading ? <View className="home-empty">加载中…</View> : null}
|
{loading ? <View className="home-empty">加载中…</View> : null}
|
||||||
{!loading && products.length === 0 ? (
|
{!loading && products.length === 0 ? (
|
||||||
<View className="home-empty">当前城市暂无在售商品</View>
|
<View className="home-empty">当前城市暂无在售商品</View>
|
||||||
) : null}
|
) : null}
|
||||||
{!loading && products.length > 0 && filteredProducts.length === 0 ? (
|
|
||||||
<View className="home-empty">暂无符合履约方式的商品</View>
|
|
||||||
) : null}
|
|
||||||
{!loading &&
|
{!loading &&
|
||||||
filteredProducts.length > 0 &&
|
products.length > 0 &&
|
||||||
AROMA_TABS.map((t) => {
|
visibleAromaTabs.map((t) => {
|
||||||
const list = productsByAroma[t.key];
|
const list = productsByAroma[t.key];
|
||||||
return (
|
return (
|
||||||
<View key={t.key} id={aromaSectionId(t.key)} className="home-aroma-section">
|
<View key={t.key} id={aromaSectionId(t.key)} className="home-aroma-section">
|
||||||
<Text className="home-aroma-section-title">{t.label}</Text>
|
<Text className="home-aroma-section-title">{t.label}</Text>
|
||||||
{list.length === 0 ? (
|
{list.map((p) => renderProductCard(p))}
|
||||||
<View className="home-empty home-empty--section">该香型暂未上线</View>
|
|
||||||
) : (
|
|
||||||
list.map((p) => renderProductCard(p))
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import iconStores from '../../assets/icons/可用门店.png';
|
|||||||
import iconCs from '../../assets/icons/联系客服.png';
|
import iconCs from '../../assets/icons/联系客服.png';
|
||||||
import iconQualification from '../../assets/icons/资质公示.png';
|
import iconQualification from '../../assets/icons/资质公示.png';
|
||||||
import iconAbout from '../../assets/icons/关于我们.png';
|
import iconAbout from '../../assets/icons/关于我们.png';
|
||||||
|
import { formatMoney } from '../../lib/money';
|
||||||
|
|
||||||
const ORDER_SHORTCUTS = [
|
const ORDER_SHORTCUTS = [
|
||||||
{ tab: 'pending_pay', icon: iconPendingPay, label: '待付款' },
|
{ tab: 'pending_pay', icon: iconPendingPay, label: '待付款' },
|
||||||
@@ -54,10 +55,6 @@ const SERVICES = [
|
|||||||
|
|
||||||
const isWeapp = process.env.TARO_ENV === 'weapp';
|
const isWeapp = process.env.TARO_ENV === 'weapp';
|
||||||
|
|
||||||
function formatMoney(amount: number) {
|
|
||||||
return amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function MinePage() {
|
export default function MinePage() {
|
||||||
const [authed, setAuthed] = useState(() => isLoggedIn());
|
const [authed, setAuthed] = useState(() => isLoggedIn());
|
||||||
const [profile, setProfile] = useState<UserProfile | null>(null);
|
const [profile, setProfile] = useState<UserProfile | null>(null);
|
||||||
@@ -221,7 +218,10 @@ export default function MinePage() {
|
|||||||
|
|
||||||
/** 点击头像:绑定账号后用 chooseAvatar + nickname 获取头像昵称 */
|
/** 点击头像:绑定账号后用 chooseAvatar + nickname 获取头像昵称 */
|
||||||
async function handleAvatarTap() {
|
async function handleAvatarTap() {
|
||||||
if (bindingWx || savingProfile) return;
|
if (bindingWx || savingProfile) {
|
||||||
|
toast(savingProfile ? '资料保存中…' : '请稍候…');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isLoggedIn()) {
|
if (!isLoggedIn()) {
|
||||||
goLogin('/pages/mine/index');
|
goLogin('/pages/mine/index');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { goLogin } from '../../lib/auth-nav';
|
|||||||
import { buildPayUrl } from '../../lib/checkout-nav';
|
import { buildPayUrl } from '../../lib/checkout-nav';
|
||||||
import { ensurePayReady } from '../../lib/pay-ready';
|
import { ensurePayReady } from '../../lib/pay-ready';
|
||||||
import { fetchUserProfile } from '../../lib/pay-wechat';
|
import { fetchUserProfile } from '../../lib/pay-wechat';
|
||||||
import { request } from '../../lib/api';
|
import { request, toast } from '../../lib/api';
|
||||||
import { getProductMainImage } from '../../lib/product-images';
|
import { getProductMainImage } from '../../lib/product-images';
|
||||||
|
|
||||||
type PreviewProduct = {
|
type PreviewProduct = {
|
||||||
@@ -75,7 +75,14 @@ export default function OrderConfirmPickupPage() {
|
|||||||
const canSubmit = !!preview && quantityOk && !loading && !previewLoading;
|
const canSubmit = !!preview && quantityOk && !loading && !previewLoading;
|
||||||
|
|
||||||
function updateQuantity(next: number) {
|
function updateQuantity(next: number) {
|
||||||
if (next < minQty) return;
|
if (next < minQty) {
|
||||||
|
const tip = `现场提货至少购买 ${minQty} 瓶`;
|
||||||
|
toast(tip);
|
||||||
|
setMsg(tip);
|
||||||
|
if (next < 1) return;
|
||||||
|
setQuantity(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setQuantity(next);
|
setQuantity(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,8 +102,12 @@ export default function OrderConfirmPickupPage() {
|
|||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!canSubmit) {
|
if (!canSubmit) {
|
||||||
if (!quantityOk) setMsg(`现场提货至少购买 ${minQty} 瓶`);
|
if (!quantityOk) {
|
||||||
return;
|
const tip = `现场提货至少购买 ${minQty} 瓶`;
|
||||||
|
setMsg(tip);
|
||||||
|
toast(tip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnPath = `/pages/order-confirm-pickup/index?productId=${productId}&qty=${quantity}`;
|
const returnPath = `/pages/order-confirm-pickup/index?productId=${productId}&qty=${quantity}`;
|
||||||
@@ -185,8 +196,8 @@ export default function OrderConfirmPickupPage() {
|
|||||||
<Text>购买数量</Text>
|
<Text>购买数量</Text>
|
||||||
<View className="order-qty-controls">
|
<View className="order-qty-controls">
|
||||||
<View
|
<View
|
||||||
className={`order-qty-btn${quantity <= minQty ? ' order-qty-btn--disabled' : ''}`}
|
className="order-qty-btn"
|
||||||
onClick={() => updateQuantity(Math.max(minQty, quantity - 1))}
|
onClick={() => updateQuantity(quantity - 1)}
|
||||||
>
|
>
|
||||||
<Text>−</Text>
|
<Text>−</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import { tryGetClientGpsLocation } from '../../lib/client-location';
|
|||||||
import { maskPhone } from '../../lib/phone';
|
import { maskPhone } from '../../lib/phone';
|
||||||
import { ensurePayReady } from '../../lib/pay-ready';
|
import { ensurePayReady } from '../../lib/pay-ready';
|
||||||
import { fetchUserProfile } from '../../lib/pay-wechat';
|
import { fetchUserProfile } from '../../lib/pay-wechat';
|
||||||
import { request } from '../../lib/api';
|
import { request, toast } from '../../lib/api';
|
||||||
|
import { canCrossCity, isCrossCityAddress } from '../../lib/product-fulfillment';
|
||||||
import { getProductMainImage } from '../../lib/product-images';
|
import { getProductMainImage } from '../../lib/product-images';
|
||||||
|
|
||||||
type Address = {
|
type Address = {
|
||||||
@@ -31,6 +32,8 @@ type PreviewProduct = {
|
|||||||
price: number;
|
price: number;
|
||||||
mainImageUrl?: string | null;
|
mainImageUrl?: string | null;
|
||||||
carouselUrls?: string[] | null;
|
carouselUrls?: string[] | null;
|
||||||
|
allowCrossCityDelivery?: boolean;
|
||||||
|
allowOnlinePurchase?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OrderPreview = {
|
type OrderPreview = {
|
||||||
@@ -41,12 +44,18 @@ type OrderPreview = {
|
|||||||
freightPayType: 'COD' | null;
|
freightPayType: 'COD' | null;
|
||||||
payAmount: number;
|
payAmount: number;
|
||||||
benefitAmount: number;
|
benefitAmount: number;
|
||||||
city?: { localMinQty: number; crossMinQty: number };
|
city?: { name?: string; localMinQty: number; crossMinQty: number };
|
||||||
quantityOk?: boolean;
|
quantityOk?: boolean;
|
||||||
quantityMessage?: string | null;
|
quantityMessage?: string | null;
|
||||||
|
addressOk?: boolean;
|
||||||
|
addressMessage?: string | null;
|
||||||
minQty?: number;
|
minQty?: number;
|
||||||
|
allowCrossCityDelivery?: boolean;
|
||||||
|
allowOnlinePurchase?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CROSS_CITY_BLOCK_MSG = '该商品不支持跨城配送,请更换为开城城市内的收货地址';
|
||||||
|
|
||||||
function formatAddress(a: Address) {
|
function formatAddress(a: Address) {
|
||||||
return `${a.province}${a.city}${a.district}${a.detail}`;
|
return `${a.province}${a.city}${a.district}${a.detail}`;
|
||||||
}
|
}
|
||||||
@@ -64,6 +73,7 @@ export default function OrderConfirmPage() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [msg, setMsg] = useState('');
|
const [msg, setMsg] = useState('');
|
||||||
const phonePromptSkipped = useRef(false);
|
const phonePromptSkipped = useRef(false);
|
||||||
|
const toastedAddressBlockRef = useRef('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
request<Address[]>('/user/addresses')
|
request<Address[]>('/user/addresses')
|
||||||
@@ -94,7 +104,24 @@ export default function OrderConfirmPage() {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setPreview(data);
|
setPreview(data);
|
||||||
setMsg(data.quantityOk === false ? (data.quantityMessage || '') : '');
|
const nextMsg =
|
||||||
|
data.addressOk === false
|
||||||
|
? data.addressMessage || CROSS_CITY_BLOCK_MSG
|
||||||
|
: data.quantityOk === false
|
||||||
|
? data.quantityMessage || ''
|
||||||
|
: '';
|
||||||
|
setMsg(nextMsg);
|
||||||
|
if (
|
||||||
|
data.addressOk === false &&
|
||||||
|
addressId &&
|
||||||
|
toastedAddressBlockRef.current !== addressId
|
||||||
|
) {
|
||||||
|
toastedAddressBlockRef.current = addressId;
|
||||||
|
toast(data.addressMessage || CROSS_CITY_BLOCK_MSG);
|
||||||
|
}
|
||||||
|
if (data.addressOk !== false) {
|
||||||
|
toastedAddressBlockRef.current = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
@@ -117,15 +144,39 @@ export default function OrderConfirmPage() {
|
|||||||
[addresses, addressId],
|
[addresses, addressId],
|
||||||
);
|
);
|
||||||
|
|
||||||
const isCross = forceCross || preview?.deliveryType === 'CROSS_CITY';
|
const allowCross =
|
||||||
|
preview?.allowCrossCityDelivery !== undefined
|
||||||
|
? canCrossCity({ allowCrossCityDelivery: preview.allowCrossCityDelivery })
|
||||||
|
: canCrossCity(preview?.product ?? {});
|
||||||
|
const localCross =
|
||||||
|
!!selectedAddress &&
|
||||||
|
isCrossCityAddress(selectedAddress.city, preview?.city?.name);
|
||||||
|
const isCross =
|
||||||
|
forceCross || preview?.deliveryType === 'CROSS_CITY' || localCross;
|
||||||
|
const crossBlocked = isCross && !allowCross;
|
||||||
|
const addressOk = preview ? preview.addressOk !== false && !crossBlocked : !crossBlocked;
|
||||||
const minQty =
|
const minQty =
|
||||||
preview?.minQty ??
|
preview?.minQty ??
|
||||||
(isCross ? (preview?.city?.crossMinQty ?? 6) : (preview?.city?.localMinQty ?? 2));
|
(isCross ? (preview?.city?.crossMinQty ?? 6) : (preview?.city?.localMinQty ?? 2));
|
||||||
const quantityOk = preview ? preview.quantityOk !== false && quantity >= minQty : false;
|
const quantityOk = preview ? preview.quantityOk !== false && quantity >= minQty : false;
|
||||||
const canSubmit = !!addressId && !!preview && quantityOk && !loading && !previewLoading;
|
const canSubmit =
|
||||||
|
!!addressId && !!preview && quantityOk && addressOk && !loading && !previewLoading;
|
||||||
|
|
||||||
|
const addressHint = !addressOk
|
||||||
|
? preview?.addressMessage || CROSS_CITY_BLOCK_MSG
|
||||||
|
: '';
|
||||||
|
|
||||||
function updateQuantity(next: number) {
|
function updateQuantity(next: number) {
|
||||||
if (next < 1) return;
|
if (next < minQty) {
|
||||||
|
const tip = isCross
|
||||||
|
? `跨城配送至少购买 ${minQty} 瓶(1箱)`
|
||||||
|
: `同城配送至少购买 ${minQty} 瓶`;
|
||||||
|
toast(tip);
|
||||||
|
setMsg(tip);
|
||||||
|
if (next < 1) return;
|
||||||
|
setQuantity(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setQuantity(next);
|
setQuantity(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,12 +213,18 @@ export default function OrderConfirmPage() {
|
|||||||
setMsg('请选择收货地址');
|
setMsg('请选择收货地址');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!addressOk) {
|
||||||
|
const tip = addressHint || CROSS_CITY_BLOCK_MSG;
|
||||||
|
setMsg(tip);
|
||||||
|
toast(tip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!quantityOk) {
|
if (!quantityOk) {
|
||||||
setMsg(
|
const tip = isCross
|
||||||
isCross
|
? `跨城配送至少购买 ${minQty} 瓶(1箱)`
|
||||||
? `跨城配送至少购买 ${minQty} 瓶(1箱)`
|
: `同城配送至少购买 ${minQty} 瓶`;
|
||||||
: `同城配送至少购买 ${minQty} 瓶`,
|
setMsg(tip);
|
||||||
);
|
toast(tip);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -219,9 +276,12 @@ export default function OrderConfirmPage() {
|
|||||||
? '提交中…'
|
? '提交中…'
|
||||||
: !addressId
|
: !addressId
|
||||||
? '请选择地址'
|
? '请选择地址'
|
||||||
: !quantityOk
|
: !addressOk
|
||||||
? `至少购买 ${minQty} 瓶`
|
? '请更换地址'
|
||||||
: '提交订单';
|
: !quantityOk
|
||||||
|
? `至少购买 ${minQty} 瓶`
|
||||||
|
: '提交订单';
|
||||||
|
const displayMsg = msg || addressHint;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell variant="sub" className="order-confirm-page" hasFixedFooter>
|
<PageShell variant="sub" className="order-confirm-page" hasFixedFooter>
|
||||||
@@ -254,7 +314,13 @@ export default function OrderConfirmPage() {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{isCross ? (
|
{!addressOk && addressId ? (
|
||||||
|
<View className="order-card order-card--warn">
|
||||||
|
<Text className="order-warn-text">{addressHint || CROSS_CITY_BLOCK_MSG}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{isCross && addressOk ? (
|
||||||
<View className="order-card">
|
<View className="order-card">
|
||||||
<Text className="u-muted">
|
<Text className="u-muted">
|
||||||
该地址超出同城配送范围,将由总部物流发货,运费到付
|
该地址超出同城配送范围,将由总部物流发货,运费到付
|
||||||
@@ -286,7 +352,7 @@ export default function OrderConfirmPage() {
|
|||||||
<Text>购买数量</Text>
|
<Text>购买数量</Text>
|
||||||
<View className="order-qty-controls">
|
<View className="order-qty-controls">
|
||||||
<View
|
<View
|
||||||
className={`order-qty-btn${quantity <= 1 ? ' order-qty-btn--disabled' : ''}`}
|
className="order-qty-btn"
|
||||||
onClick={() => updateQuantity(quantity - 1)}
|
onClick={() => updateQuantity(quantity - 1)}
|
||||||
>
|
>
|
||||||
<Text>−</Text>
|
<Text>−</Text>
|
||||||
@@ -333,9 +399,9 @@ export default function OrderConfirmPage() {
|
|||||||
{!previewLoading && !preview && productId ? (
|
{!previewLoading && !preview && productId ? (
|
||||||
<View className="u-empty">无法加载商品信息</View>
|
<View className="u-empty">无法加载商品信息</View>
|
||||||
) : null}
|
) : null}
|
||||||
{msg ? (
|
{displayMsg ? (
|
||||||
<Text className="u-muted" style={{ display: 'block', marginTop: 8, textAlign: 'center' }}>
|
<Text className="order-warn-text" style={{ display: 'block', marginTop: 8, textAlign: 'center' }}>
|
||||||
{msg}
|
{displayMsg}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
DEFAULT_SHARE_TITLE,
|
DEFAULT_SHARE_TITLE,
|
||||||
toWeappShareMessage,
|
toWeappShareMessage,
|
||||||
} from '../../lib/wechat-share';
|
} from '../../lib/wechat-share';
|
||||||
|
import { usePageView } from '../../lib/usePageView';
|
||||||
|
|
||||||
const isWeapp = process.env.TARO_ENV === 'weapp';
|
const isWeapp = process.env.TARO_ENV === 'weapp';
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ function fullReceiverAddress(order: OrderDetail) {
|
|||||||
export default function OrderDetailPage() {
|
export default function OrderDetailPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const orderId = router.params.id ?? '';
|
const orderId = router.params.id ?? '';
|
||||||
|
usePageView('order_detail_view', orderId ? { orderId } : undefined);
|
||||||
const [order, setOrder] = useState<OrderDetail | null>(null);
|
const [order, setOrder] = useState<OrderDetail | null>(null);
|
||||||
const [confirming, setConfirming] = useState(false);
|
const [confirming, setConfirming] = useState(false);
|
||||||
|
|
||||||
@@ -180,6 +182,17 @@ export default function OrderDetailPage() {
|
|||||||
<WechatShareReady payload={sharePayload} />
|
<WechatShareReady payload={sharePayload} />
|
||||||
<SubPageHeader
|
<SubPageHeader
|
||||||
title="订单详情"
|
title="订单详情"
|
||||||
|
onBack={() => {
|
||||||
|
// 支付完成后 reLaunch 进详情:栈仅一页时 navigateBack 会退出小程序,统一回首页
|
||||||
|
const fromPay = String(router.params.from || '') === 'pay';
|
||||||
|
if (fromPay || Taro.getCurrentPages().length <= 1) {
|
||||||
|
Taro.switchTab({ url: '/pages/home/index' }).catch(() => {
|
||||||
|
Taro.reLaunch({ url: '/pages/home/index' });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Taro.navigateBack();
|
||||||
|
}}
|
||||||
right={<ShareNavButton payload={sharePayload} />}
|
right={<ShareNavButton payload={sharePayload} />}
|
||||||
/>
|
/>
|
||||||
<View className="sub-page-body">
|
<View className="sub-page-body">
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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';
|
import { buildPayUrl } from '../../lib/checkout-nav';
|
||||||
|
import { usePageView } from '../../lib/usePageView';
|
||||||
|
|
||||||
import { ORDER_STATUS_LABELS } from '@dukang/shared-types';
|
import { ORDER_STATUS_LABELS } from '@dukang/shared-types';
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ type OrderRow = {
|
|||||||
export default function OrdersPage() {
|
export default function OrdersPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [tab, setTab] = useState(() => normalizeOrdersTab(router.params.tab as string));
|
const [tab, setTab] = useState(() => normalizeOrdersTab(router.params.tab as string));
|
||||||
|
usePageView('order_list_view', { tab });
|
||||||
const [orders, setOrders] = useState<OrderRow[]>([]);
|
const [orders, setOrders] = useState<OrderRow[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
@@ -93,7 +95,14 @@ export default function OrdersPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell variant="sub" className="orders-page">
|
<PageShell variant="sub" className="orders-page">
|
||||||
<SubPageHeader title="我的订单" />
|
<SubPageHeader
|
||||||
|
title="我的订单"
|
||||||
|
onBack={() => {
|
||||||
|
Taro.switchTab({ url: '/pages/home/index' }).catch(() => {
|
||||||
|
Taro.reLaunch({ url: '/pages/home/index' });
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<View className="order-tabs">
|
<View className="order-tabs">
|
||||||
{TABS.map((t) => (
|
{TABS.map((t) => (
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
@@ -144,10 +144,10 @@ export default function PayPage() {
|
|||||||
toast('支付成功', 'success');
|
toast('支付成功', 'success');
|
||||||
}
|
}
|
||||||
if (deliveryType === 'ON_SITE_PICKUP') {
|
if (deliveryType === 'ON_SITE_PICKUP') {
|
||||||
// 现场提货支付即完成 → 订单详情(已完成)
|
// 现场提货支付即完成 → 订单详情;from=pay 返回强制回首页,避免 navigateBack 退出小程序
|
||||||
Taro.redirectTo({ url: `/pages/order-detail/index?id=${orderId}` });
|
Taro.reLaunch({ url: `/pages/order-detail/index?id=${orderId}&from=pay` });
|
||||||
} else {
|
} else {
|
||||||
Taro.redirectTo({ url: '/pages/orders/index?tab=paid' });
|
Taro.reLaunch({ url: '/pages/orders/index?tab=paid&from=pay' });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isWechatAuthRequiredError(e)) {
|
if (isWechatAuthRequiredError(e)) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user