2025-08-07 09:22:49 +08:00
|
|
|
// ViewReviewPage.tsx
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
import { useLocation } from 'umi'; // 或者 'react-router-dom'
|
|
|
|
import ResultModal from './components/ResultModal';
|
|
|
|
import ViewModal from './components/ViewModal';
|
2025-08-07 14:41:00 +08:00
|
|
|
import { refreshDictCache } from '@/servers/api/login';
|
2025-08-07 14:44:19 +08:00
|
|
|
import { encryptWithRsa } from '@/utils/encryptWithRsa'
|
2025-08-07 14:41:00 +08:00
|
|
|
|
2025-08-07 09:22:49 +08:00
|
|
|
|
|
|
|
const ViewReviewPage: React.FC = () => {
|
|
|
|
const [modalVisible, setModalVisible] = useState(false); // 控制弹窗
|
|
|
|
const [modalRecord, setModalRecord] = useState<any>(null);
|
2025-08-07 14:41:00 +08:00
|
|
|
|
2025-08-07 09:22:49 +08:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const params = new URLSearchParams(location.search);
|
2025-08-07 14:41:00 +08:00
|
|
|
const base64 = params.get('code');
|
|
|
|
console.log(base64);
|
2025-08-07 09:22:49 +08:00
|
|
|
|
2025-08-07 14:41:00 +08:00
|
|
|
if (!base64) return;
|
|
|
|
// 解码
|
|
|
|
const decodedStr = atob(base64);
|
|
|
|
// 再次转成参数
|
|
|
|
const p2 = new URLSearchParams(decodedStr);
|
|
|
|
if (p2.get('id')) {
|
|
|
|
if (!sessionStorage.getItem('dict')) {
|
|
|
|
refreshDictCache().then((res) => {
|
|
|
|
if (res.code == 200) {
|
|
|
|
sessionStorage.setItem('dict', JSON.stringify(res.data))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2025-08-07 14:44:19 +08:00
|
|
|
sessionStorage.setItem('userId', encryptWithRsa(p2.get('userId')))
|
2025-08-07 14:41:00 +08:00
|
|
|
setModalRecord({ id: p2.get('id') });
|
2025-08-07 09:22:49 +08:00
|
|
|
setModalVisible(true);
|
|
|
|
}
|
2025-08-07 14:41:00 +08:00
|
|
|
}, []);
|
2025-08-07 09:22:49 +08:00
|
|
|
|
2025-08-07 14:41:00 +08:00
|
|
|
|
2025-08-07 09:22:49 +08:00
|
|
|
return (
|
2025-08-07 14:41:00 +08:00
|
|
|
<div style={{ padding: '20px' }}>
|
2025-08-07 09:22:49 +08:00
|
|
|
{/* 其他页面内容 */}
|
|
|
|
<ViewModal
|
|
|
|
visible={modalVisible}
|
|
|
|
record={modalRecord}
|
|
|
|
onCancel={() => setModalVisible(false)}
|
|
|
|
/>
|
|
|
|
<ResultModal
|
|
|
|
visible={modalVisible}
|
|
|
|
record={modalRecord}
|
|
|
|
onCancel={() => setModalVisible(false)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ViewReviewPage;
|