From eaa665c5dc4d3a62e66942a9e2f9a4dbf4631580 Mon Sep 17 00:00:00 2001 From: Pine Date: Thu, 27 Aug 2026 20:57:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E7=99=BB=E5=BD=95):=20=E5=8E=BB=E9=99=A4=20.jsx=20?= =?UTF-8?q?=E5=86=85=20TS=20=E6=B3=9B=E5=9E=8B=20+=20=E5=8E=BB=E6=8E=89=20?= =?UTF-8?q?setInterval=20=E5=80=92=E8=AE=A1=E6=97=B6(=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=20setState=20=E8=A7=A6=E5=8F=91=20I?= =?UTF-8?q?nvalid=20attempt=20to=20destruct=20non-iterable=E2=86=92?= =?UTF-8?q?=E9=BB=91=E5=B1=8F)=20+=20=E7=99=BB=E5=BD=95=20tab=20=E6=94=B9?= =?UTF-8?q?=E6=9F=94=E5=BD=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/src/pages/scan-login/index.jsx | 9 +++------ miniprogram/src/pages/scan-login/index.scss | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/miniprogram/src/pages/scan-login/index.jsx b/miniprogram/src/pages/scan-login/index.jsx index 8af2850..10b9b27 100644 --- a/miniprogram/src/pages/scan-login/index.jsx +++ b/miniprogram/src/pages/scan-login/index.jsx @@ -15,10 +15,9 @@ export default function ScanLogin() { const [busy, setBusy] = useState(false); const [msg, setMsg] = useState(''); const [done, setDone] = useState(false); - const [loginMode, setLoginMode] = useState<'wx' | 'phone'>('wx'); + const [loginMode, setLoginMode] = useState('wx'); const [gatePhone, setGatePhone] = useState(''); const [gateCode, setGateCode] = useState(''); - const [cd, setCd] = useState(0); // 冷启动/扫码进入:纯 React useEffect 读当前实例参数(wxacode 的 scene 在 router.params.scene)。 // 不再用 useLoad/useDidShow 等 Taro 元钩子(其内部在原生计时器里调度 React hook,会触发 @@ -51,9 +50,7 @@ export default function ScanLogin() { try { const r = await sendCode(gatePhone); setMsg(`验证码已发送${r.debugCode ? `(演示 ${r.debugCode})` : ''}`); - setCd(60); - // 小程序无 window,用全局 setInterval/clearInterval(源码里 window.* 会导致运行时 ReferenceError) - const t = setInterval(() => setCd((c) => (c <= 1 ? (clearInterval(t), 0) : c - 1)), 1000); + // 不启用 setInterval 倒计时:小程序原生定时器里 setState 会触发 "Invalid attempt to destruct non-iterable",改为允许随时重发 } catch (e) { setMsg((e && e.message) || '发送失败'); } finally { setBusy(false); } }; @@ -101,7 +98,7 @@ export default function ScanLogin() { setGatePhone(e.detail.value)} /> setGateCode(e.detail.value)} /> - + diff --git a/miniprogram/src/pages/scan-login/index.scss b/miniprogram/src/pages/scan-login/index.scss index 13418f1..5151df7 100644 --- a/miniprogram/src/pages/scan-login/index.scss +++ b/miniprogram/src/pages/scan-login/index.scss @@ -13,9 +13,9 @@ .sl-actions { display: flex; flex-direction: column; gap: 16rpx; margin-top: 40rpx; } /* 登录门 */ -.sl-tabs { display: flex; gap: 4px; margin: 24rpx 0; padding: 4px; border-radius: 12px; background: #161618; border: 1px solid #d7ddf0; } +.sl-tabs { display: flex; gap: 4px; margin: 24rpx 0; padding: 4px; border-radius: 12px; background: #eef1ff; border: 1px solid rgba(99,132,255,.14); } .sl-tab { flex: 1; text-align: center; padding: 12rpx 0; border-radius: 9px; color: #7a86b0; font-size: 26rpx; } -.sl-tab.on { background: #fff; color: #111; } +.sl-tab.on { background: #fff; color: #23315c; box-shadow: 0 4rpx 12rpx rgba(59,79,125,.10); } .sl-field { display: flex; flex-direction: column; gap: 14rpx; margin-top: 8rpx; } .sl-code { display: flex; gap: 12rpx; align-items: center; } .sl-code .input { flex: 1; }