feat: audit diff, mock SMS 999888, env photos, proxy pay lock, mini-user UX

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 20:47:28 +08:00
parent d90847bad0
commit e93e4b8f84
23 changed files with 524 additions and 135 deletions
+68 -8
View File
@@ -70,6 +70,8 @@ export default function ProxyOrderPage() {
const [codeUrl, setCodeUrl] = useState<string | null>(null);
const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);
const [paying, setPaying] = useState(false);
const [cancelling, setCancelling] = useState(false);
const [lockedPayMethod, setLockedPayMethod] = useState<ProxyPayMethod | null>(null);
const pollRef = useRef<number | null>(null);
const region = useMemo(() => parseRegionCodes(regionCodes), [regionCodes]);
@@ -234,8 +236,17 @@ export default function ProxyOrderPage() {
}
async function startPay(orderId: string, method: ProxyPayMethod) {
if (lockedPayMethod && lockedPayMethod !== method) {
setMsg(
lockedPayMethod === 'JSAPI'
? '该订单已发起微信代付,请先取消支付后重新下单'
: '该订单已生成收款码,请先取消支付后重新下单',
);
return;
}
setPaying(true);
setMsg('');
setPayMethod(method);
try {
if (method === 'JSAPI') {
if (!isWechatEnv()) {
@@ -266,11 +277,14 @@ export default function ProxyOrderPage() {
if (pay.mode === 'native' && pay.codeUrl) {
setCodeUrl(pay.codeUrl);
setLockedPayMethod(method);
startPoll(orderId);
return;
}
if (pay.mode === 'jsapi' && pay.prepay) {
setCodeUrl(null);
setLockedPayMethod(method);
await invokeWechatPay(pay.prepay, {
apiBase: '/api/v1',
clientApp: 'PARTNER_H5',
@@ -289,6 +303,40 @@ export default function ProxyOrderPage() {
}
}
async function cancelPay(orderId: string) {
setCancelling(true);
setMsg('');
stopPoll();
try {
await request('PARTNER_H5', `/partner/proxy-orders/${orderId}/cancel-pay`, {
method: 'POST',
body: '{}',
});
toastSuccess('已取消支付,可重新下单并选择其他支付方式');
setStep('form');
setCreated(null);
setCodeUrl(null);
setLockedPayMethod(null);
} catch (e) {
setMsg(e instanceof Error ? e.message : '取消失败');
} finally {
setCancelling(false);
}
}
function switchPayMethod(method: ProxyPayMethod) {
if (lockedPayMethod && lockedPayMethod !== method) {
setMsg(
lockedPayMethod === 'JSAPI'
? '该订单已发起微信代付,请先取消支付后重新下单'
: '该订单已生成收款码,请先取消支付后重新下单',
);
return;
}
setPayMethod(method);
setMsg('');
}
async function submit() {
setMsg('');
const err = validateForm();
@@ -322,6 +370,7 @@ export default function ProxyOrderPage() {
setCreated(order);
setStep('pay');
setCodeUrl(null);
setLockedPayMethod(null);
await startPay(order.id, payMethod);
} catch (e) {
setMsg(e instanceof Error ? e.message : '下单失败');
@@ -359,24 +408,25 @@ export default function ProxyOrderPage() {
<button
type="button"
className={`partner-proxy-mode-tab${payMethod === 'NATIVE' ? ' is-active' : ''}`}
onClick={() => {
setPayMethod('NATIVE');
void startPay(created.id, 'NATIVE');
}}
disabled={!!lockedPayMethod && lockedPayMethod !== 'NATIVE'}
onClick={() => switchPayMethod('NATIVE')}
>
</button>
<button
type="button"
className={`partner-proxy-mode-tab${payMethod === 'JSAPI' ? ' is-active' : ''}`}
onClick={() => {
setPayMethod('JSAPI');
void startPay(created.id, 'JSAPI');
}}
disabled={!!lockedPayMethod && lockedPayMethod !== 'JSAPI'}
onClick={() => switchPayMethod('JSAPI')}
>
</button>
</div>
{lockedPayMethod ? (
<p className="label-md text-muted" style={{ marginTop: 8 }}>
{lockedPayMethod === 'NATIVE' ? '收款码' : '微信代付'}
</p>
) : null}
</section>
{payMethod === 'NATIVE' ? (
@@ -419,6 +469,16 @@ export default function ProxyOrderPage() {
{msg}
</p>
) : null}
<button
type="button"
className="btn btn-block"
style={{ marginTop: 16 }}
disabled={cancelling || paying}
onClick={() => void cancelPay(created.id)}
>
{cancelling ? '取消中…' : '取消支付'}
</button>
</>
) : loadingOptions ? (
<p className="label-md text-muted"></p>