From ac7badf745b01fe4fd6c02076851d023bca29ce9 Mon Sep 17 00:00:00 2001 From: yuchenglong Date: Tue, 2 Dec 2025 11:24:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BA=AB=E4=BB=BD=E8=AF=81?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A1=A3=E6=A1=88=E4=BF=A1=E6=81=AF=E9=AA=8C=E8=AF=81=E5=8F=8A?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/U1/u1.css | 40 ++++++++++++++++++++++------- src/pages/U1/u1.tsx | 62 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/src/pages/U1/u1.css b/src/pages/U1/u1.css index a446916..d9fc48c 100644 --- a/src/pages/U1/u1.css +++ b/src/pages/U1/u1.css @@ -1,4 +1,4 @@ -.u1-root{ +.u1-root { display: flex; position: relative; flex-direction: column; @@ -18,6 +18,14 @@ line-height: 114px; } +.u1-instruction-wrapper { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + margin-bottom: 20%; +} + .u1-instruction { width: 374px; height: 33px; @@ -29,9 +37,25 @@ text-align: left; white-space: nowrap; line-height: 44px; - margin-bottom: 20%; } -.u1-decor-line{ + +.u1-error { + position: absolute; + top: 60px; + left: 50%; + transform: translateX(-50%); + width: 800px; + overflow-wrap: break-word; + color: rgba(255, 0, 0, 1); + font-size: 36px; + font-family: NotoSansCJKsc-Medium; + font-weight: 500; + text-align: center; + line-height: 48px; + white-space: normal; +} + +.u1-decor-line { margin-top: 3%; margin-bottom: 3%; } @@ -39,8 +63,7 @@ display: flex; height: 108px; width: 594px; - background: url(../../assets/buttons/button.png) - 100% no-repeat; + background: url(../../assets/buttons/button.png) 100% no-repeat; background-size: 100% 100%; align-items: center; justify-content: center; @@ -59,13 +82,12 @@ line-height: 49px; } - .u1-semicircle { position: absolute; left: 27%; transform: translateX(-50%); - top: 810px; - width: 578px; + top: 810px; + width: 578px; height: 588px; z-index: -1; -} \ No newline at end of file +} diff --git a/src/pages/U1/u1.tsx b/src/pages/U1/u1.tsx index f4babbf..87f0aff 100644 --- a/src/pages/U1/u1.tsx +++ b/src/pages/U1/u1.tsx @@ -8,14 +8,17 @@ import semicircle from "../../assets/semicircle.png"; import LongButton from "../../components/LongButton"; import LongButtonLoading from "../../components/LongButtonLoading"; import DecorLine from "../../components/DecorLine"; +import { getPatientInfo } from "../../api/hisApi"; const U1: React.FC = () => { const navigate = useNavigate(); const [reading, setReading] = useState(false); const [countdown, setCountdown] = useState(6); + const [errorMsg, setErrorMsg] = useState(""); const timerRef = useRef(null); const intervalRef = useRef(null); + const errorTimerRef = useRef(null); // 实时监听身份证读取 useEffect(() => { @@ -40,7 +43,7 @@ const U1: React.FC = () => { `Read IDCard success: ${payload.name} ${payload.id_card_no}` ); - // 读到卡即跳转;清理倒计时 + // 清理倒计时 if (timerRef.current) { clearTimeout(timerRef.current); timerRef.current = null; @@ -49,9 +52,36 @@ const U1: React.FC = () => { clearInterval(intervalRef.current); intervalRef.current = null; } - window.electronAPI.stopIdCardListen().catch(() => {}); - setReading(false); - navigate("/u2"); + + // 先验证档案信息,查询到才跳转 + const idCardNo = payload.id_card_no; + if (!idCardNo) { + setErrorMsg("未读取到身份证号"); + setReading(false); + window.electronAPI.stopIdCardListen().catch(() => {}); + return; + } + + getPatientInfo(idCardNo) + .then((res) => { + if (res.Status === 200 && res.Data) { + // 查询成功,跳转到 u2 + window.electronAPI.stopIdCardListen().catch(() => {}); + setReading(false); + navigate("/u2"); + } else { + // 未查询到档案信息,显示错误提示,不跳转 + setErrorMsg("未查询到您的档案信息,请联系前台工作人员"); + setReading(false); + window.electronAPI.stopIdCardListen().catch(() => {}); + } + }) + .catch((err) => { + console.error("getPatientInfo error", err); + setErrorMsg("获取用户信息异常,请联系前台工作人员"); + setReading(false); + window.electronAPI.stopIdCardListen().catch(() => {}); + }); }); window.electronAPI.onIdCardError((e: any) => { @@ -64,13 +94,32 @@ const U1: React.FC = () => { window.electronAPI.removeIdCardListeners(); if (timerRef.current) clearTimeout(timerRef.current); if (intervalRef.current) clearInterval(intervalRef.current); + if (errorTimerRef.current) clearTimeout(errorTimerRef.current); }; }, [navigate]); + // 错误信息 10 秒后自动消失 + useEffect(() => { + if (errorMsg) { + if (errorTimerRef.current) clearTimeout(errorTimerRef.current); + errorTimerRef.current = window.setTimeout(() => { + setErrorMsg(""); + errorTimerRef.current = null; + }, 10000); + } + return () => { + if (errorTimerRef.current) { + clearTimeout(errorTimerRef.current); + errorTimerRef.current = null; + } + }; + }, [errorMsg]); + const handleStart = () => { if (reading) return; // 避免重复点击 setReading(true); setCountdown(6); + setErrorMsg(""); // 清空之前的错误信息 // 6 秒倒计时逻辑 if (intervalRef.current) clearInterval(intervalRef.current); @@ -109,7 +158,10 @@ const U1: React.FC = () => { card reader - 请放置身份证在读卡区域 +
+ 请放置身份证在读卡区域 + {errorMsg && {errorMsg}} +
start button {!reading && } {reading && (