feat(v3.4.14): mini-user store UX, brand config, client settings
Store list/detail package flow, configurable WeChat mini brand assets and customer service, shop H5 home refresh. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,293 +1,585 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
import PullToRefresh from '@dukang/shared-ui/PullToRefresh';
|
||||||
|
|
||||||
import { isScanPermissionWarmupError } from '@dukang/weixin-sdk';
|
import { isScanPermissionWarmupError } from '@dukang/weixin-sdk';
|
||||||
|
|
||||||
import { useStoreSession } from '../contexts/StoreSessionContext';
|
import { useStoreSession } from '../contexts/StoreSessionContext';
|
||||||
|
|
||||||
import { request } from '../lib/api';
|
import { request } from '../lib/api';
|
||||||
|
|
||||||
import { parseRedeemTokenFromScan } from '../lib/redeem-scan';
|
import { parseRedeemTokenFromScan } from '../lib/redeem-scan';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
||||||
authorizeShopWechat,
|
authorizeShopWechat,
|
||||||
|
|
||||||
checkNeedsWechatAuth,
|
checkNeedsWechatAuth,
|
||||||
|
|
||||||
fetchShopAccount,
|
fetchShopAccount,
|
||||||
|
|
||||||
} from '../lib/wechat-auth';
|
} from '../lib/wechat-auth';
|
||||||
|
|
||||||
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
import { isWechatEnv, weixinSdk } from '../lib/weixin';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
||||||
clearPendingScanAfterAuth,
|
clearPendingScanAfterAuth,
|
||||||
|
|
||||||
getPostAuthScanDelayMs,
|
getPostAuthScanDelayMs,
|
||||||
|
|
||||||
markPendingScanAfterAuth,
|
markPendingScanAfterAuth,
|
||||||
|
|
||||||
peekPendingScanAfterAuth,
|
peekPendingScanAfterAuth,
|
||||||
|
|
||||||
} from '../lib/shop-scan-auth';
|
} from '../lib/shop-scan-auth';
|
||||||
|
|
||||||
import WechatScanAuthModal from '../components/WechatScanAuthModal';
|
import WechatScanAuthModal from '../components/WechatScanAuthModal';
|
||||||
|
|
||||||
import { useStorePageView } from '../lib/usePageView';
|
import { useStorePageView } from '../lib/usePageView';
|
||||||
|
|
||||||
import { trackStore } from '../lib/analytics';
|
import { trackStore } from '../lib/analytics';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatMoney(n: number) {
|
function formatMoney(n: number) {
|
||||||
|
|
||||||
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 0, maximumFractionDigits: 2 });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formatScanError(e: unknown, opts?: { afterAuth?: boolean }): string {
|
function formatScanError(e: unknown, opts?: { afterAuth?: boolean }): string {
|
||||||
|
|
||||||
const msg = e instanceof Error ? e.message : '扫码失败,请重试';
|
const msg = e instanceof Error ? e.message : '扫码失败,请重试';
|
||||||
|
|
||||||
if (/invalid signature/i.test(msg)) {
|
if (/invalid signature/i.test(msg)) {
|
||||||
|
|
||||||
return '微信 JSSDK 签名校验失败:请确认公众号已配置 JS 接口安全域名,并刷新页面后重试';
|
return '微信 JSSDK 签名校验失败:请确认公众号已配置 JS 接口安全域名,并刷新页面后重试';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isScanPermissionWarmupError(msg)) {
|
if (isScanPermissionWarmupError(msg)) {
|
||||||
|
|
||||||
if (opts?.afterAuth) {
|
if (opts?.afterAuth) {
|
||||||
|
|
||||||
return '微信授权已完成,扫码权限仍在准备中,请再点一次「扫码核销」';
|
return '微信授权已完成,扫码权限仍在准备中,请再点一次「扫码核销」';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '微信权限校验尚未完成,请等待 1~2 秒后再次点击扫码(首次绑定微信时较常见)';
|
return '微信权限校验尚未完成,请等待 1~2 秒后再次点击扫码(首次绑定微信时较常见)';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
|
|
||||||
useStorePageView('store_home_view');
|
useStorePageView('store_home_view');
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { ready, authenticated } = useStoreSession();
|
const { ready, authenticated } = useStoreSession();
|
||||||
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
|
|
||||||
const [dash, setDash] = useState<Record<string, unknown> | null>(null);
|
const [dash, setDash] = useState<Record<string, unknown> | null>(null);
|
||||||
|
|
||||||
const [scanMsg, setScanMsg] = useState('');
|
const [scanMsg, setScanMsg] = useState('');
|
||||||
|
|
||||||
const [scanning, setScanning] = useState(false);
|
const [scanning, setScanning] = useState(false);
|
||||||
|
|
||||||
const [authModalOpen, setAuthModalOpen] = useState(false);
|
const [authModalOpen, setAuthModalOpen] = useState(false);
|
||||||
|
|
||||||
const [authLoading, setAuthLoading] = useState(false);
|
const [authLoading, setAuthLoading] = useState(false);
|
||||||
|
|
||||||
const [authError, setAuthError] = useState('');
|
const [authError, setAuthError] = useState('');
|
||||||
|
|
||||||
const pendingScanStartedRef = useRef(false);
|
const pendingScanStartedRef = useRef(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const loadDashboard = useCallback(() => {
|
const loadDashboard = useCallback(() => {
|
||||||
|
|
||||||
return request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard')
|
return request<Record<string, unknown>>('SHOP_H5', '/shop/dashboard')
|
||||||
|
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
|
|
||||||
setDash(d);
|
setDash(d);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isScanPermissionWarmupError(msg)) {
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
return '微信授权已完成,扫码权限仍在准备中,请再点一次「扫码核销」';
|
|
||||||
void loadDashboard();
|
void loadDashboard();
|
||||||
}
|
|
||||||
|
|
||||||
return '微信权限校验尚未完成,请等待 1~2 秒后再次点击扫码(首次绑定微信时较常见)';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, [loadDashboard]);
|
}, [loadDashboard]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
function onResume() {
|
||||||
|
|
||||||
|
setScanning(false);
|
||||||
|
|
||||||
|
void loadDashboard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVisibility() {
|
||||||
|
|
||||||
|
if (document.visibilityState === 'visible') onResume();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', onVisibility);
|
||||||
|
|
||||||
|
window.addEventListener('pageshow', onResume);
|
||||||
|
|
||||||
|
window.addEventListener('focus', onResume);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
|
||||||
|
document.removeEventListener('visibilitychange', onVisibility);
|
||||||
|
|
||||||
|
window.removeEventListener('pageshow', onResume);
|
||||||
|
|
||||||
|
window.removeEventListener('focus', onResume);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}, [loadDashboard]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const runScan = useCallback(
|
const runScan = useCallback(
|
||||||
|
|
||||||
async (opts?: { postAuthWarmup?: boolean }) => {
|
async (opts?: { postAuthWarmup?: boolean }) => {
|
||||||
|
|
||||||
trackStore('store_redeem_scan_start');
|
trackStore('store_redeem_scan_start');
|
||||||
|
|
||||||
if (!isWechatEnv()) {
|
if (!isWechatEnv()) {
|
||||||
|
|
||||||
setScanMsg('请在微信内打开门店端进行扫码核销');
|
setScanMsg('请在微信内打开门店端进行扫码核销');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setScanning(true);
|
setScanning(true);
|
||||||
|
|
||||||
if (!opts?.postAuthWarmup) {
|
if (!opts?.postAuthWarmup) {
|
||||||
|
|
||||||
setScanMsg('');
|
setScanMsg('');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (opts?.postAuthWarmup) {
|
if (opts?.postAuthWarmup) {
|
||||||
|
|
||||||
weixinSdk.reset();
|
weixinSdk.reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await weixinSdk.init();
|
await weixinSdk.init();
|
||||||
|
|
||||||
const raw = await weixinSdk.scanQrCode(
|
const raw = await weixinSdk.scanQrCode(
|
||||||
|
|
||||||
opts?.postAuthWarmup ? { postAuthWarmup: true } : undefined,
|
opts?.postAuthWarmup ? { postAuthWarmup: true } : undefined,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
|
|
||||||
void loadDashboard();
|
void loadDashboard();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = parseRedeemTokenFromScan(raw);
|
const token = parseRedeemTokenFromScan(raw);
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|
||||||
setScanMsg('无法识别核销码,请扫描用户出示的核销二维码');
|
setScanMsg('无法识别核销码,请扫描用户出示的核销二维码');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(`/redeem?token=${encodeURIComponent(token)}`);
|
navigate(`/redeem?token=${encodeURIComponent(token)}`);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
setScanMsg(formatScanError(e, { afterAuth: opts?.postAuthWarmup }));
|
setScanMsg(formatScanError(e, { afterAuth: opts?.postAuthWarmup }));
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
setScanning(false);
|
setScanning(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
[loadDashboard, navigate],
|
[loadDashboard, navigate],
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// OAuth 由 StoreSessionContext 单例处理;此处仅在授权完成后续扫
|
// OAuth 由 StoreSessionContext 单例处理;此处仅在授权完成后续扫
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
if (!ready || !authenticated || !isWechatEnv()) return;
|
if (!ready || !authenticated || !isWechatEnv()) return;
|
||||||
|
|
||||||
if (searchParams.get('code')) return;
|
if (searchParams.get('code')) return;
|
||||||
|
|
||||||
if (!peekPendingScanAfterAuth() || pendingScanStartedRef.current) return;
|
if (!peekPendingScanAfterAuth() || pendingScanStartedRef.current) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pendingScanStartedRef.current = true;
|
pendingScanStartedRef.current = true;
|
||||||
|
|
||||||
clearPendingScanAfterAuth();
|
clearPendingScanAfterAuth();
|
||||||
|
|
||||||
setAuthModalOpen(false);
|
setAuthModalOpen(false);
|
||||||
|
|
||||||
setAuthLoading(false);
|
setAuthLoading(false);
|
||||||
|
|
||||||
setAuthError('');
|
setAuthError('');
|
||||||
|
|
||||||
setScanMsg('微信授权成功,正在准备扫码…');
|
setScanMsg('微信授权成功,正在准备扫码…');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const timer = window.setTimeout(() => {
|
const timer = window.setTimeout(() => {
|
||||||
|
|
||||||
void runScan({ postAuthWarmup: true });
|
void runScan({ postAuthWarmup: true });
|
||||||
|
|
||||||
}, getPostAuthScanDelayMs());
|
}, getPostAuthScanDelayMs());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
|
|
||||||
}, [ready, authenticated, searchParams, runScan]);
|
}, [ready, authenticated, searchParams, runScan]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function handleScan() {
|
async function handleScan() {
|
||||||
|
|
||||||
setScanMsg('');
|
setScanMsg('');
|
||||||
|
|
||||||
if (!isWechatEnv()) {
|
if (!isWechatEnv()) {
|
||||||
|
|
||||||
setScanMsg('请在微信内打开门店端进行扫码核销');
|
setScanMsg('请在微信内打开门店端进行扫码核销');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const profile = await fetchShopAccount();
|
const profile = await fetchShopAccount();
|
||||||
|
|
||||||
if (await checkNeedsWechatAuth(profile)) {
|
if (await checkNeedsWechatAuth(profile)) {
|
||||||
|
|
||||||
pendingScanStartedRef.current = false;
|
pendingScanStartedRef.current = false;
|
||||||
|
|
||||||
setAuthModalOpen(true);
|
setAuthModalOpen(true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await runScan();
|
await runScan();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
setScanMsg(e instanceof Error ? e.message : '无法发起扫码');
|
setScanMsg(e instanceof Error ? e.message : '无法发起扫码');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function startWechatAuth() {
|
async function startWechatAuth() {
|
||||||
|
|
||||||
setAuthLoading(true);
|
setAuthLoading(true);
|
||||||
|
|
||||||
setAuthError('');
|
setAuthError('');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
pendingScanStartedRef.current = false;
|
pendingScanStartedRef.current = false;
|
||||||
|
|
||||||
markPendingScanAfterAuth();
|
markPendingScanAfterAuth();
|
||||||
|
|
||||||
await authorizeShopWechat();
|
await authorizeShopWechat();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
clearPendingScanAfterAuth();
|
clearPendingScanAfterAuth();
|
||||||
|
|
||||||
setAuthError(e instanceof Error ? e.message : '微信授权失败');
|
setAuthError(e instanceof Error ? e.message : '微信授权失败');
|
||||||
|
|
||||||
setAuthLoading(false);
|
setAuthLoading(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const store = dash?.store as Record<string, unknown> | undefined;
|
const store = dash?.store as Record<string, unknown> | undefined;
|
||||||
|
|
||||||
const recent = (dash?.recentRecords as Array<Record<string, unknown>>) || [];
|
const recent = (dash?.recentRecords as Array<Record<string, unknown>>) || [];
|
||||||
|
|
||||||
const status = String(store?.status || '');
|
const status = String(store?.status || '');
|
||||||
|
|
||||||
const open = status === 'OPEN';
|
const open = status === 'OPEN';
|
||||||
|
|
||||||
const hoursParts: string[] = [];
|
const hoursParts: string[] = [];
|
||||||
|
|
||||||
if (store?.openTime && store?.closeTime) hoursParts.push(`${store.openTime} - ${store.closeTime}`);
|
if (store?.openTime && store?.closeTime) hoursParts.push(`${store.openTime} - ${store.closeTime}`);
|
||||||
|
|
||||||
if (store?.openTime2 && store?.closeTime2) hoursParts.push(`${store.openTime2} - ${store.closeTime2}`);
|
if (store?.openTime2 && store?.closeTime2) hoursParts.push(`${store.openTime2} - ${store.closeTime2}`);
|
||||||
|
|
||||||
const hoursText = hoursParts.length ? hoursParts.join(',') : '10:00 - 22:00';
|
const hoursText = hoursParts.length ? hoursParts.join(',') : '10:00 - 22:00';
|
||||||
|
|
||||||
const statusText =
|
const statusText =
|
||||||
|
|
||||||
status === 'CLOSED' ? '永久关闭' : open ? '当前正在营业中' : '当前临时闭店';
|
status === 'CLOSED' ? '永久关闭' : open ? '当前正在营业中' : '当前临时闭店';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<PullToRefresh onRefresh={loadDashboard} className="shop-home-page">
|
<PullToRefresh onRefresh={loadDashboard} className="shop-home-page">
|
||||||
|
|
||||||
<header className="shop-home-header">
|
<header className="shop-home-header">
|
||||||
|
|
||||||
<h1 className="app-page-title">门店管理中心</h1>
|
<h1 className="app-page-title">门店管理中心</h1>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="shop-home-content">
|
<div className="shop-home-content">
|
||||||
|
|
||||||
<section className="shop-home-hero">
|
<section className="shop-home-hero">
|
||||||
|
|
||||||
<div className="shop-home-hero-store">
|
<div className="shop-home-hero-store">
|
||||||
|
|
||||||
<span className="material-symbols-outlined shop-fill-icon">store</span>
|
<span className="material-symbols-outlined shop-fill-icon">store</span>
|
||||||
|
|
||||||
<h2>{String(store?.name || '门店')}</h2>
|
<h2>{String(store?.name || '门店')}</h2>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shop-home-stats">
|
<div className="shop-home-stats">
|
||||||
|
|
||||||
<div className="shop-home-stat">
|
<div className="shop-home-stat">
|
||||||
|
|
||||||
<p className="shop-home-stat-label">今日核销笔数</p>
|
<p className="shop-home-stat-label">今日核销笔数</p>
|
||||||
|
|
||||||
<p className="shop-home-stat-value">{Number(dash?.todayCount || 0)}</p>
|
<p className="shop-home-stat-value">{Number(dash?.todayCount || 0)}</p>
|
||||||
|
|
||||||
<p className="shop-home-stat-sub">
|
<p className="shop-home-stat-sub">
|
||||||
|
|
||||||
扫码 {Number(dash?.todayScanCount || 0)} · 手机号 {Number(dash?.todayPhoneCount || 0)}
|
扫码 {Number(dash?.todayScanCount || 0)} · 手机号 {Number(dash?.todayPhoneCount || 0)}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shop-home-stat">
|
<div className="shop-home-stat">
|
||||||
|
|
||||||
<p className="shop-home-stat-label">今日到账金额</p>
|
<p className="shop-home-stat-label">今日到账金额</p>
|
||||||
|
|
||||||
<p className="shop-home-stat-value">
|
<p className="shop-home-stat-value">
|
||||||
|
|
||||||
<span style={{ fontSize: 18 }}>¥</span>
|
<span style={{ fontSize: 18 }}>¥</span>
|
||||||
|
|
||||||
{formatMoney(Number(dash?.todayAmount || 0))}
|
{formatMoney(Number(dash?.todayAmount || 0))}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section className="shop-home-scan">
|
<section className="shop-home-scan">
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
||||||
type="button"
|
type="button"
|
||||||
|
|
||||||
className="shop-home-scan-btn"
|
className="shop-home-scan-btn"
|
||||||
|
|
||||||
disabled={scanning}
|
disabled={scanning}
|
||||||
|
|
||||||
onClick={() => void handleScan()}
|
onClick={() => void handleScan()}
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<span className="material-symbols-outlined">qr_code_scanner</span>
|
<span className="material-symbols-outlined">qr_code_scanner</span>
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<p className="shop-home-scan-label">{scanning ? '正在打开相机…' : '扫码核销'}</p>
|
<p className="shop-home-scan-label">{scanning ? '正在打开相机…' : '扫码核销'}</p>
|
||||||
|
|
||||||
{scanMsg && <p className="shop-home-scan-msg" role="alert">{scanMsg}</p>}
|
{scanMsg && <p className="shop-home-scan-msg" role="alert">{scanMsg}</p>}
|
||||||
|
|
||||||
<Link to="/redeem/phone" className="shop-home-phone-link">
|
<Link to="/redeem/phone" className="shop-home-phone-link">
|
||||||
|
|
||||||
<span className="material-symbols-outlined">smartphone</span>
|
<span className="material-symbols-outlined">smartphone</span>
|
||||||
|
|
||||||
手机号核销
|
手机号核销
|
||||||
|
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section className="shop-home-status">
|
<section className="shop-home-status">
|
||||||
|
|
||||||
<div className="shop-home-status-left">
|
<div className="shop-home-status-left">
|
||||||
|
|
||||||
<div className={`shop-home-status-icon${open ? '' : ' closed'}`}>
|
<div className={`shop-home-status-icon${open ? '' : ' closed'}`}>
|
||||||
|
|
||||||
<span className="material-symbols-outlined shop-fill-icon">schedule</span>
|
<span className="material-symbols-outlined shop-fill-icon">schedule</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<p className="shop-home-status-title">营业状态</p>
|
<p className="shop-home-status-title">营业状态</p>
|
||||||
|
|
||||||
<p className="shop-home-status-sub">{statusText}</p>
|
<p className="shop-home-status-sub">{statusText}</p>
|
||||||
|
|
||||||
<p className="shop-home-status-sub">营业时间: {hoursText}</p>
|
<p className="shop-home-status-sub">营业时间: {hoursText}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label className="shop-home-switch" onClick={() => navigate('/status')}>
|
<label className="shop-home-switch" onClick={() => navigate('/status')}>
|
||||||
|
|
||||||
<input type="checkbox" checked={open && status !== 'CLOSED'} readOnly tabIndex={-1} />
|
<input type="checkbox" checked={open && status !== 'CLOSED'} readOnly tabIndex={-1} />
|
||||||
|
|
||||||
<span className="shop-home-switch-track" />
|
<span className="shop-home-switch-track" />
|
||||||
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|
||||||
<div className="shop-home-records-head">
|
<div className="shop-home-records-head">
|
||||||
|
|
||||||
<h3 className="shop-home-records-title">核销记录</h3>
|
<h3 className="shop-home-records-title">核销记录</h3>
|
||||||
|
|
||||||
<Link to="/records" className="shop-home-records-link">
|
<Link to="/records" className="shop-home-records-link">
|
||||||
|
|
||||||
查看全部
|
查看全部
|
||||||
|
|
||||||
<span className="material-symbols-outlined" style={{ fontSize: 16 }}>chevron_right</span>
|
<span className="material-symbols-outlined" style={{ fontSize: 16 }}>chevron_right</span>
|
||||||
|
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="shop-home-record-list">
|
<div className="shop-home-record-list">
|
||||||
|
|
||||||
{recent.length === 0 && (
|
{recent.length === 0 && (
|
||||||
|
|
||||||
<p className="shop-home-status-sub" style={{ textAlign: 'center', padding: '16px 0' }}>暂无核销记录</p>
|
<p className="shop-home-status-sub" style={{ textAlign: 'center', padding: '16px 0' }}>暂无核销记录</p>
|
||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{recent.map((r) => (
|
{recent.map((r) => (
|
||||||
|
|
||||||
<div key={String(r.id)} className="shop-home-record-item">
|
<div key={String(r.id)} className="shop-home-record-item">
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<p className="shop-home-record-time">核销时间</p>
|
<p className="shop-home-record-time">核销时间</p>
|
||||||
|
|
||||||
<p className="shop-home-record-value">
|
<p className="shop-home-record-value">
|
||||||
|
|
||||||
{new Date(String(r.createdAt)).toLocaleString('zh-CN')}
|
{new Date(String(r.createdAt)).toLocaleString('zh-CN')}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="shop-home-record-amount">¥{formatMoney(Number(r.amount))}</p>
|
<p className="shop-home-record-amount">¥{formatMoney(Number(r.amount))}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
))}
|
))}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<WechatScanAuthModal
|
<WechatScanAuthModal
|
||||||
|
|
||||||
open={authModalOpen}
|
open={authModalOpen}
|
||||||
|
|
||||||
loading={authLoading}
|
loading={authLoading}
|
||||||
|
|
||||||
error={authError}
|
error={authError}
|
||||||
|
|
||||||
onAuthorize={() => void startWechatAuth()}
|
onAuthorize={() => void startWechatAuth()}
|
||||||
|
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
|
|
||||||
setAuthModalOpen(false);
|
setAuthModalOpen(false);
|
||||||
|
|
||||||
setAuthError('');
|
setAuthError('');
|
||||||
|
|
||||||
clearPendingScanAfterAuth();
|
clearPendingScanAfterAuth();
|
||||||
|
|
||||||
pendingScanStartedRef.current = false;
|
pendingScanStartedRef.current = false;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</PullToRefresh>
|
</PullToRefresh>
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { CUSTOMER_SERVICE_PHONE } from '@dukang/shared-types';
|
import { useEffect, useState } from 'react';
|
||||||
import { track } from '../lib/analytics';
|
import { track } from '../lib/analytics';
|
||||||
import { openWecomCustomerService } from '../lib/customer-service';
|
import {
|
||||||
|
getCustomerServicePhone,
|
||||||
|
loadCustomerServicePhone,
|
||||||
|
openWecomCustomerService,
|
||||||
|
} from '../lib/customer-service';
|
||||||
|
|
||||||
type ContactCustomerSheetProps = {
|
type ContactCustomerSheetProps = {
|
||||||
orderId?: string;
|
orderId?: string;
|
||||||
@@ -9,7 +13,13 @@ type ContactCustomerSheetProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function ContactCustomerSheet({ orderId, onClose }: ContactCustomerSheetProps) {
|
export default function ContactCustomerSheet({ orderId, onClose }: ContactCustomerSheetProps) {
|
||||||
const tel = CUSTOMER_SERVICE_PHONE.replace(/-/g, '');
|
const [phone, setPhone] = useState(getCustomerServicePhone);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadCustomerServicePhone().then(setPhone);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const tel = phone.replace(/-/g, '');
|
||||||
|
|
||||||
function openPhone() {
|
function openPhone() {
|
||||||
track('cs_contact', { type: 'phone', orderId });
|
track('cs_contact', { type: 'phone', orderId });
|
||||||
@@ -41,7 +51,7 @@ export default function ContactCustomerSheet({ orderId, onClose }: ContactCustom
|
|||||||
</div>
|
</div>
|
||||||
<div className="contact-customer-option-body">
|
<div className="contact-customer-option-body">
|
||||||
<p className="contact-customer-option-title">拨打总部客服电话</p>
|
<p className="contact-customer-option-title">拨打总部客服电话</p>
|
||||||
<p className="contact-customer-option-sub">{CUSTOMER_SERVICE_PHONE}</p>
|
<p className="contact-customer-option-sub">{phone}</p>
|
||||||
</div>
|
</div>
|
||||||
<span className="material-symbols-outlined contact-customer-chevron">chevron_right</span>
|
<span className="material-symbols-outlined contact-customer-chevron">chevron_right</span>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,12 +1,31 @@
|
|||||||
import { CUSTOMER_SERVICE_PHONE, CUSTOMER_SERVICE_WECOM_URL } from '@dukang/shared-types';
|
import { CUSTOMER_SERVICE_PHONE, CUSTOMER_SERVICE_WECOM_URL } from '@dukang/shared-types';
|
||||||
|
import { fetchClientConfig } from './pay-wechat';
|
||||||
import { isWechatEnv } from './weixin';
|
import { isWechatEnv } from './weixin';
|
||||||
|
|
||||||
|
let cachedPhone = CUSTOMER_SERVICE_PHONE;
|
||||||
|
|
||||||
/** 企微客服链接:优先 Vite env,否则 shared-types 默认 */
|
/** 企微客服链接:优先 Vite env,否则 shared-types 默认 */
|
||||||
export function getCustomerServiceWecomUrl(): string {
|
export function getCustomerServiceWecomUrl(): string {
|
||||||
const fromEnv = import.meta.env.VITE_CS_WECOM_URL?.trim();
|
const fromEnv = import.meta.env.VITE_CS_WECOM_URL?.trim();
|
||||||
return fromEnv || CUSTOMER_SERVICE_WECOM_URL;
|
return fromEnv || CUSTOMER_SERVICE_WECOM_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCustomerServicePhone(): string {
|
||||||
|
return cachedPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 从系统设置拉取客服电话(失败则保持默认常量) */
|
||||||
|
export async function loadCustomerServicePhone(): Promise<string> {
|
||||||
|
try {
|
||||||
|
const cfg = await fetchClientConfig();
|
||||||
|
const phone = cfg.customerServicePhone?.trim();
|
||||||
|
if (phone) cachedPhone = phone;
|
||||||
|
} catch {
|
||||||
|
/* keep fallback */
|
||||||
|
}
|
||||||
|
return cachedPhone;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开企业微信客服会话(须在微信内;需用户点击手势)。
|
* 打开企业微信客服会话(须在微信内;需用户点击手势)。
|
||||||
* @returns true 已跳转;false 非微信环境已提示
|
* @returns true 已跳转;false 非微信环境已提示
|
||||||
@@ -20,4 +39,5 @@ export function openWecomCustomerService(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated 请用 getCustomerServicePhone(),保留兼容旧引用 */
|
||||||
export { CUSTOMER_SERVICE_PHONE };
|
export { CUSTOMER_SERVICE_PHONE };
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import SubPageHeader from '../components/SubPageHeader';
|
import SubPageHeader from '../components/SubPageHeader';
|
||||||
import { CUSTOMER_SERVICE_PHONE, openWecomCustomerService } from '../lib/customer-service';
|
import {
|
||||||
|
getCustomerServicePhone,
|
||||||
|
loadCustomerServicePhone,
|
||||||
|
openWecomCustomerService,
|
||||||
|
} from '../lib/customer-service';
|
||||||
import { track } from '../lib/analytics';
|
import { track } from '../lib/analytics';
|
||||||
|
|
||||||
export default function CustomerServicePage() {
|
export default function CustomerServicePage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const tel = CUSTOMER_SERVICE_PHONE.replace(/-/g, '');
|
const [phone, setPhone] = useState(getCustomerServicePhone);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadCustomerServicePhone().then(setPhone);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const tel = phone.replace(/-/g, '');
|
||||||
|
|
||||||
function openOnline() {
|
function openOnline() {
|
||||||
track('cs_contact', { type: 'wecom_kf' });
|
track('cs_contact', { type: 'wecom_kf' });
|
||||||
@@ -27,7 +38,7 @@ export default function CustomerServicePage() {
|
|||||||
|
|
||||||
<a className="customer-service-phone-link" href={`tel:${tel}`}>
|
<a className="customer-service-phone-link" href={`tel:${tel}`}>
|
||||||
<span className="material-symbols-outlined">call</span>
|
<span className="material-symbols-outlined">call</span>
|
||||||
或拨打客服电话 {CUSTOMER_SERVICE_PHONE}
|
或拨打客服电话 {phone}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dukang/mini-user",
|
"name": "@dukang/mini-user",
|
||||||
"version": "3.4.13",
|
"version": "3.4.14",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
"description": "杜康好客 · C 端用户微信小程序(Taro)",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export default defineAppConfig({
|
|||||||
'pages/mine/index',
|
'pages/mine/index',
|
||||||
'pages/product-detail/index',
|
'pages/product-detail/index',
|
||||||
'pages/store-detail/index',
|
'pages/store-detail/index',
|
||||||
|
'pages/store-package-detail/index',
|
||||||
'pages/order-confirm/index',
|
'pages/order-confirm/index',
|
||||||
'pages/order-confirm-pickup/index',
|
'pages/order-confirm-pickup/index',
|
||||||
'pages/pay/index',
|
'pages/pay/index',
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import WechatShareBootstrap from './components/WechatShareBootstrap';
|
|||||||
import { patchTaroH5Hooks } from './lib/patch-taro-h5-hooks';
|
import { patchTaroH5Hooks } from './lib/patch-taro-h5-hooks';
|
||||||
import { handleWechatOrderConfirmShow } from './lib/wechat-order-confirm';
|
import { handleWechatOrderConfirmShow } from './lib/wechat-order-confirm';
|
||||||
import { installClientErrorReporting } from './lib/client-error';
|
import { installClientErrorReporting } from './lib/client-error';
|
||||||
|
import { prefetchShareBrandAssets } from './lib/wechat-share';
|
||||||
import './app.css';
|
import './app.css';
|
||||||
|
|
||||||
// H5:在首屏 page hooks 执行前,把 Taro.useDidShow 等绑到与 createReactApp 同一份 runtime
|
// H5:在首屏 page hooks 执行前,把 Taro.useDidShow 等绑到与 createReactApp 同一份 runtime
|
||||||
patchTaroH5Hooks();
|
patchTaroH5Hooks();
|
||||||
installClientErrorReporting();
|
installClientErrorReporting();
|
||||||
|
prefetchShareBrandAssets();
|
||||||
|
|
||||||
function App({ children }: PropsWithChildren) {
|
function App({ children }: PropsWithChildren) {
|
||||||
const handlingRef = useRef(false);
|
const handlingRef = useRef(false);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ type ProductCarouselProps = {
|
|||||||
alt: string;
|
alt: string;
|
||||||
variant?: 'home' | 'detail' | 'store';
|
variant?: 'home' | 'detail' | 'store';
|
||||||
previewable?: boolean;
|
previewable?: boolean;
|
||||||
|
/** cover=aspectFill 裁剪铺满;contain=aspectFit 缩放完整显示(门店门头固定区) */
|
||||||
|
imageFit?: 'cover' | 'contain';
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 商品/门店轮播(对齐 h5 ProductCarousel 三变体) */
|
/** 商品/门店轮播(对齐 h5 ProductCarousel 三变体) */
|
||||||
@@ -15,12 +17,14 @@ export default function ProductCarousel({
|
|||||||
alt,
|
alt,
|
||||||
variant = 'detail',
|
variant = 'detail',
|
||||||
previewable = false,
|
previewable = false,
|
||||||
|
imageFit = 'cover',
|
||||||
}: ProductCarouselProps) {
|
}: ProductCarouselProps) {
|
||||||
const slides = images.length > 0 ? images : [''];
|
const slides = images.length > 0 ? images : [''];
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
const prefix =
|
const prefix =
|
||||||
variant === 'store' ? 'store-detail-carousel' : variant === 'home' ? 'home-carousel' : 'detail-carousel';
|
variant === 'store' ? 'store-detail-carousel' : variant === 'home' ? 'home-carousel' : 'detail-carousel';
|
||||||
const imageMode = 'aspectFill';
|
const isContain = imageFit === 'contain';
|
||||||
|
const wrapClass = `${prefix}-wrap${isContain ? ` ${prefix}-wrap--contain` : ''}`;
|
||||||
|
|
||||||
function previewAt(index: number) {
|
function previewAt(index: number) {
|
||||||
const urls = slides.filter(Boolean);
|
const urls = slides.filter(Boolean);
|
||||||
@@ -30,7 +34,7 @@ export default function ProductCarousel({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={`${prefix}-wrap`}>
|
<View className={wrapClass}>
|
||||||
<Swiper
|
<Swiper
|
||||||
className={prefix}
|
className={prefix}
|
||||||
circular={slides.length > 1}
|
circular={slides.length > 1}
|
||||||
@@ -42,7 +46,7 @@ export default function ProductCarousel({
|
|||||||
<Image
|
<Image
|
||||||
className={`${prefix}-image`}
|
className={`${prefix}-image`}
|
||||||
src={src}
|
src={src}
|
||||||
mode={imageMode}
|
mode={isContain ? 'aspectFit' : 'aspectFill'}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
onClick={previewable ? () => previewAt(index) : undefined}
|
onClick={previewable ? () => previewAt(index) : undefined}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import {
|
||||||
|
BRAND_LOGO_MARK_URL,
|
||||||
|
BRAND_LOGO_URL,
|
||||||
|
BRAND_LOGO_WIDE_URL,
|
||||||
|
CUSTOMER_SERVICE_PHONE,
|
||||||
|
QUALIFICATION_DISCLOSURE_URL,
|
||||||
|
type ClientRuntimeConfig,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
|
import { fetchClientConfig } from './pay-wechat';
|
||||||
|
|
||||||
|
export type BrandAssets = {
|
||||||
|
brandLogoUrl: string;
|
||||||
|
brandLogoWideUrl: string;
|
||||||
|
brandLogoMarkUrl: string;
|
||||||
|
qualificationDisclosureUrl: string;
|
||||||
|
customerServicePhone: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FALLBACK: BrandAssets = {
|
||||||
|
brandLogoUrl: BRAND_LOGO_URL,
|
||||||
|
brandLogoWideUrl: BRAND_LOGO_WIDE_URL,
|
||||||
|
brandLogoMarkUrl: BRAND_LOGO_MARK_URL,
|
||||||
|
qualificationDisclosureUrl: QUALIFICATION_DISCLOSURE_URL,
|
||||||
|
customerServicePhone: CUSTOMER_SERVICE_PHONE,
|
||||||
|
};
|
||||||
|
|
||||||
|
let cached: BrandAssets | null = null;
|
||||||
|
let inflight: Promise<BrandAssets> | null = null;
|
||||||
|
|
||||||
|
function fromConfig(config: ClientRuntimeConfig | null | undefined): BrandAssets {
|
||||||
|
return {
|
||||||
|
brandLogoUrl: config?.brandLogoUrl?.trim() || FALLBACK.brandLogoUrl,
|
||||||
|
brandLogoWideUrl: config?.brandLogoWideUrl?.trim() || FALLBACK.brandLogoWideUrl,
|
||||||
|
brandLogoMarkUrl: config?.brandLogoMarkUrl?.trim() || FALLBACK.brandLogoMarkUrl,
|
||||||
|
qualificationDisclosureUrl:
|
||||||
|
config?.qualificationDisclosureUrl?.trim() || FALLBACK.qualificationDisclosureUrl,
|
||||||
|
customerServicePhone: config?.customerServicePhone?.trim() || FALLBACK.customerServicePhone,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 同步读取最近一次缓存(未拉取前返回代码默认常量) */
|
||||||
|
export function getBrandAssetsSync(): BrandAssets {
|
||||||
|
return cached ?? FALLBACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拉取 /common/client-config 中的品牌与客服配置并缓存 */
|
||||||
|
export async function loadBrandAssets(force = false): Promise<BrandAssets> {
|
||||||
|
if (!force && cached) return cached;
|
||||||
|
if (!force && inflight) return inflight;
|
||||||
|
inflight = fetchClientConfig()
|
||||||
|
.then((cfg) => {
|
||||||
|
cached = fromConfig(cfg);
|
||||||
|
return cached;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
cached = FALLBACK;
|
||||||
|
return cached;
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
inflight = null;
|
||||||
|
});
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function applyBrandFromClientConfig(config: ClientRuntimeConfig | null | undefined) {
|
||||||
|
cached = fromConfig(config);
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import Taro from '@tarojs/taro';
|
|||||||
import { fetchClientConfig } from './pay-wechat';
|
import { fetchClientConfig } from './pay-wechat';
|
||||||
|
|
||||||
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */
|
/** 与 package.json version 同步,供服务端 minClientVersion 比对 */
|
||||||
export const APP_VERSION = '3.4.13';
|
export const APP_VERSION = '3.4.14';
|
||||||
|
|
||||||
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
export const APP_VERSION_LABEL = `v${APP_VERSION}`;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { BRAND_LOGO_URL } from '@dukang/shared-types';
|
|
||||||
import type { WechatShareData } from '@dukang/weixin-sdk';
|
import type { WechatShareData } from '@dukang/weixin-sdk';
|
||||||
import { getWechatShareLink, isWechatBrowser, isMiniProgram } from '@dukang/weixin-sdk';
|
import { getWechatShareLink, isWechatBrowser, isMiniProgram } from '@dukang/weixin-sdk';
|
||||||
import { toast } from './api';
|
import { toast } from './api';
|
||||||
|
import { getBrandAssetsSync, loadBrandAssets } from './brand-assets';
|
||||||
import { isWechatEnv, weixinSdk } from './weixin';
|
import { isWechatEnv, weixinSdk } from './weixin';
|
||||||
|
|
||||||
export const DEFAULT_SHARE_TITLE = '你吃饭,杜康买单';
|
export const DEFAULT_SHARE_TITLE = '你吃饭,我买单';
|
||||||
export const DEFAULT_SHARE_DESC = '杜康好客 · 买美酒,享好礼,全城门店可用';
|
export const DEFAULT_SHARE_DESC = '杜康好客 · 买美酒,享好礼,全城门店可用';
|
||||||
export const WECHAT_SHARE_HINT = '请点击右上角 ··· 分享给好友';
|
export const WECHAT_SHARE_HINT = '请点击右上角 ··· 分享给好友';
|
||||||
|
|
||||||
export function getDefaultShareImageUrl(): string {
|
export function getDefaultShareImageUrl(): string {
|
||||||
return BRAND_LOGO_URL;
|
return getBrandAssetsSync().brandLogoUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 预热分享默认图(来自系统设置) */
|
||||||
|
export function prefetchShareBrandAssets() {
|
||||||
|
void loadBrandAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildDefaultShareData(
|
export function buildDefaultShareData(
|
||||||
|
|||||||
@@ -1,19 +1,26 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
import { View, Text } from '@tarojs/components';
|
import { View, Text } from '@tarojs/components';
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { CUSTOMER_SERVICE_PHONE } from '@dukang/shared-types';
|
|
||||||
import PageShell from '../../components/PageShell';
|
import PageShell from '../../components/PageShell';
|
||||||
import SubPageHeader from '../../components/SubPageHeader';
|
import SubPageHeader from '../../components/SubPageHeader';
|
||||||
import ContactCsButton from '../../components/ContactCsButton';
|
import ContactCsButton from '../../components/ContactCsButton';
|
||||||
import { toast } from '../../lib/api';
|
import { toast } from '../../lib/api';
|
||||||
|
import { getBrandAssetsSync, loadBrandAssets } from '../../lib/brand-assets';
|
||||||
|
|
||||||
const isWeapp = process.env.TARO_ENV === 'weapp';
|
const isWeapp = process.env.TARO_ENV === 'weapp';
|
||||||
const DIAL_PHONE = CUSTOMER_SERVICE_PHONE.replace(/-/g, '');
|
|
||||||
|
|
||||||
function dialPhone() {
|
function dialPhone(phone: string) {
|
||||||
Taro.makePhoneCall({ phoneNumber: DIAL_PHONE }).catch(() => toast('无法拨打电话'));
|
const tel = phone.replace(/-/g, '');
|
||||||
|
Taro.makePhoneCall({ phoneNumber: tel }).catch(() => toast('无法拨打电话'));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CustomerServicePage() {
|
export default function CustomerServicePage() {
|
||||||
|
const [phone, setPhone] = useState(() => getBrandAssetsSync().customerServicePhone);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void loadBrandAssets().then((b) => setPhone(b.customerServicePhone));
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell variant="sub" className="cs-page">
|
<PageShell variant="sub" className="cs-page">
|
||||||
<SubPageHeader title="联系客服" />
|
<SubPageHeader title="联系客服" />
|
||||||
@@ -30,14 +37,14 @@ export default function CustomerServicePage() {
|
|||||||
<ContactCsButton className="cs-online-btn" session={{ from: 'customer-service' }} />
|
<ContactCsButton className="cs-online-btn" session={{ from: 'customer-service' }} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<View className={isWeapp ? 'cs-phone-link' : 'cs-call-btn'} onClick={dialPhone}>
|
<View className={isWeapp ? 'cs-phone-link' : 'cs-call-btn'} onClick={() => dialPhone(phone)}>
|
||||||
<Text>
|
<Text>
|
||||||
{isWeapp ? `或拨打客服电话 ${CUSTOMER_SERVICE_PHONE}` : '拨打客服电话'}
|
{isWeapp ? `或拨打客服电话 ${phone}` : '拨打客服电话'}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{!isWeapp ? (
|
{!isWeapp ? (
|
||||||
<Text className="cs-phone-display">{CUSTOMER_SERVICE_PHONE}</Text>
|
<Text className="cs-phone-display">{phone}</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
</PageShell>
|
</PageShell>
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ import {
|
|||||||
import PageShell from '../../components/PageShell';
|
import PageShell from '../../components/PageShell';
|
||||||
import WechatLoginButton from '../../components/WechatLoginButton';
|
import WechatLoginButton from '../../components/WechatLoginButton';
|
||||||
import PhoneQuickLoginButton from '../../components/PhoneQuickLoginButton';
|
import PhoneQuickLoginButton from '../../components/PhoneQuickLoginButton';
|
||||||
import { BRAND_LOGO_WIDE_URL } from '@dukang/shared-types';
|
import {
|
||||||
|
applyBrandFromClientConfig,
|
||||||
|
getBrandAssetsSync,
|
||||||
|
loadBrandAssets,
|
||||||
|
} from '../../lib/brand-assets';
|
||||||
import { finishLoginNavigate, forceReloadAfterAccountMerge } from '../../lib/auth-nav';
|
import { finishLoginNavigate, forceReloadAfterAccountMerge } from '../../lib/auth-nav';
|
||||||
import {
|
import {
|
||||||
bindWechatForUser,
|
bindWechatForUser,
|
||||||
@@ -98,11 +102,18 @@ export default function LoginPage() {
|
|||||||
const [wxAuthorize, setWxAuthorize] = useState(true);
|
const [wxAuthorize, setWxAuthorize] = useState(true);
|
||||||
const [completeMode, setCompleteMode] = useState<'phone' | 'wechat' | null>(null);
|
const [completeMode, setCompleteMode] = useState<'phone' | 'wechat' | null>(null);
|
||||||
const [showSmsForm, setShowSmsForm] = useState(!IS_WEAPP);
|
const [showSmsForm, setShowSmsForm] = useState(!IS_WEAPP);
|
||||||
|
const [logoWideUrl, setLogoWideUrl] = useState(() => getBrandAssetsSync().brandLogoWideUrl);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
request<ClientRuntimeConfig>('/common/client-config')
|
request<ClientRuntimeConfig>('/common/client-config')
|
||||||
.then((config) => setWxAuthorize(isWxAuthorizeEnabled(config)))
|
.then((config) => {
|
||||||
.catch(() => setWxAuthorize(true));
|
setWxAuthorize(isWxAuthorizeEnabled(config));
|
||||||
|
setLogoWideUrl(applyBrandFromClientConfig(config).brandLogoWideUrl);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setWxAuthorize(true);
|
||||||
|
void loadBrandAssets().then((b) => setLogoWideUrl(b.brandLogoWideUrl));
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -394,7 +405,7 @@ export default function LoginPage() {
|
|||||||
<View className="login-header">
|
<View className="login-header">
|
||||||
<View className="login-logo-wrap">
|
<View className="login-logo-wrap">
|
||||||
<View className="login-logo">
|
<View className="login-logo">
|
||||||
<Image className="login-logo-img" src={BRAND_LOGO_WIDE_URL} mode="aspectFit" />
|
<Image className="login-logo-img" src={logoWideUrl} mode="aspectFit" />
|
||||||
</View>
|
</View>
|
||||||
<Text className="login-logo-badge">官方</Text>
|
<Text className="login-logo-badge">官方</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { useEffect, useMemo, useState } from 'react';
|
|||||||
import { View, Text, Image, Button, Input, ScrollView } from '@tarojs/components';
|
import { View, Text, Image, Button, Input, ScrollView } from '@tarojs/components';
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
||||||
import {
|
import {
|
||||||
BRAND_LOGO_MARK_URL,
|
|
||||||
QUALIFICATION_DISCLOSURE_URL,
|
|
||||||
isWxAuthorizeEnabled,
|
isWxAuthorizeEnabled,
|
||||||
type ClientRuntimeConfig,
|
type ClientRuntimeConfig,
|
||||||
} from '@dukang/shared-types';
|
} from '@dukang/shared-types';
|
||||||
@@ -13,6 +11,11 @@ import WechatShareReady from '../../components/WechatShareReady';
|
|||||||
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
import UserTabBar, { shouldRenderPageTabBar, syncTabBarSelected } from '../../components/UserTabBar';
|
||||||
import { goLogin } from '../../lib/auth-nav';
|
import { goLogin } from '../../lib/auth-nav';
|
||||||
import { bindWechatForUser } from '../../lib/wechat-auth';
|
import { bindWechatForUser } from '../../lib/wechat-auth';
|
||||||
|
import {
|
||||||
|
applyBrandFromClientConfig,
|
||||||
|
getBrandAssetsSync,
|
||||||
|
loadBrandAssets,
|
||||||
|
} from '../../lib/brand-assets';
|
||||||
import {
|
import {
|
||||||
fetchMiniWechatUserInfo,
|
fetchMiniWechatUserInfo,
|
||||||
isDefaultMiniNickname,
|
isDefaultMiniNickname,
|
||||||
@@ -70,6 +73,10 @@ export default function MinePage() {
|
|||||||
const [savingProfile, setSavingProfile] = useState(false);
|
const [savingProfile, setSavingProfile] = useState(false);
|
||||||
const [profileLoadError, setProfileLoadError] = useState('');
|
const [profileLoadError, setProfileLoadError] = useState('');
|
||||||
const [qualificationOpen, setQualificationOpen] = useState(false);
|
const [qualificationOpen, setQualificationOpen] = useState(false);
|
||||||
|
const [brandMarkUrl, setBrandMarkUrl] = useState(() => getBrandAssetsSync().brandLogoMarkUrl);
|
||||||
|
const [qualificationUrl, setQualificationUrl] = useState(
|
||||||
|
() => getBrandAssetsSync().qualificationDisclosureUrl,
|
||||||
|
);
|
||||||
|
|
||||||
function resetGuestState() {
|
function resetGuestState() {
|
||||||
setProfile(null);
|
setProfile(null);
|
||||||
@@ -141,8 +148,16 @@ export default function MinePage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
request<ClientRuntimeConfig>('/common/client-config')
|
request<ClientRuntimeConfig>('/common/client-config')
|
||||||
.then((config) => setWxAuthorize(isWxAuthorizeEnabled(config)))
|
.then((config) => {
|
||||||
.catch(() => setWxAuthorize(true));
|
setWxAuthorize(isWxAuthorizeEnabled(config));
|
||||||
|
const brand = applyBrandFromClientConfig(config);
|
||||||
|
setBrandMarkUrl(brand.brandLogoMarkUrl);
|
||||||
|
setQualificationUrl(brand.qualificationDisclosureUrl);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setWxAuthorize(true);
|
||||||
|
void loadBrandAssets();
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const sharePayload = useMemo(
|
const sharePayload = useMemo(
|
||||||
@@ -304,7 +319,7 @@ export default function MinePage() {
|
|||||||
if (displayAvatarUrl) {
|
if (displayAvatarUrl) {
|
||||||
return <Image className="mine-avatar-img" src={displayAvatarUrl} mode="aspectFill" />;
|
return <Image className="mine-avatar-img" src={displayAvatarUrl} mode="aspectFill" />;
|
||||||
}
|
}
|
||||||
return <Image className="mine-avatar-img" src={BRAND_LOGO_MARK_URL} mode="aspectFit" />;
|
return <Image className="mine-avatar-img" src={brandMarkUrl} mode="aspectFit" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!authed) {
|
if (!authed) {
|
||||||
@@ -317,7 +332,7 @@ export default function MinePage() {
|
|||||||
<View className="mine-profile">
|
<View className="mine-profile">
|
||||||
<View className="mine-avatar-wrap mine-avatar-wrap--action" onClick={() => goLogin('/pages/mine/index')}>
|
<View className="mine-avatar-wrap mine-avatar-wrap--action" onClick={() => goLogin('/pages/mine/index')}>
|
||||||
<View className="mine-avatar mine-avatar--wx-pending">
|
<View className="mine-avatar mine-avatar--wx-pending">
|
||||||
<Image className="mine-avatar-img" src={BRAND_LOGO_MARK_URL} mode="aspectFit" />
|
<Image className="mine-avatar-img" src={brandMarkUrl} mode="aspectFit" />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View>
|
<View>
|
||||||
@@ -526,7 +541,7 @@ export default function MinePage() {
|
|||||||
{previewAvatar ? (
|
{previewAvatar ? (
|
||||||
<Image className="mine-avatar-img" src={previewAvatar} mode="aspectFill" />
|
<Image className="mine-avatar-img" src={previewAvatar} mode="aspectFill" />
|
||||||
) : (
|
) : (
|
||||||
<Image className="mine-avatar-img" src={BRAND_LOGO_MARK_URL} mode="aspectFit" />
|
<Image className="mine-avatar-img" src={brandMarkUrl} mode="aspectFit" />
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<Text className="mine-profile-avatar-tip">点击选择头像</Text>
|
<Text className="mine-profile-avatar-tip">点击选择头像</Text>
|
||||||
@@ -579,7 +594,7 @@ export default function MinePage() {
|
|||||||
<View className="mine-qualification-body">
|
<View className="mine-qualification-body">
|
||||||
<Image
|
<Image
|
||||||
className="mine-qualification-img"
|
className="mine-qualification-img"
|
||||||
src={QUALIFICATION_DISCLOSURE_URL}
|
src={qualificationUrl}
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { View, Text, Image, ScrollView } from '@tarojs/components';
|
import { View, Text, Image } from '@tarojs/components';
|
||||||
import Taro, {
|
import Taro, {
|
||||||
useDidShow,
|
useDidShow,
|
||||||
useLoad,
|
useLoad,
|
||||||
@@ -156,14 +156,9 @@ export default function StoreDetailPage() {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [loadError, setLoadError] = useState('');
|
const [loadError, setLoadError] = useState('');
|
||||||
const [headerSolid, setHeaderSolid] = useState(false);
|
const [headerSolid, setHeaderSolid] = useState(false);
|
||||||
const [activePackageIndex, setActivePackageIndex] = useState(0);
|
|
||||||
const storeRef = useRef<Store | null>(null);
|
const storeRef = useRef<Store | null>(null);
|
||||||
storeRef.current = store;
|
storeRef.current = store;
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setActivePackageIndex(0);
|
|
||||||
}, [store?.id]);
|
|
||||||
|
|
||||||
usePageScroll(({ scrollTop }) => {
|
usePageScroll(({ scrollTop }) => {
|
||||||
setHeaderSolid(scrollTop > 100);
|
setHeaderSolid(scrollTop > 100);
|
||||||
});
|
});
|
||||||
@@ -326,13 +321,18 @@ export default function StoreDetailPage() {
|
|||||||
const envPhotos = envPhotoUrls(store);
|
const envPhotos = envPhotoUrls(store);
|
||||||
const heroImages = uniqueUrls([store.coverUrl, ...(store.carouselUrls || [])]);
|
const heroImages = uniqueUrls([store.coverUrl, ...(store.carouselUrls || [])]);
|
||||||
const packages = store.packages ?? [];
|
const packages = store.packages ?? [];
|
||||||
const activePackage = packages[activePackageIndex] ?? packages[0];
|
|
||||||
|
|
||||||
const intro = store.intro?.trim() || '';
|
const intro = store.intro?.trim() || '';
|
||||||
const benefitRuleRaw = store.benefitUsageRule?.trim() || '';
|
const benefitRuleRaw = store.benefitUsageRule?.trim() || '';
|
||||||
const benefitRule =
|
const benefitRule =
|
||||||
benefitRuleRaw && !/^null$/i.test(benefitRuleRaw) ? benefitRuleRaw : '';
|
benefitRuleRaw && !/^null$/i.test(benefitRuleRaw) ? benefitRuleRaw : '';
|
||||||
|
|
||||||
|
function openPackageDetail(index: number) {
|
||||||
|
Taro.navigateTo({
|
||||||
|
url: `/pages/store-package-detail/index?storeId=${storeId}&index=${index}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function previewEnv(index: number) {
|
function previewEnv(index: number) {
|
||||||
if (!envPhotos.length) return;
|
if (!envPhotos.length) return;
|
||||||
Taro.previewImage({
|
Taro.previewImage({
|
||||||
@@ -353,7 +353,13 @@ export default function StoreDetailPage() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<View className="store-detail-hero full-bleed">
|
<View className="store-detail-hero full-bleed">
|
||||||
<ProductCarousel images={heroImages} alt={store.name} variant="store" previewable />
|
<ProductCarousel
|
||||||
|
images={heroImages}
|
||||||
|
alt={store.name}
|
||||||
|
variant="store"
|
||||||
|
previewable
|
||||||
|
imageFit="contain"
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className="store-detail-info-card">
|
<View className="store-detail-info-card">
|
||||||
@@ -408,49 +414,20 @@ export default function StoreDetailPage() {
|
|||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{packages.length > 0 && activePackage ? (
|
{packages.length > 0 ? (
|
||||||
<View className="store-detail-section store-detail-section--packages">
|
<View className="store-detail-section store-detail-section--packages">
|
||||||
<Text className="store-detail-section-title">门店套餐</Text>
|
<Text className="store-detail-section-title">门店套餐</Text>
|
||||||
{packages.length > 1 ? (
|
<View className="store-detail-package-list">
|
||||||
<ScrollView className="store-detail-package-tabs" scrollX showScrollbar={false} enhanced>
|
|
||||||
<View className="store-detail-package-tabs-inner">
|
|
||||||
{packages.map((pkg, index) => (
|
{packages.map((pkg, index) => (
|
||||||
<View
|
<View
|
||||||
key={`${pkg.name}-${index}`}
|
key={`${pkg.name}-${index}`}
|
||||||
className={`store-detail-package-tab${
|
className="store-detail-package-list-item"
|
||||||
index === activePackageIndex ? ' store-detail-package-tab--active' : ''
|
onClick={() => openPackageDetail(index)}
|
||||||
}`}
|
|
||||||
onClick={() => setActivePackageIndex(index)}
|
|
||||||
>
|
>
|
||||||
<Text className="store-detail-package-tab-text">{pkg.name}</Text>
|
<Text className="store-detail-package-list-title">{pkg.name}</Text>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
|
||||||
) : null}
|
|
||||||
<View className="store-detail-package-panel">
|
|
||||||
{activePackage.imageUrl ? (
|
|
||||||
<Image
|
|
||||||
className="store-detail-package-thumb"
|
|
||||||
src={activePackage.imageUrl}
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<View className="store-detail-package-panel-body">
|
|
||||||
{packages.length === 1 ? (
|
|
||||||
<Text className="store-detail-package-name">{activePackage.name}</Text>
|
|
||||||
) : null}
|
|
||||||
<Text className="store-detail-package-body">
|
|
||||||
{formatRedeemAmountYuan(activePackage.price)} 元 · {activePackage.dishes}
|
|
||||||
</Text>
|
|
||||||
{activePackage.usableTime ? (
|
|
||||||
<Text className="store-detail-package-meta">使用时间:{activePackage.usableTime}</Text>
|
|
||||||
) : null}
|
|
||||||
{activePackage.otherNotes ? (
|
|
||||||
<Text className="store-detail-package-meta">说明:{activePackage.otherNotes}</Text>
|
|
||||||
) : null}
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
navigationBarTitleText: '套餐详情',
|
||||||
|
});
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
import { View, Text, Image } from '@tarojs/components';
|
||||||
|
import Taro, { useLoad, useRouter } from '@tarojs/taro';
|
||||||
|
import PageShell from '../../components/PageShell';
|
||||||
|
import PageNavBar from '../../components/PageNavBar';
|
||||||
|
import { request, toast } from '../../lib/api';
|
||||||
|
|
||||||
|
type StorePackage = {
|
||||||
|
name: string;
|
||||||
|
price: string | number;
|
||||||
|
dishes: string;
|
||||||
|
usableTime?: string | null;
|
||||||
|
otherNotes?: string | null;
|
||||||
|
imageUrl?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Store = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
packages?: StorePackage[] | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function pickStoreId(raw?: string | null) {
|
||||||
|
return String(raw || '')
|
||||||
|
.trim()
|
||||||
|
.replace(/[^\d]/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function parsePackageIndex(raw?: string | null) {
|
||||||
|
const n = Number.parseInt(String(raw ?? ''), 10);
|
||||||
|
return Number.isFinite(n) && n >= 0 ? n : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatPriceYuan(price: string | number) {
|
||||||
|
const n = typeof price === 'number' ? price : Number(price);
|
||||||
|
if (!Number.isFinite(n)) return '0';
|
||||||
|
if (Math.abs(n - Math.round(n)) < 1e-9) return String(Math.round(n));
|
||||||
|
return n.toFixed(2).replace(/\.?0+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function StorePackageDetailPage() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [storeId, setStoreId] = useState(() => pickStoreId(router.params.storeId));
|
||||||
|
const [storeName, setStoreName] = useState('');
|
||||||
|
const [pkg, setPkg] = useState<StorePackage | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [loadError, setLoadError] = useState('');
|
||||||
|
|
||||||
|
const loadPackage = useCallback(async (sid: string, index: number) => {
|
||||||
|
if (!sid) {
|
||||||
|
setLoading(false);
|
||||||
|
setLoadError('缺少门店参数');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (index < 0) {
|
||||||
|
setLoading(false);
|
||||||
|
setLoadError('套餐不存在');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setLoadError('');
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const data = await request<Store>(`/stores/${sid}`);
|
||||||
|
const packages = data?.packages ?? [];
|
||||||
|
const item = packages[index];
|
||||||
|
if (!data?.id || !item) {
|
||||||
|
setPkg(null);
|
||||||
|
setLoadError('套餐不存在或已下架');
|
||||||
|
toast('套餐不存在或已下架');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setStoreName(data.name);
|
||||||
|
setPkg(item);
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e instanceof Error ? e.message : '加载失败';
|
||||||
|
setLoadError(msg);
|
||||||
|
toast(msg);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useLoad((options) => {
|
||||||
|
const sid = pickStoreId(options?.storeId || router.params.storeId);
|
||||||
|
const index = parsePackageIndex(options?.index ?? router.params.index);
|
||||||
|
setStoreId(sid);
|
||||||
|
void loadPackage(sid, index);
|
||||||
|
});
|
||||||
|
|
||||||
|
function goBack() {
|
||||||
|
const pages = Taro.getCurrentPages();
|
||||||
|
if (pages.length > 1) Taro.navigateBack();
|
||||||
|
else if (storeId) {
|
||||||
|
Taro.redirectTo({ url: `/pages/store-detail/index?id=${storeId}` });
|
||||||
|
} else {
|
||||||
|
Taro.switchTab({ url: '/pages/stores/index' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewImage(url: string) {
|
||||||
|
Taro.previewImage({ urls: [url], current: url }).catch(() => toast('无法预览图片'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<PageShell variant="scroll" className="store-package-detail-page">
|
||||||
|
<PageNavBar title="套餐详情" solid onBack={goBack} />
|
||||||
|
<View className="page-with-nav-bar u-empty">加载中…</View>
|
||||||
|
</PageShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pkg) {
|
||||||
|
return (
|
||||||
|
<PageShell variant="scroll" className="store-package-detail-page">
|
||||||
|
<PageNavBar title="套餐详情" solid onBack={goBack} />
|
||||||
|
<View className="page-with-nav-bar u-empty">{loadError || '套餐不存在'}</View>
|
||||||
|
</PageShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageUrl = (pkg.imageUrl || '').trim();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<PageShell variant="scroll" className="store-package-detail-page">
|
||||||
|
<PageNavBar title={pkg.name} solid titleVisible onBack={goBack} />
|
||||||
|
|
||||||
|
<View className="store-package-detail-body">
|
||||||
|
<View className="store-package-detail-inner">
|
||||||
|
<View className="store-package-detail-header">
|
||||||
|
<View className="store-package-detail-title-row">
|
||||||
|
<Text className="store-package-detail-title">{pkg.name}</Text>
|
||||||
|
<Text className="store-package-detail-price">¥{formatPriceYuan(pkg.price)}</Text>
|
||||||
|
</View>
|
||||||
|
{storeName ? (
|
||||||
|
<Text className="store-package-detail-store">{storeName}</Text>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{imageUrl ? (
|
||||||
|
<View
|
||||||
|
className="store-package-detail-photo"
|
||||||
|
onClick={() => previewImage(imageUrl)}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
className="store-package-detail-photo-image"
|
||||||
|
src={imageUrl}
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<View className="store-package-detail-content">
|
||||||
|
<View className="store-detail-package-field">
|
||||||
|
<Text className="store-detail-package-field-label">菜品</Text>
|
||||||
|
<Text className="store-detail-package-field-value">{pkg.dishes || '—'}</Text>
|
||||||
|
</View>
|
||||||
|
{pkg.usableTime ? (
|
||||||
|
<View className="store-detail-package-field">
|
||||||
|
<Text className="store-detail-package-field-label">使用时间</Text>
|
||||||
|
<Text className="store-detail-package-field-value">{pkg.usableTime}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
{pkg.otherNotes ? (
|
||||||
|
<View className="store-detail-package-field">
|
||||||
|
<Text className="store-detail-package-field-label">其他说明</Text>
|
||||||
|
<Text className="store-detail-package-field-value">{pkg.otherNotes}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</PageShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { View, Text, Image, Input } from '@tarojs/components';
|
import { View, Text, Image, Input } from '@tarojs/components';
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
import Taro, { useDidShow, usePullDownRefresh, useShareAppMessage, useShareTimeline } from '@tarojs/taro';
|
||||||
import { StoreStatus, STORE_STATUS_LABELS } from '@dukang/shared-types';
|
|
||||||
import PageShell from '../../components/PageShell';
|
import PageShell from '../../components/PageShell';
|
||||||
import TabMainHeader from '../../components/TabMainHeader';
|
import TabMainHeader from '../../components/TabMainHeader';
|
||||||
import WechatShareReady from '../../components/WechatShareReady';
|
import WechatShareReady from '../../components/WechatShareReady';
|
||||||
@@ -342,17 +341,12 @@ export default function StoresPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatHours(store: Store) {
|
function hoursLines(store: Store): string[] {
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
if (store.openTime && store.closeTime) parts.push(`${store.openTime}-${store.closeTime}`);
|
if (store.openTime && store.closeTime) parts.push(`${store.openTime}-${store.closeTime}`);
|
||||||
if (store.openTime2 && store.closeTime2) parts.push(`${store.openTime2}-${store.closeTime2}`);
|
if (store.openTime2 && store.closeTime2) parts.push(`${store.openTime2}-${store.closeTime2}`);
|
||||||
return parts.length ? `营业时间: ${parts.join(',')}` : '营业时间: 10:00-22:00';
|
if (!parts.length) parts.push('10:00-22:00');
|
||||||
}
|
return parts.map((p, i) => (i === 0 ? `营业时间: ${p}` : p));
|
||||||
|
|
||||||
function formatStatus(store: Store) {
|
|
||||||
const status = store.status as StoreStatus | undefined;
|
|
||||||
if (status && STORE_STATUS_LABELS[status]) return STORE_STATUS_LABELS[status];
|
|
||||||
return STORE_STATUS_LABELS[StoreStatus.OPEN];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharePayload = useMemo(
|
const sharePayload = useMemo(
|
||||||
@@ -446,14 +440,17 @@ export default function StoresPage() {
|
|||||||
{formatDistanceMeters(s.distanceMeters)}
|
{formatDistanceMeters(s.distanceMeters)}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{/* 第2行:状态 + 营业时间(含第二段) */}
|
{/* 第2行:营业时间(多段各占一行,居左) */}
|
||||||
<View className="store-card-row store-card-row--meta">
|
<View className="store-card-hours">
|
||||||
<Text className="store-card-status">{formatStatus(s)}</Text>
|
{hoursLines(s).map((line) => (
|
||||||
<Text className="store-card-hours">{formatHours(s)}</Text>
|
<Text key={line} className="store-card-hours-line">
|
||||||
|
{line}
|
||||||
|
</Text>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
{/* 第3行:地址 + 去核销 */}
|
{/* 第3行:地址(最多两行)+ 去核销 */}
|
||||||
<View className="store-card-row store-card-row--foot">
|
<View className="store-card-row store-card-row--foot">
|
||||||
<Text className="store-card-address" numberOfLines={1}>
|
<Text className="store-card-address" numberOfLines={2}>
|
||||||
{s.address || (s.district ? `${s.district}` : '地址待完善')}
|
{s.address || (s.district ? `${s.district}` : '地址待完善')}
|
||||||
</Text>
|
</Text>
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -12,7 +12,22 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
aspect-ratio: 4 / 3;
|
aspect-ratio: 4 / 3;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--color-surface-container);
|
/* background: var(--color-surface-container); */
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 门店门头:固定 4:3 区域,图片 aspectFit 缩放完整显示(不裁剪) */
|
||||||
|
.store-detail-carousel-wrap--contain .store-detail-carousel-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-carousel-wrap--contain .store-detail-carousel-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
object-position: center center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-carousel {
|
.store-detail-carousel {
|
||||||
@@ -29,6 +44,7 @@
|
|||||||
|
|
||||||
.store-detail-carousel-image {
|
.store-detail-carousel-image {
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
object-position: center center;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +75,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-info-card {
|
.store-detail-info-card {
|
||||||
margin: -40px var(--space-page) 16px;
|
margin: 0 var(--space-page) 16px;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
background: var(--color-card);
|
background: var(--color-card);
|
||||||
@@ -246,100 +262,142 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-tabs {
|
.store-detail-package-list {
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-tabs-inner {
|
|
||||||
display: inline-flex;
|
|
||||||
flex-wrap: nowrap;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 2px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-tab {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-shrink: 0;
|
|
||||||
max-width: 132px;
|
|
||||||
padding: 6px 12px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: rgba(0, 0, 0, 0.04);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-tab--active {
|
|
||||||
background: rgba(166, 29, 36, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-tab-text {
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 18px;
|
|
||||||
color: var(--color-text-secondary, #666);
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-tab--active .store-detail-package-tab-text {
|
|
||||||
color: var(--color-heritage-red, #a61d24);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-detail-package-panel {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
flex-direction: column;
|
||||||
gap: 10px;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: var(--radius-md, 8px);
|
|
||||||
background: var(--color-surface-container, #f7f7f7);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-thumb {
|
.store-detail-package-list-item {
|
||||||
width: 72px;
|
padding: 14px 0;
|
||||||
height: 72px;
|
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
|
||||||
border-radius: 6px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.04);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-panel-body {
|
.store-detail-package-list-item:first-child {
|
||||||
flex: 1;
|
padding-top: 4px;
|
||||||
min-width: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-body,
|
.store-detail-package-list-item:last-child {
|
||||||
.store-detail-package-meta {
|
border-bottom: none;
|
||||||
display: -webkit-box;
|
padding-bottom: 0;
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-name {
|
.store-detail-package-list-title {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-package-list-item:active {
|
||||||
|
opacity: 0.72;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── 套餐详情页(独立于门店详情) ── */
|
||||||
|
.store-package-detail-page {
|
||||||
|
background: var(--color-background);
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-body {
|
||||||
|
/* 避开状态栏+胶囊导航,并额外 12px 顶白 */
|
||||||
|
padding: calc(var(--nav-bar-height, 56px) + 12px) 0 24px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-inner {
|
||||||
|
/* 左右留白,内容不贴边 */
|
||||||
|
padding: 8px 16px 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-header {
|
||||||
|
padding: 8px 16px 4px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-title-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-title {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
font-family: var(--font-headline);
|
||||||
|
font-size: 20px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: var(--color-text-primary, #1a1a1a);
|
line-height: 1.4;
|
||||||
margin-bottom: 4px;
|
color: var(--color-ink-black);
|
||||||
overflow: hidden;
|
word-break: break-word;
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-body {
|
.store-package-detail-price {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.35;
|
||||||
|
color: #a61d24;
|
||||||
|
color: var(--color-heritage-red, #a61d24);
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-store {
|
||||||
|
display: block;
|
||||||
|
margin-top: 10px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--color-text-secondary, #666);
|
line-height: 1.5;
|
||||||
line-height: 1.45;
|
color: var(--color-on-surface-variant);
|
||||||
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-meta {
|
.store-package-detail-photo {
|
||||||
font-size: 12px;
|
margin: 14px 0 0;
|
||||||
color: var(--color-text-tertiary, #999);
|
border-radius: var(--radius-lg);
|
||||||
margin-top: 4px;
|
overflow: hidden;
|
||||||
|
background: var(--color-card);
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-photo-image {
|
||||||
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-package-detail-content {
|
||||||
|
margin-top: 16px;
|
||||||
|
background: var(--color-card);
|
||||||
|
border-radius: var(--radius-lg);
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-package-field-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--color-on-surface-variant);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-package-field-value {
|
||||||
|
display: block;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-on-surface);
|
||||||
|
line-height: 1.7;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-package-field {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-detail-package-field:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-detail-package-dispute {
|
.store-detail-package-dispute {
|
||||||
|
|||||||
@@ -144,11 +144,11 @@
|
|||||||
padding: 4px var(--space-page) 16px;
|
padding: 4px var(--space-page) 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 左图右文,卡片等高 */
|
/* 左图右文 */
|
||||||
.store-card {
|
.store-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: stretch;
|
align-items: flex-start;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -174,10 +174,11 @@
|
|||||||
.store-card-body {
|
.store-card-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 96px;
|
min-height: 96px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
gap: 4px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,39 +219,29 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 第2行:营业状态 + 营业时间(可含两段) */
|
/* 第2行:营业时间独自居左;多段各占一行 */
|
||||||
.store-card-row--meta {
|
|
||||||
gap: 6px;
|
|
||||||
min-height: 20px;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-card-status {
|
|
||||||
flex-shrink: 0;
|
|
||||||
padding: 0 6px;
|
|
||||||
margin-top: 1px;
|
|
||||||
border-radius: 4px;
|
|
||||||
background: rgba(45, 106, 79, 0.12);
|
|
||||||
color: #2d6a4f;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 18px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.store-card-hours {
|
.store-card-hours {
|
||||||
flex: 1;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 2px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.store-card-hours-line {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 第3行:地址(单行截断)+ 右对齐去核销 */
|
/* 第3行:地址最多两行截断 + 右对齐去核销;与按钮垂直居中 */
|
||||||
.store-card-row--foot {
|
.store-card-row--foot {
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
height: 28px;
|
min-height: 28px;
|
||||||
|
align-items: center;
|
||||||
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-address {
|
.store-card-address {
|
||||||
@@ -258,11 +249,18 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: 28px;
|
line-height: 14px;
|
||||||
|
max-height: 28px;
|
||||||
color: #999;
|
color: #999;
|
||||||
|
text-align: left;
|
||||||
|
white-space: normal;
|
||||||
|
word-break: break-word;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
line-clamp: 2;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.store-card-cta {
|
.store-card-cta {
|
||||||
|
|||||||
@@ -32,29 +32,29 @@ export interface AppConfig {
|
|||||||
userH5Url: string;
|
userH5Url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 推广码 / C 端 H5 默认落地页(未配置 USER_H5_URL 时使用) */
|
/** 推广码 / C 端 H5 默认落地页(系统设置 USER_H5_URL 未配时回退;HQ 可改) */
|
||||||
export const DEFAULT_USER_H5_URL = 'https://user.runxian.top/user';
|
export const DEFAULT_USER_H5_URL = 'https://user.runxian.top/user';
|
||||||
|
|
||||||
/** 品牌 Logo OSS 根路径(改环境时只改此处) */
|
/** 品牌 Logo OSS 根路径(默认;系统设置 BRAND_LOGO_OSS_BASE 可覆盖) */
|
||||||
export const BRAND_LOGO_OSS_BASE = 'https://dukang-dev.oss-cn-beijing.aliyuncs.com/logo/';
|
export const BRAND_LOGO_OSS_BASE = 'https://dukang-dev.oss-cn-beijing.aliyuncs.com/logo/';
|
||||||
|
|
||||||
/** 方形 Logo(首页等品牌展示;商品列表顶栏仍用文字标题) */
|
/** 方形 Logo(默认;系统设置 BRAND_LOGO_URL 可覆盖) */
|
||||||
export const BRAND_LOGO_URL = `${BRAND_LOGO_OSS_BASE}logo.png`;
|
export const BRAND_LOGO_URL = `${BRAND_LOGO_OSS_BASE}logo.png`;
|
||||||
|
|
||||||
/** 长方形 Logo(含文字,登录等场景) */
|
/** 长方形 Logo(默认;系统设置 BRAND_LOGO_WIDE_URL 可覆盖) */
|
||||||
export const BRAND_LOGO_WIDE_URL = `${BRAND_LOGO_OSS_BASE}logo1.png`;
|
export const BRAND_LOGO_WIDE_URL = `${BRAND_LOGO_OSS_BASE}logo1.png`;
|
||||||
|
|
||||||
/** 仅图标 Logo(默认头像:未微信授权时) */
|
/** 仅图标 Logo(默认;系统设置 BRAND_LOGO_MARK_URL 可覆盖) */
|
||||||
export const BRAND_LOGO_MARK_URL = `${BRAND_LOGO_OSS_BASE}logo2.png`;
|
export const BRAND_LOGO_MARK_URL = `${BRAND_LOGO_OSS_BASE}logo2.png`;
|
||||||
|
|
||||||
/** 小程序静态资源(资质公示等) */
|
/** 小程序静态资源根路径(默认;系统设置 MINI_USER_STATIC_OSS_BASE 可覆盖) */
|
||||||
export const MINI_USER_STATIC_OSS_BASE =
|
export const MINI_USER_STATIC_OSS_BASE =
|
||||||
'https://dukang-dev.oss-cn-beijing.aliyuncs.com/static/mini-user/';
|
'https://dukang-dev.oss-cn-beijing.aliyuncs.com/static/mini-user/';
|
||||||
|
|
||||||
/** 「我的」页资质公示长图 */
|
/** 「我的」页资质公示长图(默认;系统设置 QUALIFICATION_DISCLOSURE_URL 可覆盖) */
|
||||||
export const QUALIFICATION_DISCLOSURE_URL = `${MINI_USER_STATIC_OSS_BASE}qualification-disclosure.png`;
|
export const QUALIFICATION_DISCLOSURE_URL = `${MINI_USER_STATIC_OSS_BASE}qualification-disclosure.png`;
|
||||||
|
|
||||||
/** 总部客服电话(C 端联系客服) */
|
/** 总部客服电话(默认;系统设置 CUSTOMER_SERVICE_PHONE 可覆盖) */
|
||||||
export const CUSTOMER_SERVICE_PHONE = '13203801799';
|
export const CUSTOMER_SERVICE_PHONE = '13203801799';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,6 +64,46 @@ export const CUSTOMER_SERVICE_PHONE = '13203801799';
|
|||||||
export const CUSTOMER_SERVICE_WECOM_URL =
|
export const CUSTOMER_SERVICE_WECOM_URL =
|
||||||
'https://work.weixin.qq.com/kfid/kfc8b88659a1dffa8cd';
|
'https://work.weixin.qq.com/kfid/kfc8b88659a1dffa8cd';
|
||||||
|
|
||||||
|
/** 从 env / 系统设置解析的 C 端品牌与客服展示配置(缺省回退常量) */
|
||||||
|
export type ClientBrandRuntime = {
|
||||||
|
userH5Url: string;
|
||||||
|
brandLogoOssBase: string;
|
||||||
|
brandLogoUrl: string;
|
||||||
|
brandLogoWideUrl: string;
|
||||||
|
brandLogoMarkUrl: string;
|
||||||
|
miniUserStaticOssBase: string;
|
||||||
|
qualificationDisclosureUrl: string;
|
||||||
|
customerServicePhone: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function resolveClientBrandRuntime(
|
||||||
|
env?: Record<string, string | undefined>,
|
||||||
|
): ClientBrandRuntime {
|
||||||
|
const e = readEnv(env);
|
||||||
|
const brandBase = (e.BRAND_LOGO_OSS_BASE || BRAND_LOGO_OSS_BASE).trim().replace(/\/*$/, '/');
|
||||||
|
const staticBase = (e.MINI_USER_STATIC_OSS_BASE || MINI_USER_STATIC_OSS_BASE)
|
||||||
|
.trim()
|
||||||
|
.replace(/\/*$/, '/');
|
||||||
|
return {
|
||||||
|
userH5Url: (e.USER_H5_URL || DEFAULT_USER_H5_URL).replace(/\/$/, ''),
|
||||||
|
brandLogoOssBase: brandBase,
|
||||||
|
brandLogoUrl: (e.BRAND_LOGO_URL || '').trim() || `${brandBase}logo.png`,
|
||||||
|
brandLogoWideUrl: (e.BRAND_LOGO_WIDE_URL || '').trim() || `${brandBase}logo1.png`,
|
||||||
|
brandLogoMarkUrl: (e.BRAND_LOGO_MARK_URL || '').trim() || `${brandBase}logo2.png`,
|
||||||
|
miniUserStaticOssBase: staticBase,
|
||||||
|
qualificationDisclosureUrl:
|
||||||
|
(e.QUALIFICATION_DISCLOSURE_URL || '').trim() ||
|
||||||
|
`${staticBase}qualification-disclosure.png`,
|
||||||
|
customerServicePhone: (e.CUSTOMER_SERVICE_PHONE || CUSTOMER_SERVICE_PHONE).trim(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mock 短信固定验证码(系统设置 MOCK_SMS_FIXED_CODE 可覆盖) */
|
||||||
|
export function resolveMockSmsFixedCode(env?: Record<string, string | undefined>): string {
|
||||||
|
const code = (readEnv(env).MOCK_SMS_FIXED_CODE || '').trim();
|
||||||
|
return code || MOCK_SMS_FIXED_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
function readEnv(env?: Record<string, string | undefined>) {
|
function readEnv(env?: Record<string, string | undefined>) {
|
||||||
return (
|
return (
|
||||||
env ??
|
env ??
|
||||||
@@ -142,5 +182,5 @@ export function loadAppConfig(env?: Record<string, string | undefined>): AppConf
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mock 短信环境固定验证码 */
|
/** Mock 短信环境固定验证码(默认;系统设置 MOCK_SMS_FIXED_CODE 可覆盖) */
|
||||||
export const MOCK_SMS_FIXED_CODE = '999888';
|
export const MOCK_SMS_FIXED_CODE = '999888';
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ export type ClientRuntimeConfig = {
|
|||||||
};
|
};
|
||||||
/** 小程序最低兼容版本(semver,如 3.4.13);客户端低于此值时提示更新 */
|
/** 小程序最低兼容版本(semver,如 3.4.13);客户端低于此值时提示更新 */
|
||||||
minClientVersion?: string | null;
|
minClientVersion?: string | null;
|
||||||
|
/** C 端 H5 落地页(推广码等) */
|
||||||
|
userH5Url?: string;
|
||||||
|
/** 方形品牌 Logo */
|
||||||
|
brandLogoUrl?: string;
|
||||||
|
/** 长方形品牌 Logo(登录) */
|
||||||
|
brandLogoWideUrl?: string;
|
||||||
|
/** 图标 Logo(默认头像) */
|
||||||
|
brandLogoMarkUrl?: string;
|
||||||
|
/** 「我的」资质公示长图 */
|
||||||
|
qualificationDisclosureUrl?: string;
|
||||||
|
/** 总部客服电话 */
|
||||||
|
customerServicePhone?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 是否展示微信授权入口 */
|
/** 是否展示微信授权入口 */
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
import type { SystemConfigFieldMeta, SystemConfigGroupMeta } from '@dukang/shared-types';
|
import type { SystemConfigFieldMeta, SystemConfigGroupMeta } from '@dukang/shared-types';
|
||||||
|
import {
|
||||||
|
BRAND_LOGO_MARK_URL,
|
||||||
|
BRAND_LOGO_OSS_BASE,
|
||||||
|
BRAND_LOGO_URL,
|
||||||
|
BRAND_LOGO_WIDE_URL,
|
||||||
|
CUSTOMER_SERVICE_PHONE,
|
||||||
|
DEFAULT_USER_H5_URL,
|
||||||
|
MINI_USER_STATIC_OSS_BASE,
|
||||||
|
MOCK_SMS_FIXED_CODE,
|
||||||
|
QUALIFICATION_DISCLOSURE_URL,
|
||||||
|
} from '@dukang/shared-types';
|
||||||
|
|
||||||
/** 运行环境、安全与鉴权仅保留在 .env,不在 HQ 系统设置中维护 */
|
/** 运行环境、安全与鉴权仅保留在 .env,不在 HQ 系统设置中维护 */
|
||||||
export const SYSTEM_CONFIG_GROUPS: SystemConfigGroupMeta[] = [
|
export const SYSTEM_CONFIG_GROUPS: SystemConfigGroupMeta[] = [
|
||||||
@@ -122,9 +133,86 @@ export const SYSTEM_CONFIG_FIELDS: SystemConfigFieldMeta[] = [
|
|||||||
group: G.wechat_mini,
|
group: G.wechat_mini,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
requiresRestart: false,
|
requiresRestart: false,
|
||||||
placeholder: '3.4.13',
|
placeholder: '3.4.14',
|
||||||
description: 'semver 格式;客户端低于此版本时提示更新',
|
description: 'semver 格式;客户端低于此版本时提示更新',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'USER_H5_URL',
|
||||||
|
label: 'C 端 H5 落地页',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'string',
|
||||||
|
requiresRestart: false,
|
||||||
|
placeholder: 'https://user.example.com/user',
|
||||||
|
description: '推广码二维码 / 未配置时的默认落地页前缀(无末尾斜杠)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'BRAND_LOGO_OSS_BASE',
|
||||||
|
label: '品牌 Logo OSS 根路径',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'string',
|
||||||
|
requiresRestart: false,
|
||||||
|
placeholder: 'https://xxx.oss-cn-beijing.aliyuncs.com/logo/',
|
||||||
|
description: '仅作说明/备份;下方三张 Logo 请直接配置完整 URL',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'BRAND_LOGO_URL',
|
||||||
|
label: '方形 Logo',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'image',
|
||||||
|
requiresRestart: false,
|
||||||
|
description: '分享卡片默认图、首页等品牌展示',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'BRAND_LOGO_WIDE_URL',
|
||||||
|
label: '长方形 Logo',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'image',
|
||||||
|
requiresRestart: false,
|
||||||
|
description: '含文字,登录页等场景',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'BRAND_LOGO_MARK_URL',
|
||||||
|
label: '图标 Logo',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'image',
|
||||||
|
requiresRestart: false,
|
||||||
|
description: '默认头像(未微信授权时)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'MINI_USER_STATIC_OSS_BASE',
|
||||||
|
label: '小程序静态资源 OSS 根路径',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'string',
|
||||||
|
requiresRestart: false,
|
||||||
|
placeholder: 'https://xxx.oss-cn-beijing.aliyuncs.com/static/mini-user/',
|
||||||
|
description: '资质公示等静态资源根路径;完整 URL 优先用下方「资质公示图」',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'QUALIFICATION_DISCLOSURE_URL',
|
||||||
|
label: '资质公示长图',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'image',
|
||||||
|
requiresRestart: false,
|
||||||
|
description: '「我的」页资质公示大图',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'CUSTOMER_SERVICE_PHONE',
|
||||||
|
label: '总部客服电话',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'string',
|
||||||
|
requiresRestart: false,
|
||||||
|
placeholder: '13203801799',
|
||||||
|
description: 'C 端联系客服拨号号码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'MOCK_SMS_FIXED_CODE',
|
||||||
|
label: 'Mock 短信固定验证码',
|
||||||
|
group: G.wechat_mini,
|
||||||
|
type: 'string',
|
||||||
|
requiresRestart: false,
|
||||||
|
placeholder: '999888',
|
||||||
|
description: '仅 MOCK_SMS 开启时生效;留空则用默认 999888',
|
||||||
|
},
|
||||||
|
|
||||||
{ key: 'OSS_ACCESS_KEY_ID', label: 'OSS AccessKey ID', group: G.oss, type: 'password', secret: true, requiresRestart: true },
|
{ key: 'OSS_ACCESS_KEY_ID', label: 'OSS AccessKey ID', group: G.oss, type: 'password', secret: true, requiresRestart: true },
|
||||||
{ key: 'OSS_ACCESS_KEY_SECRET', label: 'OSS AccessKey Secret', group: G.oss, type: 'password', secret: true, requiresRestart: true },
|
{ key: 'OSS_ACCESS_KEY_SECRET', label: 'OSS AccessKey Secret', group: G.oss, type: 'password', secret: true, requiresRestart: true },
|
||||||
@@ -137,7 +225,6 @@ export const SYSTEM_CONFIG_FIELDS: SystemConfigFieldMeta[] = [
|
|||||||
{ key: 'OSS_UPLOAD_EXPIRE_SECONDS', label: '直传凭证有效期(秒)', group: G.oss, type: 'number', requiresRestart: false },
|
{ key: 'OSS_UPLOAD_EXPIRE_SECONDS', label: '直传凭证有效期(秒)', group: G.oss, type: 'number', requiresRestart: false },
|
||||||
{ key: 'OSS_MAX_UPLOAD_BYTES', label: '单文件上限(字节)', group: G.oss, type: 'number', requiresRestart: false },
|
{ key: 'OSS_MAX_UPLOAD_BYTES', label: '单文件上限(字节)', group: G.oss, type: 'number', requiresRestart: false },
|
||||||
|
|
||||||
{ key: 'USER_H5_URL', label: 'C 端 H5 落地页', group: G.app, type: 'string', requiresRestart: false },
|
|
||||||
{
|
{
|
||||||
key: 'TENCENT_LBS_KEY',
|
key: 'TENCENT_LBS_KEY',
|
||||||
label: '腾讯位置服务 Key',
|
label: '腾讯位置服务 Key',
|
||||||
@@ -247,6 +334,23 @@ export const SYSTEM_CONFIG_RETIRED_KEYS = [
|
|||||||
|
|
||||||
export const SYSTEM_CONFIG_KEY_SET = new Set(SYSTEM_CONFIG_FIELDS.map((f) => f.key));
|
export const SYSTEM_CONFIG_KEY_SET = new Set(SYSTEM_CONFIG_FIELDS.map((f) => f.key));
|
||||||
|
|
||||||
|
/** 表单空值时展示 / 启动补种的默认值(与 shared-types 常量对齐) */
|
||||||
|
export const SYSTEM_CONFIG_DEFAULTS: Record<string, string> = {
|
||||||
|
USER_H5_URL: DEFAULT_USER_H5_URL.replace(/\/$/, ''),
|
||||||
|
BRAND_LOGO_OSS_BASE: BRAND_LOGO_OSS_BASE,
|
||||||
|
BRAND_LOGO_URL: BRAND_LOGO_URL,
|
||||||
|
BRAND_LOGO_WIDE_URL: BRAND_LOGO_WIDE_URL,
|
||||||
|
BRAND_LOGO_MARK_URL: BRAND_LOGO_MARK_URL,
|
||||||
|
MINI_USER_STATIC_OSS_BASE: MINI_USER_STATIC_OSS_BASE,
|
||||||
|
QUALIFICATION_DISCLOSURE_URL: QUALIFICATION_DISCLOSURE_URL,
|
||||||
|
CUSTOMER_SERVICE_PHONE: CUSTOMER_SERVICE_PHONE,
|
||||||
|
MOCK_SMS_FIXED_CODE: MOCK_SMS_FIXED_CODE,
|
||||||
|
};
|
||||||
|
|
||||||
export function getSystemConfigField(key: string): SystemConfigFieldMeta | undefined {
|
export function getSystemConfigField(key: string): SystemConfigFieldMeta | undefined {
|
||||||
return SYSTEM_CONFIG_FIELDS.find((f) => f.key === key);
|
return SYSTEM_CONFIG_FIELDS.find((f) => f.key === key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSystemConfigDefault(key: string): string {
|
||||||
|
return SYSTEM_CONFIG_DEFAULTS[key] ?? '';
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type {
|
|||||||
import { loadAppConfig, parseMiniHomeBanners, serializeMiniHomeBanners } from '@dukang/shared-types';
|
import { loadAppConfig, parseMiniHomeBanners, serializeMiniHomeBanners } from '@dukang/shared-types';
|
||||||
import { PrismaService } from '../prisma/prisma.module';
|
import { PrismaService } from '../prisma/prisma.module';
|
||||||
import {
|
import {
|
||||||
|
SYSTEM_CONFIG_DEFAULTS,
|
||||||
SYSTEM_CONFIG_FIELDS,
|
SYSTEM_CONFIG_FIELDS,
|
||||||
SYSTEM_CONFIG_GROUPS,
|
SYSTEM_CONFIG_GROUPS,
|
||||||
SYSTEM_CONFIG_KEY_SET,
|
SYSTEM_CONFIG_KEY_SET,
|
||||||
@@ -42,6 +43,7 @@ export class SystemConfigService implements OnModuleInit {
|
|||||||
try {
|
try {
|
||||||
await this.purgeRetiredKeys();
|
await this.purgeRetiredKeys();
|
||||||
await this.seedMissingFromProcessEnv();
|
await this.seedMissingFromProcessEnv();
|
||||||
|
await this.seedMissingDefaults();
|
||||||
const rows = await this.prisma.systemConfig.findMany();
|
const rows = await this.prisma.systemConfig.findMany();
|
||||||
applyEnvOverlay(Object.fromEntries(rows.map((r) => [r.configKey, r.value])));
|
applyEnvOverlay(Object.fromEntries(rows.map((r) => [r.configKey, r.value])));
|
||||||
this.lastUpdatedAt = rows.reduce<Date | null>(
|
this.lastUpdatedAt = rows.reduce<Date | null>(
|
||||||
@@ -82,7 +84,7 @@ export class SystemConfigService implements OnModuleInit {
|
|||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
const fromDb = dbMap.get(field.key);
|
const fromDb = dbMap.get(field.key);
|
||||||
const fromEnv = process.env[field.key];
|
const fromEnv = process.env[field.key];
|
||||||
const raw = fromDb ?? fromEnv ?? '';
|
const raw = (fromDb ?? fromEnv ?? SYSTEM_CONFIG_DEFAULTS[field.key] ?? '').trim();
|
||||||
if (field.secret) {
|
if (field.secret) {
|
||||||
if (raw) configuredSecrets.push(field.key);
|
if (raw) configuredSecrets.push(field.key);
|
||||||
values[field.key] = '';
|
values[field.key] = '';
|
||||||
@@ -227,6 +229,26 @@ export class SystemConfigService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 将代码默认值写入空缺配置,便于 HQ 表单可见、可改 */
|
||||||
|
private async seedMissingDefaults() {
|
||||||
|
const overlay: Record<string, string> = {};
|
||||||
|
for (const field of SYSTEM_CONFIG_FIELDS) {
|
||||||
|
const defaultVal = SYSTEM_CONFIG_DEFAULTS[field.key];
|
||||||
|
if (!defaultVal?.trim()) continue;
|
||||||
|
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
|
||||||
|
if (existing?.value?.trim()) continue;
|
||||||
|
if (process.env[field.key]?.trim()) continue;
|
||||||
|
const value = this.normalizeByMeta(field, defaultVal);
|
||||||
|
await this.prisma.systemConfig.upsert({
|
||||||
|
where: { configKey: field.key },
|
||||||
|
create: { configKey: field.key, value },
|
||||||
|
update: { value },
|
||||||
|
});
|
||||||
|
overlay[field.key] = value;
|
||||||
|
}
|
||||||
|
if (Object.keys(overlay).length) applyEnvOverlay(overlay);
|
||||||
|
}
|
||||||
|
|
||||||
private normalizeByMeta(meta: { key?: string; type: string }, raw: string): string {
|
private normalizeByMeta(meta: { key?: string; type: string }, raw: string): string {
|
||||||
if (meta.type === 'boolean') {
|
if (meta.type === 'boolean') {
|
||||||
return raw === 'true' || raw === '1' ? 'true' : 'false';
|
return raw === 'true' || raw === '1' ? 'true' : 'false';
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable, Logger } from '@nestjs/common';
|
||||||
|
import { resolveMockSmsFixedCode } from '@dukang/shared-types';
|
||||||
import { PrismaService } from '../../common/prisma/prisma.module';
|
import { PrismaService } from '../../common/prisma/prisma.module';
|
||||||
import { MockSmsCodeService } from '../../common/mock-sms-code/mock-sms-code.service';
|
import { MockSmsCodeService } from '../../common/mock-sms-code/mock-sms-code.service';
|
||||||
import type { ISmsProvider, SmsActorRef, SmsSendResult } from './sms.interface';
|
import type { ISmsProvider, SmsActorRef, SmsSendResult } from './sms.interface';
|
||||||
import { MOCK_SMS_FIXED_CODE, SmsCodeStore } from './sms-code.store';
|
import { SmsCodeStore } from './sms-code.store';
|
||||||
|
|
||||||
function maskPhone(phone: string) {
|
function maskPhone(phone: string) {
|
||||||
return `${phone.slice(0, 3)}****${phone.slice(-4)}`;
|
return `${phone.slice(0, 3)}****${phone.slice(-4)}`;
|
||||||
@@ -19,7 +20,8 @@ export class SmsMockProvider implements ISmsProvider {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async send(phone: string, scene: string, actorRef?: SmsActorRef): Promise<SmsSendResult> {
|
async send(phone: string, scene: string, actorRef?: SmsActorRef): Promise<SmsSendResult> {
|
||||||
const code = await this.smsCodeStore.storeCode(phone, scene, MOCK_SMS_FIXED_CODE);
|
const fixedCode = resolveMockSmsFixedCode(process.env);
|
||||||
|
const code = await this.smsCodeStore.storeCode(phone, scene, fixedCode);
|
||||||
await this.mockSmsCodeService.record(phone, scene, code);
|
await this.mockSmsCodeService.record(phone, scene, code);
|
||||||
const masked = maskPhone(phone);
|
const masked = maskPhone(phone);
|
||||||
this.logger.log(`Mock SMS → ${masked} scene=${scene} code=${code}`);
|
this.logger.log(`Mock SMS → ${masked} scene=${scene} code=${code}`);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Controller, Get } from '@nestjs/common';
|
||||||
import { parseMiniHomeBanners } from '@dukang/shared-types';
|
import { parseMiniHomeBanners, resolveClientBrandRuntime } from '@dukang/shared-types';
|
||||||
import { SystemConfigService } from '../../common/system-config/system-config.service';
|
import { SystemConfigService } from '../../common/system-config/system-config.service';
|
||||||
|
|
||||||
@Controller('common')
|
@Controller('common')
|
||||||
@@ -12,6 +12,7 @@ export class ClientConfigController {
|
|||||||
const env = this.systemConfig.getMergedEnv();
|
const env = this.systemConfig.getMergedEnv();
|
||||||
const footer = (env.MINI_HOME_FOOTER_URL ?? '').trim();
|
const footer = (env.MINI_HOME_FOOTER_URL ?? '').trim();
|
||||||
const minClientVersion = (env.MINI_USER_MIN_VERSION ?? '').trim() || null;
|
const minClientVersion = (env.MINI_USER_MIN_VERSION ?? '').trim() || null;
|
||||||
|
const brand = resolveClientBrandRuntime(env);
|
||||||
return {
|
return {
|
||||||
mockPay: cfg.mockPay,
|
mockPay: cfg.mockPay,
|
||||||
wechatPayEnabled: cfg.wechatPayEnabled,
|
wechatPayEnabled: cfg.wechatPayEnabled,
|
||||||
@@ -25,6 +26,12 @@ export class ClientConfigController {
|
|||||||
banners: parseMiniHomeBanners(env.MINI_HOME_BANNERS),
|
banners: parseMiniHomeBanners(env.MINI_HOME_BANNERS),
|
||||||
footerUrl: footer || null,
|
footerUrl: footer || null,
|
||||||
},
|
},
|
||||||
|
userH5Url: brand.userH5Url,
|
||||||
|
brandLogoUrl: brand.brandLogoUrl,
|
||||||
|
brandLogoWideUrl: brand.brandLogoWideUrl,
|
||||||
|
brandLogoMarkUrl: brand.brandLogoMarkUrl,
|
||||||
|
qualificationDisclosureUrl: brand.qualificationDisclosureUrl,
|
||||||
|
customerServicePhone: brand.customerServicePhone,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
| 3.4.11 | 08-04 | 开发计划 + 企微机器人/消息推送 | [`开发计划`](./杜康好客-开发计划功能开发文档-v3.4.11.md) |
|
| 3.4.11 | 08-04 | 开发计划 + 企微机器人/消息推送 | [`开发计划`](./杜康好客-开发计划功能开发文档-v3.4.11.md) |
|
||||||
| 3.4.12 | 08-04 | 退款回滚/财务/批量任务·工单/套餐 imageUrl | [`v3.4.12`](./杜康好客-v3.4.12-工单迭代开发文档.md) |
|
| 3.4.12 | 08-04 | 退款回滚/财务/批量任务·工单/套餐 imageUrl | [`v3.4.12`](./杜康好客-v3.4.12-工单迭代开发文档.md) |
|
||||||
| 3.4.13 | 08-05 | metrics/核销详情/版本联动 PUBLISHED/mini 体验/H5 OAuth | [`v3.4.13`](./杜康好客-v3.4.13-体验优化开发文档.md) |
|
| 3.4.13 | 08-05 | metrics/核销详情/版本联动 PUBLISHED/mini 体验/H5 OAuth | [`v3.4.13`](./杜康好客-v3.4.13-体验优化开发文档.md) |
|
||||||
|
| 3.4.14 | 08-06 | mini-user 门头/套餐详情;**微信小程序配置可配 Logo·客服·H5·Mock码** | [`v3.4.14`](./杜康好客-v3.4.14-mini-user门店体验开发文档.md) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -54,13 +54,14 @@
|
|||||||
| 3.4.10 | [`门店套餐`](./杜康好客-门店套餐功能开发文档-v3.4.10.md) | ✅ |
|
| 3.4.10 | [`门店套餐`](./杜康好客-门店套餐功能开发文档-v3.4.10.md) | ✅ |
|
||||||
| 3.4.11 | [`开发计划`](./杜康好客-开发计划功能开发文档-v3.4.11.md) | ✅ |
|
| 3.4.11 | [`开发计划`](./杜康好客-开发计划功能开发文档-v3.4.11.md) | ✅ |
|
||||||
| 3.4.12 | [`工单迭代`](./杜康好客-v3.4.12-工单迭代开发文档.md) | ✅ |
|
| 3.4.12 | [`工单迭代`](./杜康好客-v3.4.12-工单迭代开发文档.md) | ✅ |
|
||||||
| 3.4.13 | [`体验优化`](./杜康好客-v3.4.13-体验优化开发文档.md) | ✅ 生产 `0181af0` |
|
| 3.4.13 | [`体验优化`](./杜康好客-v3.4.13-体验优化开发文档.md) | ✅ 生产 |
|
||||||
|
| 3.4.14 | [`mini-user 门店体验 + 小程序可配置`](./杜康好客-v3.4.14-mini-user门店体验开发文档.md) | 🔶 开发中 |
|
||||||
|
|
||||||
## 5. 变更记录
|
## 5. 变更记录
|
||||||
|
|
||||||
| 日期 | 说明 |
|
| 日期 | 说明 |
|
||||||
|------|------|
|
|------|------|
|
||||||
| 2026-08-06 | 文档压缩;现状对照更新 |
|
| 2026-08-06 | v3.4.14 mini-user 门头/套餐详情(开发中) |
|
||||||
| 2026-08-05 | v3.4.13 |
|
| 2026-08-05 | v3.4.13 |
|
||||||
| 2026-08-04 | v3.4.11 / v3.4.12 |
|
| 2026-08-04 | v3.4.11 / v3.4.12 |
|
||||||
| 2026-07-11 | 首版对照表 |
|
| 2026-07-11 | 首版对照表 |
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# 杜康好客 · v3.4.14 mini-user 门店体验 + 小程序可配置项
|
||||||
|
|
||||||
|
> **2026-08-06** · **开发中** · PRD §0.6 · mini-user `3.4.14` · **未发版**
|
||||||
|
|
||||||
|
## 范围
|
||||||
|
|
||||||
|
| 项 | 交付 |
|
||||||
|
|----|------|
|
||||||
|
| 门头照 | **固定 4:3 区域**;`aspectFit` 缩放完整显示(不裁剪);标题信息卡固定接在门头下方 |
|
||||||
|
| 门店详情·套餐 | 仅完整标题纵向列表;点击进入详情 |
|
||||||
|
| 套餐详情页 | 实底导航让出胶囊区;内容区顶/左右留白;有图在门店名下;无图直接菜品 |
|
||||||
|
| **系统设置·微信小程序** | Logo / 资质图 / 客服电话 / C 端 H5 / Mock 验证码 **可配置**,经 `client-config` 下发 |
|
||||||
|
|
||||||
|
## 页面路由
|
||||||
|
|
||||||
|
| 路径 | 参数 |
|
||||||
|
|------|------|
|
||||||
|
| `pages/store-detail/index` | `id` 门店 ID |
|
||||||
|
| `pages/store-package-detail/index` | `storeId` · `index` 套餐序号(0-based) |
|
||||||
|
|
||||||
|
数据:复用 `GET /stores/:id` 内嵌 `packages[]`,详情页按 index 取项。
|
||||||
|
|
||||||
|
## 系统设置(微信小程序配置)
|
||||||
|
|
||||||
|
HQ → 系统设置 → **微信小程序配置**。启动时空缺键用 shared-types 默认值补种。
|
||||||
|
|
||||||
|
| 配置键 | 说明 |
|
||||||
|
|--------|------|
|
||||||
|
| `USER_H5_URL` | C 端 H5 落地页(推广码等) |
|
||||||
|
| `BRAND_LOGO_OSS_BASE` | Logo OSS 根路径(说明用) |
|
||||||
|
| `BRAND_LOGO_URL` / `_WIDE_` / `_MARK_` | 方形 / 长方形 / 图标 Logo |
|
||||||
|
| `MINI_USER_STATIC_OSS_BASE` | 小程序静态资源根路径 |
|
||||||
|
| `QUALIFICATION_DISCLOSURE_URL` | 资质公示长图 |
|
||||||
|
| `CUSTOMER_SERVICE_PHONE` | 总部客服电话 |
|
||||||
|
| `MOCK_SMS_FIXED_CODE` | Mock 短信固定验证码(仅 MOCK_SMS 开启) |
|
||||||
|
|
||||||
|
**下发**:`GET /common/client-config` 增加 `userH5Url`、`brandLogoUrl`、`brandLogoWideUrl`、`brandLogoMarkUrl`、`qualificationDisclosureUrl`、`customerServicePhone`。
|
||||||
|
`MOCK_SMS_FIXED_CODE` 仅服务端 Mock 短信读取,不下发客户端。
|
||||||
|
|
||||||
|
## ACC
|
||||||
|
|
||||||
|
- [ ] 门头区高度固定(4:3);图片 aspectFit 完整缩放;标题 section 位置不随图高变化
|
||||||
|
- [ ] 门店详情套餐区仅标题列表,标题完整展示、可换行
|
||||||
|
- [ ] 点击套餐进入详情页,字段完整;返回回到门店详情
|
||||||
|
- [ ] 无套餐时不展示区块;index 非法时友好提示
|
||||||
|
- [ ] HQ 微信小程序配置可改 Logo/电话/落地页/Mock 码;保存后 client-config 立即生效(无需重启)
|
||||||
|
- [ ] mini-user 登录/我的/客服/分享图读取配置;未配置时回退代码默认常量
|
||||||
|
|
||||||
|
## HQ 开发计划
|
||||||
|
|
||||||
|
创建版本 `v3.4.14`(`IN_PROGRESS`),关联本迭代任务。发版前再合并发布。
|
||||||
Reference in New Issue
Block a user