feat(assoc): v4.0.1 合伙人关联码、分佣账单与 H5 用户管理
订单佣金只认关联用户;合伙人备注写入独立表;H5 增加用户管理与首页统计。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -105,6 +105,10 @@ body.admin-col-resizing * {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.admin-users-filter-item--keyword {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.admin-orders-filter-item--status {
|
||||
width: 220px;
|
||||
min-width: 180px;
|
||||
|
||||
@@ -1,458 +1,465 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Drawer,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tabs,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import {
|
||||
CITY_PARTNER_SCOPE_LABELS,
|
||||
CITY_PARTNER_STATUS_LABELS,
|
||||
CityPartnerScopeType,
|
||||
CityPartnerStatus,
|
||||
PARTNER_PERMISSION_KEYS,
|
||||
PARTNER_PERMISSION_LABELS,
|
||||
PARTNER_STAFF_ROLE_LABELS,
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import CityDistrictMultiSelect from './CityDistrictMultiSelect';
|
||||
import PartnerSubAccountList from './PartnerSubAccountList';
|
||||
|
||||
type PartnerRow = {
|
||||
id: string;
|
||||
companyName: string;
|
||||
phone: string;
|
||||
name: string;
|
||||
scopeType?: string;
|
||||
districtCodes?: string[] | null;
|
||||
orderCommissionRate?: number;
|
||||
redeemCommissionRate?: number;
|
||||
accountCount: number;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
type PartnerDetail = PartnerRow & {
|
||||
address?: string;
|
||||
districtCodes?: string[] | null;
|
||||
bindingStatus?: string;
|
||||
bankAccountName?: string | null;
|
||||
bankAccountNo?: string | null;
|
||||
bankBranch?: string | null;
|
||||
managedWarehouseId?: string | null;
|
||||
managedWarehouseName?: string | null;
|
||||
contactPhone?: string | null;
|
||||
children?: Array<{
|
||||
id: string;
|
||||
phone: string;
|
||||
name: string;
|
||||
staffRole?: string;
|
||||
permissions?: string[];
|
||||
status: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cityId: string;
|
||||
cityCode?: string;
|
||||
maxPartnerCommissionRate?: number;
|
||||
onChanged?: () => void;
|
||||
};
|
||||
|
||||
const SCOPE_OPTIONS = Object.entries(CITY_PARTNER_SCOPE_LABELS).map(([value, label]) => ({ value, label }));
|
||||
const BINDING_OPTIONS = Object.entries(CITY_PARTNER_STATUS_LABELS).map(([value, label]) => ({ value, label }));
|
||||
const PERM_OPTIONS = PARTNER_PERMISSION_KEYS.map((k: PartnerPermissionKey) => ({
|
||||
value: k,
|
||||
label: PARTNER_PERMISSION_LABELS[k],
|
||||
}));
|
||||
const STAFF_ROLE_OPTIONS = Object.entries(PARTNER_STAFF_ROLE_LABELS)
|
||||
.filter(([value]) => value !== 'PARTNER')
|
||||
.map(([value, label]) => ({ value, label }));
|
||||
|
||||
function flattenDistrictCodes(values: string[] | string[][] | undefined): string[] {
|
||||
if (!values?.length) return [];
|
||||
if (Array.isArray(values[0])) {
|
||||
return (values as string[][]).map((path) => path[path.length - 1]).filter(Boolean);
|
||||
}
|
||||
return values as string[];
|
||||
}
|
||||
|
||||
function commissionSumError(
|
||||
orderPercent: number,
|
||||
redeemPercent: number,
|
||||
maxRate: number,
|
||||
): string | null {
|
||||
// API 可能把 Prisma Decimal 序列化为字符串;`"0.05" + 1e-9` 会变成字符串拼接导致误判超限
|
||||
const max = Number(maxRate);
|
||||
const sum = Number(orderPercent) / 100 + Number(redeemPercent) / 100;
|
||||
if (!Number.isFinite(max) || !Number.isFinite(sum)) return '佣金比例无效';
|
||||
if (sum > max + 1e-9) {
|
||||
return `订单佣金与核销佣金合计不得超过 ${(max * 100).toFixed(2)}%(当前 ${(sum * 100).toFixed(2)}%)`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatApiError(err: unknown): string | null {
|
||||
if (err && typeof err === 'object' && 'errorFields' in err) return null;
|
||||
if (!(err instanceof Error)) return '操作失败';
|
||||
return err.message.replace(/\b(\d{6})\b/g, (code) => {
|
||||
const label = districtCodeLabel(code);
|
||||
return label !== code ? `${label}(${code})` : code;
|
||||
});
|
||||
}
|
||||
|
||||
export default function CityPartnersPanel({
|
||||
cityId,
|
||||
cityCode,
|
||||
maxPartnerCommissionRate = 0.05,
|
||||
onChanged,
|
||||
}: Props) {
|
||||
const [editForm] = Form.useForm();
|
||||
const [createForm] = Form.useForm();
|
||||
const [subForm] = Form.useForm();
|
||||
const [subEditForm] = Form.useForm();
|
||||
const [partners, setPartners] = useState<PartnerRow[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detail, setDetail] = useState<PartnerDetail | null>(null);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [subOpen, setSubOpen] = useState(false);
|
||||
const [subEditOpen, setSubEditOpen] = useState(false);
|
||||
const [subEditId, setSubEditId] = useState<string | null>(null);
|
||||
const [createScopeType, setCreateScopeType] = useState<CityPartnerScopeType>(CityPartnerScopeType.CITY_WIDE);
|
||||
const [editScopeType, setEditScopeType] = useState<CityPartnerScopeType>(CityPartnerScopeType.CITY_WIDE);
|
||||
|
||||
const loadPartners = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<Paginated<PartnerRow>>(`/admin/partners?cityId=${cityId}&pageSize=100`);
|
||||
setPartners(res.items);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [cityId]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadPartners();
|
||||
}, [loadPartners]);
|
||||
|
||||
async function openPartner(id: string) {
|
||||
const d = await request<PartnerDetail>(`/admin/partners/${id}`);
|
||||
setDetail(d);
|
||||
setEditScopeType((d.scopeType as CityPartnerScopeType) || CityPartnerScopeType.CITY_WIDE);
|
||||
editForm.setFieldsValue({
|
||||
name: d.name,
|
||||
phone: d.phone,
|
||||
companyName: d.companyName,
|
||||
contactPhone: d.contactPhone ?? d.phone,
|
||||
address: d.address ?? '',
|
||||
scopeType: d.scopeType,
|
||||
districtCodes: d.districtCodes ?? [],
|
||||
orderCommissionRate: (d.orderCommissionRate ?? 0) * 100,
|
||||
redeemCommissionRate: (d.redeemCommissionRate ?? 0.03) * 100,
|
||||
bindingStatus: d.bindingStatus ?? CityPartnerStatus.ACTIVE,
|
||||
bankAccountName: d.bankAccountName ?? '',
|
||||
bankAccountNo: d.bankAccountNo ?? '',
|
||||
bankBranch: d.bankBranch ?? '',
|
||||
});
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
async function savePartner() {
|
||||
if (!detail) return;
|
||||
try {
|
||||
const v = await editForm.validateFields();
|
||||
const err = commissionSumError(
|
||||
Number(v.orderCommissionRate ?? 0),
|
||||
Number(v.redeemCommissionRate ?? 0),
|
||||
maxPartnerCommissionRate,
|
||||
);
|
||||
if (err) {
|
||||
message.error(err);
|
||||
return;
|
||||
}
|
||||
await request(`/admin/partners/${detail.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
}),
|
||||
});
|
||||
message.success('已保存');
|
||||
setDrawerOpen(false);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
} catch (e) {
|
||||
const msg = formatApiError(e);
|
||||
if (msg) message.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSubAccount(subId: string) {
|
||||
await request(`/admin/partner-accounts/${subId}`, { method: 'DELETE' });
|
||||
message.success('子账号已删除');
|
||||
if (detail) void openPartner(detail.id);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
}
|
||||
|
||||
const columns: ColumnsType<PartnerRow> = [
|
||||
{
|
||||
title: '区县',
|
||||
dataIndex: 'districtCodes',
|
||||
width: 160,
|
||||
|
||||
render: (codes: string[] | null | undefined, row) =>
|
||||
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
||||
},
|
||||
{ title: '公司名', dataIndex: 'companyName' },
|
||||
{ title: '主账号', dataIndex: 'phone', width: 120 },
|
||||
{
|
||||
title: '管辖',
|
||||
dataIndex: 'scopeType',
|
||||
width: 100,
|
||||
render: (v) => (v ? CITY_PARTNER_SCOPE_LABELS[v as keyof typeof CITY_PARTNER_SCOPE_LABELS] || v : '—'),
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
width: 120,
|
||||
render: (_, row) => `${Math.round((row.orderCommissionRate ?? 0) * 100)}% / ${Math.round((row.redeemCommissionRate ?? 0.03) * 100)}%`,
|
||||
},
|
||||
{ title: '子账号', dataIndex: 'accountCount', width: 70, render: (n) => Math.max(0, n - 1) },
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
render: (_, row) => (
|
||||
<Button type="link" size="small" onClick={() => void openPartner(row.id)}>
|
||||
管理
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ marginBottom: 12 }}
|
||||
onClick={() => {
|
||||
createForm.resetFields();
|
||||
createForm.setFieldsValue({
|
||||
cityId,
|
||||
orderCommissionRate: 0,
|
||||
redeemCommissionRate: 3,
|
||||
scopeType: CityPartnerScopeType.CITY_WIDE,
|
||||
});
|
||||
setCreateScopeType(CityPartnerScopeType.CITY_WIDE);
|
||||
setCreateOpen(true);
|
||||
}}
|
||||
>
|
||||
新建合伙人
|
||||
</Button>
|
||||
<Table rowKey="id" size="small" loading={loading} columns={columns} dataSource={partners} pagination={false} />
|
||||
|
||||
<Drawer
|
||||
title="城市合伙人"
|
||||
width={640}
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
extra={<Button type="primary" onClick={() => void savePartner()}>保存</Button>}
|
||||
>
|
||||
{detail && (
|
||||
<Tabs
|
||||
items={[
|
||||
{
|
||||
key: 'info',
|
||||
label: '主账号',
|
||||
children: (
|
||||
<Form form={editForm} layout="vertical">
|
||||
<Form.Item name="companyName" label="公司名"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="name" label="主账号姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="登录手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="contactPhone" label="业务联系电话"><Input /></Form.Item>
|
||||
<Form.Item name="address" label="地址"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="bindingStatus" label="绑定状态" rules={[{ required: true }]}>
|
||||
<Select options={BINDING_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="scopeType" label="管辖类型" rules={[{ required: true }]}>
|
||||
<Select options={SCOPE_OPTIONS} onChange={(v) => setEditScopeType(v)} />
|
||||
</Form.Item>
|
||||
{editScopeType === CityPartnerScopeType.DISTRICT && (
|
||||
<Form.Item
|
||||
name="districtCodes"
|
||||
label="区县"
|
||||
extra="仅作标识,可多选当前城市下的区县(不做互斥)"
|
||||
>
|
||||
<CityDistrictMultiSelect cityCode={cityCode} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Space style={{ width: '100%' }} size="large">
|
||||
<Form.Item name="orderCommissionRate" label="订单佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
<Form.Item name="redeemCommissionRate" label="核销佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
</Space>
|
||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||
订单 + 核销合计不得超过 {(maxPartnerCommissionRate * 100).toFixed(2)}%(可在城市基本信息中调整)
|
||||
</Typography.Text>
|
||||
<Form.Item label="管仓仓库">
|
||||
<Input
|
||||
disabled
|
||||
value={detail.managedWarehouseName ?? '未分配(请在仓库管理中设置)'}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="bankAccountName" label="户名"><Input /></Form.Item>
|
||||
<Form.Item name="bankAccountNo" label="账号"><Input /></Form.Item>
|
||||
<Form.Item name="bankBranch" label="开户行"><Input /></Form.Item>
|
||||
</Form>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'staff',
|
||||
label: `子账号 (${Math.max(0, (detail.accountCount ?? 1) - 1)})`,
|
||||
children: (
|
||||
<PartnerSubAccountList
|
||||
subs={detail.children ?? []}
|
||||
onAdd={() => {
|
||||
subForm.resetFields();
|
||||
subForm.setFieldsValue({ staffRole: 'INTERNAL', permissions: ['store:create', 'store:manage'] });
|
||||
setSubOpen(true);
|
||||
}}
|
||||
onEdit={(row) => {
|
||||
setSubEditId(row.id);
|
||||
subEditForm.setFieldsValue({
|
||||
name: row.name,
|
||||
phone: row.phone,
|
||||
staffRole: row.staffRole ?? 'INTERNAL',
|
||||
permissions: row.permissions ?? [],
|
||||
status: row.status,
|
||||
});
|
||||
setSubEditOpen(true);
|
||||
}}
|
||||
onDelete={(subId) => void deleteSubAccount(subId)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
<Modal title="新建城市合伙人" open={createOpen} width={560} onCancel={() => setCreateOpen(false)} onOk={async () => {
|
||||
try {
|
||||
const v = await createForm.validateFields();
|
||||
const err = commissionSumError(
|
||||
Number(v.orderCommissionRate ?? 0),
|
||||
Number(v.redeemCommissionRate ?? 3),
|
||||
maxPartnerCommissionRate,
|
||||
);
|
||||
if (err) {
|
||||
message.error(err);
|
||||
return;
|
||||
}
|
||||
await request('/admin/partners', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
cityId,
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: createScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
}),
|
||||
});
|
||||
message.success('已创建');
|
||||
setCreateOpen(false);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
} catch (e) {
|
||||
const msg = formatApiError(e);
|
||||
if (msg) message.error(msg);
|
||||
}
|
||||
}}>
|
||||
<Form form={createForm} layout="vertical">
|
||||
<Form.Item name="companyName" label="公司名"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="name" label="主账号姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="登录手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="address" label="地址"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="scopeType" label="管辖类型" rules={[{ required: true }]}>
|
||||
<Select options={SCOPE_OPTIONS} onChange={(v) => setCreateScopeType(v)} />
|
||||
</Form.Item>
|
||||
{createScopeType === CityPartnerScopeType.DISTRICT && (
|
||||
<Form.Item
|
||||
name="districtCodes"
|
||||
label="区县"
|
||||
extra="选填;仅作标识,可多选当前城市下的区县(不做互斥)"
|
||||
>
|
||||
<CityDistrictMultiSelect cityCode={cityCode} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Space style={{ width: '100%' }} size="large">
|
||||
<Form.Item name="orderCommissionRate" label="订单佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
<Form.Item name="redeemCommissionRate" label="核销佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
</Space>
|
||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||
订单 + 核销合计不得超过 {(maxPartnerCommissionRate * 100).toFixed(2)}%
|
||||
</Typography.Text>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal title="添加子账号" open={subOpen} onCancel={() => setSubOpen(false)} onOk={async () => {
|
||||
if (!detail) return;
|
||||
const v = await subForm.validateFields();
|
||||
await request('/admin/partner-accounts', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ...v, parentAccountId: detail.id }),
|
||||
});
|
||||
message.success('已创建');
|
||||
setSubOpen(false);
|
||||
void openPartner(detail.id);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
}}>
|
||||
<Form form={subForm} layout="vertical">
|
||||
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="staffRole" label="角色" initialValue="INTERNAL">
|
||||
<Select options={STAFF_ROLE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="permissions" label="权限">
|
||||
<Checkbox.Group options={PERM_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal title="编辑子账号" open={subEditOpen} onCancel={() => setSubEditOpen(false)} onOk={async () => {
|
||||
if (!subEditId || !detail) return;
|
||||
const v = await subEditForm.validateFields();
|
||||
await request(`/admin/partner-accounts/${subEditId}`, { method: 'PUT', body: JSON.stringify(v) });
|
||||
message.success('已更新');
|
||||
setSubEditOpen(false);
|
||||
void openPartner(detail.id);
|
||||
}}>
|
||||
<Form form={subEditForm} layout="vertical">
|
||||
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="staffRole" label="角色"><Select options={STAFF_ROLE_OPTIONS} /></Form.Item>
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select options={[{ value: 'ACTIVE', label: '启用' }, { value: 'DISABLED', label: '停用' }]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="permissions" label="权限">
|
||||
<Checkbox.Group options={PERM_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Drawer,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tabs,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import {
|
||||
CITY_PARTNER_SCOPE_LABELS,
|
||||
CITY_PARTNER_STATUS_LABELS,
|
||||
CityPartnerScopeType,
|
||||
CityPartnerStatus,
|
||||
PARTNER_PERMISSION_KEYS,
|
||||
PARTNER_PERMISSION_LABELS,
|
||||
PARTNER_STAFF_ROLE_LABELS,
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
import CityDistrictMultiSelect from './CityDistrictMultiSelect';
|
||||
import PartnerSubAccountList from './PartnerSubAccountList';
|
||||
import PartnerAssocPanel from './PartnerAssocPanel';
|
||||
|
||||
type PartnerRow = {
|
||||
id: string;
|
||||
companyName: string;
|
||||
phone: string;
|
||||
name: string;
|
||||
scopeType?: string;
|
||||
districtCodes?: string[] | null;
|
||||
orderCommissionRate?: number;
|
||||
redeemCommissionRate?: number;
|
||||
accountCount: number;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
type PartnerDetail = PartnerRow & {
|
||||
address?: string;
|
||||
districtCodes?: string[] | null;
|
||||
bindingStatus?: string;
|
||||
bankAccountName?: string | null;
|
||||
bankAccountNo?: string | null;
|
||||
bankBranch?: string | null;
|
||||
managedWarehouseId?: string | null;
|
||||
managedWarehouseName?: string | null;
|
||||
contactPhone?: string | null;
|
||||
children?: Array<{
|
||||
id: string;
|
||||
phone: string;
|
||||
name: string;
|
||||
staffRole?: string;
|
||||
permissions?: string[];
|
||||
status: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
cityId: string;
|
||||
cityCode?: string;
|
||||
maxPartnerCommissionRate?: number;
|
||||
onChanged?: () => void;
|
||||
};
|
||||
|
||||
const SCOPE_OPTIONS = Object.entries(CITY_PARTNER_SCOPE_LABELS).map(([value, label]) => ({ value, label }));
|
||||
const BINDING_OPTIONS = Object.entries(CITY_PARTNER_STATUS_LABELS).map(([value, label]) => ({ value, label }));
|
||||
const PERM_OPTIONS = PARTNER_PERMISSION_KEYS.map((k: PartnerPermissionKey) => ({
|
||||
value: k,
|
||||
label: PARTNER_PERMISSION_LABELS[k],
|
||||
}));
|
||||
const STAFF_ROLE_OPTIONS = Object.entries(PARTNER_STAFF_ROLE_LABELS)
|
||||
.filter(([value]) => value !== 'PARTNER')
|
||||
.map(([value, label]) => ({ value, label }));
|
||||
|
||||
function flattenDistrictCodes(values: string[] | string[][] | undefined): string[] {
|
||||
if (!values?.length) return [];
|
||||
if (Array.isArray(values[0])) {
|
||||
return (values as string[][]).map((path) => path[path.length - 1]).filter(Boolean);
|
||||
}
|
||||
return values as string[];
|
||||
}
|
||||
|
||||
function commissionSumError(
|
||||
orderPercent: number,
|
||||
redeemPercent: number,
|
||||
maxRate: number,
|
||||
): string | null {
|
||||
// API 可能把 Prisma Decimal 序列化为字符串;`"0.05" + 1e-9` 会变成字符串拼接导致误判超限
|
||||
const max = Number(maxRate);
|
||||
const sum = Number(orderPercent) / 100 + Number(redeemPercent) / 100;
|
||||
if (!Number.isFinite(max) || !Number.isFinite(sum)) return '佣金比例无效';
|
||||
if (sum > max + 1e-9) {
|
||||
return `订单佣金与核销佣金合计不得超过 ${(max * 100).toFixed(2)}%(当前 ${(sum * 100).toFixed(2)}%)`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatApiError(err: unknown): string | null {
|
||||
if (err && typeof err === 'object' && 'errorFields' in err) return null;
|
||||
if (!(err instanceof Error)) return '操作失败';
|
||||
return err.message.replace(/\b(\d{6})\b/g, (code) => {
|
||||
const label = districtCodeLabel(code);
|
||||
return label !== code ? `${label}(${code})` : code;
|
||||
});
|
||||
}
|
||||
|
||||
export default function CityPartnersPanel({
|
||||
cityId,
|
||||
cityCode,
|
||||
maxPartnerCommissionRate = 0.05,
|
||||
onChanged,
|
||||
}: Props) {
|
||||
const [editForm] = Form.useForm();
|
||||
const [createForm] = Form.useForm();
|
||||
const [subForm] = Form.useForm();
|
||||
const [subEditForm] = Form.useForm();
|
||||
const [partners, setPartners] = useState<PartnerRow[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detail, setDetail] = useState<PartnerDetail | null>(null);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [subOpen, setSubOpen] = useState(false);
|
||||
const [subEditOpen, setSubEditOpen] = useState(false);
|
||||
const [subEditId, setSubEditId] = useState<string | null>(null);
|
||||
const [createScopeType, setCreateScopeType] = useState<CityPartnerScopeType>(CityPartnerScopeType.CITY_WIDE);
|
||||
const [editScopeType, setEditScopeType] = useState<CityPartnerScopeType>(CityPartnerScopeType.CITY_WIDE);
|
||||
|
||||
const loadPartners = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<Paginated<PartnerRow>>(`/admin/partners?cityId=${cityId}&pageSize=100`);
|
||||
setPartners(res.items);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [cityId]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadPartners();
|
||||
}, [loadPartners]);
|
||||
|
||||
async function openPartner(id: string) {
|
||||
const d = await request<PartnerDetail>(`/admin/partners/${id}`);
|
||||
setDetail(d);
|
||||
setEditScopeType((d.scopeType as CityPartnerScopeType) || CityPartnerScopeType.CITY_WIDE);
|
||||
editForm.setFieldsValue({
|
||||
name: d.name,
|
||||
phone: d.phone,
|
||||
companyName: d.companyName,
|
||||
contactPhone: d.contactPhone ?? d.phone,
|
||||
address: d.address ?? '',
|
||||
scopeType: d.scopeType,
|
||||
districtCodes: d.districtCodes ?? [],
|
||||
orderCommissionRate: (d.orderCommissionRate ?? 0) * 100,
|
||||
redeemCommissionRate: (d.redeemCommissionRate ?? 0.03) * 100,
|
||||
bindingStatus: d.bindingStatus ?? CityPartnerStatus.ACTIVE,
|
||||
bankAccountName: d.bankAccountName ?? '',
|
||||
bankAccountNo: d.bankAccountNo ?? '',
|
||||
bankBranch: d.bankBranch ?? '',
|
||||
});
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
async function savePartner() {
|
||||
if (!detail) return;
|
||||
try {
|
||||
const v = await editForm.validateFields();
|
||||
const err = commissionSumError(
|
||||
Number(v.orderCommissionRate ?? 0),
|
||||
Number(v.redeemCommissionRate ?? 0),
|
||||
maxPartnerCommissionRate,
|
||||
);
|
||||
if (err) {
|
||||
message.error(err);
|
||||
return;
|
||||
}
|
||||
await request(`/admin/partners/${detail.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
}),
|
||||
});
|
||||
message.success('已保存');
|
||||
setDrawerOpen(false);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
} catch (e) {
|
||||
const msg = formatApiError(e);
|
||||
if (msg) message.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSubAccount(subId: string) {
|
||||
await request(`/admin/partner-accounts/${subId}`, { method: 'DELETE' });
|
||||
message.success('子账号已删除');
|
||||
if (detail) void openPartner(detail.id);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
}
|
||||
|
||||
const columns: ColumnsType<PartnerRow> = [
|
||||
{
|
||||
title: '区县',
|
||||
dataIndex: 'districtCodes',
|
||||
width: 160,
|
||||
render: (codes: string[] | null | undefined, row) =>
|
||||
row.scopeType === CityPartnerScopeType.CITY_WIDE ? '全城' : formatDistrictLabels(codes),
|
||||
},
|
||||
{ title: '公司名', dataIndex: 'companyName' },
|
||||
{ title: '主账号', dataIndex: 'phone', width: 120 },
|
||||
{
|
||||
title: '管辖',
|
||||
dataIndex: 'scopeType',
|
||||
width: 100,
|
||||
render: (v) => (v ? CITY_PARTNER_SCOPE_LABELS[v as keyof typeof CITY_PARTNER_SCOPE_LABELS] || v : '—'),
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
width: 120,
|
||||
render: (_, row) => `${Math.round((row.orderCommissionRate ?? 0) * 100)}% / ${Math.round((row.redeemCommissionRate ?? 0.03) * 100)}%`,
|
||||
},
|
||||
{ title: '子账号', dataIndex: 'accountCount', width: 70, render: (n) => Math.max(0, n - 1) },
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
|
||||
{
|
||||
title: '操作',
|
||||
width: 80,
|
||||
render: (_, row) => (
|
||||
<Button type="link" size="small" onClick={() => void openPartner(row.id)}>
|
||||
管理
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ marginBottom: 12 }}
|
||||
onClick={() => {
|
||||
createForm.resetFields();
|
||||
createForm.setFieldsValue({
|
||||
cityId,
|
||||
orderCommissionRate: 0,
|
||||
redeemCommissionRate: 3,
|
||||
scopeType: CityPartnerScopeType.CITY_WIDE,
|
||||
});
|
||||
setCreateScopeType(CityPartnerScopeType.CITY_WIDE);
|
||||
setCreateOpen(true);
|
||||
}}
|
||||
>
|
||||
新建合伙人
|
||||
</Button>
|
||||
<Table rowKey="id" size="small" loading={loading} columns={columns} dataSource={partners} pagination={false} />
|
||||
|
||||
<Drawer
|
||||
title="城市合伙人"
|
||||
width={640}
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
extra={<Button type="primary" onClick={() => void savePartner()}>保存</Button>}
|
||||
>
|
||||
{detail && (
|
||||
<Tabs
|
||||
items={[
|
||||
{
|
||||
key: 'info',
|
||||
label: '主账号',
|
||||
children: (
|
||||
<Form form={editForm} layout="vertical">
|
||||
<Form.Item name="companyName" label="公司名"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="name" label="主账号姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="登录手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="contactPhone" label="业务联系电话"><Input /></Form.Item>
|
||||
<Form.Item name="address" label="地址"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="bindingStatus" label="绑定状态" rules={[{ required: true }]}>
|
||||
<Select options={BINDING_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="scopeType" label="管辖类型" rules={[{ required: true }]}>
|
||||
<Select options={SCOPE_OPTIONS} onChange={(v) => setEditScopeType(v)} />
|
||||
</Form.Item>
|
||||
{editScopeType === CityPartnerScopeType.DISTRICT && (
|
||||
<Form.Item
|
||||
name="districtCodes"
|
||||
label="区县"
|
||||
extra="仅作标识,可多选当前城市下的区县(不做互斥)"
|
||||
>
|
||||
<CityDistrictMultiSelect cityCode={cityCode} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Space style={{ width: '100%' }} size="large">
|
||||
<Form.Item name="orderCommissionRate" label="订单佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
<Form.Item name="redeemCommissionRate" label="核销佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
</Space>
|
||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||
订单 + 核销合计不得超过 {(maxPartnerCommissionRate * 100).toFixed(2)}%(可在城市基本信息中调整)
|
||||
</Typography.Text>
|
||||
<Form.Item label="管仓仓库">
|
||||
<Input
|
||||
disabled
|
||||
value={detail.managedWarehouseName ?? '未分配(请在仓库管理中设置)'}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="bankAccountName" label="户名"><Input /></Form.Item>
|
||||
<Form.Item name="bankAccountNo" label="账号"><Input /></Form.Item>
|
||||
<Form.Item name="bankBranch" label="开户行"><Input /></Form.Item>
|
||||
</Form>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'staff',
|
||||
label: `子账号 (${Math.max(0, (detail.accountCount ?? 1) - 1)})`,
|
||||
children: (
|
||||
<PartnerSubAccountList
|
||||
subs={detail.children ?? []}
|
||||
onAdd={() => {
|
||||
subForm.resetFields();
|
||||
subForm.setFieldsValue({ staffRole: 'INTERNAL', permissions: ['store:create', 'store:manage'] });
|
||||
setSubOpen(true);
|
||||
}}
|
||||
onEdit={(row) => {
|
||||
setSubEditId(row.id);
|
||||
subEditForm.setFieldsValue({
|
||||
name: row.name,
|
||||
phone: row.phone,
|
||||
staffRole: row.staffRole ?? 'INTERNAL',
|
||||
permissions: row.permissions ?? [],
|
||||
status: row.status,
|
||||
});
|
||||
setSubEditOpen(true);
|
||||
}}
|
||||
onDelete={(subId) => void deleteSubAccount(subId)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
<Modal title="新建城市合伙人" open={createOpen} width={560} onCancel={() => setCreateOpen(false)} onOk={async () => {
|
||||
try {
|
||||
const v = await createForm.validateFields();
|
||||
const err = commissionSumError(
|
||||
Number(v.orderCommissionRate ?? 0),
|
||||
Number(v.redeemCommissionRate ?? 3),
|
||||
maxPartnerCommissionRate,
|
||||
);
|
||||
if (err) {
|
||||
message.error(err);
|
||||
return;
|
||||
}
|
||||
await request('/admin/partners', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
cityId,
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: createScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
}),
|
||||
});
|
||||
message.success('已创建');
|
||||
setCreateOpen(false);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
} catch (e) {
|
||||
const msg = formatApiError(e);
|
||||
if (msg) message.error(msg);
|
||||
}
|
||||
}}>
|
||||
<Form form={createForm} layout="vertical">
|
||||
<Form.Item name="companyName" label="公司名"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="name" label="主账号姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="登录手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="address" label="地址"><Input placeholder="选填" /></Form.Item>
|
||||
<Form.Item name="scopeType" label="管辖类型" rules={[{ required: true }]}>
|
||||
<Select options={SCOPE_OPTIONS} onChange={(v) => setCreateScopeType(v)} />
|
||||
</Form.Item>
|
||||
{createScopeType === CityPartnerScopeType.DISTRICT && (
|
||||
<Form.Item
|
||||
name="districtCodes"
|
||||
label="区县"
|
||||
extra="选填;仅作标识,可多选当前城市下的区县(不做互斥)"
|
||||
>
|
||||
<CityDistrictMultiSelect cityCode={cityCode} />
|
||||
</Form.Item>
|
||||
)}
|
||||
<Space style={{ width: '100%' }} size="large">
|
||||
<Form.Item name="orderCommissionRate" label="订单佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
<Form.Item name="redeemCommissionRate" label="核销佣金 %"><InputNumber min={0} max={100} precision={2} /></Form.Item>
|
||||
</Space>
|
||||
<Typography.Text type="secondary" style={{ display: 'block', marginBottom: 12 }}>
|
||||
订单 + 核销合计不得超过 {(maxPartnerCommissionRate * 100).toFixed(2)}%
|
||||
</Typography.Text>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal title="添加子账号" open={subOpen} onCancel={() => setSubOpen(false)} onOk={async () => {
|
||||
if (!detail) return;
|
||||
const v = await subForm.validateFields();
|
||||
await request('/admin/partner-accounts', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ ...v, parentAccountId: detail.id }),
|
||||
});
|
||||
message.success('已创建');
|
||||
setSubOpen(false);
|
||||
void openPartner(detail.id);
|
||||
void loadPartners();
|
||||
onChanged?.();
|
||||
}}>
|
||||
<Form form={subForm} layout="vertical">
|
||||
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="staffRole" label="角色" initialValue="INTERNAL">
|
||||
<Select options={STAFF_ROLE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item name="permissions" label="权限">
|
||||
<Checkbox.Group options={PERM_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<Modal title="编辑子账号" open={subEditOpen} onCancel={() => setSubEditOpen(false)} onOk={async () => {
|
||||
if (!subEditId || !detail) return;
|
||||
const v = await subEditForm.validateFields();
|
||||
await request(`/admin/partner-accounts/${subEditId}`, { method: 'PUT', body: JSON.stringify(v) });
|
||||
message.success('已更新');
|
||||
setSubEditOpen(false);
|
||||
void openPartner(detail.id);
|
||||
}}>
|
||||
<Form form={subEditForm} layout="vertical">
|
||||
<Form.Item name="name" label="姓名" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="phone" label="手机号" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="staffRole" label="角色"><Select options={STAFF_ROLE_OPTIONS} /></Form.Item>
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select options={[{ value: 'ACTIVE', label: '启用' }, { value: 'DISABLED', label: '停用' }]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="permissions" label="权限">
|
||||
<Checkbox.Group options={PERM_OPTIONS} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Button, Popconfirm, Space, Table, Typography, message } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { PartnerAssocSummary, PartnerAssocUserItem } from '@dukang/shared-types';
|
||||
import { request, type HqProfile, type Paginated } from '../lib/api';
|
||||
import { fmtTime } from '../lib/constants';
|
||||
|
||||
function formatNicknameWithRemark(row: PartnerAssocUserItem) {
|
||||
const name = row.nickname?.trim() || '—';
|
||||
const remark = row.hqRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
}
|
||||
|
||||
type PartnerAssocPanelProps = {
|
||||
partnerId: string;
|
||||
};
|
||||
|
||||
export default function PartnerAssocPanel({ partnerId }: PartnerAssocPanelProps) {
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [users, setUsers] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [page, setPage] = useState(1);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [issuing, setIssuing] = useState(false);
|
||||
const [canEditAssoc, setCanEditAssoc] = useState(false);
|
||||
|
||||
const loadSummary = useCallback(async () => {
|
||||
const data = await request<PartnerAssocSummary>(`/admin/partners/${partnerId}/assoc`);
|
||||
setSummary(data);
|
||||
}, [partnerId]);
|
||||
|
||||
const loadUsers = useCallback(async (p = 1) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<Paginated<PartnerAssocUserItem>>(
|
||||
`/admin/partners/${partnerId}/assoc/users?page=${p}&pageSize=20`,
|
||||
);
|
||||
setUsers(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
setPage(p);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [partnerId]);
|
||||
|
||||
useEffect(() => {
|
||||
void request<HqProfile>('/admin/auth/me')
|
||||
.then((p) => setCanEditAssoc((p.permissionKeys ?? []).includes('users_partner_assoc')))
|
||||
.catch(() => setCanEditAssoc(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void loadSummary().catch((e) => message.error(e instanceof Error ? e.message : '加载关联码失败'));
|
||||
void loadUsers(1).catch(() => undefined);
|
||||
}, [loadSummary, loadUsers]);
|
||||
|
||||
async function reissue() {
|
||||
setIssuing(true);
|
||||
try {
|
||||
await request(`/admin/partners/${partnerId}/assoc/qrcode`, { method: 'POST' });
|
||||
message.success('已重新生成关联码');
|
||||
await loadSummary();
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '生成失败');
|
||||
} finally {
|
||||
setIssuing(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function unbind(userId: string) {
|
||||
try {
|
||||
await request(`/admin/partners/${partnerId}/assoc/users/${userId}/unbind`, { method: 'POST' });
|
||||
message.success('已解绑');
|
||||
await Promise.all([loadSummary(), loadUsers(page)]);
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '解绑失败');
|
||||
}
|
||||
}
|
||||
|
||||
const columns: ColumnsType<PartnerAssocUserItem> = [
|
||||
{ title: '用户编号', dataIndex: 'userNo', width: 140 },
|
||||
{
|
||||
title: '用户',
|
||||
dataIndex: 'nickname',
|
||||
render: (_, row) => (
|
||||
<Link
|
||||
className="admin-primary-link"
|
||||
to={`/users?userId=${encodeURIComponent(row.id)}`}
|
||||
title="在用户列表中查看"
|
||||
>
|
||||
{formatNicknameWithRemark(row)}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{ title: '手机', dataIndex: 'phone', render: (v) => v || '—' },
|
||||
{ title: '关联时间', dataIndex: 'boundAt', render: (v) => (v ? fmtTime(v) : '—') },
|
||||
{ title: '已付订单', dataIndex: 'orderCount', width: 90 },
|
||||
...(canEditAssoc
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
render: (_: unknown, row: PartnerAssocUserItem) => (
|
||||
<Popconfirm title="解绑后该用户新单不再计订单佣金" onConfirm={() => void unbind(row.id)}>
|
||||
<Button type="link" size="small" danger>
|
||||
解绑
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
),
|
||||
} satisfies ColumnsType<PartnerAssocUserItem>[number],
|
||||
]
|
||||
: []),
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Space align="start" style={{ marginBottom: 16 }} wrap>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img src={summary.qrcodeUrl} alt="关联码" style={{ width: 160, height: 160, background: '#fff' }} />
|
||||
) : (
|
||||
<Typography.Text type="secondary">尚未生成关联码</Typography.Text>
|
||||
)}
|
||||
<div>
|
||||
<Typography.Paragraph style={{ marginBottom: 8 }}>
|
||||
<Link to={`/users?assocPartnerAccountId=${encodeURIComponent(partnerId)}`}>
|
||||
关联用户 {summary?.userCount ?? 0} 人
|
||||
</Link>
|
||||
</Typography.Paragraph>
|
||||
<Button loading={issuing} onClick={() => void reissue()}>
|
||||
{summary?.qrcodeUrl ? '补发关联码' : '生成关联码'}
|
||||
</Button>
|
||||
</div>
|
||||
</Space>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={users}
|
||||
pagination={{
|
||||
current: page,
|
||||
pageSize: 20,
|
||||
total,
|
||||
onChange: (p) => void loadUsers(p),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -54,6 +54,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
const [skuId, setSkuId] = useState<string>();
|
||||
const [quantity, setQuantity] = useState(2);
|
||||
const [promoCodeId, setPromoCodeId] = useState<string>();
|
||||
const [assocPartnerAccountId, setAssocPartnerAccountId] = useState<string>();
|
||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>('ADDRESS');
|
||||
const [autoReceive, setAutoReceive] = useState(false);
|
||||
const [preview, setPreview] = useState<PartnerProxyOrderPreviewResult | null>(null);
|
||||
@@ -168,6 +169,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
setProductId(undefined);
|
||||
setSkuId(undefined);
|
||||
setPromoCodeId(undefined);
|
||||
setAssocPartnerAccountId(undefined);
|
||||
setDeliveryMode('ADDRESS');
|
||||
setAutoReceive(false);
|
||||
setPreview(null);
|
||||
@@ -235,6 +237,7 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
quantity,
|
||||
promoCodeId: promoCodeId || undefined,
|
||||
skuId: skuId || undefined,
|
||||
assocPartnerAccountId: assocPartnerAccountId || undefined,
|
||||
};
|
||||
|
||||
setSubmitting(true);
|
||||
@@ -388,6 +391,21 @@ export default function ProxyOrderModal({ open, onClose, onSuccess }: ProxyOrder
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="关联合伙人(选填)">
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="不选则本单不计订单佣金"
|
||||
value={assocPartnerAccountId}
|
||||
onChange={setAssocPartnerAccountId}
|
||||
options={(options?.partners ?? []).map((p) => ({
|
||||
value: p.id,
|
||||
label: `${p.companyName || p.name}${p.phone ? ` · ${p.phone}` : ''}`,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 ? (
|
||||
<Form.Item label="绑定推广码(选填)">
|
||||
<Select
|
||||
|
||||
@@ -103,6 +103,9 @@ export default function RedeemRecordDetailDescriptions({ detail, maskUserPhone =
|
||||
<Descriptions.Item label="评价">
|
||||
服务 {(detail.rating as { serviceScore?: number }).serviceScore ?? '—'} 分 / 环境{' '}
|
||||
{(detail.rating as { envScore?: number }).envScore ?? '—'} 分
|
||||
{(detail.rating as { comment?: string | null }).comment
|
||||
? ` · ${(detail.rating as { comment?: string }).comment}`
|
||||
: ''}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
</Descriptions>
|
||||
|
||||
@@ -183,6 +183,12 @@ export type AdminUserRow = {
|
||||
benefitUsedAmount?: number;
|
||||
/** 好客权益·剩余未使用 */
|
||||
benefitBalance?: number;
|
||||
assocPartner?: {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
export type AdminOrderItem = {
|
||||
|
||||
@@ -16,6 +16,7 @@ export const HQ_OPERATION_ACTION_OPTIONS = [
|
||||
{ value: 'HQ_ACCOUNT_CREATE', label: '新增 HQ 管理员' },
|
||||
{ value: 'HQ_ACCOUNT_UPDATE', label: '编辑 HQ 管理员' },
|
||||
{ value: 'HQ_PERMISSION_UPDATE', label: '配置 HQ 权限' },
|
||||
{ value: 'USER_ASSOC_UPDATE', label: '修改用户关联合伙人' },
|
||||
{ value: 'USER_DELETE', label: '删除用户' },
|
||||
{ value: 'USER_BATCH_DELETE', label: '批量删除用户' },
|
||||
{ value: 'ORDER_SHIP', label: '订单发货' },
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/** 表单选填项常为 null,PUT 时去掉以免后端对 null 调 trim */
|
||||
export function omitNullFields<T extends Record<string, unknown>>(input: T): Partial<T> {
|
||||
const out: Partial<T> = {};
|
||||
for (const [key, value] of Object.entries(input)) {
|
||||
if (value === null || value === undefined) continue;
|
||||
(out as Record<string, unknown>)[key] = value;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -31,11 +31,13 @@ import {
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
@@ -60,6 +62,7 @@ type Row = {
|
||||
managedWarehouseName?: string | null;
|
||||
maxPartnerCommissionRate?: number | null;
|
||||
storeCount: number;
|
||||
assocUserCount?: number;
|
||||
accountCount: number;
|
||||
subAccounts?: SubRow[];
|
||||
createdAt: string;
|
||||
@@ -209,7 +212,7 @@ export default function CityPartnersPage() {
|
||||
await request(`/admin/partners/${detail.id}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({
|
||||
...v,
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
@@ -332,6 +335,19 @@ export default function CityPartnersPage() {
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '关联用户',
|
||||
dataIndex: 'assocUserCount',
|
||||
width: 80,
|
||||
render: (n: number, row) => (
|
||||
<Link
|
||||
to={`/users?assocPartnerAccountId=${encodeURIComponent(row.id)}`}
|
||||
title={`查看「${row.companyName || row.phone}」关联用户`}
|
||||
>
|
||||
{n ?? 0}
|
||||
</Link>
|
||||
),
|
||||
},
|
||||
{ title: '子账号', dataIndex: 'accountCount', width: 70, render: (n) => Math.max(0, n - 1) },
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
|
||||
{
|
||||
@@ -355,7 +371,9 @@ export default function CityPartnersPage() {
|
||||
title="城市合伙人"
|
||||
settings={settingsButton}
|
||||
actions={
|
||||
<Button
|
||||
<>
|
||||
<Link to="/users?assocPartnerAccountId=any">全部关联用户</Link>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
createForm.resetFields();
|
||||
@@ -372,6 +390,7 @@ export default function CityPartnersPage() {
|
||||
>
|
||||
新建合伙人
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -486,6 +505,14 @@ export default function CityPartnersPage() {
|
||||
{detail.storeCount ?? 0}
|
||||
</Link>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联用户">
|
||||
<Link
|
||||
to={`/users?assocPartnerAccountId=${encodeURIComponent(detail.id)}`}
|
||||
title="查看该城市合伙人关联用户"
|
||||
>
|
||||
{detail.assocUserCount ?? 0}
|
||||
</Link>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="管仓仓库" span={2}>
|
||||
{detail.managedWarehouseName ?? (
|
||||
<Typography.Text type="secondary">
|
||||
@@ -570,6 +597,11 @@ export default function CityPartnersPage() {
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -244,7 +244,7 @@ export default function HqPermissionsPage() {
|
||||
<Typography.Title level={4}>权限分配</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
按角色配置基础权限;按用户可追加或撤销。最终生效权限 =(角色权限 ∪ 追加)− 撤销。
|
||||
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市需在「按用户分配」中单独勾选(默认均无)。
|
||||
超级管理员默认拥有除「危险操作」外的全部权限;删除用户/订单/城市、修改用户关联合伙人需在「按用户分配」或「按角色分配」中单独勾选(默认均无)。
|
||||
运营/财务默认可删除门店分类;城市门店服务可新增分类,不可删除。
|
||||
「系统设置」已拆分为各配置分组;「财务」对应门店/合伙人/酒厂账单。
|
||||
</Typography.Paragraph>
|
||||
@@ -274,7 +274,7 @@ export default function HqPermissionsPage() {
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="超级管理员基础权限固定(不含危险操作)。删除用户/订单/城市请到「按用户分配」为具体账号勾选。"
|
||||
message="超级管理员基础权限固定(不含危险操作)。删除用户/订单/城市、修改用户关联合伙人请到「按用户分配」为具体账号勾选。"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -57,6 +57,7 @@ type ShipDefaults = {
|
||||
};
|
||||
|
||||
type CityOption = { id: string; name: string; code: string };
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string; phone?: string };
|
||||
|
||||
type WarehouseOption = {
|
||||
id: string;
|
||||
@@ -93,6 +94,20 @@ type OrderRedeemSummary = {
|
||||
redeemRecordSum: number;
|
||||
};
|
||||
|
||||
type AssocPartnerBrief = {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
orderCommissionRate?: number | null;
|
||||
};
|
||||
|
||||
function formatAssocPartner(p?: AssocPartnerBrief | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name;
|
||||
return [title, p.phone].filter(Boolean).join(' / ') || '—';
|
||||
}
|
||||
|
||||
type OrderDetail = AdminOrderRow & {
|
||||
receiverAddress?: string;
|
||||
receiverProvince?: string;
|
||||
@@ -136,6 +151,11 @@ type OrderDetail = AdminOrderRow & {
|
||||
lng?: number | null;
|
||||
lat?: number | null;
|
||||
} | null;
|
||||
assocPartnerAtPay?: AssocPartnerBrief | null;
|
||||
orderCommissionRateAtPay?: number | null;
|
||||
user?: AdminOrderRow['user'] & {
|
||||
assocPartner?: AssocPartnerBrief | null;
|
||||
};
|
||||
};
|
||||
|
||||
type ShipMode = 'WAREHOUSE' | 'EXPRESS';
|
||||
@@ -154,6 +174,7 @@ type OrderExportFilters = {
|
||||
fulfillmentHold?: boolean;
|
||||
deliveryType?: string;
|
||||
promoCodeId?: string;
|
||||
assocPartnerAccountId?: string;
|
||||
dateRange?: [Dayjs, Dayjs];
|
||||
};
|
||||
|
||||
@@ -261,6 +282,7 @@ function buildExportPayload(
|
||||
if (filters.deliveryType) payload.deliveryType = filters.deliveryType;
|
||||
if (filters.fulfillmentHold) payload.fulfillmentHold = true;
|
||||
if (filters.promoCodeId) payload.promoCodeId = filters.promoCodeId;
|
||||
if (filters.assocPartnerAccountId) payload.assocPartnerAccountId = filters.assocPartnerAccountId;
|
||||
if (filters.dateRange?.[0]) payload.createdFrom = filters.dateRange[0].format('YYYY-MM-DD');
|
||||
if (filters.dateRange?.[1]) payload.createdTo = filters.dateRange[1].format('YYYY-MM-DD');
|
||||
return payload;
|
||||
@@ -330,6 +352,7 @@ export default function OrdersPage() {
|
||||
const [shipping, setShipping] = useState(false);
|
||||
const [logisticsShipping, setLogisticsShipping] = useState(false);
|
||||
const [cities, setCities] = useState<CityOption[]>([]);
|
||||
const [partners, setPartners] = useState<PartnerOption[]>([]);
|
||||
const [shipModalOpen, setShipModalOpen] = useState(false);
|
||||
const [shipTarget, setShipTarget] = useState<OrderDetail | null>(null);
|
||||
const [shipMode, setShipMode] = useState<ShipMode>('EXPRESS');
|
||||
@@ -418,6 +441,7 @@ export default function OrdersPage() {
|
||||
if (values.productKeyword) qs.set('productKeyword', values.productKeyword);
|
||||
if (values.fulfillmentHold) qs.set('fulfillmentHold', 'true');
|
||||
if (values.deliveryType) qs.set('deliveryType', values.deliveryType);
|
||||
if (values.assocPartnerAccountId) qs.set('assocPartnerAccountId', values.assocPartnerAccountId);
|
||||
if (initialPromoCodeId) qs.set('promoCodeId', initialPromoCodeId);
|
||||
if (values.dateRange?.[0]) qs.set('createdFrom', values.dateRange[0].format('YYYY-MM-DD'));
|
||||
if (values.dateRange?.[1]) qs.set('createdTo', values.dateRange[1].format('YYYY-MM-DD'));
|
||||
@@ -437,6 +461,9 @@ export default function OrdersPage() {
|
||||
void request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setCities(res.items ?? []))
|
||||
.catch(() => {});
|
||||
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setPartners(res.items ?? []))
|
||||
.catch(() => setPartners([]));
|
||||
}, []);
|
||||
|
||||
function applyShipDefaults(defaults: ShipDefaults, warehouseId?: string | null) {
|
||||
@@ -888,6 +915,30 @@ export default function OrdersPage() {
|
||||
<Form.Item name="deliveryType" label="配送" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={DELIVERY_TYPE_OPTIONS} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="assocPartnerAccountId"
|
||||
label="关联合伙人"
|
||||
className="admin-orders-filter-item admin-orders-filter-item--status"
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ value: 'none', label: '未关联' },
|
||||
...partners.map((p) => ({
|
||||
value: p.id,
|
||||
label: formatAssocPartner({
|
||||
id: p.id,
|
||||
name: p.name || p.id,
|
||||
companyName: p.companyName,
|
||||
phone: p.phone,
|
||||
}),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label=" " colon={false} className="admin-orders-filter-item admin-orders-filter-actions">
|
||||
<Space size={8} wrap>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
@@ -1082,6 +1133,21 @@ export default function OrdersPage() {
|
||||
{[detail.proxyPartnerName, detail.proxyPartnerPhone].filter(Boolean).join(' / ') || '—'}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
<Descriptions.Item label="关联合伙人(本单佣金)">
|
||||
{detail.assocPartnerAtPay
|
||||
? `${formatAssocPartner(detail.assocPartnerAtPay)}${
|
||||
detail.assocPartnerAtPay.orderCommissionRate != null
|
||||
? ` · 费率 ${(Number(detail.assocPartnerAtPay.orderCommissionRate) * 100).toFixed(2)}%`
|
||||
: ''
|
||||
}`
|
||||
: '—'}
|
||||
</Descriptions.Item>
|
||||
{detail.user?.assocPartner &&
|
||||
detail.user.assocPartner.id !== detail.assocPartnerAtPay?.id ? (
|
||||
<Descriptions.Item label="用户当前关联">
|
||||
{formatAssocPartner(detail.user.assocPartner)}
|
||||
</Descriptions.Item>
|
||||
) : null}
|
||||
<Descriptions.Item label="用户">
|
||||
{detail.user?.id ? (
|
||||
<AdminPrimaryLink
|
||||
|
||||
@@ -9,6 +9,7 @@ import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import { ACCOUNT_STATUS_LABELS, ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, PARTNER_BILL_STATUS_LABELS, fmtTime } from '../lib/constants';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
|
||||
|
||||
type PartnerOption = { id: string; companyName: string };
|
||||
@@ -413,6 +414,13 @@ export default function PartnerAccountsPage() {
|
||||
dataSource={detail.orders ?? []} pagination={false} scroll={{ x: 'max-content' }} />
|
||||
),
|
||||
},
|
||||
...(!detail.parentAccountId
|
||||
? [{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
}]
|
||||
: []),
|
||||
]} />
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
Space,
|
||||
Statistic,
|
||||
Table,
|
||||
Tabs,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
@@ -27,6 +28,19 @@ import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
|
||||
|
||||
type BillItemRow = {
|
||||
id: string;
|
||||
kind: 'ORDER' | 'REDEEM';
|
||||
refId: string;
|
||||
refNo: string;
|
||||
title?: string | null;
|
||||
extra?: string | null;
|
||||
baseAmount: number;
|
||||
rate: number;
|
||||
commission: number;
|
||||
occurredAt: string;
|
||||
};
|
||||
|
||||
type Row = {
|
||||
id: string;
|
||||
billNo: string;
|
||||
@@ -39,6 +53,8 @@ type Row = {
|
||||
rejectReason?: string | null;
|
||||
paymentRef?: string | null;
|
||||
paidAt?: string | null;
|
||||
orderItems?: BillItemRow[];
|
||||
redeemItems?: BillItemRow[];
|
||||
partner?: {
|
||||
companyName?: string;
|
||||
phone?: string;
|
||||
@@ -531,7 +547,7 @@ export default function PartnerBillsPage() {
|
||||
title="合伙人账单明细"
|
||||
open={drawerOpen}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
width={560}
|
||||
width={720}
|
||||
>
|
||||
{detail && (
|
||||
<>
|
||||
@@ -562,6 +578,84 @@ export default function PartnerBillsPage() {
|
||||
{detail.paymentRef ? String(detail.paymentRef) : '—'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Tabs
|
||||
style={{ marginTop: 16 }}
|
||||
items={[
|
||||
{
|
||||
key: 'orders',
|
||||
label: `酒订单 (${detail.orderItems?.length ?? 0})`,
|
||||
children: (
|
||||
<>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
pagination={false}
|
||||
dataSource={detail.orderItems ?? []}
|
||||
columns={[
|
||||
{ title: '订单号', dataIndex: 'refNo', width: 160 },
|
||||
{ title: '商品', dataIndex: 'title' },
|
||||
{ title: '数量', dataIndex: 'extra', width: 70 },
|
||||
{
|
||||
title: '实付',
|
||||
dataIndex: 'baseAmount',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '费率',
|
||||
dataIndex: 'rate',
|
||||
render: (v: number) => `${(Number(v) * 100).toFixed(2)}%`,
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
dataIndex: 'commission',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Paragraph style={{ textAlign: 'right', marginTop: 8 }}>
|
||||
酒单佣金 ¥{Number(detail.orderCommission).toFixed(2)}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'redeems',
|
||||
label: `核销订单 (${detail.redeemItems?.length ?? 0})`,
|
||||
children: (
|
||||
<>
|
||||
<Table
|
||||
rowKey="id"
|
||||
size="small"
|
||||
pagination={false}
|
||||
dataSource={detail.redeemItems ?? []}
|
||||
columns={[
|
||||
{ title: '核销单号', dataIndex: 'refNo', width: 160 },
|
||||
{ title: '门店', dataIndex: 'title' },
|
||||
{
|
||||
title: '核销额',
|
||||
dataIndex: 'baseAmount',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
title: '费率',
|
||||
dataIndex: 'rate',
|
||||
render: (v: number) => `${(Number(v) * 100).toFixed(2)}%`,
|
||||
},
|
||||
{
|
||||
title: '佣金',
|
||||
dataIndex: 'commission',
|
||||
render: (v: number) => `¥${Number(v).toFixed(2)}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Paragraph style={{ textAlign: 'right', marginTop: 8 }}>
|
||||
核销佣金 ¥{Number(detail.redeemCommission).toFixed(2)}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Typography.Title level={5} style={{ marginTop: 16 }}>
|
||||
收款账户
|
||||
</Typography.Title>
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
type PartnerPermissionKey,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { omitNullFields } from '../lib/omit-null-fields';
|
||||
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
@@ -30,6 +31,7 @@ import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import PartnerAssocPanel from '../components/PartnerAssocPanel';
|
||||
|
||||
|
||||
type Row = {
|
||||
@@ -162,7 +164,7 @@ export default function PartnersPage() {
|
||||
try {
|
||||
const v = await editForm.validateFields();
|
||||
const body = {
|
||||
...v,
|
||||
...omitNullFields(v),
|
||||
orderCommissionRate: Number(v.orderCommissionRate ?? 0) / 100,
|
||||
redeemCommissionRate: Number(v.redeemCommissionRate ?? 3) / 100,
|
||||
districtCodes: editScopeType === CityPartnerScopeType.DISTRICT ? flattenDistrictCodes(v.districtCodes) : undefined,
|
||||
@@ -320,6 +322,11 @@ export default function PartnersPage() {
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'assoc',
|
||||
label: '关联码',
|
||||
children: <PartnerAssocPanel partnerId={detail.id} />,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -13,6 +13,7 @@ type Row = {
|
||||
id: string;
|
||||
serviceScore: number;
|
||||
envScore: number;
|
||||
comment?: string | null;
|
||||
createdAt: string;
|
||||
redeemNo: string;
|
||||
redeemAmount: number;
|
||||
@@ -62,6 +63,12 @@ export default function StoreRatingsPage() {
|
||||
{ title: '核销额', dataIndex: 'redeemAmount', width: 90, render: (v) => `¥${v}` },
|
||||
{ title: '服务分', dataIndex: 'serviceScore', width: 80 },
|
||||
{ title: '环境分', dataIndex: 'envScore', width: 80 },
|
||||
{
|
||||
title: '评语',
|
||||
dataIndex: 'comment',
|
||||
ellipsis: true,
|
||||
render: (v: string | null) => v || '—',
|
||||
},
|
||||
{ title: '评价时间', dataIndex: 'createdAt', width: 170, render: fmtTime },
|
||||
];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Link, useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Alert,
|
||||
@@ -17,12 +17,13 @@ import {
|
||||
message,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
||||
import { USER_SOURCE_TYPE_LABELS, type UserSourceType } from '@dukang/shared-types';
|
||||
import { request, type AdminUserRow, type HqProfile, type Paginated } from '../lib/api';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
|
||||
import { ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, ORDER_STATUS_LABELS, fmtTime, maskPhone } from '../lib/constants';
|
||||
import { clientAppLabel, eventNameLabel, userEventCategoryLabel } from '../lib/display-labels';
|
||||
|
||||
type UserOrderRow = {
|
||||
@@ -120,6 +121,24 @@ type UserBehaviorLog = {
|
||||
extraJson?: Record<string, unknown> | null;
|
||||
};
|
||||
|
||||
type AssocPartnerBrief = {
|
||||
id: string;
|
||||
name: string;
|
||||
companyName?: string | null;
|
||||
phone?: string | null;
|
||||
};
|
||||
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string; phone?: string };
|
||||
|
||||
const FILTERS_COLLAPSED_KEY = 'admin-users-filters-collapsed';
|
||||
const ASSOC_UNBOUND = 'none';
|
||||
|
||||
function formatAssocPartner(p?: AssocPartnerBrief | PartnerOption | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name || p.id;
|
||||
return [title, p.phone].filter(Boolean).join(' / ') || '—';
|
||||
}
|
||||
|
||||
type UserDetail = AdminUserRow & {
|
||||
wxUnionId?: string | null;
|
||||
cityPref?: Record<string, unknown> | null;
|
||||
@@ -128,6 +147,8 @@ type UserDetail = AdminUserRow & {
|
||||
orders?: UserOrderRow[];
|
||||
mergedFromCount?: number;
|
||||
addressCount?: number;
|
||||
assocPartner?: AssocPartnerBrief | null;
|
||||
assocBoundAt?: string | null;
|
||||
};
|
||||
|
||||
type BatchDeletePreviewItem = {
|
||||
@@ -176,11 +197,36 @@ export default function UsersPage() {
|
||||
const [batchDeleting, setBatchDeleting] = useState(false);
|
||||
const [batchRiskAck, setBatchRiskAck] = useState(false);
|
||||
const canDeleteUsers = (profile?.permissionKeys ?? []).includes('users_delete');
|
||||
const canEditAssoc = (profile?.permissionKeys ?? []).includes('users_partner_assoc');
|
||||
const [partners, setPartners] = useState<PartnerOption[]>([]);
|
||||
const [assocPartnerId, setAssocPartnerId] = useState<string | undefined>();
|
||||
const [savingAssoc, setSavingAssoc] = useState(false);
|
||||
const [filtersCollapsed, setFiltersCollapsed] = useState(() => {
|
||||
try {
|
||||
return localStorage.getItem(FILTERS_COLLAPSED_KEY) === '1';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const partnerOptions = useMemo(() => {
|
||||
const map = new Map(partners.map((p) => [p.id, p]));
|
||||
if (detail?.assocPartner && !map.has(detail.assocPartner.id)) {
|
||||
map.set(detail.assocPartner.id, detail.assocPartner);
|
||||
}
|
||||
return [...map.values()];
|
||||
}, [partners, detail?.assocPartner]);
|
||||
|
||||
useEffect(() => {
|
||||
request<HqProfile>('/admin/auth/me').then(setProfile).catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
void request<Paginated<PartnerOption>>(`/admin/partners?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`)
|
||||
.then((res) => setPartners(res.items ?? []))
|
||||
.catch(() => setPartners([]));
|
||||
}, []);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -190,24 +236,32 @@ export default function UsersPage() {
|
||||
if (userId) qs.set('userId', userId);
|
||||
if (values.phone) qs.set('phone', values.phone);
|
||||
if (values.userNo) qs.set('userNo', values.userNo);
|
||||
if (values.deviceKey) qs.set('deviceKey', values.deviceKey);
|
||||
if (values.phoneVerified !== undefined && values.phoneVerified !== '') {
|
||||
qs.set('phoneVerified', values.phoneVerified);
|
||||
}
|
||||
if (values.status !== undefined && values.status !== '') {
|
||||
qs.set('status', String(values.status));
|
||||
}
|
||||
if (values.excludeTest) qs.set('excludeTest', 'true');
|
||||
const keyword = String(values.keyword || '').trim();
|
||||
if (keyword) qs.set('keyword', keyword);
|
||||
const assocPartnerAccountId = String(
|
||||
values.assocPartnerAccountId || searchParams.get('assocPartnerAccountId') || '',
|
||||
).trim();
|
||||
if (assocPartnerAccountId) qs.set('assocPartnerAccountId', assocPartnerAccountId);
|
||||
const res = await request<Paginated<AdminUserRow>>(`/admin/users?${qs}`);
|
||||
setData(res);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [form, page, pageSize]);
|
||||
}, [form, page, pageSize, searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
const userId = searchParams.get('userId');
|
||||
if (userId) form.setFieldsValue({ userId });
|
||||
const assocPartnerAccountId = searchParams.get('assocPartnerAccountId');
|
||||
form.setFieldsValue({
|
||||
...(userId ? { userId } : {}),
|
||||
...(assocPartnerAccountId ? { assocPartnerAccountId } : {}),
|
||||
});
|
||||
}, [searchParams, form]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -234,10 +288,29 @@ export default function UsersPage() {
|
||||
),
|
||||
]);
|
||||
setDetail(res);
|
||||
setAssocPartnerId(res.assocPartner?.id);
|
||||
setBehaviorLogs(logs.items ?? []);
|
||||
setDrawerOpen(true);
|
||||
}
|
||||
|
||||
async function saveAssoc() {
|
||||
if (!detail) return;
|
||||
setSavingAssoc(true);
|
||||
try {
|
||||
await request(`/admin/users/${detail.id}/assoc`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ partnerAccountId: assocPartnerId || null }),
|
||||
});
|
||||
message.success(assocPartnerId ? '已更新关联合伙人' : '已解除关联');
|
||||
await openDetail(detail.id);
|
||||
void load();
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '保存失败');
|
||||
} finally {
|
||||
setSavingAssoc(false);
|
||||
}
|
||||
}
|
||||
|
||||
function openDeleteModal() {
|
||||
setDeleteConfirm('');
|
||||
setDeleteOpen(true);
|
||||
@@ -420,6 +493,12 @@ export default function UsersPage() {
|
||||
width: 120,
|
||||
render: (v) => v || '—',
|
||||
},
|
||||
{
|
||||
title: '关联合伙人',
|
||||
dataIndex: 'assocPartner',
|
||||
width: 180,
|
||||
render: (p: AdminUserRow['assocPartner']) => formatAssocPartner(p),
|
||||
},
|
||||
{
|
||||
title: 'deviceKey',
|
||||
dataIndex: 'deviceKey',
|
||||
@@ -512,64 +591,106 @@ export default function UsersPage() {
|
||||
/>
|
||||
<Form
|
||||
form={form}
|
||||
layout="inline"
|
||||
style={{ marginBottom: 16 }}
|
||||
layout="vertical"
|
||||
onFinish={() => {
|
||||
setPage(1);
|
||||
const next = new URLSearchParams();
|
||||
const userId = String(form.getFieldValue('userId') || '').trim();
|
||||
const current = searchParams.get('userId') ?? '';
|
||||
if (userId !== current) {
|
||||
if (userId) setSearchParams({ userId }, { replace: true });
|
||||
else setSearchParams({}, { replace: true });
|
||||
const assoc = String(form.getFieldValue('assocPartnerAccountId') || '').trim();
|
||||
if (userId) next.set('userId', userId);
|
||||
if (assoc) next.set('assocPartnerAccountId', assoc);
|
||||
if (next.toString() !== searchParams.toString()) {
|
||||
setSearchParams(next, { replace: true });
|
||||
}
|
||||
void load();
|
||||
}}
|
||||
>
|
||||
<Form.Item name="phone" label="手机号">
|
||||
<Input placeholder="模糊搜索" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userNo" label="用户编号">
|
||||
<Input placeholder="DK..." allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userId" label="用户ID">
|
||||
<Input placeholder="精确匹配" allowClear style={{ width: 140 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="deviceKey" label="deviceKey">
|
||||
<Input placeholder="UUID" allowClear style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="phoneVerified" label="验手机">
|
||||
<Select allowClear style={{ width: 100 }} options={[
|
||||
{ value: '1', label: '已验证' },
|
||||
{ value: '0', label: '访客' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label="状态">
|
||||
<Select allowClear style={{ width: 90 }} options={[
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="excludeTest" valuePropName="checked">
|
||||
<Checkbox>过滤测试账号</Checkbox>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
form.resetFields();
|
||||
setPage(1);
|
||||
if (searchParams.get('userId')) {
|
||||
setSearchParams({}, { replace: true });
|
||||
} else {
|
||||
void load();
|
||||
}
|
||||
}}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item name="keyword" label="搜索" className="admin-orders-filter-item admin-users-filter-item--keyword">
|
||||
<Input allowClear placeholder="编号/昵称/备注/手机" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="assocPartnerAccountId"
|
||||
label="关联合伙人"
|
||||
className="admin-orders-filter-item admin-orders-filter-item--status"
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="全部"
|
||||
options={[
|
||||
{ value: 'any', label: '已关联(全部)' },
|
||||
{ value: ASSOC_UNBOUND, label: '未关联' },
|
||||
...partners.map((p) => ({
|
||||
value: p.id,
|
||||
label: formatAssocPartner(p),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label=" " colon={false} className="admin-orders-filter-item admin-orders-filter-actions">
|
||||
<Space size={8} wrap>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
form.resetFields();
|
||||
setPage(1);
|
||||
if (searchParams.toString()) {
|
||||
setSearchParams({}, { replace: true });
|
||||
} else {
|
||||
void load();
|
||||
}
|
||||
}}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
icon={filtersCollapsed ? <DownOutlined /> : <UpOutlined />}
|
||||
onClick={() => {
|
||||
setFiltersCollapsed((prev) => {
|
||||
const next = !prev;
|
||||
try {
|
||||
localStorage.setItem(FILTERS_COLLAPSED_KEY, next ? '1' : '0');
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}}
|
||||
>
|
||||
{filtersCollapsed ? '展开' : '收起'}
|
||||
</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
{!filtersCollapsed ? (
|
||||
<div className="admin-orders-filter-row">
|
||||
<Form.Item name="phone" label="手机号" className="admin-orders-filter-item admin-orders-filter-item--md">
|
||||
<Input placeholder="模糊搜索" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userNo" label="用户编号" className="admin-orders-filter-item admin-orders-filter-item--md">
|
||||
<Input placeholder="DK..." allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="userId" label="用户ID" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Input placeholder="精确匹配" allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="phoneVerified" label="验手机" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={[
|
||||
{ value: '1', label: '已验证' },
|
||||
{ value: '0', label: '访客' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
<Form.Item name="status" label="状态" className="admin-orders-filter-item admin-orders-filter-item--sm">
|
||||
<Select allowClear placeholder="全部" options={[
|
||||
{ value: 1, label: '正常' },
|
||||
{ value: 0, label: '停用' },
|
||||
]} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
) : null}
|
||||
</Form>
|
||||
|
||||
<Table
|
||||
@@ -633,6 +754,38 @@ export default function UsersPage() {
|
||||
) : '—'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="来源标签">{detail.sourceLabel || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="关联合伙人">
|
||||
{canEditAssoc ? (
|
||||
<Space wrap>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="未关联"
|
||||
style={{ minWidth: 260 }}
|
||||
value={assocPartnerId}
|
||||
onChange={setAssocPartnerId}
|
||||
options={partnerOptions.map((p) => ({
|
||||
value: p.id,
|
||||
label: `${p.companyName || p.name || p.id}${p.phone ? ` · ${p.phone}` : ''}`,
|
||||
}))}
|
||||
/>
|
||||
<Button type="primary" size="small" loading={savingAssoc} onClick={() => void saveAssoc()}>
|
||||
保存关联
|
||||
</Button>
|
||||
<Typography.Text type="secondary">清空后保存即解绑;已支付订单佣金快照不变</Typography.Text>
|
||||
</Space>
|
||||
) : detail.assocPartner ? (
|
||||
`${detail.assocPartner.companyName || detail.assocPartner.name}${
|
||||
detail.assocPartner.phone ? ` / ${detail.assocPartner.phone}` : ''
|
||||
}`
|
||||
) : (
|
||||
'—'
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联时间">
|
||||
{detail.assocBoundAt ? fmtTime(detail.assocBoundAt) : '—'}
|
||||
</Descriptions.Item>
|
||||
{detail.sourcePromo && (
|
||||
<Descriptions.Item label="推广码">
|
||||
<Link to={`/promo-codes/${detail.sourcePromo.id}`}>
|
||||
|
||||
@@ -22,12 +22,16 @@ import ProxyOrderDetailPage from './pages/ProxyOrderDetailPage';
|
||||
import StaffListPage from './pages/StaffListPage';
|
||||
import StaffCreatePage from './pages/StaffCreatePage';
|
||||
import LeaderboardPage from './pages/LeaderboardPage';
|
||||
import UsersManagePage from './pages/UsersManagePage';
|
||||
import AssocOrdersPage from './pages/AssocOrdersPage';
|
||||
import CommissionOrdersPage from './pages/CommissionOrdersPage';
|
||||
|
||||
function PrimaryRoutes() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<TabLayout />}>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/users" element={<UsersManagePage />} />
|
||||
<Route path="/stores" element={<StoreListPage />} />
|
||||
<Route path="/center" element={<CenterPage />} />
|
||||
</Route>
|
||||
@@ -37,6 +41,11 @@ function PrimaryRoutes() {
|
||||
<Route path="/center/settlement" element={<SettlementPage />} />
|
||||
<Route path="/center/staff" element={<StaffListPage />} />
|
||||
<Route path="/center/staff/new" element={<StaffCreatePage />} />
|
||||
<Route path="/center/assoc" element={<Navigate to="/users" replace />} />
|
||||
<Route path="/center/assoc/users" element={<Navigate to="/users" replace />} />
|
||||
<Route path="/users/orders" element={<AssocOrdersPage />} />
|
||||
<Route path="/users/:userId/orders" element={<AssocOrdersPage />} />
|
||||
<Route path="/center/commissions" element={<CommissionOrdersPage />} />
|
||||
<Route path="/center/proxy-orders" element={<ProxyOrderListPage />} />
|
||||
<Route path="/center/proxy-orders/:id" element={<ProxyOrderDetailPage />} />
|
||||
<Route path="/proxy-order" element={<ProxyOrderPage />} />
|
||||
|
||||
@@ -3,6 +3,7 @@ import { isLoggedIn } from '../lib/api';
|
||||
|
||||
const TABS = [
|
||||
{ to: '/', end: true, icon: 'dashboard', label: '首页' },
|
||||
{ to: '/users', icon: 'group', label: '用户管理' },
|
||||
{ to: '/stores', icon: 'store', label: '门店管理' },
|
||||
{ to: '/center', icon: 'account_circle', label: '合伙人中心' },
|
||||
] as const;
|
||||
|
||||
@@ -12,6 +12,7 @@ export type ProxyOrderDraft = {
|
||||
promoCodeId: string;
|
||||
deliveryMode: PartnerProxyDeliveryMode;
|
||||
autoReceive: boolean;
|
||||
assocEnabled: boolean;
|
||||
};
|
||||
|
||||
export function saveProxyOrderDraft(draft: ProxyOrderDraft) {
|
||||
@@ -40,6 +41,7 @@ export function loadProxyOrderDraft(): ProxyOrderDraft | null {
|
||||
promoCodeId: typeof parsed.promoCodeId === 'string' ? parsed.promoCodeId : '',
|
||||
deliveryMode: parsed.deliveryMode === 'ON_SITE_PICKUP' ? 'ON_SITE_PICKUP' : 'ADDRESS',
|
||||
autoReceive: parsed.autoReceive === true,
|
||||
assocEnabled: parsed.assocEnabled !== false,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerAssocUserOrderItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserOrderItem[]; total: number };
|
||||
|
||||
function fmtMoney(n: number) {
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
export default function AssocOrdersPage() {
|
||||
const { userId } = useParams();
|
||||
usePartnerPageView(userId ? 'partner_assoc_user_orders_view' : 'partner_assoc_orders_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerAssocUserOrderItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const path = userId
|
||||
? `/partner/assoc/users/${userId}/orders?page=1&pageSize=50`
|
||||
: '/partner/assoc/orders?page=1&pageSize=50';
|
||||
const res = await request<ListRes>('PARTNER_H5', path);
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [userId]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title={userId ? '用户订单' : '关联用户订单'} onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 笔已付购酒单`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无订单</div>}
|
||||
{items.map((o) => (
|
||||
<div key={o.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 0 }}>
|
||||
<div>
|
||||
<p className="body-md">{o.productName}</p>
|
||||
<p className="label-md text-muted">{o.orderNo} · ×{o.quantity}</p>
|
||||
<p className="label-md text-muted">{o.paidAt ? o.paidAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="amount-lg" style={{ fontSize: 18 }}>¥{fmtMoney(o.payAmount)}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import type { PartnerAssocSummary } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { isWechatEnv } from '../lib/weixin';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
export default function AssocQrcodePage() {
|
||||
usePartnerPageView('partner_assoc_qrcode_view');
|
||||
const navigate = useNavigate();
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
request<PartnerAssocSummary>('PARTNER_H5', '/partner/assoc')
|
||||
.then(setSummary)
|
||||
.catch((e) => toastError(e instanceof Error ? e.message : '加载失败'))
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
}, [previewUrl]);
|
||||
|
||||
async function downloadQr() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
try {
|
||||
const res = await fetch('/api/v1/partner/assoc/qrcode', {
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : '',
|
||||
'X-Client-App': 'PARTNER_H5',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('下载失败');
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (isWechatEnv()) {
|
||||
setPreviewUrl(url);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `partner-assoc-${summary?.partnerId || 'qr'}.png`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
toastSuccess('已开始下载');
|
||||
} catch (e) {
|
||||
if (summary?.qrcodeUrl) {
|
||||
setPreviewUrl(summary.qrcodeUrl);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
toastError(e instanceof Error ? e.message : '下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageHeader title="关联码" onBack={() => navigate(-1)} />
|
||||
{loading && <div className="empty">加载中…</div>}
|
||||
{!loading && (
|
||||
<section className="partner-bill-card" style={{ margin: 16 }}>
|
||||
<div style={{ padding: 24, textAlign: 'center' }}>
|
||||
<p className="body-md text-muted" style={{ marginBottom: 16 }}>
|
||||
用户扫码后首次锁定本合伙人,后续酒单按订单佣金结算
|
||||
</p>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img
|
||||
src={previewUrl || summary.qrcodeUrl}
|
||||
alt="关联码"
|
||||
style={{ width: 220, height: 220, background: '#fff' }}
|
||||
/>
|
||||
) : (
|
||||
<p className="body-md text-muted">关联码尚未生成,请稍后重试或联系总部补发</p>
|
||||
)}
|
||||
<p className="label-md text-muted" style={{ marginTop: 12 }}>
|
||||
已关联 {summary?.userCount ?? 0} 人
|
||||
</p>
|
||||
<button type="button" className="partner-btn-primary" style={{ marginTop: 20 }} onClick={() => void downloadQr()}>
|
||||
下载二维码
|
||||
</button>
|
||||
{previewUrl && isWechatEnv() && (
|
||||
<p className="label-md text-muted" style={{ marginTop: 12 }}>
|
||||
微信内请长按上方图片保存
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerAssocUserItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserItem[]; total: number; page: number; pageSize: number };
|
||||
|
||||
export default function AssocUsersPage() {
|
||||
usePartnerPageView('partner_assoc_users_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
async function load() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<ListRes>('PARTNER_H5', '/partner/assoc/users?page=1&pageSize=50');
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title="关联用户" onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 人`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无关联用户</div>}
|
||||
{items.map((u) => (
|
||||
<div key={u.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 0 }}>
|
||||
<div>
|
||||
<p className="body-md">{u.nickname || u.userNo}</p>
|
||||
<p className="label-md text-muted">{u.phone || '未绑定手机'}</p>
|
||||
<p className="label-md text-muted">{u.boundAt ? u.boundAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="label-md">{u.orderCount} 单</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerBillDto } from '@dukang/shared-types';
|
||||
import type { PartnerBillDetailDto, PartnerBillDto, PartnerBillItemDto } from '@dukang/shared-types';
|
||||
import { isLoggedIn, request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
@@ -34,6 +34,7 @@ export default function BillsPage() {
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
const [detail, setDetail] = useState<PartnerBillDetailDto | null>(null);
|
||||
|
||||
async function loadBills() {
|
||||
setLoading(true);
|
||||
@@ -67,6 +68,44 @@ export default function BillsPage() {
|
||||
const isRejected = status === 'REJECTED';
|
||||
const isPaid = status === 'PAID';
|
||||
|
||||
useEffect(() => {
|
||||
if (!bill?.id) {
|
||||
setDetail(null);
|
||||
return;
|
||||
}
|
||||
request<PartnerBillDetailDto>('PARTNER_H5', `/partner/settlement/bills/${bill.id}`)
|
||||
.then(setDetail)
|
||||
.catch(() => setDetail(null));
|
||||
}, [bill?.id]);
|
||||
|
||||
function renderItemList(title: string, items: PartnerBillItemDto[] | undefined, subtotal: number) {
|
||||
const list = items ?? [];
|
||||
return (
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<div className="partner-info-row" style={{ marginBottom: 8 }}>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>{title}</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(subtotal)}</span>
|
||||
</div>
|
||||
{list.length === 0 ? (
|
||||
<p className="label-md text-muted">本账期无明细</p>
|
||||
) : (
|
||||
list.map((it) => (
|
||||
<div key={it.id} className="partner-info-row" style={{ alignItems: 'flex-start' }}>
|
||||
<div>
|
||||
<p className="body-md">{it.title || it.refNo}</p>
|
||||
<p className="label-md text-muted">
|
||||
{it.refNo}
|
||||
{it.extra ? ` ${it.extra}` : ''} · {((it.rate ?? 0) * 100).toFixed(2)}%
|
||||
</p>
|
||||
</div>
|
||||
<span className="body-md">¥ {fmtMoney(it.commission)}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function askConfirm(ids: string[]) {
|
||||
if (!window.confirm(`确认 ${ids.length} 笔账单无误并提交?确认后状态将变为「未打款」,等待总部打款。`)) {
|
||||
return;
|
||||
@@ -183,16 +222,8 @@ export default function BillsPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div className="partner-info-row">
|
||||
<span className="text-variant body-md">订单分佣收入</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(Number(bill.orderCommission || 0))}</span>
|
||||
</div>
|
||||
<div className="partner-info-row">
|
||||
<span className="text-variant body-md">核销权益分佣</span>
|
||||
<span className="body-md" style={{ fontWeight: 700 }}>¥ {fmtMoney(Number(bill.redeemCommission || 0))}</span>
|
||||
</div>
|
||||
</div>
|
||||
{renderItemList('酒订单', detail?.orderItems, Number(detail?.orderCommission ?? bill.orderCommission ?? 0))}
|
||||
{renderItemList('核销订单', detail?.redeemItems, Number(detail?.redeemCommission ?? bill.redeemCommission ?? 0))}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
@@ -219,6 +219,24 @@ export default function CenterPage({ variant = 'primary', roleLabel }: CenterPag
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</div>
|
||||
</Link>
|
||||
<Link to="/users" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
<span className="material-symbols-outlined">group</span>
|
||||
</div>
|
||||
<span className="body-md" style={{ fontSize: 16 }}>用户管理</span>
|
||||
</div>
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</Link>
|
||||
<Link to="/center/commissions" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
<span className="material-symbols-outlined">payments</span>
|
||||
</div>
|
||||
<span className="body-md" style={{ fontSize: 16 }}>订单佣金</span>
|
||||
</div>
|
||||
<span className="material-symbols-outlined text-muted">chevron_right</span>
|
||||
</Link>
|
||||
<Link to="/center/proxy-orders" className="partner-menu-item">
|
||||
<div className="partner-menu-item-left">
|
||||
<div className="partner-menu-icon">
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import PageHeader from '@dukang/shared-ui/PageHeader';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type { PartnerCommissionOrderItem } from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError } from '../lib/toast';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
function fmtMoney(n: number) {
|
||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
||||
}
|
||||
|
||||
type ListRes = { items: PartnerCommissionOrderItem[]; total: number };
|
||||
|
||||
export default function CommissionOrdersPage() {
|
||||
usePartnerPageView('partner_commission_orders_view');
|
||||
const navigate = useNavigate();
|
||||
const [items, setItems] = useState<PartnerCommissionOrderItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
async function load() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await request<ListRes>('PARTNER_H5', '/partner/commissions/orders?page=1&pageSize=50');
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
setItems([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load}>
|
||||
<PageHeader title="订单佣金" onBack={() => navigate(-1)} />
|
||||
<div style={{ padding: '0 20px 24px' }}>
|
||||
<p className="label-md text-muted" style={{ margin: '12px 0' }}>
|
||||
{loading ? '加载中…' : `共 ${total} 笔关联酒单`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无订单佣金</div>}
|
||||
{items.map((o) => (
|
||||
<div key={o.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header">
|
||||
<div>
|
||||
<p className="body-md">{o.productName}</p>
|
||||
<p className="label-md text-muted">{o.orderNo} · ×{o.quantity}</p>
|
||||
<p className="label-md text-muted">{o.paidAt ? o.paidAt.slice(0, 16).replace('T', ' ') : ''}</p>
|
||||
</div>
|
||||
<span className="amount-lg" style={{ fontSize: 18 }}>¥{fmtMoney(o.commission)}</span>
|
||||
</div>
|
||||
<p className="label-md text-muted">
|
||||
实付 ¥{fmtMoney(o.payAmount)} × {((o.rate ?? 0) * 100).toFixed(2)}%
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import type { PartnerLeaderboardEntry } from '@dukang/shared-types';
|
||||
import type { PartnerAssocStats, PartnerLeaderboardEntry } from '@dukang/shared-types';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
import { isLoggedIn, request } from '../lib/api';
|
||||
@@ -153,6 +153,7 @@ export default function HomePage() {
|
||||
const [stores, setStores] = useState<Array<Record<string, unknown>>>([]);
|
||||
const [orders, setOrders] = useState<Array<Record<string, unknown>>>([]);
|
||||
const [leaderboardEntries, setLeaderboardEntries] = useState<PartnerLeaderboardEntry[]>([]);
|
||||
const [assocStats, setAssocStats] = useState<PartnerAssocStats | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = '工作台';
|
||||
@@ -197,6 +198,16 @@ export default function HomePage() {
|
||||
setStores([]);
|
||||
}
|
||||
|
||||
if (isPrimary) {
|
||||
tasks.push(
|
||||
request<PartnerAssocStats>('PARTNER_H5', '/partner/assoc/stats', { silent: true })
|
||||
.then(setAssocStats)
|
||||
.catch(() => setAssocStats(null)),
|
||||
);
|
||||
} else {
|
||||
setAssocStats(null);
|
||||
}
|
||||
|
||||
tasks.push(
|
||||
fetchPartnerLeaderboard('month')
|
||||
.then((data) => {
|
||||
@@ -208,7 +219,7 @@ export default function HomePage() {
|
||||
);
|
||||
|
||||
return Promise.all(tasks).then(() => undefined);
|
||||
}, [navigate, account, canOrders, canDashboard, canStores]);
|
||||
}, [navigate, account, canOrders, canDashboard, canStores, isPrimary]);
|
||||
|
||||
useEffect(() => {
|
||||
void loadHome();
|
||||
@@ -287,6 +298,51 @@ export default function HomePage() {
|
||||
</>
|
||||
)}
|
||||
|
||||
{isPrimary && (
|
||||
<>
|
||||
<Link to="/users" className="partner-bento-card" style={{ display: 'block', marginBottom: 16, color: 'inherit', textDecoration: 'none' }}>
|
||||
<div className="partner-bento-header">
|
||||
<h2 className="headline-md">关联用户</h2>
|
||||
<span className="amount-lg" style={{ fontSize: 24 }}>{assocStats?.userTotal ?? 0}</span>
|
||||
</div>
|
||||
<div className="partner-store-stats">
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本日</p>
|
||||
<p className="headline-md">{assocStats?.userToday ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本月</p>
|
||||
<p className="headline-md">{assocStats?.userMonth ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
<Link to="/users/orders" className="partner-bento-card" style={{ display: 'block', marginBottom: 16, color: 'inherit', textDecoration: 'none' }}>
|
||||
<div className="partner-bento-header">
|
||||
<h2 className="headline-md">关联用户订单</h2>
|
||||
<span className="amount-lg" style={{ fontSize: 24 }}>{assocStats?.orderTotal ?? 0}</span>
|
||||
</div>
|
||||
<div className="partner-store-stats">
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本日</p>
|
||||
<p className="headline-md">{assocStats?.orderToday ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="partner-store-stat">
|
||||
<div>
|
||||
<p className="label-md text-muted">本月</p>
|
||||
<p className="headline-md">{assocStats?.orderMonth ?? 0}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isWarehouse && (
|
||||
<p className="headline-md" style={{ marginBottom: 8 }}>订单管理</p>
|
||||
)}
|
||||
|
||||
@@ -42,6 +42,7 @@ function initialDraft(): ProxyOrderDraft {
|
||||
promoCodeId: '',
|
||||
deliveryMode: 'ADDRESS',
|
||||
autoReceive: false,
|
||||
assocEnabled: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -63,6 +64,7 @@ export default function ProxyOrderPage() {
|
||||
const [promoCodeId, setPromoCodeId] = useState(draft0.promoCodeId);
|
||||
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>(draft0.deliveryMode);
|
||||
const [autoReceive, setAutoReceive] = useState(draft0.autoReceive);
|
||||
const [assocEnabled, setAssocEnabled] = useState(draft0.assocEnabled !== false);
|
||||
const [preview, setPreview] = useState<PartnerProxyOrderPreviewResult | null>(null);
|
||||
const [previewLoading, setPreviewLoading] = useState(false);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
@@ -108,6 +110,7 @@ export default function ProxyOrderPage() {
|
||||
promoCodeId,
|
||||
deliveryMode,
|
||||
autoReceive,
|
||||
assocEnabled,
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
@@ -154,6 +157,7 @@ export default function ProxyOrderPage() {
|
||||
promoCodeId,
|
||||
deliveryMode,
|
||||
autoReceive,
|
||||
assocEnabled,
|
||||
]);
|
||||
|
||||
const selectedProduct = options?.products.find((p) => p.id === productId);
|
||||
@@ -390,6 +394,9 @@ export default function ProxyOrderPage() {
|
||||
quantity,
|
||||
promoCodeId: promoCodeId || undefined,
|
||||
skuId: skuId || undefined,
|
||||
assocPartnerAccountId: assocEnabled
|
||||
? options?.partners?.[0]?.id || undefined
|
||||
: undefined,
|
||||
};
|
||||
|
||||
setSubmitting(true);
|
||||
@@ -595,6 +602,17 @@ export default function ProxyOrderPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-checkbox-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={assocEnabled}
|
||||
onChange={(e) => setAssocEnabled(e.target.checked)}
|
||||
/>
|
||||
<span>关联合伙人(本单计订单佣金;取消则本单不计)</span>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
{(options?.promoCodes.length ?? 0) > 0 && (
|
||||
<section className="partner-form-section">
|
||||
<label className="partner-form-label">绑定推广码(选填)</label>
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||
import type {
|
||||
PartnerAssocSummary,
|
||||
PartnerAssocUserItem,
|
||||
PartnerAssocUserSort,
|
||||
} from '@dukang/shared-types';
|
||||
import { request } from '../lib/api';
|
||||
import { toastError, toastSuccess } from '../lib/toast';
|
||||
import { isWechatEnv } from '../lib/weixin';
|
||||
import { usePartnerPageView } from '../lib/usePageView';
|
||||
|
||||
type ListRes = { items: PartnerAssocUserItem[]; total: number };
|
||||
|
||||
const SORTS: { key: PartnerAssocUserSort; label: string }[] = [
|
||||
{ key: 'boundAt', label: '关联时间' },
|
||||
{ key: 'createdAt', label: '注册时间' },
|
||||
{ key: 'orderCount', label: '订单数' },
|
||||
];
|
||||
|
||||
function formatUserLabel(u: PartnerAssocUserItem) {
|
||||
const name = u.nickname?.trim() || u.userNo || '—';
|
||||
const remark = u.partnerRemark?.trim();
|
||||
return remark ? `${name}(${remark})` : name;
|
||||
}
|
||||
|
||||
function fmtTime(iso?: string | null) {
|
||||
if (!iso) return '—';
|
||||
return iso.slice(0, 16).replace('T', ' ');
|
||||
}
|
||||
|
||||
export default function UsersManagePage() {
|
||||
usePartnerPageView('partner_users_manage_view');
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const [summary, setSummary] = useState<PartnerAssocSummary | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
const [items, setItems] = useState<PartnerAssocUserItem[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [keyword, setKeyword] = useState('');
|
||||
const [appliedKeyword, setAppliedKeyword] = useState('');
|
||||
const [sort, setSort] = useState<PartnerAssocUserSort>('boundAt');
|
||||
const [editing, setEditing] = useState<PartnerAssocUserItem | null>(null);
|
||||
const [remarkDraft, setRemarkDraft] = useState('');
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = '用户管理';
|
||||
}, []);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
||||
}, [previewUrl]);
|
||||
|
||||
const loadSummary = useCallback(async () => {
|
||||
const data = await request<PartnerAssocSummary>('PARTNER_H5', '/partner/assoc');
|
||||
setSummary(data);
|
||||
}, []);
|
||||
|
||||
const loadUsers = useCallback(async () => {
|
||||
const qs = new URLSearchParams({ page: '1', pageSize: '50', sort });
|
||||
const q = appliedKeyword.trim();
|
||||
if (q) qs.set('keyword', q);
|
||||
const res = await request<ListRes>('PARTNER_H5', `/partner/assoc/users?${qs}`);
|
||||
setItems(res.items ?? []);
|
||||
setTotal(res.total ?? 0);
|
||||
}, [appliedKeyword, sort]);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await Promise.all([loadSummary(), loadUsers()]);
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '加载失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [loadSummary, loadUsers]);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
useEffect(() => {
|
||||
const t = window.setTimeout(() => setAppliedKeyword(keyword.trim()), 400);
|
||||
return () => window.clearTimeout(t);
|
||||
}, [keyword]);
|
||||
|
||||
useEffect(() => {
|
||||
const uid = searchParams.get('userId');
|
||||
if (uid) navigate(`/users/${uid}/orders`, { replace: true });
|
||||
}, [searchParams, navigate]);
|
||||
|
||||
async function downloadQr() {
|
||||
const token = localStorage.getItem('accessToken');
|
||||
try {
|
||||
const res = await fetch('/api/v1/partner/assoc/qrcode', {
|
||||
headers: {
|
||||
Authorization: token ? `Bearer ${token}` : '',
|
||||
'X-Client-App': 'PARTNER_H5',
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('下载失败');
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
if (isWechatEnv()) {
|
||||
setPreviewUrl(url);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `partner-assoc-${summary?.partnerId || 'qr'}.png`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
toastSuccess('已开始下载');
|
||||
} catch (e) {
|
||||
if (summary?.qrcodeUrl) {
|
||||
setPreviewUrl(summary.qrcodeUrl);
|
||||
toastSuccess('请长按图片保存到相册');
|
||||
return;
|
||||
}
|
||||
toastError(e instanceof Error ? e.message : '下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
async function saveRemark() {
|
||||
if (!editing) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await request(`PARTNER_H5`, `/partner/assoc/users/${editing.id}/remark`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ remark: remarkDraft }),
|
||||
});
|
||||
toastSuccess(remarkDraft.trim() ? '备注已保存' : '已清除备注');
|
||||
setEditing(null);
|
||||
await loadUsers();
|
||||
} catch (e) {
|
||||
toastError(e instanceof Error ? e.message : '保存失败');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<PullToRefresh onRefresh={load} className="page partner-users-page">
|
||||
<div style={{ padding: '16px 20px 24px' }}>
|
||||
<h1 className="headline-lg" style={{ marginBottom: 16 }}>用户管理</h1>
|
||||
|
||||
<section className="partner-bill-card" style={{ marginBottom: 20, textAlign: 'center', padding: 20 }}>
|
||||
<p className="body-md text-muted" style={{ marginBottom: 12 }}>
|
||||
用户扫码后首次锁定,后续购酒计入关联订单
|
||||
</p>
|
||||
{summary?.qrcodeUrl ? (
|
||||
<img
|
||||
src={previewUrl || summary.qrcodeUrl}
|
||||
alt="关联码"
|
||||
style={{ width: 200, height: 200, background: '#fff' }}
|
||||
/>
|
||||
) : (
|
||||
<p className="body-md text-muted">{loading ? '加载中…' : '关联码尚未生成'}</p>
|
||||
)}
|
||||
<p className="label-md text-muted" style={{ marginTop: 8 }}>
|
||||
已关联 {summary?.userCount ?? total} 人
|
||||
</p>
|
||||
<button type="button" className="partner-btn-primary" style={{ marginTop: 16 }} onClick={() => void downloadQr()}>
|
||||
下载二维码
|
||||
</button>
|
||||
{previewUrl && isWechatEnv() && (
|
||||
<p className="label-md text-muted" style={{ marginTop: 8 }}>微信内请长按上方图片保存</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<h2 className="headline-md" style={{ marginBottom: 12 }}>已关联用户</h2>
|
||||
<div className="partner-search">
|
||||
<span className="material-symbols-outlined">search</span>
|
||||
<input
|
||||
value={keyword}
|
||||
placeholder="搜索昵称 / 手机 / 备注 / 编号"
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') void loadUsers();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="partner-filter-row" style={{ marginBottom: 12, paddingLeft: 0, paddingRight: 0 }}>
|
||||
{SORTS.map((s) => (
|
||||
<button
|
||||
key={s.key}
|
||||
type="button"
|
||||
className={`partner-filter-tab${sort === s.key ? ' active' : ''}`}
|
||||
onClick={() => setSort(s.key)}
|
||||
>
|
||||
{s.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="label-md text-muted" style={{ marginBottom: 12 }}>
|
||||
{loading ? '加载中…' : `共 ${total} 人`}
|
||||
</p>
|
||||
{!loading && items.length === 0 && <div className="empty">暂无关联用户</div>}
|
||||
{items.map((u) => (
|
||||
<div key={u.id} className="partner-store-card" style={{ marginBottom: 12 }}>
|
||||
<div className="partner-store-card-header" style={{ marginBottom: 8 }}>
|
||||
<div>
|
||||
<p className="body-md">{formatUserLabel(u)}</p>
|
||||
<p className="label-md text-muted">{u.phone || '未绑定手机'}</p>
|
||||
<p className="label-md text-muted">注册 {fmtTime(u.createdAt)}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="label-md text-primary"
|
||||
style={{ background: 'none', border: 0, padding: 0 }}
|
||||
onClick={() => navigate(`/users/${u.id}/orders`)}
|
||||
>
|
||||
{u.orderCount} 单
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="label-md text-primary"
|
||||
style={{ background: 'none', border: 0, padding: 0 }}
|
||||
onClick={() => {
|
||||
setEditing(u);
|
||||
setRemarkDraft(u.partnerRemark ?? '');
|
||||
}}
|
||||
>
|
||||
{u.partnerRemark ? '改备注' : '添加备注'}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{editing && (
|
||||
<div className="partner-remark-mask" onClick={() => setEditing(null)}>
|
||||
<div className="partner-remark-sheet" onClick={(e) => e.stopPropagation()}>
|
||||
<p className="headline-md" style={{ marginBottom: 8 }}>用户备注</p>
|
||||
<p className="label-md text-muted" style={{ marginBottom: 12 }}>仅自己可见,总部看不到</p>
|
||||
<textarea
|
||||
value={remarkDraft}
|
||||
maxLength={128}
|
||||
rows={3}
|
||||
placeholder="最多 128 字"
|
||||
style={{ width: '100%', padding: 12, borderRadius: 8, border: '1px solid #eee' }}
|
||||
onChange={(e) => setRemarkDraft(e.target.value)}
|
||||
/>
|
||||
<div className="partner-ship-actions">
|
||||
<button type="button" className="partner-btn-secondary" onClick={() => setEditing(null)}>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="partner-btn-primary"
|
||||
disabled={saving}
|
||||
onClick={() => void saveRemark()}
|
||||
>
|
||||
保存
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</PullToRefresh>
|
||||
);
|
||||
}
|
||||
@@ -278,6 +278,22 @@ html {
|
||||
|
||||
.partner-btn-primary:active { transform: scale(0.98); }
|
||||
|
||||
.partner-btn-secondary {
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-outline-variant);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-surface-container-low);
|
||||
color: var(--color-on-surface);
|
||||
font-family: var(--font-headline);
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.partner-btn-ghost {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
@@ -1344,7 +1360,7 @@ nav.app-tabbar {
|
||||
nav.app-tabbar .app-tabbar-item {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
max-width: 33.333%;
|
||||
max-width: 25%;
|
||||
height: 56px;
|
||||
padding: 6px 0 4px;
|
||||
border-radius: 0;
|
||||
@@ -3932,3 +3948,26 @@ header:has(> .app-page-title:only-child),
|
||||
margin-left: var(--space-page);
|
||||
margin-right: var(--space-page);
|
||||
}
|
||||
|
||||
.partner-users-page {
|
||||
padding-bottom: 96px;
|
||||
}
|
||||
|
||||
.partner-remark-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 200;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.partner-remark-sheet {
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
background: var(--color-card, #fff);
|
||||
border-radius: 16px 16px 0 0;
|
||||
padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@dukang/mini-user",
|
||||
"version": "3.5.10",
|
||||
"version": "3.5.16",
|
||||
"private": true,
|
||||
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
||||
"scripts": {
|
||||
|
||||
@@ -26,6 +26,7 @@ export default defineAppConfig({
|
||||
{ root: 'pages/login', pages: ['index'] },
|
||||
{ root: 'pages/user-agreement', pages: ['index'] },
|
||||
{ root: 'pages/privacy-policy', pages: ['index'] },
|
||||
{ root: 'pages/benefit-rules', pages: ['index'] },
|
||||
{ root: 'pages/invoice-titles', pages: ['index'] },
|
||||
{ root: 'pages/invoice-apply', pages: ['index'] },
|
||||
],
|
||||
@@ -75,7 +76,7 @@ export default defineAppConfig({
|
||||
pagePath: 'pages/benefit/index',
|
||||
text: '好客权益',
|
||||
iconPath: 'assets/tabbar/benefit.png',
|
||||
selectedIconPath: 'assets/tabbar/benefit-active.png',
|
||||
selectedIconPath: 'assets/icons/store-benefit-y.png',
|
||||
},
|
||||
{
|
||||
pagePath: 'pages/mine/index',
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
@import './styles/benefit.css';
|
||||
@import './styles/mine.css';
|
||||
@import './styles/address.css';
|
||||
@import './styles/benefit-promo.css';
|
||||
@import './components/JiuzuSplash.css';
|
||||
|
||||
page,
|
||||
body {
|
||||
|
||||
@@ -6,12 +6,14 @@ import { patchTaroH5Hooks } from './lib/patch-taro-h5-hooks';
|
||||
import { handleWechatOrderConfirmShow } from './lib/wechat-order-confirm';
|
||||
import { installClientErrorReporting } from './lib/client-error';
|
||||
import { prefetchShareBrandAssets } from './lib/wechat-share';
|
||||
import { prefetchJiuzuSplashAssets } from './lib/jiuzu-splash';
|
||||
import './app.css';
|
||||
|
||||
// H5:在首屏 page hooks 执行前,把 Taro.useDidShow 等绑到与 createReactApp 同一份 runtime
|
||||
patchTaroH5Hooks();
|
||||
installClientErrorReporting();
|
||||
prefetchShareBrandAssets();
|
||||
prefetchJiuzuSplashAssets();
|
||||
|
||||
function App({ children }: PropsWithChildren) {
|
||||
const handlingRef = useRef(false);
|
||||
|
||||
@@ -4,12 +4,14 @@ import Taro, { useDidShow } from '@tarojs/taro';
|
||||
import { handleWechatOrderConfirmShow } from './lib/wechat-order-confirm';
|
||||
import { installClientErrorReporting } from './lib/client-error';
|
||||
import { prefetchShareBrandAssets } from './lib/wechat-share';
|
||||
import { prefetchJiuzuSplashAssets } from './lib/jiuzu-splash';
|
||||
import { capturePromoSceneAndTouchScan } from './lib/promo';
|
||||
import { initClientVersionChecks } from './lib/client-version';
|
||||
import './app.css';
|
||||
|
||||
installClientErrorReporting();
|
||||
prefetchShareBrandAssets();
|
||||
prefetchJiuzuSplashAssets();
|
||||
|
||||
function App({ children }: PropsWithChildren) {
|
||||
const handlingRef = useRef(false);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 307 B |
Binary file not shown.
|
Before Width: | Height: | Size: 69 KiB |
@@ -1,5 +1,5 @@
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import iconStoreBenefit from '../assets/icons/store-benefit.png';
|
||||
import iconStoreBenefit from '../assets/icons/store-benefit-y.png';
|
||||
|
||||
type BenefitFigureSize = 'sm' | 'md' | 'lg' | 'xl';
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import {
|
||||
BENEFIT_INTRO,
|
||||
BENEFIT_INTRO_EMPHASIS,
|
||||
BENEFIT_RULES_PATH,
|
||||
BENEFIT_SLOGAN,
|
||||
} from '../lib/benefit-copy';
|
||||
|
||||
type BenefitIntroCardProps = {
|
||||
showLink?: boolean;
|
||||
className?: string;
|
||||
/** 左侧金色粗条(门店详情等强调卡) */
|
||||
accent?: boolean;
|
||||
};
|
||||
|
||||
export default function BenefitIntroCard({
|
||||
showLink = false,
|
||||
className,
|
||||
accent = false,
|
||||
}: BenefitIntroCardProps) {
|
||||
const prefix = BENEFIT_INTRO.endsWith(BENEFIT_INTRO_EMPHASIS)
|
||||
? BENEFIT_INTRO.slice(0, -BENEFIT_INTRO_EMPHASIS.length)
|
||||
: BENEFIT_INTRO;
|
||||
|
||||
function goRules() {
|
||||
Taro.navigateTo({ url: BENEFIT_RULES_PATH });
|
||||
}
|
||||
|
||||
const inner = (
|
||||
<>
|
||||
<Text className="benefit-intro-card-title">{BENEFIT_SLOGAN}</Text>
|
||||
<Text className="benefit-intro-card-body">
|
||||
{prefix}
|
||||
<Text className="benefit-intro-card-em">{BENEFIT_INTRO_EMPHASIS}</Text>
|
||||
</Text>
|
||||
{showLink ? (
|
||||
<Text className="benefit-intro-card-link" onClick={goRules}>
|
||||
查看完整说明 ›
|
||||
</Text>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`benefit-intro-card${accent ? ' benefit-intro-card--accent' : ''}${className ? ` ${className}` : ''}`}
|
||||
>
|
||||
{accent ? <View className="benefit-intro-card-bar" /> : null}
|
||||
{accent ? <View className="benefit-intro-card-main">{inner}</View> : inner}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import { BENEFIT_SLOGAN } from '../lib/benefit-copy';
|
||||
|
||||
type BenefitSloganBarProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export default function BenefitSloganBar({ className }: BenefitSloganBarProps) {
|
||||
return (
|
||||
<View className={`benefit-slogan-bar${className ? ` ${className}` : ''}`}>
|
||||
<View className="benefit-slogan-bar-accent" />
|
||||
<Text className="benefit-slogan-bar-text">{BENEFIT_SLOGAN}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export const EMPTY_CATEGORY: CategorySelection = {
|
||||
export function formatCategoryLabel(sel: CategorySelection): string {
|
||||
if (sel.childName) return sel.childName;
|
||||
if (sel.parentName) return sel.parentName;
|
||||
return '全部分类';
|
||||
return '全部菜系';
|
||||
}
|
||||
|
||||
type CategoryPickerProps = {
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
/* 酒祖杜康开场:黑红底 → GIF 播完消失 → 四字上移 → 副标题跟上 */
|
||||
|
||||
.jiuzu-splash {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10010;
|
||||
overflow: hidden;
|
||||
background-color: #140808;
|
||||
background-image: radial-gradient(ellipse at 50% 42%, #5a1014 0%, #2a080a 48%, #140808 100%);
|
||||
animation: jiuzu-bg-in 0.35s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash--out {
|
||||
animation: jiuzu-bg-out 0.8s ease-in forwards;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
filter: blur(48px);
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist--a {
|
||||
width: 280px;
|
||||
height: 280px;
|
||||
left: -72px;
|
||||
top: 12%;
|
||||
background: rgba(166, 29, 36, 0.38);
|
||||
}
|
||||
|
||||
.jiuzu-splash-mist--b {
|
||||
width: 240px;
|
||||
height: 240px;
|
||||
right: -56px;
|
||||
bottom: 16%;
|
||||
background: rgba(90, 16, 20, 0.5);
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif {
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif--out {
|
||||
animation: jiuzu-bg-out 0.35s ease-in forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-gif img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.jiuzu-splash-copy {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 26%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.jiuzu-splash-lockup {
|
||||
position: relative;
|
||||
width: 320px;
|
||||
height: 180px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jiuzu-splash-title {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
opacity: 0;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-title {
|
||||
animation: jiuzu-title-rise 2.4s cubic-bezier(0.22, 1, 0.32, 1) forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mark {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 320px;
|
||||
height: 180px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-mark {
|
||||
animation: fadeInTo4 1s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash-mark img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.jiuzu-splash-chars {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
.jiuzu-splash-char {
|
||||
width: 52px;
|
||||
}
|
||||
|
||||
.jiuzu-splash-char-text {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'PingFang SC', serif;
|
||||
font-size: 46px;
|
||||
font-weight: 700;
|
||||
line-height: 1.15;
|
||||
text-align: center;
|
||||
color: #f5d76e;
|
||||
text-shadow: 0 0 12px rgba(255, 191, 0, 0.85), 0 0 28px rgba(20, 8, 8, 0.65);
|
||||
}
|
||||
|
||||
.jiuzu-splash-shimmer {
|
||||
position: absolute;
|
||||
top: -10%;
|
||||
bottom: -10%;
|
||||
width: 36px;
|
||||
z-index: 3;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
rgba(255, 255, 255, 0) 0%,
|
||||
rgba(255, 248, 210, 0.55) 50%,
|
||||
rgba(255, 255, 255, 0) 100%
|
||||
);
|
||||
transform: translateX(-80px) skewX(-18deg);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-shimmer {
|
||||
animation: jiuzu-shimmer 0.7s 2.2s ease-out both;
|
||||
}
|
||||
|
||||
.jiuzu-splash-sub {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
margin-top: 4px;
|
||||
opacity: 0;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
|
||||
.jiuzu-splash--after-gif .jiuzu-splash-sub {
|
||||
animation: jiuzu-sub-rise 0.4s 1.3s cubic-bezier(0.22, 1, 0.32, 1) forwards;
|
||||
}
|
||||
|
||||
.jiuzu-splash-sub-text {
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.28em;
|
||||
color: rgba(245, 215, 110, 0.88);
|
||||
}
|
||||
|
||||
.jiuzu-splash-skip {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
z-index: 6;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid rgba(245, 215, 110, 0.45);
|
||||
background: rgba(20, 8, 8, 0.35);
|
||||
}
|
||||
|
||||
.jiuzu-splash-skip-text {
|
||||
color: rgba(255, 248, 210, 0.92);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
@keyframes fadeInTo4 {
|
||||
0% { opacity: 0; }
|
||||
100% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
@keyframes jiuzu-bg-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-bg-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-title-rise {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
14% {
|
||||
opacity: 1;
|
||||
transform: translateY(48vh);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-sub-rise {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
18% {
|
||||
opacity: 1;
|
||||
transform: translateY(36vh);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes jiuzu-shimmer {
|
||||
from {
|
||||
transform: translateX(-80px) skewX(-18deg);
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
transform: translateX(280px) skewX(-18deg);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Image, Text, View } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { JIUZU_SPLASH_GIF_URL, JIUZU_SPLASH_MARK_URL } from '@dukang/shared-types';
|
||||
import { markJiuzuSplashPlayed } from '../lib/jiuzu-splash';
|
||||
|
||||
const CHARS = ['酒', '祖', '杜', '康'] as const;
|
||||
|
||||
const SPLASH_NAV_BG = '#140808';
|
||||
const HOME_NAV_BG = '#FAF9F7';
|
||||
/** GIF 21 帧 × 80ms,略提前淡出避免循环 */
|
||||
const GIF_MS = 1650;
|
||||
const GIF_FADE_MS = 350;
|
||||
/** 四字显现并升到偏上位置 */
|
||||
const TITLE_MS = 2400;
|
||||
/** 副标题在四字到位后再升起 */
|
||||
const SUB_DELAY_MS = 2300;
|
||||
const SUB_MS = 1400;
|
||||
const HOLD_MS = 900;
|
||||
const FADE_MS = 800;
|
||||
const FADE_AT_MS = GIF_MS + SUB_DELAY_MS + SUB_MS + HOLD_MS;
|
||||
|
||||
type JiuzuSplashProps = {
|
||||
onDone: () => void;
|
||||
};
|
||||
|
||||
function applySplashChrome() {
|
||||
try {
|
||||
void Taro.hideTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#ffffff',
|
||||
backgroundColor: SPLASH_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeIn' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
function restoreChrome() {
|
||||
try {
|
||||
void Taro.showTabBar({ animation: false });
|
||||
} catch {
|
||||
/* H5 无原生 TabBar */
|
||||
}
|
||||
void Taro.setNavigationBarColor({
|
||||
frontColor: '#000000',
|
||||
backgroundColor: HOME_NAV_BG,
|
||||
animation: { duration: 200, timingFunc: 'easeOut' },
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
export default function JiuzuSplash({ onDone }: JiuzuSplashProps) {
|
||||
const finishedRef = useRef(false);
|
||||
const fadingRef = useRef(false);
|
||||
const onDoneRef = useRef(onDone);
|
||||
onDoneRef.current = onDone;
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
const [gifDone, setGifDone] = useState(false);
|
||||
const [gifGone, setGifGone] = useState(false);
|
||||
|
||||
const finish = useCallback(() => {
|
||||
if (finishedRef.current) return;
|
||||
finishedRef.current = true;
|
||||
restoreChrome();
|
||||
onDoneRef.current();
|
||||
}, []);
|
||||
|
||||
const beginExit = useCallback(() => {
|
||||
if (fadingRef.current || finishedRef.current) return;
|
||||
fadingRef.current = true;
|
||||
setLeaving(true);
|
||||
setTimeout(finish, FADE_MS);
|
||||
}, [finish]);
|
||||
|
||||
useEffect(() => {
|
||||
markJiuzuSplashPlayed();
|
||||
applySplashChrome();
|
||||
const gifTimer = setTimeout(() => setGifDone(true), GIF_MS);
|
||||
const gifGoneTimer = setTimeout(() => setGifGone(true), GIF_MS + GIF_FADE_MS);
|
||||
const exitTimer = setTimeout(beginExit, FADE_AT_MS);
|
||||
return () => {
|
||||
clearTimeout(gifTimer);
|
||||
clearTimeout(gifGoneTimer);
|
||||
clearTimeout(exitTimer);
|
||||
if (!finishedRef.current) restoreChrome();
|
||||
};
|
||||
}, [beginExit]);
|
||||
|
||||
return (
|
||||
<View
|
||||
className={`jiuzu-splash${gifDone ? ' jiuzu-splash--after-gif' : ''}${leaving ? ' jiuzu-splash--out' : ''}`}
|
||||
catchMove
|
||||
onTouchMove={(e) => {
|
||||
e.stopPropagation?.();
|
||||
}}
|
||||
>
|
||||
<View className="jiuzu-splash-mist jiuzu-splash-mist--a" />
|
||||
<View className="jiuzu-splash-mist jiuzu-splash-mist--b" />
|
||||
|
||||
{gifGone ? null : (
|
||||
<Image
|
||||
className={`jiuzu-splash-gif${gifDone ? ' jiuzu-splash-gif--out' : ''}`}
|
||||
src={JIUZU_SPLASH_GIF_URL}
|
||||
mode="aspectFill"
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
/>
|
||||
)}
|
||||
|
||||
<View className="jiuzu-splash-copy">
|
||||
<View className="jiuzu-splash-lockup">
|
||||
<Image
|
||||
className="jiuzu-splash-mark"
|
||||
src={JIUZU_SPLASH_MARK_URL}
|
||||
mode="aspectFit"
|
||||
style={{ width: '320px', height: '180px' }}
|
||||
/>
|
||||
<View className="jiuzu-splash-title">
|
||||
<View className="jiuzu-splash-chars">
|
||||
<View className="jiuzu-splash-shimmer" />
|
||||
{CHARS.map((ch) => (
|
||||
<View key={ch} className="jiuzu-splash-char">
|
||||
<Text className="jiuzu-splash-char-text">{ch}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="jiuzu-splash-sub">
|
||||
<Text className="jiuzu-splash-sub-text">千年酒祖 · 杜康好客</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="jiuzu-splash-skip" onClick={finish}>
|
||||
<Text className="jiuzu-splash-skip-text">跳过</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text, Input } from '@tarojs/components';
|
||||
|
||||
type OrderQtyControlsProps = {
|
||||
value: number;
|
||||
unitLabel: string;
|
||||
onChange: (next: number) => void;
|
||||
};
|
||||
|
||||
const MAX_QTY = 999;
|
||||
|
||||
function parseQty(raw: string): number | null {
|
||||
const n = parseInt(String(raw).replace(/\D/g, ''), 10);
|
||||
if (!Number.isFinite(n)) return null;
|
||||
return Math.min(MAX_QTY, Math.max(1, n));
|
||||
}
|
||||
|
||||
/** 下单数量:加减 + 手动输入,旁注单位(瓶/箱) */
|
||||
export default function OrderQtyControls({ value, unitLabel, onChange }: OrderQtyControlsProps) {
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
function current(): number {
|
||||
return parseQty(draft) ?? value;
|
||||
}
|
||||
|
||||
function commit() {
|
||||
const next = parseQty(draft);
|
||||
if (next == null) {
|
||||
setDraft(String(value));
|
||||
return;
|
||||
}
|
||||
setDraft(String(next));
|
||||
if (next !== value) onChange(next);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="order-qty-row">
|
||||
<Text>购买数量</Text>
|
||||
<View className="order-qty-controls">
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.max(1, current() - 1))}>
|
||||
<Text>−</Text>
|
||||
</View>
|
||||
<Input
|
||||
className="order-qty-input"
|
||||
type="number"
|
||||
maxlength={3}
|
||||
value={draft}
|
||||
onInput={(e) => setDraft(String(e.detail.value ?? ''))}
|
||||
onBlur={commit}
|
||||
onConfirm={commit}
|
||||
/>
|
||||
<Text className="order-qty-unit">{unitLabel}</Text>
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.min(MAX_QTY, current() + 1))}>
|
||||
<Text>+</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,215 +1,67 @@
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useMemo } from 'react';
|
||||
import { View, Text, Swiper, SwiperItem } from '@tarojs/components';
|
||||
|
||||
type StoreRedeemMarqueeProps = {
|
||||
lines: string[];
|
||||
export type StoreRedeemMarqueeItem = {
|
||||
userLabel: string;
|
||||
amount: 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;
|
||||
type StoreRedeemMarqueeProps = {
|
||||
items: StoreRedeemMarqueeItem[];
|
||||
};
|
||||
|
||||
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` };
|
||||
const STAY_MS = 20000;
|
||||
|
||||
function MarqueeRow({ item }: { item: StoreRedeemMarqueeItem }) {
|
||||
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 className="store-detail-marquee-inner">
|
||||
<View className="store-detail-marquee-dot" />
|
||||
<Text className="store-detail-marquee-text">{item.userLabel} 刚刚到店核销</Text>
|
||||
<Text className="store-detail-marquee-amount">{item.amount}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** 核销记录:单条静止;多条竖向循环,每条停留 20 秒 */
|
||||
export default function StoreRedeemMarquee({ items }: StoreRedeemMarqueeProps) {
|
||||
const list = useMemo(
|
||||
() =>
|
||||
items
|
||||
.map((row) => ({
|
||||
userLabel: String(row.userLabel || '用户***').trim() || '用户***',
|
||||
amount: String(row.amount || '').trim(),
|
||||
}))
|
||||
.filter((row) => row.amount),
|
||||
[items],
|
||||
);
|
||||
|
||||
if (!list.length) return null;
|
||||
|
||||
if (list.length === 1) {
|
||||
return (
|
||||
<View className="store-detail-marquee">
|
||||
<MarqueeRow item={list[0]} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="store-detail-marquee">
|
||||
<Swiper
|
||||
className="store-detail-marquee-swiper"
|
||||
vertical
|
||||
circular
|
||||
autoplay
|
||||
interval={STAY_MS}
|
||||
duration={400}
|
||||
indicatorDots={false}
|
||||
>
|
||||
{list.map((row, index) => (
|
||||
<SwiperItem key={`${row.userLabel}|${row.amount}|${index}`}>
|
||||
<MarqueeRow item={row} />
|
||||
</SwiperItem>
|
||||
))}
|
||||
</Swiper>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import iconHomeActive from '../assets/tabbar/home-active.png';
|
||||
import iconStore from '../assets/tabbar/store.png';
|
||||
import iconStoreActive from '../assets/tabbar/store-active.png';
|
||||
import iconBenefit from '../assets/tabbar/benefit.png';
|
||||
import iconBenefitActive from '../assets/tabbar/benefit-active.png';
|
||||
import iconBenefitActive from '../assets/icons/store-benefit-y.png';
|
||||
import iconMine from '../assets/tabbar/mine.png';
|
||||
import iconMineActive from '../assets/tabbar/mine-active.png';
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
export const BENEFIT_SLOGAN = '购杜康好酒,赠用餐权益';
|
||||
|
||||
export const BENEFIT_INTRO =
|
||||
'购杜康好酒,赠用餐权益,到签约饭店核销。权益随酒赠送,仅限签约饭店到店用餐,不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_INTRO_EMPHASIS = '不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_GIFT_TAG = '买酒即赠用餐权益';
|
||||
|
||||
export const BENEFIT_TAG = '好客权益';
|
||||
|
||||
export const BENEFIT_RULES_PATH = '/pages/benefit-rules/index';
|
||||
|
||||
export const BENEFIT_RULES_TITLE = '好客权益使用说明';
|
||||
|
||||
export const BENEFIT_RULES_SUMMARY =
|
||||
'购杜康好酒,赠用餐权益,到签约饭店核销。权益随酒赠送,仅限杜康好客平台签约饭店到店用餐,不可兑现、不可转卖。';
|
||||
|
||||
export const BENEFIT_RULES_SECTIONS = [
|
||||
{
|
||||
heading: '一、权益从哪来',
|
||||
paragraphs: [
|
||||
'好客权益是购买杜康好酒时随酒赠送的用餐权益,用于在签约饭店到店用餐,不是储值卡、预付卡,也不是现金账户。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '二、如何获得',
|
||||
paragraphs: [
|
||||
'在小程序内购买杜康好酒并支付成功后,系统按商品说明发放对应用餐权益。未支付或已取消的订单不产生权益。不支持单独购买或充值权益。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '三、如何使用',
|
||||
paragraphs: [
|
||||
'1. 在「门店」中选择签约饭店,到店用餐时出示核销码或提供手机号,由门店完成核销。',
|
||||
'2. 核销码有效期为 3 分钟,过期请重新生成。',
|
||||
'3. 权益可按实际消费分次核销,累计核销金额不可超过已获得的权益总额。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '四、使用范围',
|
||||
paragraphs: [
|
||||
'仅限杜康好客平台签约饭店到店用餐使用。香烟、酒水一律不可核销。其他菜品是否可核销以门店当场说明为准。',
|
||||
],
|
||||
emphasize: '香烟、酒水一律不可核销。',
|
||||
},
|
||||
{
|
||||
heading: '五、使用限制',
|
||||
paragraphs: ['不可兑现、不可转卖、不可提现、不可充值,不可当现金使用。'],
|
||||
emphasizeAll: true,
|
||||
},
|
||||
{
|
||||
heading: '六、退货与权益收回',
|
||||
paragraphs: [
|
||||
'酒水退货退款时,未使用的权益将收回;已核销部分不退回。酒款按原支付路径退回。仅换货不退款的,一般保留原权益。',
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: '七、有效期',
|
||||
paragraphs: ['好客权益暂无使用期限,持续有效,直至收回或全部核销完毕。'],
|
||||
},
|
||||
{
|
||||
heading: '八、联系客服',
|
||||
paragraphs: ['如有疑问,可通过小程序「联系客服」咨询,或拨打客服电话。'],
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const BENEFIT_RULES_FOOTER = '请理性饮酒。未满十八周岁不得饮酒。过量饮酒有害健康。';
|
||||
@@ -2,7 +2,7 @@ import Taro from '@tarojs/taro';
|
||||
import { fetchClientConfig } from './pay-wechat';
|
||||
|
||||
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */
|
||||
export const APP_VERSION = '3.5.10';
|
||||
export const APP_VERSION = '3.5.16';
|
||||
|
||||
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
||||
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
/** Canvas 金龙:盘成一圈,仿照立体金龙的鳞片、须、角、爪与光晕 */
|
||||
|
||||
export type DragonCanvasNode = {
|
||||
width: number;
|
||||
height: number;
|
||||
getContext: (type: '2d') => CanvasRenderingContext2D;
|
||||
requestAnimationFrame?: (cb: (time: number) => void) => number;
|
||||
cancelAnimationFrame?: (id: number) => void;
|
||||
};
|
||||
|
||||
type SpinePt = {
|
||||
x: number;
|
||||
y: number;
|
||||
ang: number;
|
||||
nx: number;
|
||||
ny: number;
|
||||
w: number;
|
||||
};
|
||||
|
||||
const GOLD_HI = '#fff6c8';
|
||||
const GOLD = '#ffbf00';
|
||||
const GOLD_MID = '#e8a800';
|
||||
const GOLD_DEEP = '#b87500';
|
||||
|
||||
function lerp(a: number, b: number, t: number) {
|
||||
return a + (b - a) * t;
|
||||
}
|
||||
|
||||
function fillOval(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
x: number,
|
||||
y: number,
|
||||
rw: number,
|
||||
rh: number,
|
||||
rot: number,
|
||||
) {
|
||||
ctx.save();
|
||||
ctx.translate(x, y);
|
||||
ctx.rotate(rot);
|
||||
ctx.scale(Math.max(0.01, rw), Math.max(0.01, rh));
|
||||
ctx.beginPath();
|
||||
ctx.arc(0, 0, 1, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function easeInCubic(t: number) {
|
||||
return t * t * t;
|
||||
}
|
||||
|
||||
function buildSpine(cx: number, cy: number, r: number, phase: number, segs: number): SpinePt[] {
|
||||
const pts: SpinePt[] = [];
|
||||
const turns = 0.94;
|
||||
for (let i = 0; i < segs; i++) {
|
||||
const u = i / (segs - 1);
|
||||
const ang = -Math.PI / 2 + u * Math.PI * 2 * turns;
|
||||
const wobble = Math.sin(u * 14 + phase) * r * 0.042 + Math.sin(u * 5.5 - phase * 0.7) * r * 0.02;
|
||||
const rr = r + wobble;
|
||||
const nx = Math.cos(ang);
|
||||
const ny = Math.sin(ang);
|
||||
pts.push({
|
||||
x: cx + nx * rr,
|
||||
y: cy + ny * rr,
|
||||
ang,
|
||||
nx,
|
||||
ny,
|
||||
w: lerp(20, 6.5, u ** 0.62),
|
||||
});
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
function strokeRibbon(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
pts: SpinePt[],
|
||||
widthScale: number,
|
||||
color: string,
|
||||
alpha: number,
|
||||
) {
|
||||
if (pts.length < 2) return;
|
||||
ctx.save();
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.strokeStyle = color;
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pts[0].x, pts[0].y);
|
||||
for (let i = 1; i < pts.length; i++) ctx.lineTo(pts[i].x, pts[i].y);
|
||||
ctx.lineWidth = pts[Math.floor(pts.length * 0.15)].w * widthScale;
|
||||
ctx.stroke();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawScales(ctx: CanvasRenderingContext2D, pts: SpinePt[]) {
|
||||
for (let i = 2; i < pts.length - 1; i += 1) {
|
||||
const p = pts[i];
|
||||
const u = i / (pts.length - 1);
|
||||
const ox = p.x + p.nx * p.w * 0.18;
|
||||
const oy = p.y + p.ny * p.w * 0.18;
|
||||
ctx.save();
|
||||
ctx.translate(ox, oy);
|
||||
ctx.rotate(p.ang + Math.PI / 2);
|
||||
ctx.fillStyle = i % 2 === 0 ? GOLD_HI : GOLD;
|
||||
ctx.globalAlpha = 0.55 + (1 - u) * 0.25;
|
||||
fillOval(ctx, 0, 0, p.w * 0.55, p.w * 0.38, 0);
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
function drawSpines(ctx: CanvasRenderingContext2D, pts: SpinePt[]) {
|
||||
ctx.fillStyle = GOLD_HI;
|
||||
for (let i = 3; i < pts.length - 6; i += 3) {
|
||||
const p = pts[i];
|
||||
const len = p.w * 1.35;
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 0.85;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(p.x + p.nx * p.w * 0.2, p.y + p.ny * p.w * 0.2);
|
||||
ctx.lineTo(
|
||||
p.x + p.nx * (p.w + len),
|
||||
p.y + p.ny * (p.w + len),
|
||||
);
|
||||
const tx = -p.ny;
|
||||
const ty = p.nx;
|
||||
ctx.lineTo(p.x + tx * 2.2, p.y + ty * 2.2);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
function drawClaw(ctx: CanvasRenderingContext2D, p: SpinePt, side: number) {
|
||||
const tx = -p.ny * side;
|
||||
const ty = p.nx * side;
|
||||
const baseX = p.x + tx * p.w * 0.7;
|
||||
const baseY = p.y + ty * p.w * 0.7;
|
||||
ctx.save();
|
||||
ctx.translate(baseX, baseY);
|
||||
ctx.rotate(Math.atan2(ty, tx));
|
||||
ctx.fillStyle = GOLD;
|
||||
ctx.strokeStyle = GOLD_DEEP;
|
||||
ctx.lineWidth = 0.8;
|
||||
for (let k = -1; k <= 1; k++) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, k * 4);
|
||||
ctx.quadraticCurveTo(10, k * 6 - 2, 18, k * 5);
|
||||
ctx.quadraticCurveTo(10, k * 4, 0, k * 3);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawHead(ctx: CanvasRenderingContext2D, p: SpinePt, phase: number) {
|
||||
ctx.save();
|
||||
ctx.translate(p.x + p.nx * 10, p.y + p.ny * 10);
|
||||
ctx.rotate(Math.atan2(p.ny, p.nx) + Math.PI / 2);
|
||||
|
||||
const mane = 6;
|
||||
for (let i = 0; i < mane; i++) {
|
||||
const a = -0.9 + (i / (mane - 1)) * 1.8;
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = i % 2 ? GOLD_HI : GOLD;
|
||||
ctx.globalAlpha = 0.7;
|
||||
ctx.lineWidth = 2.2;
|
||||
ctx.moveTo(Math.sin(a) * 6, -4);
|
||||
ctx.quadraticCurveTo(Math.sin(a) * 16, -18 - Math.sin(phase + i) * 3, Math.sin(a) * 8, -28);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(-7, -18);
|
||||
ctx.quadraticCurveTo(-16, -32, -5, -38);
|
||||
ctx.quadraticCurveTo(-2, -26, -3, -16);
|
||||
ctx.fillStyle = GOLD_MID;
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(7, -18);
|
||||
ctx.quadraticCurveTo(16, -32, 5, -38);
|
||||
ctx.quadraticCurveTo(2, -26, 3, -16);
|
||||
ctx.fill();
|
||||
|
||||
const g = ctx.createRadialGradient(-4, -4, 2, 0, 4, 20);
|
||||
g.addColorStop(0, GOLD_HI);
|
||||
g.addColorStop(0.45, GOLD);
|
||||
g.addColorStop(1, GOLD_DEEP);
|
||||
ctx.fillStyle = g;
|
||||
fillOval(ctx, 0, 2, 16, 18, 0);
|
||||
|
||||
ctx.fillStyle = GOLD_MID;
|
||||
fillOval(ctx, 0, 10, 9, 8, 0);
|
||||
|
||||
for (const sx of [-6.5, 6.5]) {
|
||||
ctx.fillStyle = '#3a1a00';
|
||||
fillOval(ctx, sx, -2, 3.2, 3.6, 0);
|
||||
ctx.fillStyle = '#ffe566';
|
||||
fillOval(ctx, sx, -2.4, 1.5, 1.7, 0);
|
||||
ctx.fillStyle = '#fff';
|
||||
fillOval(ctx, sx - 0.5, -3, 0.6, 0.6, 0);
|
||||
}
|
||||
|
||||
ctx.strokeStyle = GOLD_HI;
|
||||
ctx.lineWidth = 1.15;
|
||||
ctx.globalAlpha = 0.9;
|
||||
for (const side of [-1, 1]) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(side * 12, 6);
|
||||
ctx.quadraticCurveTo(side * 36, 10 + Math.sin(phase) * 2, side * 42, 22);
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(side * 10, 9);
|
||||
ctx.quadraticCurveTo(side * 28, 18, side * 34, 28);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function drawSparks(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
cx: number,
|
||||
cy: number,
|
||||
r: number,
|
||||
phase: number,
|
||||
) {
|
||||
for (let i = 0; i < 28; i++) {
|
||||
const a = (i / 28) * Math.PI * 2 + phase * 0.35;
|
||||
const rr = r * (0.72 + ((i * 17) % 10) / 40);
|
||||
const x = cx + Math.cos(a) * rr + Math.sin(phase * 1.4 + i) * 4;
|
||||
const y = cy + Math.sin(a) * rr + Math.cos(phase * 1.1 + i) * 3;
|
||||
const s = 1.1 + (i % 5) * 0.35;
|
||||
ctx.beginPath();
|
||||
ctx.globalAlpha = 0.25 + (Math.sin(phase * 2 + i) + 1) * 0.25;
|
||||
ctx.fillStyle = i % 3 === 0 ? GOLD_HI : GOLD;
|
||||
ctx.arc(x, y, s, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
export function drawJiuzuDragonFrame(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
width: number,
|
||||
height: number,
|
||||
elapsedMs: number,
|
||||
) {
|
||||
const cx = width / 2;
|
||||
const cy = height * 0.42;
|
||||
const radius = Math.min(width, height) * 0.3;
|
||||
|
||||
const fadeIn = Math.min(1, elapsedMs / 380);
|
||||
const spinT = Math.min(1, Math.max(0, (elapsedMs - 120) / 2050));
|
||||
const flyT = Math.min(1, Math.max(0, (elapsedMs - 2200) / 1200));
|
||||
const spin = spinT * Math.PI * 2;
|
||||
const fly = easeInCubic(flyT);
|
||||
const phase = elapsedMs / 220;
|
||||
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
ctx.save();
|
||||
ctx.globalAlpha = fadeIn * (1 - fly);
|
||||
ctx.translate(cx, cy + fly * -height * 0.42);
|
||||
ctx.scale(1 + fly * 0.55, 1 + fly * 0.55);
|
||||
ctx.rotate(spin);
|
||||
ctx.translate(-cx, -cy);
|
||||
|
||||
const pts = buildSpine(cx, cy, radius, phase, 56);
|
||||
strokeRibbon(ctx, pts, 2.4, 'rgba(255, 191, 0, 0.18)', 1);
|
||||
strokeRibbon(ctx, pts, 1.55, 'rgba(255, 214, 80, 0.4)', 1);
|
||||
|
||||
ctx.save();
|
||||
ctx.lineCap = 'round';
|
||||
ctx.lineJoin = 'round';
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(pts[0].x, pts[0].y);
|
||||
for (let i = 1; i < pts.length; i++) ctx.lineTo(pts[i].x, pts[i].y);
|
||||
const bodyGrad = ctx.createLinearGradient(cx - radius, cy, cx + radius, cy);
|
||||
bodyGrad.addColorStop(0, GOLD_DEEP);
|
||||
bodyGrad.addColorStop(0.5, GOLD);
|
||||
bodyGrad.addColorStop(1, GOLD_HI);
|
||||
ctx.strokeStyle = bodyGrad;
|
||||
ctx.lineWidth = pts[0].w * 1.15;
|
||||
ctx.shadowColor = 'rgba(255, 191, 0, 0.7)';
|
||||
ctx.shadowBlur = 16;
|
||||
ctx.stroke();
|
||||
ctx.shadowBlur = 0;
|
||||
ctx.restore();
|
||||
|
||||
drawScales(ctx, pts);
|
||||
drawSpines(ctx, pts);
|
||||
drawClaw(ctx, pts[Math.floor(pts.length * 0.32)], 1);
|
||||
drawClaw(ctx, pts[Math.floor(pts.length * 0.68)], -1);
|
||||
drawHead(ctx, pts[0], phase);
|
||||
drawSparks(ctx, cx, cy, radius, phase);
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
export function scheduleDragonFrame(
|
||||
canvas: DragonCanvasNode,
|
||||
cb: (time: number) => void,
|
||||
): number {
|
||||
if (typeof canvas.requestAnimationFrame === 'function') {
|
||||
return canvas.requestAnimationFrame(cb);
|
||||
}
|
||||
return requestAnimationFrame(cb);
|
||||
}
|
||||
|
||||
export function cancelDragonFrame(canvas: DragonCanvasNode, id: number) {
|
||||
if (typeof canvas.cancelAnimationFrame === 'function') {
|
||||
canvas.cancelAnimationFrame(id);
|
||||
return;
|
||||
}
|
||||
cancelAnimationFrame(id);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { JIUZU_SPLASH_GIF_URL, JIUZU_SPLASH_MARK_URL } from '@dukang/shared-types';
|
||||
|
||||
/** 冷启动会话内是否已播过「酒祖杜康」开场(进程级,切 Tab 不重播) */
|
||||
|
||||
let played = false;
|
||||
|
||||
export function hasJiuzuSplashPlayed() {
|
||||
return played;
|
||||
}
|
||||
|
||||
export function markJiuzuSplashPlayed() {
|
||||
played = true;
|
||||
}
|
||||
|
||||
/** 冷启动预拉 OSS 开场图(仅 weapp;H5 的 getImageInfo 会走 CORS) */
|
||||
export function prefetchJiuzuSplashAssets() {
|
||||
if (played) return;
|
||||
if (process.env.TARO_ENV !== 'weapp') return;
|
||||
void Taro.getImageInfo({ src: JIUZU_SPLASH_GIF_URL }).catch(() => {});
|
||||
void Taro.getImageInfo({ src: JIUZU_SPLASH_MARK_URL }).catch(() => {});
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { request } from './api';
|
||||
import { request, isLoggedIn, toast } from './api';
|
||||
|
||||
const PROMO_ID_KEY = 'dukang_promo_id';
|
||||
const ASSOC_SCENE_KEY = 'dukang_partner_assoc_scene';
|
||||
|
||||
/** 同一次进入只 touch 一次扫码计数,避免首页反复 onShow 刷量 */
|
||||
let lastScanTouchKey = '';
|
||||
@@ -28,10 +29,54 @@ type EnterOptionsLike = {
|
||||
path?: string;
|
||||
};
|
||||
|
||||
function normalizeAssocScene(raw: unknown): string | null {
|
||||
if (raw == null || raw === '') return null;
|
||||
const s = safeDecode(String(raw)).trim();
|
||||
return /^pa_\d+$/.test(s) ? s : null;
|
||||
}
|
||||
|
||||
function extractAssocSceneFromEnterOptions(opts?: EnterOptionsLike | null): string | null {
|
||||
if (!opts) return null;
|
||||
const q = opts.query ?? {};
|
||||
return (
|
||||
normalizeAssocScene(q.scene) ||
|
||||
normalizeAssocScene(opts.scene) ||
|
||||
normalizeAssocScene(q.partnerId) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
export function getStoredAssocScene(): string | null {
|
||||
try {
|
||||
return normalizeAssocScene(Taro.getStorageSync(ASSOC_SCENE_KEY));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function setStoredAssocScene(scene: string) {
|
||||
const id = normalizeAssocScene(scene);
|
||||
if (!id) return;
|
||||
try {
|
||||
Taro.setStorageSync(ASSOC_SCENE_KEY, id);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function clearStoredAssocScene() {
|
||||
try {
|
||||
Taro.removeStorageSync(ASSOC_SCENE_KEY);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/** 从启动/进入参数解析推广活动 ID(优先 query.scene,与 getwxacodeunlimit 一致) */
|
||||
export function extractPromoIdFromEnterOptions(opts?: EnterOptionsLike | null): string | null {
|
||||
if (!opts) return null;
|
||||
const q = opts.query ?? {};
|
||||
if (extractAssocSceneFromEnterOptions(opts)) return null;
|
||||
return (
|
||||
normalizePromoId(q.scene) ||
|
||||
normalizePromoId(q.promoId) ||
|
||||
@@ -92,8 +137,35 @@ function readEnterOptions(): EnterOptionsLike | null {
|
||||
* 主页面进入时:取出 scene(活动 ID)本地缓存,并回传 /promo/touch 累加扫码次数。
|
||||
* 同一进入会话只计一次扫码。
|
||||
*/
|
||||
async function bindStoredAssocIfLoggedIn(): Promise<void> {
|
||||
const scene = getStoredAssocScene();
|
||||
if (!scene || !isLoggedIn()) return;
|
||||
try {
|
||||
const result = await request<{ alreadyBound?: boolean; bound?: boolean }>('/user/partner-assoc/bind', {
|
||||
method: 'POST',
|
||||
data: { scene },
|
||||
});
|
||||
clearStoredAssocScene();
|
||||
if (result.alreadyBound) toast('已关联');
|
||||
else if (result.bound) toast('关联成功', 'success');
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : '';
|
||||
if (msg.includes('已关联')) {
|
||||
clearStoredAssocScene();
|
||||
toast('已关联');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function capturePromoSceneAndTouchScan(): Promise<void> {
|
||||
const opts = readEnterOptions();
|
||||
const assocScene = extractAssocSceneFromEnterOptions(opts);
|
||||
if (assocScene) {
|
||||
setStoredAssocScene(assocScene);
|
||||
await bindStoredAssocIfLoggedIn();
|
||||
return;
|
||||
}
|
||||
|
||||
const fromEnter = extractPromoIdFromEnterOptions(opts);
|
||||
if (fromEnter) {
|
||||
setStoredPromoId(fromEnter);
|
||||
@@ -109,6 +181,7 @@ export async function capturePromoSceneAndTouchScan(): Promise<void> {
|
||||
|
||||
/** 登录成功后:用已缓存的活动 ID 做归因(不重复加扫码次数) */
|
||||
export async function touchStoredPromoAfterLogin(): Promise<void> {
|
||||
await bindStoredAssocIfLoggedIn();
|
||||
const promoId = getStoredPromoId();
|
||||
if (!promoId) return;
|
||||
await touchPromo({ promoId, countScan: false });
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
export type StoreCategoryLike = {
|
||||
id?: string;
|
||||
name?: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
};
|
||||
|
||||
export type StoreCategoryTreeNode = {
|
||||
id: string;
|
||||
name: string;
|
||||
children?: { id: string; name: string }[];
|
||||
};
|
||||
|
||||
export function storeStarCount(rating?: number | string | null): number {
|
||||
const n = Number(rating);
|
||||
if (!Number.isFinite(n) || n <= 0) return 5;
|
||||
return Math.min(5, Math.max(1, Math.round(n)));
|
||||
}
|
||||
|
||||
export function storeCategoryTags(
|
||||
store: {
|
||||
tags?: unknown;
|
||||
categoryId?: string | null;
|
||||
category?: StoreCategoryLike | null;
|
||||
},
|
||||
tree: StoreCategoryTreeNode[] = [],
|
||||
): string[] {
|
||||
const fromJson = Array.isArray(store.tags)
|
||||
? store.tags.map((t) => String(t).trim()).filter(Boolean)
|
||||
: [];
|
||||
if (fromJson.length) return fromJson;
|
||||
|
||||
const names: string[] = [];
|
||||
const childName = String(store.category?.name || '').trim();
|
||||
const parentName = String(store.category?.parent?.name || '').trim();
|
||||
if (parentName) names.push(parentName);
|
||||
if (childName && childName !== parentName) names.push(childName);
|
||||
|
||||
const storeCatId = String(store.categoryId || store.category?.id || '');
|
||||
const storeParentId = String(store.category?.parentId || '');
|
||||
for (const root of tree) {
|
||||
if (root.id === storeParentId || root.id === storeCatId) {
|
||||
if (root.name && !names.includes(root.name)) names.unshift(root.name);
|
||||
}
|
||||
for (const child of root.children ?? []) {
|
||||
if (child.id === storeCatId) {
|
||||
if (root.name && !names.includes(root.name)) names.unshift(root.name);
|
||||
if (child.name && !names.includes(child.name)) names.push(child.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
@@ -19,6 +19,8 @@ export type StoresSessionCategory = {
|
||||
childName: string;
|
||||
};
|
||||
|
||||
export type StoreSortKey = 'nearby' | 'rating' | 'redeem';
|
||||
|
||||
export type StoresListCache = {
|
||||
cityKey: string;
|
||||
cityCode: string;
|
||||
@@ -30,6 +32,7 @@ export type StoresListCache = {
|
||||
keyword: string;
|
||||
keywordInput: string;
|
||||
category: StoresSessionCategory;
|
||||
sort?: StoreSortKey;
|
||||
};
|
||||
|
||||
type StoresSession = {
|
||||
@@ -37,7 +40,7 @@ type StoresSession = {
|
||||
cache: StoresListCache | null;
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'dukang_stores_session_v1';
|
||||
const STORAGE_KEY = 'dukang_stores_session_v2';
|
||||
|
||||
let memory: StoresSession | null = null;
|
||||
|
||||
@@ -94,7 +97,7 @@ export function setStoresListCache(cache: StoresListCache | null): void {
|
||||
|
||||
export function patchStoresFilterCache(
|
||||
patch: Partial<
|
||||
Pick<StoresListCache, 'filterRegion' | 'keyword' | 'keywordInput' | 'category'>
|
||||
Pick<StoresListCache, 'filterRegion' | 'keyword' | 'keywordInput' | 'category' | 'sort'>
|
||||
>,
|
||||
): void {
|
||||
const cur = readSession();
|
||||
@@ -105,6 +108,7 @@ export function patchStoresFilterCache(
|
||||
cache: {
|
||||
cityKey: '',
|
||||
cityCode: '',
|
||||
authKey: '',
|
||||
listRegion: patch.filterRegion ?? { province: '', city: '', district: '' },
|
||||
items: [],
|
||||
filterRegion: patch.filterRegion ?? { province: '', city: '', district: '' },
|
||||
@@ -116,6 +120,7 @@ export function patchStoresFilterCache(
|
||||
childId: '',
|
||||
childName: '',
|
||||
},
|
||||
sort: patch.sort ?? 'nearby',
|
||||
},
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import Taro from '@tarojs/taro';
|
||||
import { STORE_RATING_MAX_IMAGES } from '@dukang/shared-types';
|
||||
|
||||
export async function chooseAndUploadRatingImages(already: number): Promise<string[]> {
|
||||
const remain = STORE_RATING_MAX_IMAGES - already;
|
||||
if (remain <= 0) {
|
||||
throw new Error(`最多上传${STORE_RATING_MAX_IMAGES}张图片`);
|
||||
}
|
||||
|
||||
const picked = await Taro.chooseImage({
|
||||
count: remain,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
});
|
||||
const paths = picked.tempFilePaths || [];
|
||||
if (!paths.length) return [];
|
||||
|
||||
const urls: string[] = [];
|
||||
for (const path of paths) {
|
||||
urls.push(await uploadRatingImage(path));
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
export async function uploadRatingImage(tempFilePath: string): Promise<string> {
|
||||
const { API_BASE, CLIENT_APP, getToken } = await import('./api');
|
||||
const { compressWeappImageIfNeeded } = await import('./compress-image');
|
||||
const token = getToken();
|
||||
if (!token) throw new Error('请先登录');
|
||||
|
||||
const filePath = await compressWeappImageIfNeeded(tempFilePath);
|
||||
const res = await Taro.uploadFile({
|
||||
url: `${API_BASE}/common/resources/upload`,
|
||||
filePath,
|
||||
name: 'file',
|
||||
formData: {
|
||||
bizType: 'STORE_RATING',
|
||||
mediaType: 'IMAGE',
|
||||
},
|
||||
header: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'X-Client-App': CLIENT_APP,
|
||||
},
|
||||
});
|
||||
|
||||
let body: { code?: number; message?: string; data?: { url?: string } } = {};
|
||||
try {
|
||||
body = JSON.parse(String(res.data || '{}')) as typeof body;
|
||||
} catch {
|
||||
throw new Error('图片上传响应异常');
|
||||
}
|
||||
if (res.statusCode === 401 || body.code === 401) {
|
||||
throw new Error(body.message || '登录已过期,请重新登录');
|
||||
}
|
||||
if (res.statusCode >= 400 || body.code !== 0 || !body.data?.url) {
|
||||
throw new Error(body.message || '图片上传失败');
|
||||
}
|
||||
return body.data.url;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '好客权益使用说明',
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import '../../styles/legal.css';
|
||||
import Taro from '@tarojs/taro';
|
||||
import PageShell from '../../components/PageShell';
|
||||
import SubPageHeader from '../../components/SubPageHeader';
|
||||
import { toast } from '../../lib/api';
|
||||
import { getBrandAssetsSync, loadBrandAssets } from '../../lib/brand-assets';
|
||||
import {
|
||||
BENEFIT_RULES_FOOTER,
|
||||
BENEFIT_RULES_SECTIONS,
|
||||
BENEFIT_RULES_SUMMARY,
|
||||
BENEFIT_RULES_TITLE,
|
||||
} from '../../lib/benefit-copy';
|
||||
|
||||
export default function BenefitRulesPage() {
|
||||
const [phone, setPhone] = useState(() => getBrandAssetsSync().customerServicePhone);
|
||||
|
||||
useEffect(() => {
|
||||
void loadBrandAssets().then((brand) => setPhone(brand.customerServicePhone));
|
||||
}, []);
|
||||
|
||||
function dial() {
|
||||
const tel = phone.replace(/-/g, '');
|
||||
Taro.makePhoneCall({ phoneNumber: tel }).catch(() => toast('无法拨打电话'));
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell variant="sub" className="legal-page benefit-rules-page">
|
||||
<SubPageHeader title={BENEFIT_RULES_TITLE} />
|
||||
<View className="sub-page-body inset-page legal-body">
|
||||
<View className="benefit-rules-summary">
|
||||
<Text className="benefit-rules-summary-text">
|
||||
{BENEFIT_RULES_SUMMARY.replace(/不可兑现、不可转卖。$/, '')}
|
||||
<Text className="benefit-rules-em">不可兑现、不可转卖。</Text>
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{BENEFIT_RULES_SECTIONS.map((section) => (
|
||||
<View key={section.heading} className="benefit-rules-section">
|
||||
<View className="benefit-rules-heading-row">
|
||||
<View className="benefit-rules-heading-bar" />
|
||||
<Text className="benefit-rules-heading">{section.heading}</Text>
|
||||
</View>
|
||||
{section.paragraphs.map((p, i) => {
|
||||
const emphasize = 'emphasize' in section ? section.emphasize : '';
|
||||
const emphasizeAll = 'emphasizeAll' in section && section.emphasizeAll;
|
||||
if (emphasizeAll) {
|
||||
return (
|
||||
<Text key={`${section.heading}-${i}`} className="benefit-rules-paragraph benefit-rules-em">
|
||||
{p}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
if (emphasize && p.includes(emphasize)) {
|
||||
const [before, after] = p.split(emphasize);
|
||||
return (
|
||||
<Text key={`${section.heading}-${i}`} className="benefit-rules-paragraph">
|
||||
{before}
|
||||
<Text className="benefit-rules-em">{emphasize}</Text>
|
||||
{after}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Text key={`${section.heading}-${i}`} className="benefit-rules-paragraph">
|
||||
{p}
|
||||
</Text>
|
||||
);
|
||||
})}
|
||||
{section.heading === '八、联系客服' ? (
|
||||
<Text className="benefit-rules-phone" onClick={dial}>
|
||||
{phone}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
))}
|
||||
|
||||
<Text className="benefit-rules-footer">{BENEFIT_RULES_FOOTER}</Text>
|
||||
</View>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { View, Text, Image } from '@tarojs/components';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
||||
import PageShell from '../../components/PageShell';
|
||||
import WechatShareReady from '../../components/WechatShareReady';
|
||||
@@ -7,14 +7,16 @@ import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../co
|
||||
import BenefitFigure from '../../components/BenefitFigure';
|
||||
import { goLogin } from '../../lib/auth-nav';
|
||||
import { isLoggedIn, request, toast } from '../../lib/api';
|
||||
import { navBarStyle, tabNavContentStyle, useNavBarMetrics } from '../../lib/nav-bar';
|
||||
import { navBarStyle, useNavBarMetrics } from '../../lib/nav-bar';
|
||||
import {
|
||||
buildSceneSharePayload,
|
||||
toWeappShareMessage,
|
||||
toWeappShareTimeline,
|
||||
} from '../../lib/wechat-share';
|
||||
import { formatMoney } from '../../lib/money';
|
||||
import iconBenefit from '../../assets/tabbar/benefit-active.png';
|
||||
import { BENEFIT_SLOGAN } from '../../lib/benefit-copy';
|
||||
import BenefitIntroCard from '../../components/BenefitIntroCard';
|
||||
import type { StoreRatingDto } from '@dukang/shared-types';
|
||||
|
||||
type BenefitSummary = {
|
||||
totalBalance: number;
|
||||
@@ -36,10 +38,30 @@ type RedeemHistoryItem = {
|
||||
id: string;
|
||||
redeemNo: string;
|
||||
amount: number;
|
||||
storeId?: string;
|
||||
storeName: string;
|
||||
createdAt: string;
|
||||
rating?: StoreRatingDto | null;
|
||||
};
|
||||
|
||||
const BENEFIT_TAB_KEY = 'dukang_benefit_tab';
|
||||
|
||||
function readBenefitTab(): 'available' | 'history' {
|
||||
try {
|
||||
return Taro.getStorageSync(BENEFIT_TAB_KEY) === 'history' ? 'history' : 'available';
|
||||
} catch {
|
||||
return 'available';
|
||||
}
|
||||
}
|
||||
|
||||
function writeBenefitTab(next: 'available' | 'history') {
|
||||
try {
|
||||
Taro.setStorageSync(BENEFIT_TAB_KEY, next);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
function usagePercent(coupon: CouponItem) {
|
||||
const total = Number(coupon.totalAmount);
|
||||
if (total <= 0) return 0;
|
||||
@@ -52,7 +74,7 @@ export default function BenefitPage() {
|
||||
const [summary, setSummary] = useState<BenefitSummary | null>(null);
|
||||
const [coupons, setCoupons] = useState<CouponItem[]>([]);
|
||||
const [redeemHistory, setRedeemHistory] = useState<RedeemHistoryItem[]>([]);
|
||||
const [tab, setTab] = useState<'available' | 'history'>('available');
|
||||
const [tab, setTab] = useState<'available' | 'history'>(readBenefitTab);
|
||||
|
||||
const resetGuestState = useCallback(() => {
|
||||
setSummary(null);
|
||||
@@ -119,18 +141,7 @@ export default function BenefitPage() {
|
||||
<PageShell variant="tab" className="benefit-page">
|
||||
<WechatShareReady payload={sharePayload} />
|
||||
<View className="benefit-header" style={navBarStyle(metrics)} aria-label="好客权益">
|
||||
{process.env.TARO_ENV !== 'h5' ? (
|
||||
<Text className="benefit-header-title">好客权益</Text>
|
||||
) : null}
|
||||
<View
|
||||
className="benefit-header__content"
|
||||
style={tabNavContentStyle(metrics)}
|
||||
>
|
||||
<View className="benefit-header-city">
|
||||
<View className="benefit-header-city-pin" />
|
||||
<Text>郑州市</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Text className="benefit-header-title">好客权益</Text>
|
||||
</View>
|
||||
|
||||
{!loggedIn ? (
|
||||
@@ -146,40 +157,50 @@ export default function BenefitPage() {
|
||||
</View>
|
||||
) : (
|
||||
<View className="benefit-main">
|
||||
<BenefitIntroCard className="benefit-intro-card--page" />
|
||||
<View className="benefit-hero">
|
||||
<View className="benefit-hero-top">
|
||||
<View>
|
||||
<Text className="benefit-hero-label">当前好客权益余额</Text>
|
||||
<View className="benefit-hero-amount">
|
||||
<BenefitFigure
|
||||
value={summary ? formatMoney(summary.totalBalance) : '--'}
|
||||
size="xl"
|
||||
className="benefit-hero-value"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View className="benefit-hero-logo">
|
||||
<Image className="benefit-hero-logo-img" src={iconBenefit} mode="aspectFit" />
|
||||
<Text className="benefit-hero-label">好客权益</Text>
|
||||
<View className="benefit-hero-amount">
|
||||
<BenefitFigure
|
||||
value={summary ? formatMoney(summary.totalBalance) : '--'}
|
||||
size="xl"
|
||||
className="benefit-hero-value"
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View
|
||||
className="benefit-hero-cta"
|
||||
onClick={() => Taro.navigateTo({ url: '/pages/redeem/index' })}
|
||||
>
|
||||
<Text>去使用</Text>
|
||||
<View className="benefit-hero-actions">
|
||||
<View
|
||||
className="benefit-hero-cta benefit-hero-cta--primary"
|
||||
onClick={() => Taro.switchTab({ url: '/pages/home/index' })}
|
||||
>
|
||||
<Text>去选好酒</Text>
|
||||
</View>
|
||||
<View
|
||||
className="benefit-hero-cta benefit-hero-cta--secondary"
|
||||
onClick={() => Taro.navigateTo({ url: '/pages/redeem/index' })}
|
||||
>
|
||||
<Text>去使用</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="benefit-tabs">
|
||||
<Text
|
||||
className={`benefit-tab${tab === 'available' ? ' benefit-tab--active' : ''}`}
|
||||
onClick={() => setTab('available')}
|
||||
onClick={() => {
|
||||
setTab('available');
|
||||
writeBenefitTab('available');
|
||||
}}
|
||||
>
|
||||
可用权益
|
||||
</Text>
|
||||
<Text
|
||||
className={`benefit-tab${tab === 'history' ? ' benefit-tab--active' : ''}`}
|
||||
onClick={() => setTab('history')}
|
||||
onClick={() => {
|
||||
setTab('history');
|
||||
writeBenefitTab('history');
|
||||
}}
|
||||
>
|
||||
历史记录
|
||||
</Text>
|
||||
@@ -187,7 +208,7 @@ export default function BenefitPage() {
|
||||
|
||||
{tab === 'available' ? (
|
||||
available.length === 0 ? (
|
||||
<View className="u-empty">暂无可用权益</View>
|
||||
<View className="u-empty">{BENEFIT_SLOGAN}</View>
|
||||
) : (
|
||||
available.map((c) => (
|
||||
<View key={c.id} className="benefit-coupon">
|
||||
@@ -243,6 +264,17 @@ export default function BenefitPage() {
|
||||
<Text className="benefit-coupon-meta">
|
||||
{r.createdAt ? String(r.createdAt).slice(0, 19).replace('T', ' ') : '-'}
|
||||
</Text>
|
||||
<Text
|
||||
className={`benefit-coupon-btn${r.rating ? ' benefit-coupon-btn--ghost' : ''}`}
|
||||
onClick={() => {
|
||||
writeBenefitTab('history');
|
||||
Taro.navigateTo({
|
||||
url: `/pages/redeem-success/index?id=${r.id}&from=history`,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{r.rating ? '已评价' : '去评价'}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
))
|
||||
|
||||
@@ -9,10 +9,13 @@ import Taro, {
|
||||
} from '@tarojs/taro';
|
||||
import PageShell from '../../components/PageShell';
|
||||
import TabMainHeader from '../../components/TabMainHeader';
|
||||
import CouponBadge from '../../components/CouponBadge';
|
||||
import BenefitSloganBar from '../../components/BenefitSloganBar';
|
||||
import { BENEFIT_GIFT_TAG, BENEFIT_TAG } from '../../lib/benefit-copy';
|
||||
import WechatShareReady from '../../components/WechatShareReady';
|
||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||
import JiuzuSplash from '../../components/JiuzuSplash';
|
||||
import { goLogin } from '../../lib/auth-nav';
|
||||
import { hasJiuzuSplashPlayed } from '../../lib/jiuzu-splash';
|
||||
import { getToken, isLoggedIn, request, toast } from '../../lib/api';
|
||||
import {
|
||||
getHomeCatalogCache,
|
||||
@@ -36,6 +39,7 @@ import {
|
||||
toWeappShareTimeline,
|
||||
} from '../../lib/wechat-share';
|
||||
import { trackPageView } from '../../lib/analytics';
|
||||
import iconStoreBenefit from '../../assets/icons/store-benefit-y.png';
|
||||
type Product = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -71,7 +75,15 @@ function aromaSectionId(key: AromaKey) {
|
||||
return `aroma-section-${key}`;
|
||||
}
|
||||
|
||||
/** 商品图左上角权益角标:权益额 = benefitDisplay ?? price */
|
||||
function formatBenefitCorner(p: Product): string {
|
||||
const n = Number(p.benefitDisplay ?? p.price);
|
||||
if (!Number.isFinite(n) || n <= 0) return '';
|
||||
return String(Math.round(n));
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
const [showSplash, setShowSplash] = useState(() => !hasJiuzuSplashPlayed());
|
||||
const [activeAroma, setActiveAroma] = useState<AromaKey>('QINGXIANG');
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -282,6 +294,7 @@ export default function HomePage() {
|
||||
function renderProductCard(p: Product) {
|
||||
const thumb = getProductMainImage(p);
|
||||
const spec = p.subtitle || p.spec || '';
|
||||
const benefitCorner = formatBenefitCorner(p);
|
||||
return (
|
||||
<View key={p.id} className="home-product-card">
|
||||
<View className="home-product-card-inner" onClick={() => openProductDetail(p.id)}>
|
||||
@@ -291,6 +304,20 @@ export default function HomePage() {
|
||||
) : (
|
||||
<View className="home-product-thumb home-product-thumb--empty" />
|
||||
)}
|
||||
{benefitCorner ? (
|
||||
<View className="home-benefit-ribbon-clip">
|
||||
<View className="home-benefit-ribbon">
|
||||
<View className="home-benefit-ribbon-dk">
|
||||
<Image
|
||||
className="home-benefit-ribbon-dk-icon"
|
||||
src={iconStoreBenefit}
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</View>
|
||||
<Text className="home-benefit-ribbon-num">{benefitCorner}</Text>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
<View className="home-product-main">
|
||||
<View className="home-product-row">
|
||||
@@ -299,7 +326,10 @@ export default function HomePage() {
|
||||
</View>
|
||||
{spec ? <Text className="home-product-sub">{spec}</Text> : null}
|
||||
<View className="home-product-footer">
|
||||
<CouponBadge amount={p.benefitDisplay ?? p.price} label="好客权益" />
|
||||
<View className="home-product-tags">
|
||||
<Text className="home-gift-tag">{BENEFIT_GIFT_TAG}</Text>
|
||||
{/* <Text className="home-benefit-tag">{BENEFIT_TAG}</Text> */}
|
||||
</View>
|
||||
</View>
|
||||
<View className="home-product-actions">
|
||||
{canPickupOnSite(p) ? (
|
||||
@@ -354,6 +384,10 @@ export default function HomePage() {
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<View className="home-slogan-wrap">
|
||||
<BenefitSloganBar />
|
||||
</View>
|
||||
|
||||
<View className="home-aroma-nav">
|
||||
<View className="home-aroma-tabs">
|
||||
{visibleAromaTabs.map((t) => (
|
||||
@@ -393,7 +427,8 @@ export default function HomePage() {
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{shouldRenderPageTabBar() ? <UserTabBar selected={0} /> : null}
|
||||
{shouldRenderPageTabBar() && !showSplash ? <UserTabBar selected={0} /> : null}
|
||||
{showSplash ? <JiuzuSplash onDone={() => setShowSplash(false)} /> : null}
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ import iconCs from '../../assets/icons/联系客服.png';
|
||||
import iconQualification from '../../assets/icons/资质公示.png';
|
||||
import iconAbout from '../../assets/icons/关于我们.png';
|
||||
import { formatMoney } from '../../lib/money';
|
||||
import BenefitSloganBar from '../../components/BenefitSloganBar';
|
||||
import { BENEFIT_RULES_PATH } from '../../lib/benefit-copy';
|
||||
|
||||
const ORDER_SHORTCUTS = [
|
||||
{ tab: 'pending_pay', icon: iconPendingPay, label: '待付款' },
|
||||
@@ -56,7 +58,7 @@ const SERVICES = [
|
||||
{ icon: iconStores, label: '可用门店', tab: '/pages/stores/index' },
|
||||
{ icon: iconCs, label: '联系客服', url: '/pages/customer-service/index' },
|
||||
{ icon: iconQualification, label: '资质公示', action: 'qualification' as const },
|
||||
{ icon: iconAbout, label: '关于我们', action: 'about' as const },
|
||||
{ icon: iconAbout, label: '好客权益规则', url: BENEFIT_RULES_PATH },
|
||||
{ icon: iconAbout, label: '发票管理', url: '/pages/invoice-titles/index' },
|
||||
] as const;
|
||||
|
||||
@@ -309,10 +311,6 @@ export default function MinePage() {
|
||||
}
|
||||
if ('action' in item && item.action === 'qualification') {
|
||||
setQualificationOpen(true);
|
||||
return;
|
||||
}
|
||||
if ('action' in item && item.action === 'about') {
|
||||
toast('杜康好客 · 传承千年酒文化');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +433,7 @@ export default function MinePage() {
|
||||
|
||||
<View className="mine-main">
|
||||
<View className="mine-card">
|
||||
<BenefitSloganBar className="mine-benefit-slogan" />
|
||||
<View className="mine-card-head">
|
||||
<Text className="mine-card-title">我的资产</Text>
|
||||
<Text
|
||||
@@ -446,7 +445,7 @@ export default function MinePage() {
|
||||
</View>
|
||||
<View className="mine-asset-panel">
|
||||
<View>
|
||||
<Text className="mine-asset-label">好客权益余额</Text>
|
||||
<Text className="mine-asset-label">好客权益</Text>
|
||||
<View className="mine-asset-amount">
|
||||
<BenefitFigure value={formatMoney(benefitBalance)} size="lg" className="mine-asset-value" />
|
||||
</View>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { fetchUserProfile } from '../../lib/pay-wechat';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import { getProductMainImage } from '../../lib/product-images';
|
||||
import BenefitFigure from '../../components/BenefitFigure';
|
||||
import OrderQtyControls from '../../components/OrderQtyControls';
|
||||
|
||||
type PreviewProduct = {
|
||||
id: string;
|
||||
@@ -211,21 +212,11 @@ export default function OrderConfirmPickupPage() {
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="order-qty-row">
|
||||
<Text>购买数量</Text>
|
||||
<View className="order-qty-controls">
|
||||
<View
|
||||
className="order-qty-btn"
|
||||
onClick={() => updateQuantity(quantity - 1)}
|
||||
>
|
||||
<Text>−</Text>
|
||||
</View>
|
||||
<Text className="order-qty-value">{quantity}</Text>
|
||||
<View className="order-qty-btn" onClick={() => updateQuantity(quantity + 1)}>
|
||||
<Text>+</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<OrderQtyControls
|
||||
value={quantity}
|
||||
unitLabel={unitLabel}
|
||||
onChange={updateQuantity}
|
||||
/>
|
||||
{!quantityOk ? (
|
||||
<Text className="order-qty-hint">
|
||||
{`现场提货至少购买 ${minQty}${unitLabel},请调整数量`}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { canCrossCity, isCrossCityAddress } from '../../lib/product-fulfillment'
|
||||
import { loadLocalDeliveries, matchLocalDelivery, resolveLocalDeliveryHintHtml } from '../../lib/local-delivery';
|
||||
import { getProductMainImage } from '../../lib/product-images';
|
||||
import BenefitFigure from '../../components/BenefitFigure';
|
||||
import OrderQtyControls from '../../components/OrderQtyControls';
|
||||
|
||||
type Address = {
|
||||
id: string;
|
||||
@@ -379,24 +380,11 @@ export default function OrderConfirmPage() {
|
||||
<Text className="order-product-price">¥{Number(preview.product.price).toFixed(2)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="order-qty-row">
|
||||
<Text>购买数量</Text>
|
||||
<View className="order-qty-controls">
|
||||
<View
|
||||
className="order-qty-btn"
|
||||
onClick={() => updateQuantity(quantity - 1)}
|
||||
>
|
||||
<Text>−</Text>
|
||||
</View>
|
||||
<Text className="order-qty-value">{quantity}</Text>
|
||||
<View
|
||||
className="order-qty-btn"
|
||||
onClick={() => updateQuantity(quantity + 1)}
|
||||
>
|
||||
<Text>+</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<OrderQtyControls
|
||||
value={quantity}
|
||||
unitLabel={unitLabel}
|
||||
onChange={updateQuantity}
|
||||
/>
|
||||
{!quantityOk ? (
|
||||
<Text className="order-qty-hint">
|
||||
{isCross
|
||||
|
||||
@@ -340,7 +340,7 @@ export default function OrderDetailPage() {
|
||||
<Text className="order-card-title">商品信息</Text>
|
||||
<View className="order-row">
|
||||
<Text className="order-row-label">{productName}</Text>
|
||||
<Text className="order-row-value">x{quantity}</Text>
|
||||
<Text className="order-row-value">x{quantity}瓶</Text>
|
||||
</View>
|
||||
<View className="order-row">
|
||||
<Text className="order-row-label">实付金额</Text>
|
||||
|
||||
@@ -159,7 +159,7 @@ export default function OrdersPage() {
|
||||
<View style={{ flex: 1, minWidth: 0 }}>
|
||||
<Text className="order-list-name">{productName}</Text>
|
||||
<View className="order-list-meta-row">
|
||||
<Text className="order-list-meta">数量 {qty}</Text>
|
||||
<Text className="order-list-meta">数量 {qty}瓶</Text>
|
||||
<Text className="order-list-meta">单价 ¥{unitPrice.toFixed(2)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -19,7 +19,7 @@ import { applyWechatLoginResult } from '../../lib/wechat-auth';
|
||||
import { isWechatEnv } from '../../lib/weixin';
|
||||
import { goLogin } from '../../lib/auth-nav';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import payLogo from '../../assets/logo2.png';
|
||||
import { getBrandAssetsSync } from '../../lib/brand-assets';
|
||||
|
||||
export default function PayPage() {
|
||||
const router = useRouter();
|
||||
@@ -173,7 +173,7 @@ export default function PayPage() {
|
||||
<View className="sub-page-body">
|
||||
<View className="pay-status">
|
||||
<View className="pay-status-icon">
|
||||
<Image className="pay-status-brand" src={payLogo} mode="aspectFit" />
|
||||
<Image className="pay-status-brand" src={getBrandAssetsSync().brandLogoMarkUrl} mode="aspectFit" />
|
||||
</View>
|
||||
<Text className="pay-status-title">
|
||||
{needsWechatAuth ? '需完成微信授权' : '待支付'}
|
||||
|
||||
@@ -135,7 +135,7 @@ export default function PickupReceivePage() {
|
||||
<View style={{ flex: 1 }}>
|
||||
<Text className="order-product-name">{name}</Text>
|
||||
{spec ? <Text className="u-muted">{spec}</Text> : null}
|
||||
<Text className="u-muted">×{order.quantity ?? 1}</Text>
|
||||
<Text className="u-muted">×{order.quantity ?? 1}瓶</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { View, Text, Image } from '@tarojs/components';
|
||||
import '../../styles/product-detail.css';
|
||||
import '../../styles/benefit-promo.css';
|
||||
import Taro, {
|
||||
useDidShow,
|
||||
usePageScroll,
|
||||
@@ -13,7 +14,7 @@ import PageShell from '../../components/PageShell';
|
||||
import PageNavBar from '../../components/PageNavBar';
|
||||
import ProductCarousel from '../../components/ProductCarousel';
|
||||
import WechatShareReady from '../../components/WechatShareReady';
|
||||
import BenefitFigure from '../../components/BenefitFigure';
|
||||
import BenefitIntroCard from '../../components/BenefitIntroCard';
|
||||
import { goLogin } from '../../lib/auth-nav';
|
||||
import { ensurePayReady } from '../../lib/pay-ready';
|
||||
import { isLoggedIn, request, toast } from '../../lib/api';
|
||||
@@ -156,9 +157,6 @@ export default function ProductDetailPage() {
|
||||
}, [product, specEnabled, skus, selected, attrs]);
|
||||
|
||||
const displayPrice = activeSku ? Number(activeSku.price) : Number(product?.price ?? 0);
|
||||
const displayBenefit = activeSku
|
||||
? Number(activeSku.benefitAmount)
|
||||
: Number(product?.benefitDisplay ?? product?.benefitAmount ?? product?.price ?? 0);
|
||||
const fulfillment = activeSku
|
||||
? {
|
||||
allowOnlinePurchase: activeSku.allowOnlinePurchase,
|
||||
@@ -276,6 +274,8 @@ export default function ProductDetailPage() {
|
||||
</View>
|
||||
|
||||
<View className="product-detail-info">
|
||||
<BenefitIntroCard showLink className="product-detail-benefit-intro" />
|
||||
|
||||
<View className="product-detail-price">
|
||||
<Text className="product-detail-price-symbol">¥</Text>
|
||||
<Text className="product-detail-price-value">{displayPrice.toFixed(2)}</Text>
|
||||
@@ -317,22 +317,6 @@ export default function ProductDetailPage() {
|
||||
))}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<View className="product-detail-promo">
|
||||
<View className="product-detail-promo-glow" />
|
||||
<View className="product-detail-promo-head">
|
||||
<View className="product-detail-promo-icon">
|
||||
<Text className="product-detail-promo-icon-text">惠</Text>
|
||||
</View>
|
||||
<View className="product-detail-promo-title">
|
||||
<Text>买杜康美酒 · 享全城好客礼遇</Text>
|
||||
<BenefitFigure value={String(displayBenefit)} size="sm" className="product-detail-promo-amount" />
|
||||
</View>
|
||||
</View>
|
||||
<Text className="product-detail-promo-desc">
|
||||
购酒即享本城专属好客权益,为您安排一场地道饭局。权益金可直接用于本地签约门店消费,到店享用,醇香美酒配佳肴。
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="product-detail-content">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationStyle: 'custom',
|
||||
navigationBarTitleText: '核销成功',
|
||||
navigationBarTitleText: '评价门店',
|
||||
});
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { View, Text, Image, Textarea } from '@tarojs/components';
|
||||
import '../../styles/redeem.css';
|
||||
import Taro, { useRouter } from '@tarojs/taro';
|
||||
import Taro, { useLoad, useRouter } from '@tarojs/taro';
|
||||
import {
|
||||
STORE_RATING_MAX_COMMENT,
|
||||
STORE_RATING_MAX_IMAGES,
|
||||
STORE_RATING_QUICK_TAGS,
|
||||
type StoreRatingDto,
|
||||
} from '@dukang/shared-types';
|
||||
import PageShell from '../../components/PageShell';
|
||||
import SubPageHeader from '../../components/SubPageHeader';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import { formatShanghaiDateTime } from '../../lib/datetime';
|
||||
import { formatMoney, toMoneyNumber } from '../../lib/money';
|
||||
import BenefitFigure from '../../components/BenefitFigure';
|
||||
import { toMoneyNumber } from '../../lib/money';
|
||||
import { chooseAndUploadRatingImages } from '../../lib/upload-rating-image';
|
||||
|
||||
const LAST_REDEEM_RESULT_KEY = 'lastRedeemResult';
|
||||
|
||||
const SCORE_LABELS = ['', '较差', '一般', '还行', '很好', '非常好'] as const;
|
||||
|
||||
type RedeemRecord = {
|
||||
id: string;
|
||||
redeemNo: string;
|
||||
@@ -18,59 +26,106 @@ type RedeemRecord = {
|
||||
storeId: string;
|
||||
storeName: string;
|
||||
createdAt: string;
|
||||
rating?: StoreRatingDto | null;
|
||||
};
|
||||
|
||||
/** 与权益「历史记录」一致:2026-08-03 13:53:03(Asia/Shanghai) */
|
||||
function formatChinaDateTime(input?: string | null) {
|
||||
return formatShanghaiDateTime(input ?? new Date());
|
||||
function formatAmountYuan(amount: unknown) {
|
||||
const n = toMoneyNumber(amount);
|
||||
if (Math.abs(n - Math.round(n)) < 1e-9) return String(Math.round(n));
|
||||
return n.toFixed(2).replace(/\.?0+$/, '');
|
||||
}
|
||||
|
||||
function StarRating({
|
||||
label,
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
label: string;
|
||||
value: number;
|
||||
onChange: (score: number) => void;
|
||||
}) {
|
||||
return (
|
||||
<View className="redeem-rating-row">
|
||||
<Text className="redeem-rating-label">{label}</Text>
|
||||
<View className="redeem-star-row">
|
||||
{[1, 2, 3, 4, 5].map((score) => (
|
||||
<Text
|
||||
key={score}
|
||||
className={`redeem-star-btn${score <= value ? ' redeem-star-btn--active' : ''}`}
|
||||
onClick={() => onChange(score)}
|
||||
>
|
||||
★
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
function formatVisitLine(createdAt?: string | null, amount?: unknown) {
|
||||
const full = formatShanghaiDateTime(createdAt ?? new Date());
|
||||
if (full === '—') return `核销用餐权益 ${formatAmountYuan(amount)}`;
|
||||
const datePart = full.slice(0, 10);
|
||||
const time = full.slice(11, 16);
|
||||
const today = formatShanghaiDateTime(new Date()).slice(0, 10);
|
||||
const prefix = datePart === today ? '今日' : datePart.slice(5);
|
||||
return `${prefix} ${time} · 核销用餐权益 ${formatAmountYuan(amount)}`;
|
||||
}
|
||||
|
||||
function readCachedRecord(): RedeemRecord | null {
|
||||
try {
|
||||
const cached = Taro.getStorageSync(LAST_REDEEM_RESULT_KEY);
|
||||
return cached ? (JSON.parse(String(cached)) as RedeemRecord) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default function RedeemSuccessPage() {
|
||||
const router = useRouter();
|
||||
const [serviceScore, setServiceScore] = useState(5);
|
||||
const [envScore, setEnvScore] = useState(5);
|
||||
const [fromHistory, setFromHistory] = useState(false);
|
||||
const [record, setRecord] = useState<RedeemRecord | null>(null);
|
||||
const [score, setScore] = useState(5);
|
||||
const [tags, setTags] = useState<string[]>(['菜品好', '环境佳', '服务周到']);
|
||||
const [comment, setComment] = useState('');
|
||||
const [imageUrls, setImageUrls] = useState<string[]>([]);
|
||||
const [coverUrl, setCoverUrl] = useState('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const rated = Boolean(record?.rating);
|
||||
|
||||
const record = useMemo<RedeemRecord | null>(() => {
|
||||
try {
|
||||
const cached = Taro.getStorageSync(LAST_REDEEM_RESULT_KEY);
|
||||
return cached ? (JSON.parse(String(cached)) as RedeemRecord) : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
const applyRating = useCallback((rating: StoreRatingDto) => {
|
||||
const nextScore = Number(rating.serviceScore || rating.envScore || 5);
|
||||
setScore(Number.isFinite(nextScore) && nextScore > 0 ? Math.min(5, Math.round(nextScore)) : 5);
|
||||
setTags(Array.isArray(rating.tags) ? rating.tags : []);
|
||||
setComment(String(rating.comment || ''));
|
||||
setImageUrls(Array.isArray(rating.imageUrls) ? rating.imageUrls : []);
|
||||
}, []);
|
||||
|
||||
const loadRecord = useCallback(
|
||||
async (id: string) => {
|
||||
try {
|
||||
let data: RedeemRecord | null = null;
|
||||
try {
|
||||
data = await request<RedeemRecord>(`/redeem/records/${id}`);
|
||||
} catch {
|
||||
const records = await request<{ list?: RedeemRecord[] } | RedeemRecord[]>(
|
||||
'/redeem/records?page=1&pageSize=50',
|
||||
);
|
||||
const list = Array.isArray(records) ? records : records?.list ?? [];
|
||||
data = list.find((item) => String(item.id) === id) ?? null;
|
||||
}
|
||||
if (!data) {
|
||||
toast('核销记录不存在');
|
||||
return;
|
||||
}
|
||||
setRecord(data);
|
||||
if (data.rating) applyRating(data.rating);
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : '加载失败');
|
||||
}
|
||||
},
|
||||
[applyRating],
|
||||
);
|
||||
|
||||
useLoad((options) => {
|
||||
const id = String(options?.id || router.params.id || '').trim();
|
||||
const from = String(options?.from || router.params.from || '');
|
||||
setFromHistory(from === 'history');
|
||||
if (id) {
|
||||
void loadRecord(id);
|
||||
return;
|
||||
}
|
||||
const cached = readCachedRecord();
|
||||
if (cached) setRecord(cached);
|
||||
});
|
||||
|
||||
const amount = toMoneyNumber(record?.amount ?? router.params.amount);
|
||||
const storeName = record?.storeName || '门店';
|
||||
const redeemNo = record?.redeemNo || '—';
|
||||
const redeemedAt = formatChinaDateTime(record?.createdAt);
|
||||
const visitLine = formatVisitLine(record?.createdAt, amount);
|
||||
|
||||
useEffect(() => {
|
||||
if (!record?.storeId) return;
|
||||
void request<{ coverUrl?: string | null }>(`/stores/${record.storeId}`)
|
||||
.then((store) => {
|
||||
const url = String(store?.coverUrl || '').trim();
|
||||
if (url) setCoverUrl(url);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}, [record?.storeId]);
|
||||
|
||||
function clearCache() {
|
||||
try {
|
||||
@@ -80,81 +135,207 @@ export default function RedeemSuccessPage() {
|
||||
}
|
||||
}
|
||||
|
||||
function goBenefit() {
|
||||
function leave() {
|
||||
clearCache();
|
||||
const pages = Taro.getCurrentPages();
|
||||
if (fromHistory && pages.length > 1) {
|
||||
Taro.navigateBack();
|
||||
return;
|
||||
}
|
||||
Taro.switchTab({ url: '/pages/benefit/index' });
|
||||
}
|
||||
|
||||
function goHome() {
|
||||
clearCache();
|
||||
Taro.switchTab({ url: '/pages/home/index' });
|
||||
function toggleTag(tag: string) {
|
||||
if (rated) return;
|
||||
setTags((prev) => (prev.includes(tag) ? prev.filter((t) => t !== tag) : [...prev, tag]));
|
||||
}
|
||||
|
||||
async function addPhotos() {
|
||||
if (rated || uploading) return;
|
||||
if (imageUrls.length >= STORE_RATING_MAX_IMAGES) {
|
||||
toast(`最多上传${STORE_RATING_MAX_IMAGES}张图片`);
|
||||
return;
|
||||
}
|
||||
setUploading(true);
|
||||
try {
|
||||
const urls = await chooseAndUploadRatingImages(imageUrls.length);
|
||||
if (urls.length) setImageUrls((prev) => [...prev, ...urls].slice(0, STORE_RATING_MAX_IMAGES));
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : '上传失败');
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
}
|
||||
|
||||
function removePhoto(url: string) {
|
||||
if (rated) return;
|
||||
setImageUrls((prev) => prev.filter((item) => item !== url));
|
||||
}
|
||||
|
||||
async function submitRatingAndFinish() {
|
||||
if (!record?.id) {
|
||||
toast('找不到核销记录');
|
||||
return;
|
||||
}
|
||||
if (rated) {
|
||||
leave();
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
if (record?.id) {
|
||||
await request('/redeem/ratings', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
redeemRecordId: record.id,
|
||||
serviceScore,
|
||||
envScore,
|
||||
},
|
||||
});
|
||||
toast('评价已提交', 'success');
|
||||
}
|
||||
} catch {
|
||||
/* 评价失败不阻塞返回 */
|
||||
await request('/redeem/ratings', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
redeemRecordId: record.id,
|
||||
serviceScore: score,
|
||||
envScore: score,
|
||||
comment: comment.trim(),
|
||||
tags,
|
||||
imageUrls,
|
||||
},
|
||||
});
|
||||
toast('评价已提交', 'success');
|
||||
setRecord((prev) =>
|
||||
prev
|
||||
? {
|
||||
...prev,
|
||||
rating: { serviceScore: score, envScore: score, comment, tags, imageUrls },
|
||||
}
|
||||
: prev,
|
||||
);
|
||||
setTimeout(() => leave(), 400);
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : '评价失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
goBenefit();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell variant="sub" className="redeem-success-page">
|
||||
<SubPageHeader title="核销成功" onBack={goBenefit} />
|
||||
<View className="sub-page-body">
|
||||
<View className="redeem-success-icon">
|
||||
<Text>✓</Text>
|
||||
</View>
|
||||
<Text className="redeem-success-title">核销成功</Text>
|
||||
<BenefitFigure value={formatMoney(amount)} size="lg" className="redeem-success-amount" />
|
||||
<Text className="redeem-success-desc">已在 {storeName} 完成核销</Text>
|
||||
|
||||
<View className="redeem-success-details">
|
||||
<View className="redeem-success-detail-row">
|
||||
<Text>核销门店</Text>
|
||||
<Text>{storeName}</Text>
|
||||
</View>
|
||||
<View className="redeem-success-detail-row">
|
||||
<Text>核销时间</Text>
|
||||
<Text>{redeemedAt}</Text>
|
||||
</View>
|
||||
<View className="redeem-success-detail-row">
|
||||
<Text>核销单号</Text>
|
||||
<Text className="redeem-success-mono">{redeemNo}</Text>
|
||||
<SubPageHeader title={rated ? '查看评价' : '评价门店'} onBack={leave} />
|
||||
<View className="sub-page-body review-page-body">
|
||||
<View className="review-store-card">
|
||||
{coverUrl ? (
|
||||
<Image className="review-store-cover" src={coverUrl} mode="aspectFill" />
|
||||
) : (
|
||||
<View className="review-store-cover review-store-cover--empty" />
|
||||
)}
|
||||
<View className="review-store-meta">
|
||||
<Text className="review-store-name">{storeName}</Text>
|
||||
<Text className="review-store-visit">{visitLine}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="redeem-success-rating">
|
||||
<Text className="redeem-success-rating-title">为门店服务评分</Text>
|
||||
<StarRating label="服务态度" value={serviceScore} onChange={setServiceScore} />
|
||||
<StarRating label="用餐环境" value={envScore} onChange={setEnvScore} />
|
||||
<View className="review-card">
|
||||
<Text className="review-card-title">本次到店体验</Text>
|
||||
<View className="review-star-row">
|
||||
{[1, 2, 3, 4, 5].map((value) => (
|
||||
<Text
|
||||
key={value}
|
||||
className={`review-star${value <= score ? ' review-star--active' : ''}`}
|
||||
onClick={() => {
|
||||
if (!rated) setScore(value);
|
||||
}}
|
||||
>
|
||||
★
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
<Text className="review-score-label">{SCORE_LABELS[score]}</Text>
|
||||
</View>
|
||||
|
||||
<View
|
||||
className={`redeem-submit${loading ? ' redeem-submit--disabled' : ''}`}
|
||||
onClick={() => {
|
||||
if (!loading) void submitRatingAndFinish();
|
||||
}}
|
||||
>
|
||||
<Text>{loading ? '提交中…' : '提交评价并返回'}</Text>
|
||||
<View className="review-card">
|
||||
<View className="review-section-head">
|
||||
<View className="review-section-bar" />
|
||||
<Text className="review-section-title">快捷标签</Text>
|
||||
</View>
|
||||
<View className="review-tag-list">
|
||||
{STORE_RATING_QUICK_TAGS.map((tag) => (
|
||||
<Text
|
||||
key={tag}
|
||||
className={`review-tag${tags.includes(tag) ? ' review-tag--active' : ''}`}
|
||||
onClick={() => toggleTag(tag)}
|
||||
>
|
||||
{tag}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
<View className="redeem-cancel-btn" onClick={goHome}>
|
||||
<Text>回到首页</Text>
|
||||
|
||||
<View className="review-card">
|
||||
<View className="review-section-head">
|
||||
<View className="review-section-bar" />
|
||||
<Text className="review-section-title">补充说明</Text>
|
||||
</View>
|
||||
{process.env.TARO_ENV === 'h5' ? (
|
||||
<textarea
|
||||
className="review-comment review-comment--native"
|
||||
placeholder="口味、环境、服务都可以写,选填"
|
||||
rows={4}
|
||||
maxLength={STORE_RATING_MAX_COMMENT}
|
||||
value={comment}
|
||||
disabled={rated}
|
||||
onChange={(e) => setComment(e.currentTarget.value)}
|
||||
/>
|
||||
) : (
|
||||
<Textarea
|
||||
className="review-comment"
|
||||
placeholder="口味、环境、服务都可以写,选填"
|
||||
maxlength={STORE_RATING_MAX_COMMENT}
|
||||
value={comment}
|
||||
disabled={rated}
|
||||
onInput={(e) => setComment(e.detail.value)}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View className="review-card">
|
||||
<View className="review-section-head">
|
||||
<View className="review-section-bar" />
|
||||
<Text className="review-section-title">上传图片</Text>
|
||||
</View>
|
||||
<View className="review-photos">
|
||||
{imageUrls.map((url) => (
|
||||
<View key={url} className="review-photo">
|
||||
<Image
|
||||
className="review-photo-img"
|
||||
src={url}
|
||||
mode="aspectFill"
|
||||
onClick={() => Taro.previewImage({ current: url, urls: imageUrls })}
|
||||
/>
|
||||
{!rated ? (
|
||||
<Text className="review-photo-remove" onClick={() => removePhoto(url)}>
|
||||
×
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
))}
|
||||
{!rated && imageUrls.length < STORE_RATING_MAX_IMAGES ? (
|
||||
<View className="review-photo-add" onClick={() => void addPhotos()}>
|
||||
<Text className="review-photo-add-plus">{uploading ? '…' : '+'}</Text>
|
||||
<Text className="review-photo-add-text">{uploading ? '上传中' : '添加'}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{!rated ? (
|
||||
<View
|
||||
className={`review-submit${loading || uploading ? ' review-submit--disabled' : ''}`}
|
||||
onClick={() => {
|
||||
if (!loading && !uploading) void submitRatingAndFinish();
|
||||
}}
|
||||
>
|
||||
<Text>{loading ? '提交中…' : '提交评价'}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
{!rated && !fromHistory ? (
|
||||
<Text className="review-skip" onClick={leave}>
|
||||
暂不评价
|
||||
</Text>
|
||||
) : null}
|
||||
<Text className="review-disclaimer">评价用于帮助其他到店客人选择门店,不赠送用餐权益。</Text>
|
||||
</View>
|
||||
</PageShell>
|
||||
);
|
||||
|
||||
@@ -100,11 +100,11 @@ export default function RedeemPage() {
|
||||
async function submit() {
|
||||
const value = Math.round(Number(amount) * 100) / 100;
|
||||
if (!Number.isFinite(value) || value < MIN_REDEEM_AMOUNT) {
|
||||
toast(`核销金额不能低于 ${MIN_REDEEM_AMOUNT.toFixed(2)} 元`);
|
||||
toast(`核销权益不能低于 ${MIN_REDEEM_AMOUNT.toFixed(2)} `);
|
||||
return;
|
||||
}
|
||||
if (value > redeemableMax) {
|
||||
toast(couponId ? '核销金额不能超过该权益可用余额' : '核销金额不能超过可用余额');
|
||||
toast(couponId ? '核销权益不能超过该权益可用核销权益' : '核销权益不能超过可用核销权益');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export default function RedeemPage() {
|
||||
<View className="sub-page-body">
|
||||
<View className="redeem-hero">
|
||||
<Text className="redeem-hero-label">
|
||||
{couponId ? '当前权益可用余额' : '可用余额'}
|
||||
{couponId ? '当前可用核销权益' : '可用核销权益'}
|
||||
</Text>
|
||||
<BenefitFigure
|
||||
value={redeemableMax > 0 ? formatMoney(redeemableMax) : '--'}
|
||||
@@ -149,7 +149,7 @@ export default function RedeemPage() {
|
||||
key={inputKey}
|
||||
className="redeem-input"
|
||||
type="digit"
|
||||
placeholder="输入核销金额"
|
||||
placeholder="输入核销权益"
|
||||
placeholderClass="redeem-input-placeholder"
|
||||
value={amount}
|
||||
maxlength={12}
|
||||
@@ -160,7 +160,7 @@ export default function RedeemPage() {
|
||||
</View>
|
||||
<View className="redeem-amount-foot">
|
||||
<View className="redeem-amount-hint">
|
||||
<Text>最高可核销</Text>
|
||||
<Text>最高可核销权益</Text>
|
||||
<BenefitFigure value={formatMoney(redeemableMax)} size="sm" />
|
||||
</View>
|
||||
<Text className="redeem-fill-max" onClick={fillMaxAmount}>
|
||||
@@ -169,7 +169,7 @@ export default function RedeemPage() {
|
||||
</View>
|
||||
<View className="redeem-tips">
|
||||
<Text className="redeem-tips-text">
|
||||
核销金额最低 0.01 元,小数最多两位。不超过可用权益余额。核销码有效期 3 分钟,请到店出示给收银员扫码。
|
||||
核销权益最低 0.01,小数最多两位。不超过可用核销权益。核销码有效期 3 分钟,请到店出示给收银员扫码。
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { View, Text, Image, ScrollView } from '@tarojs/components';
|
||||
import '../../styles/store-detail.css';
|
||||
import '../../styles/benefit-promo.css';
|
||||
import Taro, {
|
||||
useDidShow,
|
||||
useLoad,
|
||||
@@ -12,13 +13,18 @@ import Taro, {
|
||||
import PageShell from '../../components/PageShell';
|
||||
import PageNavBar from '../../components/PageNavBar';
|
||||
import ProductCarousel from '../../components/ProductCarousel';
|
||||
import StoreRedeemMarquee from '../../components/StoreRedeemMarquee';
|
||||
import StoreRedeemMarquee, { type StoreRedeemMarqueeItem } from '../../components/StoreRedeemMarquee';
|
||||
import BenefitIntroCard from '../../components/BenefitIntroCard';
|
||||
import WechatShareReady from '../../components/WechatShareReady';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import { toMoneyNumber } from '../../lib/money';
|
||||
import { maskPhone, toDialablePhone } from '../../lib/phone';
|
||||
import { track } from '../../lib/analytics';
|
||||
import { formatShanghaiDateTime } from '../../lib/datetime';
|
||||
import {
|
||||
storeCategoryTags,
|
||||
storeStarCount,
|
||||
type StoreCategoryTreeNode,
|
||||
} from '../../lib/store-display';
|
||||
import {
|
||||
buildSceneSharePayload,
|
||||
toWeappShareMessage,
|
||||
@@ -63,7 +69,16 @@ type Store = {
|
||||
avgPrice?: number | null;
|
||||
latitude?: number | string | null;
|
||||
longitude?: number | string | null;
|
||||
category?: { name: string } | null;
|
||||
rating?: number | string | null;
|
||||
tags?: unknown;
|
||||
redeemCount?: number | null;
|
||||
categoryId?: string | null;
|
||||
category?: {
|
||||
id?: string;
|
||||
name: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
} | null;
|
||||
};
|
||||
|
||||
type RecentRedeem = {
|
||||
@@ -104,11 +119,6 @@ function pickStoreId(raw?: string | null) {
|
||||
.replace(/[^\d]/g, '');
|
||||
}
|
||||
|
||||
/** 与历史记录一致:2026-08-03 15:14:30(Asia/Shanghai) */
|
||||
function formatRedeemTime(input?: string | null) {
|
||||
return formatShanghaiDateTime(input);
|
||||
}
|
||||
|
||||
function formatPackagePriceYuan(price: string | number) {
|
||||
const n = typeof price === 'number' ? price : Number(price);
|
||||
if (!Number.isFinite(n)) return '0';
|
||||
@@ -122,20 +132,29 @@ function formatRedeemAmountYuan(amount: unknown) {
|
||||
return n.toFixed(2).replace(/\.?0+$/, '');
|
||||
}
|
||||
|
||||
function formatRecentRedeemLine(row: RecentRedeem) {
|
||||
function SectionTitle({
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
children: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<View className={`store-detail-section-title${className ? ` ${className}` : ''}`}>
|
||||
<View className="store-detail-section-title-bar" />
|
||||
<Text className="store-detail-section-title-text">{children}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function toMarqueeItem(row: RecentRedeem): StoreRedeemMarqueeItem | null {
|
||||
try {
|
||||
// 优先用服务端拼好的 text,避免客户端时区 / Intl 差异
|
||||
if (row.text?.trim()) return row.text.trim();
|
||||
const label = String(row.userLabel || '用户***').trim() || '用户***';
|
||||
const rawTime = String(row.createdAt || '').trim();
|
||||
const time =
|
||||
/^\d{4}-\d{2}-\d{2}/.test(rawTime)
|
||||
? rawTime.slice(0, 19).replace('T', ' ')
|
||||
: formatRedeemTime(row.createdAt);
|
||||
const userLabel = String(row.userLabel || '用户***').trim() || '用户***';
|
||||
const amount = formatRedeemAmountYuan(row.amount);
|
||||
return `${label} ${time} 核销${amount}元`;
|
||||
if (!amount) return null;
|
||||
return { userLabel, amount };
|
||||
} catch {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +179,7 @@ export default function StoreDetailPage() {
|
||||
const [storeId, setStoreId] = useState(() => pickStoreId(router.params.id));
|
||||
const [store, setStore] = useState<Store | null>(null);
|
||||
const [recentRedeems, setRecentRedeems] = useState<RecentRedeem[]>([]);
|
||||
const [categoryTree, setCategoryTree] = useState<StoreCategoryTreeNode[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [loadError, setLoadError] = useState('');
|
||||
const [headerSolid, setHeaderSolid] = useState(false);
|
||||
@@ -236,6 +256,12 @@ export default function StoreDetailPage() {
|
||||
}
|
||||
}, [router.params.id, storeId, bootstrap]);
|
||||
|
||||
useEffect(() => {
|
||||
void request<StoreCategoryTreeNode[]>('/store-categories')
|
||||
.then((tree) => setCategoryTree(Array.isArray(tree) ? tree : []))
|
||||
.catch(() => setCategoryTree([]));
|
||||
}, []);
|
||||
|
||||
// 登录态变化后回到本页:重拉详情与走马灯
|
||||
useDidShow(() => {
|
||||
const id = pickStoreId(storeId || router.params.id);
|
||||
@@ -254,8 +280,8 @@ export default function StoreDetailPage() {
|
||||
});
|
||||
}, [store, storeId]);
|
||||
|
||||
const marqueeLines = useMemo(
|
||||
() => recentRedeems.map(formatRecentRedeemLine).filter(Boolean),
|
||||
const marqueeItems = useMemo(
|
||||
() => recentRedeems.map(toMarqueeItem).filter((row): row is StoreRedeemMarqueeItem => !!row),
|
||||
[recentRedeems],
|
||||
);
|
||||
|
||||
@@ -369,7 +395,38 @@ export default function StoreDetailPage() {
|
||||
</View>
|
||||
|
||||
<View className="store-detail-info-card">
|
||||
<Text className="store-detail-name">{store.name}</Text>
|
||||
{marqueeItems.length > 0 ? (
|
||||
<View className="store-detail-marquee-wrap">
|
||||
<StoreRedeemMarquee
|
||||
key={marqueeItems.map((r) => `${r.userLabel}|${r.amount}`).join('|')}
|
||||
items={marqueeItems}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
<View className="store-detail-title-row">
|
||||
<Text className="store-detail-name">{store.name}</Text>
|
||||
{storeCategoryTags(store, categoryTree).map((tag) => (
|
||||
<Text key={tag} className="store-detail-tag">
|
||||
{tag}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
<View className="store-detail-rating-row">
|
||||
<View className="store-detail-stars">
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
<Text
|
||||
key={n}
|
||||
className={`store-detail-star${n <= storeStarCount(store.rating) ? ' store-detail-star--on' : ''}`}
|
||||
>
|
||||
★
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
{Number(store.redeemCount) > 0 ? (
|
||||
<Text className="store-detail-redeem">核销{store.redeemCount}次</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<View className="store-detail-row">
|
||||
<Text className="store-detail-meta store-detail-meta--flex">
|
||||
@@ -404,23 +461,20 @@ export default function StoreDetailPage() {
|
||||
</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{store.category?.name ? (
|
||||
<View className="store-detail-tags">
|
||||
<Text className="store-detail-tag">{store.category.name}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{marqueeLines.length > 0 ? (
|
||||
<View className="store-detail-marquee-wrap">
|
||||
<StoreRedeemMarquee key={marqueeLines.join('|')} lines={marqueeLines} />
|
||||
<BenefitIntroCard showLink accent className="store-detail-benefit-intro" />
|
||||
|
||||
{benefitRule ? (
|
||||
<View className="store-detail-section">
|
||||
<SectionTitle className="store-detail-section-title--rule">使用规则</SectionTitle>
|
||||
<Text className="store-detail-intro">{benefitRule}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{packages.length > 0 ? (
|
||||
<View className="store-detail-section store-detail-section--packages">
|
||||
<Text className="store-detail-section-title">门店套餐</Text>
|
||||
<SectionTitle>门店套餐</SectionTitle>
|
||||
<View className="store-detail-package-list">
|
||||
{packages.map((pkg, index) => (
|
||||
<View
|
||||
@@ -440,16 +494,9 @@ export default function StoreDetailPage() {
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{benefitRule ? (
|
||||
<View className="store-detail-section">
|
||||
<Text className="store-detail-section-title store-detail-section-title--rule">使用规则</Text>
|
||||
<Text className="store-detail-intro">{benefitRule}</Text>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{intro ? (
|
||||
<View className="store-detail-section">
|
||||
<Text className="store-detail-section-title">门店详情</Text>
|
||||
<SectionTitle>门店详情</SectionTitle>
|
||||
<ScrollView className="store-detail-intro-scroll" scrollY showScrollbar>
|
||||
<Text className="store-detail-intro">{intro}</Text>
|
||||
</ScrollView>
|
||||
@@ -458,7 +505,7 @@ export default function StoreDetailPage() {
|
||||
|
||||
{envPhotos.length > 0 ? (
|
||||
<View className="store-detail-section">
|
||||
<Text className="store-detail-section-title">店内环境</Text>
|
||||
<SectionTitle>店内环境</SectionTitle>
|
||||
<View className="store-detail-env-grid">
|
||||
{envPhotos.map((url, index) => (
|
||||
<View
|
||||
|
||||
@@ -34,12 +34,15 @@ import {
|
||||
markStoresSessionBootstrapped,
|
||||
patchStoresFilterCache,
|
||||
setStoresListCache,
|
||||
type StoreSortKey,
|
||||
} from '../../lib/stores-session';
|
||||
import {
|
||||
buildSceneSharePayload,
|
||||
toWeappShareMessage,
|
||||
toWeappShareTimeline,
|
||||
} from '../../lib/wechat-share';
|
||||
import BenefitSloganBar from '../../components/BenefitSloganBar';
|
||||
import { storeCategoryTags, storeStarCount } from '../../lib/store-display';
|
||||
import openBadgeImg from '../../assets/icons/store-open-badge.png';
|
||||
|
||||
type Store = {
|
||||
@@ -57,12 +60,26 @@ type Store = {
|
||||
avgPrice?: number | null;
|
||||
status?: string;
|
||||
categoryId?: string | null;
|
||||
category?: { id?: string; name?: string; parentId?: string | null } | null;
|
||||
category?: {
|
||||
id?: string;
|
||||
name?: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
} | null;
|
||||
tags?: unknown;
|
||||
rating?: number | string | null;
|
||||
latitude?: number | string | null;
|
||||
longitude?: number | string | null;
|
||||
distanceMeters?: number | null;
|
||||
redeemCount?: number | null;
|
||||
};
|
||||
|
||||
const STORE_SORT_OPTIONS: { key: StoreSortKey; label: string }[] = [
|
||||
{ key: 'nearby', label: '附近优先' },
|
||||
{ key: 'rating', label: '好评优先' },
|
||||
{ key: 'redeem', label: '核销次数' },
|
||||
];
|
||||
|
||||
function makeCityKey(region: Pick<RegionSelection, 'province' | 'city'>): string {
|
||||
return `${region.province}|${region.city}`;
|
||||
}
|
||||
@@ -98,13 +115,15 @@ export default function StoresPage() {
|
||||
);
|
||||
const [categoryOpen, setCategoryOpen] = useState(false);
|
||||
const [categoryTree, setCategoryTree] = useState<StoreCategoryNode[]>([]);
|
||||
const [locating, setLocating] = useState(false);
|
||||
const [sort, setSort] = useState<StoreSortKey>(() => cached?.sort ?? 'nearby');
|
||||
const [sortOpen, setSortOpen] = useState(false);
|
||||
const fetchCityKeyRef = useRef<string | null>(cached?.cityKey ?? null);
|
||||
const fetchSeqRef = useRef(0);
|
||||
const regionRef = useRef(region);
|
||||
regionRef.current = region;
|
||||
const regionLabel = formatRegionLabel(region);
|
||||
const categoryLabel = formatCategoryLabel(category);
|
||||
const sortLabel = STORE_SORT_OPTIONS.find((o) => o.key === sort)?.label ?? '附近优先';
|
||||
const showBootLoading = loading && stores.length === 0;
|
||||
|
||||
const childIdsByParent = useMemo(() => {
|
||||
@@ -151,6 +170,7 @@ export default function StoresPage() {
|
||||
keyword: prev?.keyword ?? keyword,
|
||||
keywordInput: prev?.keywordInput ?? keywordInput,
|
||||
category: prev?.category ?? category,
|
||||
sort: prev?.sort ?? sort,
|
||||
});
|
||||
} catch (e) {
|
||||
if (seq !== fetchSeqRef.current) return;
|
||||
@@ -278,13 +298,29 @@ export default function StoresPage() {
|
||||
return siblings.includes(storeCatId);
|
||||
}
|
||||
|
||||
const filtered = stores.filter((s) => {
|
||||
if (!matchesRegionFilter(s, region)) return false;
|
||||
if (!matchesCategory(s)) return false;
|
||||
if (!keyword.trim()) return true;
|
||||
const q = keyword.trim();
|
||||
return s.name.includes(q) || (s.address ?? '').includes(q) || (s.district ?? '').includes(q);
|
||||
});
|
||||
const filtered = useMemo(() => {
|
||||
const list = stores.filter((s) => {
|
||||
if (!matchesRegionFilter(s, region)) return false;
|
||||
if (!matchesCategory(s)) return false;
|
||||
if (!keyword.trim()) return true;
|
||||
const q = keyword.trim();
|
||||
return s.name.includes(q) || (s.address ?? '').includes(q) || (s.district ?? '').includes(q);
|
||||
});
|
||||
const next = [...list];
|
||||
next.sort((a, b) => {
|
||||
if (sort === 'rating') {
|
||||
const diff = storeStarCount(b.rating) - storeStarCount(a.rating);
|
||||
if (diff !== 0) return diff;
|
||||
} else if (sort === 'redeem') {
|
||||
const diff = (b.redeemCount ?? 0) - (a.redeemCount ?? 0);
|
||||
if (diff !== 0) return diff;
|
||||
}
|
||||
const da = a.distanceMeters ?? Number.POSITIVE_INFINITY;
|
||||
const db = b.distanceMeters ?? Number.POSITIVE_INFINITY;
|
||||
return da - db;
|
||||
});
|
||||
return next;
|
||||
}, [stores, region, category, keyword, sort, childIdsByParent]);
|
||||
|
||||
function applySearch() {
|
||||
const next = keywordInput.trim();
|
||||
@@ -296,52 +332,18 @@ export default function StoresPage() {
|
||||
setKeywordInput('');
|
||||
setKeyword('');
|
||||
setCategory(EMPTY_CATEGORY);
|
||||
setSort('nearby');
|
||||
setRegion(DEFAULT_REGION);
|
||||
regionRef.current = DEFAULT_REGION;
|
||||
patchStoresFilterCache({
|
||||
keyword: '',
|
||||
keywordInput: '',
|
||||
category: EMPTY_CATEGORY,
|
||||
sort: 'nearby',
|
||||
filterRegion: DEFAULT_REGION,
|
||||
});
|
||||
}
|
||||
|
||||
async function locateToUserRegion() {
|
||||
if (locating) return;
|
||||
const { confirm } = await Taro.showModal({
|
||||
title: '获取当前位置',
|
||||
content: '是否允许获取当前位置,并将筛选定位到您所在的城市与区县?',
|
||||
confirmText: '允许',
|
||||
cancelText: '暂不',
|
||||
}).catch(() => ({ confirm: false, cancel: true }));
|
||||
if (!confirm) return;
|
||||
|
||||
setLocating(true);
|
||||
setLoading(true);
|
||||
try {
|
||||
const resolved = await resolveUserCity(true);
|
||||
// 筛选器用真实省市+区县;拉数仍按开城 cityCode(未开城则郑州)
|
||||
const filterRegion = resolved.region;
|
||||
const { cityCode, region: listRegion } = regionForCatalogFetch(resolved);
|
||||
const nextCityKey = makeCityKey(listRegion);
|
||||
setRegion(filterRegion);
|
||||
regionRef.current = filterRegion;
|
||||
await fetchStores(
|
||||
cityCode,
|
||||
readCachedUserCoords(),
|
||||
nextCityKey,
|
||||
listRegion,
|
||||
filterRegion,
|
||||
);
|
||||
toast(`已定位到${formatRegionLabel(filterRegion)}`, 'success');
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : '定位失败');
|
||||
setLoading(false);
|
||||
} finally {
|
||||
setLocating(false);
|
||||
}
|
||||
}
|
||||
|
||||
function hoursText(store: Store): string {
|
||||
const parts: string[] = [];
|
||||
if (store.openTime && store.closeTime) parts.push(`${store.openTime}-${store.closeTime}`);
|
||||
@@ -366,30 +368,59 @@ export default function StoresPage() {
|
||||
<WechatShareReady payload={sharePayload} />
|
||||
<TabMainHeader title="门店" />
|
||||
|
||||
<View className="store-slogan-wrap">
|
||||
<BenefitSloganBar />
|
||||
</View>
|
||||
|
||||
<View className="store-filter">
|
||||
<View className="store-search-row">
|
||||
<Input
|
||||
className="store-search-input"
|
||||
placeholder="搜索门店名称/地址"
|
||||
placeholder="搜索门店名称或地址"
|
||||
value={keywordInput}
|
||||
confirmType="search"
|
||||
onInput={(e) => setKeywordInput(e.detail.value)}
|
||||
onConfirm={applySearch}
|
||||
/>
|
||||
<View className="store-search-btn" onClick={applySearch} aria-label="搜索">
|
||||
<View className="store-search-icon" />
|
||||
<View className="store-search-btn" onClick={applySearch}>
|
||||
<Text className="store-search-btn-text">搜索</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View className="store-filter-row">
|
||||
<View className="store-filter-chip" onClick={() => setRegionOpen(true)}>
|
||||
<View
|
||||
className="store-filter-chip"
|
||||
onClick={() => {
|
||||
setCategoryOpen(false);
|
||||
setSortOpen(false);
|
||||
setRegionOpen(true);
|
||||
}}
|
||||
>
|
||||
<Text className="store-filter-chip-text">{regionLabel}</Text>
|
||||
<Text className="store-filter-chip-arrow">▾</Text>
|
||||
</View>
|
||||
<View className="store-filter-chip" onClick={() => setCategoryOpen(true)}>
|
||||
<View
|
||||
className="store-filter-chip"
|
||||
onClick={() => {
|
||||
setRegionOpen(false);
|
||||
setSortOpen(false);
|
||||
setCategoryOpen(true);
|
||||
}}
|
||||
>
|
||||
<Text className="store-filter-chip-text">{categoryLabel}</Text>
|
||||
<Text className="store-filter-chip-arrow">▾</Text>
|
||||
</View>
|
||||
<View
|
||||
className="store-filter-chip"
|
||||
onClick={() => {
|
||||
setRegionOpen(false);
|
||||
setCategoryOpen(false);
|
||||
setSortOpen(true);
|
||||
}}
|
||||
>
|
||||
<Text className="store-filter-chip-text">{sortLabel}</Text>
|
||||
<Text className="store-filter-chip-arrow">▾</Text>
|
||||
</View>
|
||||
<View
|
||||
className="store-filter-icon-btn"
|
||||
onClick={resetFilters}
|
||||
@@ -398,15 +429,6 @@ export default function StoresPage() {
|
||||
{/* 小程序 View 伪元素不稳定,用 Text 保证真机可见 */}
|
||||
<Text className="store-filter-icon-glyph">↺</Text>
|
||||
</View>
|
||||
<View
|
||||
className={`store-filter-icon-btn${locating ? ' store-filter-icon-btn--busy' : ''}`}
|
||||
onClick={() => {
|
||||
void locateToUserRegion();
|
||||
}}
|
||||
aria-label="获取当前位置"
|
||||
>
|
||||
<Text className="store-filter-icon-glyph">⌖</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -435,11 +457,34 @@ export default function StoresPage() {
|
||||
/>
|
||||
</View>
|
||||
<View className="store-card-body">
|
||||
{/* 第1行:标题(截断无省略号,顶到最右) */}
|
||||
<View className="store-card-row store-card-row--head">
|
||||
<Text className="store-card-name">{s.name}</Text>
|
||||
</View>
|
||||
{/* 第2行:地址(最多两行)+ 距离 */}
|
||||
{(() => {
|
||||
const tags = storeCategoryTags(s, categoryTree);
|
||||
return tags.length ? (
|
||||
<View className="store-card-tags">
|
||||
{tags.map((tag) => (
|
||||
<Text key={tag} className="store-card-tag">
|
||||
{tag}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
) : null;
|
||||
})()}
|
||||
<View className="store-card-row store-card-row--rating">
|
||||
<View className="store-card-stars">
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
<Text
|
||||
key={n}
|
||||
className={`store-card-star${n <= storeStarCount(s.rating) ? ' store-card-star--on' : ''}`}
|
||||
>
|
||||
★
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
<Text className="store-card-redeem">核销{s.redeemCount ?? 0}次</Text>
|
||||
</View>
|
||||
<View className="store-card-row store-card-row--mid">
|
||||
<Text className="store-card-address" numberOfLines={2}>
|
||||
{s.address || (s.district ? `${s.district}` : '地址待完善')}
|
||||
@@ -448,12 +493,10 @@ export default function StoresPage() {
|
||||
{formatDistanceMeters(s.distanceMeters)}
|
||||
</Text>
|
||||
</View>
|
||||
{/* 第3行:营业时间(同行) */}
|
||||
<View className="store-card-row store-card-row--hours">
|
||||
<Text className="store-card-hours">{hoursText(s)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Text className="store-card-arrow">›</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
@@ -480,6 +523,35 @@ export default function StoresPage() {
|
||||
patchStoresFilterCache({ category: next });
|
||||
}}
|
||||
/>
|
||||
{sortOpen ? (
|
||||
<View className="region-picker-overlay" onClick={() => setSortOpen(false)}>
|
||||
<View className="region-picker-sheet store-sort-sheet" onClick={(e) => e.stopPropagation()}>
|
||||
<View className="region-picker-toolbar">
|
||||
<View className="region-picker-tabs">
|
||||
<Text className="region-picker-tab active">排序规则</Text>
|
||||
</View>
|
||||
<Text className="region-picker-confirm ready" onClick={() => setSortOpen(false)}>
|
||||
关闭
|
||||
</Text>
|
||||
</View>
|
||||
<View className="region-picker-list">
|
||||
{STORE_SORT_OPTIONS.map((opt) => (
|
||||
<View
|
||||
key={opt.key}
|
||||
className={`region-picker-option${sort === opt.key ? ' selected' : ''}`}
|
||||
onClick={() => {
|
||||
setSort(opt.key);
|
||||
patchStoresFilterCache({ sort: opt.key });
|
||||
setSortOpen(false);
|
||||
}}
|
||||
>
|
||||
<Text>{opt.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
) : null}
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/* 好客权益口号条 / 说明卡(多页共用) */
|
||||
.benefit-slogan-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 10px;
|
||||
background: #fff8e6;
|
||||
border: 1px solid rgba(201, 162, 62, 0.55);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benefit-slogan-bar-accent {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: #c9a23e;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.benefit-slogan-bar-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 20px;
|
||||
color: #8b1a1a;
|
||||
}
|
||||
|
||||
.benefit-intro-card {
|
||||
padding: 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff8e6;
|
||||
border: 1px solid rgba(201, 162, 62, 0.55);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benefit-intro-card-title {
|
||||
display: block;
|
||||
font-family: var(--font-headline);
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
line-height: 22px;
|
||||
color: #8b1a1a;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.benefit-intro-card-body {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
color: #8b1a1a;
|
||||
}
|
||||
|
||||
.benefit-intro-card-em {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.benefit-intro-card-link {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #8b1a1a;
|
||||
}
|
||||
|
||||
.benefit-intro-card--accent {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.benefit-intro-card-bar {
|
||||
width: 5px;
|
||||
flex-shrink: 0;
|
||||
align-self: stretch;
|
||||
background: #c9a23e;
|
||||
}
|
||||
|
||||
.benefit-intro-card-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 14px;
|
||||
}
|
||||
@@ -11,13 +11,6 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benefit-header__content {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.benefit-header-title {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
@@ -39,34 +32,6 @@
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.benefit-header-city {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: var(--color-heritage-red);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
max-width: 30vw;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.benefit-header__share .page-nav-bar__btn {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.benefit-header__share .page-nav-bar__icon {
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.benefit-header-city-pin {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-heritage-red);
|
||||
margin-right: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.benefit-main {
|
||||
padding: 16px var(--space-page) 24px;
|
||||
}
|
||||
@@ -83,9 +48,6 @@
|
||||
}
|
||||
|
||||
.benefit-hero-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
@@ -117,36 +79,32 @@
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.benefit-hero-logo {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 12px;
|
||||
background: rgba(166, 29, 36, 0.08);
|
||||
.benefit-hero-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-heritage-red);
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.benefit-hero-logo-img {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
display: block;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.benefit-hero-cta {
|
||||
flex: 1;
|
||||
height: 44px;
|
||||
border-radius: var(--radius-full);
|
||||
background: var(--color-heritage-red);
|
||||
color: #fff;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benefit-hero-cta--primary {
|
||||
background: var(--color-heritage-red);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.benefit-hero-cta--secondary {
|
||||
background: rgba(166, 29, 36, 0.08);
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.benefit-tabs {
|
||||
@@ -267,7 +225,21 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.benefit-coupon-btn--ghost {
|
||||
background: rgba(166, 29, 36, 0.08);
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.benefit-intro-card--page {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.benefit-intro-card--page .benefit-intro-card-body {
|
||||
font-size: 11px;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.benefit-login-gate {
|
||||
padding: 48px 24px;
|
||||
padding: 16px var(--space-page) 48px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home-slogan-wrap {
|
||||
margin: 10px var(--space-page) 0;
|
||||
}
|
||||
|
||||
.home-aroma-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -175,6 +179,7 @@
|
||||
}
|
||||
|
||||
.home-product-thumb-wrap {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
width: 88px;
|
||||
height: 88px;
|
||||
@@ -183,6 +188,60 @@
|
||||
background: var(--color-surface-container);
|
||||
}
|
||||
|
||||
.home-benefit-ribbon-clip {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.home-benefit-ribbon {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
left: -18px;
|
||||
width: 86px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
overflow: hidden;
|
||||
background: #8b1a20;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.home-benefit-ribbon-dk {
|
||||
flex-shrink: 0;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 1px;
|
||||
/* background: #fff; */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.home-benefit-ribbon-dk-icon {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home-benefit-ribbon-num {
|
||||
flex-shrink: 0;
|
||||
color: #dcb46f;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 18px;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.home-product-thumb {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -241,6 +300,36 @@
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.home-product-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.home-gift-tag,
|
||||
.home-benefit-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
border-radius: 2px;
|
||||
font-family: var(--font-label);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.home-gift-tag {
|
||||
background: var(--color-aged-amber);
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.home-benefit-tag {
|
||||
background: rgba(166, 29, 36, 0.1);
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.home-product-actions {
|
||||
margin-top: auto;
|
||||
padding-top: 4px;
|
||||
|
||||
@@ -42,3 +42,81 @@
|
||||
color: #3d3530;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.benefit-rules-summary {
|
||||
padding: 14px;
|
||||
margin-bottom: 16px;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(90deg, #fff8e6 0%, #fff3cc 100%);
|
||||
border: 1px solid rgba(201, 162, 62, 0.55);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.benefit-rules-summary-text {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
color: #3d3530;
|
||||
}
|
||||
|
||||
.benefit-rules-section {
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
margin-bottom: 12px;
|
||||
box-shadow: 0 4px 16px rgba(166, 29, 36, 0.04);
|
||||
}
|
||||
|
||||
.benefit-rules-heading-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.benefit-rules-heading-bar {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: var(--color-heritage-red, #a61d24);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.benefit-rules-heading {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #1f1a17;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.benefit-rules-paragraph {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
color: #3d3530;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.benefit-rules-em {
|
||||
color: var(--color-heritage-red, #a61d24);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.benefit-rules-phone {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
color: var(--color-heritage-red, #a61d24);
|
||||
}
|
||||
|
||||
.benefit-rules-footer {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 16px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
line-height: 1.6;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
.mine-header {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
z-index: 1;
|
||||
padding: 16px var(--space-page) 44px;
|
||||
background: linear-gradient(135deg, #820012 0%, var(--color-heritage-red) 40%, #d4a373 100%);
|
||||
overflow: visible;
|
||||
@@ -34,12 +34,10 @@
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.mine-avatar-wrap {
|
||||
position: relative;
|
||||
z-index: 4;
|
||||
flex-shrink: 0;
|
||||
margin-right: 12px;
|
||||
}
|
||||
@@ -162,7 +160,7 @@
|
||||
.mine-main {
|
||||
margin-top: -28px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
z-index: 5;
|
||||
padding: 0 var(--space-page) 0;
|
||||
}
|
||||
|
||||
@@ -185,6 +183,12 @@
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mine-benefit-slogan {
|
||||
position: relative;
|
||||
z-index: 6;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mine-card-title {
|
||||
font-family: var(--font-headline);
|
||||
font-size: 15px;
|
||||
@@ -356,7 +360,7 @@
|
||||
margin-bottom: 8px;
|
||||
padding: 16px;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
z-index: 5;
|
||||
background: var(--color-card);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
|
||||
@@ -176,6 +176,27 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-qty-input {
|
||||
width: 52px;
|
||||
height: 32px;
|
||||
margin: 0 4px 0 8px;
|
||||
padding: 0 4px;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--color-on-surface);
|
||||
background: var(--color-surface-container-low);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.order-qty-unit {
|
||||
margin-right: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.order-qty-hint {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
|
||||
@@ -88,6 +88,10 @@
|
||||
padding: var(--space-md) var(--space-page) var(--space-lg);
|
||||
}
|
||||
|
||||
.product-detail-benefit-intro {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.product-detail-price {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
|
||||
@@ -328,17 +328,247 @@
|
||||
color: var(--color-subtle-gray);
|
||||
}
|
||||
|
||||
.redeem-success-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
.review-page-body {
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
|
||||
.review-store-card,
|
||||
.review-card {
|
||||
margin: 0 var(--space-page) 12px;
|
||||
padding: 14px;
|
||||
background: var(--color-card);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-card);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.review-store-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.review-store-cover {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
background: var(--color-surface-container);
|
||||
display: block;
|
||||
}
|
||||
|
||||
.review-store-cover--empty {
|
||||
background: var(--color-surface-container);
|
||||
}
|
||||
|
||||
.review-store-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.review-store-name {
|
||||
display: block;
|
||||
font-family: var(--font-headline);
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
line-height: 22px;
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.review-store-visit {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
color: var(--color-subtle-gray);
|
||||
}
|
||||
|
||||
.review-card-title {
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-family: var(--font-headline);
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--color-on-surface);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.review-star-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.review-star {
|
||||
font-size: 32px;
|
||||
line-height: 1;
|
||||
color: #d8d8d8;
|
||||
}
|
||||
|
||||
.review-star--active {
|
||||
color: #f5a623;
|
||||
}
|
||||
|
||||
.review-score-label {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--color-heritage-red);
|
||||
}
|
||||
|
||||
.review-section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.review-section-bar {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: var(--color-heritage-red);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.review-section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.review-tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.review-tag {
|
||||
padding: 6px 12px;
|
||||
border-radius: 999px;
|
||||
background: #f3f0ee;
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.review-tag--active {
|
||||
background: rgba(166, 29, 36, 0.1);
|
||||
color: var(--color-heritage-red);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.review-comment {
|
||||
width: 100%;
|
||||
min-height: 96px;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
background: #f7f4ef;
|
||||
box-sizing: border-box;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.review-comment--native {
|
||||
border: none;
|
||||
outline: none;
|
||||
resize: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.review-photos {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.review-photo {
|
||||
position: relative;
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #f3f0ee;
|
||||
}
|
||||
|
||||
.review-photo-img {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
}
|
||||
|
||||
.review-photo-remove {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background: rgba(45, 106, 79, 0.12);
|
||||
color: var(--color-success-green);
|
||||
font-size: 40px;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.review-photo-add {
|
||||
width: 72px;
|
||||
height: 72px;
|
||||
border-radius: 8px;
|
||||
border: 1px dashed #d0c8b8;
|
||||
background: #faf7f2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.review-photo-add-plus {
|
||||
font-size: 22px;
|
||||
line-height: 22px;
|
||||
color: #b09a78;
|
||||
}
|
||||
|
||||
.review-photo-add-text {
|
||||
font-size: 10px;
|
||||
color: #b09a78;
|
||||
}
|
||||
|
||||
.review-skip {
|
||||
display: block;
|
||||
margin: 4px var(--space-page) 8px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: var(--color-subtle-gray);
|
||||
}
|
||||
|
||||
.review-submit {
|
||||
margin: 8px var(--space-page) 8px;
|
||||
height: 48px;
|
||||
border-radius: 999px;
|
||||
background: var(--color-heritage-red);
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 48px auto 16px;
|
||||
}
|
||||
|
||||
.review-submit--disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.review-disclaimer {
|
||||
display: block;
|
||||
margin: 0 var(--space-page) 16px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
line-height: 1.6;
|
||||
color: var(--color-subtle-gray);
|
||||
}
|
||||
|
||||
.redeem-success-title {
|
||||
|
||||
@@ -95,17 +95,54 @@
|
||||
z-index: 2;
|
||||
background: var(--color-card);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 20px 16px;
|
||||
padding: 16px;
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
|
||||
.store-detail-title-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.store-detail-name {
|
||||
display: block;
|
||||
font-family: var(--font-headline);
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--color-ink-black);
|
||||
margin-bottom: 8px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.store-detail-rating-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.store-detail-stars {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.store-detail-star {
|
||||
font-size: 14px;
|
||||
line-height: 18px;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.store-detail-star--on {
|
||||
color: #e8b84a;
|
||||
}
|
||||
|
||||
.store-detail-redeem {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--color-heritage-red);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.store-detail-meta {
|
||||
@@ -148,52 +185,73 @@
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.store-detail-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.store-detail-tag {
|
||||
padding: 4px 10px;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 8px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: rgba(166, 29, 36, 0.08);
|
||||
color: var(--color-heritage-red);
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.store-detail-marquee-wrap {
|
||||
margin: 0 var(--space-page) 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.store-detail-marquee {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
background: #fff7f6;
|
||||
border: 1px solid rgba(166, 29, 36, 0.12);
|
||||
padding: 0 10px;
|
||||
border-radius: 999px;
|
||||
background: #faf6ee;
|
||||
border: 1px solid rgba(201, 162, 62, 0.4);
|
||||
overflow: hidden;
|
||||
height: 40px;
|
||||
height: 32px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.store-detail-marquee-swiper {
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.store-detail-marquee-inner {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
margin-top: -10px;
|
||||
height: 32px;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.store-detail-marquee-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #e8a317;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.store-detail-marquee-text {
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #5a413f;
|
||||
}
|
||||
|
||||
.store-detail-marquee-amount {
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
font-weight: 700;
|
||||
color: #a61d24;
|
||||
}
|
||||
|
||||
.benefit-intro-card.store-detail-benefit-intro {
|
||||
margin: 0 var(--space-page) 16px;
|
||||
background: #fffaf0;
|
||||
border-color: rgba(201, 162, 62, 0.4);
|
||||
}
|
||||
|
||||
.store-detail-section {
|
||||
background: var(--color-card);
|
||||
margin: 0 var(--space-page) 16px;
|
||||
@@ -203,15 +261,28 @@
|
||||
}
|
||||
|
||||
.store-detail-section-title {
|
||||
display: block;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.store-detail-section-title-bar {
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 1px;
|
||||
background: var(--color-heritage-red, #a61d24);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.store-detail-section-title-text {
|
||||
font-family: var(--font-headline);
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
color: var(--color-on-surface);
|
||||
}
|
||||
|
||||
.store-detail-section-title--rule {
|
||||
.store-detail-section-title--rule .store-detail-section-title-text {
|
||||
color: var(--color-heritage-red, #a61d24);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
background: var(--color-background);
|
||||
}
|
||||
|
||||
.store-slogan-wrap {
|
||||
padding: 0 var(--space-page) 10px;
|
||||
}
|
||||
|
||||
.store-filter {
|
||||
padding: 0 var(--space-page) 12px;
|
||||
}
|
||||
@@ -46,8 +50,8 @@
|
||||
|
||||
.store-search-btn {
|
||||
flex-shrink: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--color-heritage-red);
|
||||
color: #fff;
|
||||
@@ -56,26 +60,11 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.store-search-icon {
|
||||
position: relative;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 2px solid currentColor;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.store-search-icon::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: -5px;
|
||||
bottom: -4px;
|
||||
width: 7px;
|
||||
height: 2px;
|
||||
background: currentColor;
|
||||
border-radius: 1px;
|
||||
transform: rotate(45deg);
|
||||
transform-origin: left center;
|
||||
.store-search-btn-text {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.store-filter-row {
|
||||
@@ -148,7 +137,7 @@
|
||||
.store-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
box-sizing: border-box;
|
||||
@@ -195,7 +184,7 @@
|
||||
min-height: 96px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
justify-content: flex-start;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
@@ -226,6 +215,57 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.store-card-tags {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.store-card-tag {
|
||||
flex-shrink: 0;
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
background: rgba(166, 29, 36, 0.1);
|
||||
color: var(--color-heritage-red);
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.store-card-row--rating {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.store-card-stars {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.store-card-star {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.store-card-star--on {
|
||||
color: #e8b84a;
|
||||
}
|
||||
|
||||
.store-card-redeem {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 16px;
|
||||
color: var(--color-heritage-red);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 第2行:地址最多两行 + 右对齐距离 */
|
||||
.store-card-row--mid {
|
||||
gap: 8px;
|
||||
@@ -289,3 +329,7 @@
|
||||
color: #ccc;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.store-sort-sheet {
|
||||
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user