From 823e439101923e66671db6eed1972e1b61e26f46 Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Wed, 22 Jul 2026 11:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E9=97=A8=E8=90=A5=E4=B8=9A=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E6=8F=90=E7=A4=BA=E3=80=8C=E5=BC=80=E5=BA=97?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E3=80=8D=20=E5=85=B3=E9=97=AD=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E6=94=B9=E4=B8=BA=E8=87=AA=E5=AE=9A=E4=B9=89=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E6=A1=86=EF=BC=8C=E4=B8=8D=E5=86=8D=E7=94=A8=20window?= =?UTF-8?q?.confirm=EF=BC=8C=E4=B8=8D=E4=BC=9A=E5=86=8D=E5=B8=A6=E5=87=BA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/h5-partner/src/pages/StoreDetailPage.tsx | 46 +++++++++++++++++-- apps/h5-partner/src/pages/StoreListPage.tsx | 44 +++++++++++++++++- 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/apps/h5-partner/src/pages/StoreDetailPage.tsx b/apps/h5-partner/src/pages/StoreDetailPage.tsx index fbe7110..3a49f16 100644 --- a/apps/h5-partner/src/pages/StoreDetailPage.tsx +++ b/apps/h5-partner/src/pages/StoreDetailPage.tsx @@ -47,6 +47,7 @@ export default function StoreDetailPage() { const [saving, setSaving] = useState(false); const [mediaSaving, setMediaSaving] = useState(false); const [actionError, setActionError] = useState(''); + const [closeConfirmOpen, setCloseConfirmOpen] = useState(false); function applyStore(data: Record) { setStore(data); @@ -92,8 +93,8 @@ export default function StoreDetailPage() { return; } if (next === 'CLOSED') { - const ok = window.confirm('关闭后不可恢复营业,确认关闭该门店?'); - if (!ok) return; + setCloseConfirmOpen(true); + return; } setStatusSaving(true); setActionError(''); @@ -104,7 +105,27 @@ export default function StoreDetailPage() { }); setStatus(next); setStore((prev) => (prev ? { ...prev, ...updated, status: next } : prev)); - toastSuccess('状态已更新'); + toastSuccess(next === 'OPEN' ? '开店成功' : '状态已更新'); + } catch (e) { + setActionError(e instanceof Error ? e.message : '状态更新失败'); + } finally { + setStatusSaving(false); + } + } + + async function confirmCloseStore() { + if (!id || statusSaving) return; + setCloseConfirmOpen(false); + setStatusSaving(true); + setActionError(''); + try { + const updated = await request>('PARTNER_H5', `/partner/stores/${id}/status`, { + method: 'PUT', + body: JSON.stringify({ status: 'CLOSED' }), + }); + setStatus('CLOSED'); + setStore((prev) => (prev ? { ...prev, ...updated, status: 'CLOSED' } : prev)); + toastSuccess('门店已关闭'); } catch (e) { setActionError(e instanceof Error ? e.message : '状态更新失败'); } finally { @@ -385,6 +406,25 @@ export default function StoreDetailPage() { )} + + {closeConfirmOpen && ( +
setCloseConfirmOpen(false)}> +
e.stopPropagation()}> +

确认关闭门店?

+

+ 关闭后不可恢复营业,确认关闭该门店? +

+
+ + +
+
+
+ )} ); } diff --git a/apps/h5-partner/src/pages/StoreListPage.tsx b/apps/h5-partner/src/pages/StoreListPage.tsx index e5bbcda..0a4d4ca 100644 --- a/apps/h5-partner/src/pages/StoreListPage.tsx +++ b/apps/h5-partner/src/pages/StoreListPage.tsx @@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { Link, useNavigate, useSearchParams } from 'react-router-dom'; import PullToRefresh from '@dukang/shared-ui/PullToRefresh'; import { isLoggedIn, request } from '../lib/api'; +import { toastSuccess } from '../lib/toast'; import { usePartnerSession } from '../contexts/PartnerSessionContext'; import { canCreatePartnerStore, canManagePartnerStore } from '../lib/partnerAccess'; import { @@ -36,6 +37,7 @@ export default function StoreListPage() { const [filter, setFilter] = useState(initialFilter); const [updatingId, setUpdatingId] = useState(null); const [error, setError] = useState(''); + const [closeTarget, setCloseTarget] = useState(null); const loadStores = useCallback(() => { return request>>('PARTNER_H5', '/partner/stores').then(setStores); @@ -67,8 +69,8 @@ export default function StoreListPage() { return; } if (next === 'CLOSED') { - const ok = window.confirm('关闭后不可恢复营业,确认关闭该门店?'); - if (!ok) return; + setCloseTarget(storeId); + return; } setUpdatingId(storeId); setError(''); @@ -78,6 +80,26 @@ export default function StoreListPage() { body: JSON.stringify({ status: next }), }); await loadStores(); + if (next === 'OPEN') toastSuccess('开店成功'); + } catch { + /* request 已 toast */ + } finally { + setUpdatingId(null); + } + } + + async function confirmCloseStore() { + if (!closeTarget) return; + const storeId = closeTarget; + setCloseTarget(null); + setUpdatingId(storeId); + setError(''); + try { + await request('PARTNER_H5', `/partner/stores/${storeId}/status`, { + method: 'PUT', + body: JSON.stringify({ status: 'CLOSED' }), + }); + await loadStores(); } catch { /* request 已 toast */ } finally { @@ -189,6 +211,24 @@ export default function StoreListPage() { ); })} + {closeTarget && ( +
setCloseTarget(null)}> +
e.stopPropagation()}> +

确认关闭门店?

+

+ 关闭后不可恢复营业,确认关闭该门店? +

+
+ + +
+
+
+ )} ); }