用户端不要强制用户输入手机号

This commit is contained in:
2026-07-15 19:57:06 +08:00
parent f15d2057f2
commit 0f5f0f4c2b
14 changed files with 167 additions and 71 deletions
@@ -105,8 +105,8 @@ export default function PhoneVerifySheet({
const sheetDesc =
description ??
(mode === 'wechat_bind_phone'
? '微信授权成功,请绑定手机号以完成支付'
: '下单前需验证手机号,以便接收订单通知');
? '建议绑定手机号,便于订单通知与售后;关闭可跳过继续支付'
: '建议绑定手机号,便于订单通知与售后;关闭可跳过继续下单');
return (
<div className="phone-verify-overlay" role="dialog" aria-modal="true">
@@ -159,6 +159,9 @@ export default function PhoneVerifySheet({
<button type="button" className="login-sms-btn" disabled={loading} onClick={submit}>
{loading ? '验证中...' : mode === 'wechat_bind_phone' ? '确认绑定' : '确认验证'}
</button>
<button type="button" className="phone-verify-skip" onClick={onClose}>
</button>
</div>
</div>
);
+6 -6
View File
@@ -51,12 +51,6 @@ export default function LoginPage() {
}, [wxAuthorize]);
function handleWechatLoginResult(result: WechatLoginResult) {
if (result.needBindPhone && result.wxSessionKey) {
setBindMode(true);
setWxSessionKey(result.wxSessionKey);
setMsg('微信授权成功,请绑定手机号完成登录');
return;
}
if (result.accessToken) {
applySession({
accessToken: result.accessToken,
@@ -68,6 +62,12 @@ export default function LoginPage() {
void finishLogin(navigate, returnTo);
return;
}
if (result.needBindPhone && result.wxSessionKey) {
setBindMode(true);
setWxSessionKey(result.wxSessionKey);
setMsg('微信授权成功,可绑定手机号(也可跳过,稍后在下单时再绑定)');
return;
}
}
function ensureAgreed() {
+48 -4
View File
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import SubPageHeader from '../components/SubPageHeader';
import AppImage from '@dukang/shared-ui/AppImage';
@@ -73,6 +73,7 @@ export default function OrderConfirmPage() {
const [previewLoading, setPreviewLoading] = useState(false);
const [loading, setLoading] = useState(false);
const [msg, setMsg] = useState('');
const phonePromptSkipped = useRef(false);
useEffect(() => {
request<Address[]>('USER_H5', '/user/addresses').then((list) => {
@@ -195,7 +196,7 @@ export default function OrderConfirmPage() {
setMsg('请选择收货地址');
return;
}
if (!phoneVerified) {
if (!phoneVerified && !phonePromptSkipped.current) {
setPendingSubmit(true);
setShowPhoneVerify(true);
return;
@@ -204,6 +205,7 @@ export default function OrderConfirmPage() {
const authResult = await ensureWechatAuthForPay();
if (!authResult.ok) {
if ('needBindPhone' in authResult) {
// 兼容旧接口:微信授权后提示可选绑定
setWxSessionKey(authResult.wxSessionKey);
setShowWechatBindPhone(true);
setPendingSubmit(true);
@@ -418,9 +420,35 @@ export default function OrderConfirmPage() {
<PhoneVerifySheet
open={showPhoneVerify}
defaultPhone={selectedAddress?.phone}
title="建议绑定手机号"
description="绑定后便于订单通知与售后联系;关闭即可跳过,不绑定也能继续下单。"
onClose={() => {
setShowPhoneVerify(false);
setPendingSubmit(false);
if (pendingSubmit) {
phonePromptSkipped.current = true;
setPendingSubmit(false);
void (async () => {
setLoading(true);
setMsg('');
try {
const authResult = await ensureWechatAuthForPay();
if (!authResult.ok) {
if ('needBindPhone' in authResult) {
setWxSessionKey(authResult.wxSessionKey);
setShowWechatBindPhone(true);
setPendingSubmit(true);
return;
}
return;
}
await doSubmit();
} catch (e) {
setMsg(e instanceof Error ? e.message : '下单失败');
} finally {
setLoading(false);
}
})();
}
}}
onSuccess={handlePhoneVerified}
/>
@@ -430,10 +458,26 @@ export default function OrderConfirmPage() {
mode="wechat_bind_phone"
wxSessionKey={wxSessionKey ?? undefined}
defaultPhone={selectedAddress?.phone}
title="建议绑定手机号"
description="绑定后便于订单通知与售后联系;关闭即可跳过继续下单。"
onClose={() => {
setShowWechatBindPhone(false);
setWxSessionKey(null);
setPendingSubmit(false);
if (pendingSubmit) {
phonePromptSkipped.current = true;
setPendingSubmit(false);
void (async () => {
setLoading(true);
setMsg('');
try {
await doSubmit();
} catch (e) {
setMsg(e instanceof Error ? e.message : '下单失败');
} finally {
setLoading(false);
}
})();
}
}}
onSuccess={handleWechatPhoneBound}
/>
+12
View File
@@ -5663,6 +5663,18 @@
line-height: 1.5;
}
.phone-verify-skip {
display: block;
width: 100%;
margin-top: 12px;
padding: 10px;
border: none;
background: transparent;
font-size: 14px;
color: var(--color-on-surface-variant, #888);
cursor: pointer;
}
.login-msg--hint {
color: var(--color-success, #2d6a4f);
}