66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import { Button, Card, Result, Typography, message } from 'antd';
|
|
|
|
const successStatuses = new Set(['group_active', 'callback_success']);
|
|
|
|
const PrivatePortraitAuthorizeResult: React.FC = () => {
|
|
const params = useMemo(() => new URLSearchParams(window.location.search), []);
|
|
const status = params.get('status') || '';
|
|
const resultCode = params.get('resultCode') || '';
|
|
const isSuccess = successStatuses.has(status) || resultCode === '10000';
|
|
|
|
const handleClose = () => {
|
|
const isWeChat = /MicroMessenger/i.test(navigator.userAgent);
|
|
const isAlipay = /AlipayClient/i.test(navigator.userAgent);
|
|
const isMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
|
|
|
|
if (isWeChat) {
|
|
try {
|
|
window.opener = null;
|
|
window.open('', '_self');
|
|
window.close();
|
|
} catch {
|
|
message.info('请点击右上角关闭按钮');
|
|
}
|
|
} else if (isAlipay) {
|
|
try {
|
|
window.close();
|
|
} catch {
|
|
message.info('请点击左上角返回');
|
|
}
|
|
} else if (isMobile) {
|
|
try {
|
|
window.history.back();
|
|
} catch {
|
|
window.location.href = '/';
|
|
}
|
|
} else {
|
|
try {
|
|
window.close();
|
|
} catch {
|
|
window.location.href = '/';
|
|
}
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div style={{ minHeight: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#f8fafc', padding: 20 }}>
|
|
<Card style={{ width: '100%', maxWidth: 520, borderRadius: 18 }}>
|
|
<Result
|
|
status={isSuccess ? 'success' : 'error'}
|
|
title={isSuccess ? '真人认证已完成' : '真人认证未完成'}
|
|
subTitle={isSuccess ? '请回到电脑端查看,项目组已创建成功。' : '请回到电脑端重新发起创建项目组。'}
|
|
extra={[
|
|
<Button key="close" type="primary" onClick={handleClose}>关闭页面</Button>,
|
|
]}
|
|
/>
|
|
<Typography.Paragraph type="secondary" style={{ textAlign: 'center', marginBottom: 0, fontSize: 13, marginTop: 12 }}>
|
|
如无法自动关闭,请手动关闭页面
|
|
</Typography.Paragraph>
|
|
</Card>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default PrivatePortraitAuthorizeResult;
|