fix:kyc证件类型修改
This commit is contained in:
@@ -103,6 +103,7 @@ export const request = createFlatRequest<App.Service.Response, InstanceState>(
|
|||||||
return response.data.data;
|
return response.data.data;
|
||||||
},
|
},
|
||||||
onError(error) {
|
onError(error) {
|
||||||
|
|
||||||
// when the request is fail, you can show error message
|
// when the request is fail, you can show error message
|
||||||
let message = error.message;
|
let message = error.message;
|
||||||
let backendErrorCode = '';
|
let backendErrorCode = '';
|
||||||
@@ -124,7 +125,6 @@ export const request = createFlatRequest<App.Service.Response, InstanceState>(
|
|||||||
if (expiredTokenCodes.includes(backendErrorCode)) {
|
if (expiredTokenCodes.includes(backendErrorCode)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backendErrorCode === import.meta.env.VITE_SERVICE_SERVER_ERROR_CODE) {
|
if (backendErrorCode === import.meta.env.VITE_SERVICE_SERVER_ERROR_CODE) {
|
||||||
clearAuthStorage();
|
clearAuthStorage();
|
||||||
return;
|
return;
|
||||||
@@ -178,4 +178,4 @@ export const rawRequest = createRequest(
|
|||||||
window.$message?.error(message);
|
window.$message?.error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import dayjs from 'dayjs'; // 导入 dayjs
|
|||||||
// const { t } = useI18n();
|
// const { t } = useI18n();
|
||||||
|
|
||||||
// KYC 状态
|
// KYC 状态
|
||||||
const kycStatus = ref<Api.KYC.KYCStatus>(0);
|
const kycStatus = ref<Api.KYC.KYCStatus>('UNVERIFIED');
|
||||||
const kycInfo = ref<Partial<Api.KYC.KYCInfo>>({
|
const kycInfo = ref<Partial<Api.KYC.KYCInfo>>({
|
||||||
status: 0,
|
status: 'UNVERIFIED',
|
||||||
fullName: '',
|
fullName: '',
|
||||||
birthDate: '',
|
birthDate: '',
|
||||||
rejectReason: '',
|
rejectReason: '',
|
||||||
@@ -24,7 +24,7 @@ const kycInfo = ref<Partial<Api.KYC.KYCInfo>>({
|
|||||||
const idTypeOptions = [
|
const idTypeOptions = [
|
||||||
{ value: 1, label: '驾驶证' },
|
{ value: 1, label: '驾驶证' },
|
||||||
{ value: 2, label: '护照' },
|
{ value: 2, label: '护照' },
|
||||||
{ value: 3, label: '居留许可' },
|
{ value: 3, label: '身份证/居住证' },
|
||||||
{ value: 4, label: '学生证' },
|
{ value: 4, label: '学生证' },
|
||||||
{ value: 5, label: '医保卡' },
|
{ value: 5, label: '医保卡' },
|
||||||
{ value: 6, label: '出生证明' }
|
{ value: 6, label: '出生证明' }
|
||||||
@@ -101,17 +101,39 @@ const getBase64 = (file: File): Promise<string> => {
|
|||||||
// 获取 KYC 状态
|
// 获取 KYC 状态
|
||||||
const getKYCStatus = async () => {
|
const getKYCStatus = async () => {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await fetchKYCStatus();
|
const { data } = await fetchKYCStatus();
|
||||||
if (error) {
|
if (data?.status) {
|
||||||
console.error('Failed to fetch KYC status:', error);
|
// 将状态转换为标准格式
|
||||||
return;
|
const normalizedStatus = data.status.toUpperCase() as Api.KYC.KYCStatus;
|
||||||
}
|
kycStatus.value = normalizedStatus;
|
||||||
if (data) {
|
kycInfo.value = {
|
||||||
kycStatus.value = data.status;
|
...data,
|
||||||
kycInfo.value = data;
|
status: normalizedStatus
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// 如果没有状态数据,设置为默认值
|
||||||
|
kycStatus.value = 'UNVERIFIED';
|
||||||
|
kycInfo.value = {
|
||||||
|
status: 'UNVERIFIED',
|
||||||
|
fullName: '',
|
||||||
|
birthDate: '',
|
||||||
|
rejectReason: '',
|
||||||
|
verifiedTime: ''
|
||||||
|
};
|
||||||
|
console.warn('No KYC status data received');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch KYC status:', error);
|
console.error('Failed to fetch KYC status:', error);
|
||||||
|
message.error('获取认证状态失败');
|
||||||
|
// 发生错误时也设置默认值
|
||||||
|
kycStatus.value = 'UNVERIFIED';
|
||||||
|
kycInfo.value = {
|
||||||
|
status: 'UNVERIFIED',
|
||||||
|
fullName: '',
|
||||||
|
birthDate: '',
|
||||||
|
rejectReason: '',
|
||||||
|
verifiedTime: ''
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -192,11 +214,10 @@ const submitKYC = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化出生日期为 YYYY-MM-DD 格式
|
|
||||||
const formattedBirthDate = dayjs(formData.value.birthDate).format('YYYY-MM-DD');
|
const formattedBirthDate = dayjs(formData.value.birthDate).format('YYYY-MM-DD');
|
||||||
|
|
||||||
await submitKYCVerification({
|
await submitKYCVerification({
|
||||||
realName: formData.value.fullName, // 添加真实姓名
|
realName: formData.value.fullName,
|
||||||
birthDate: formattedBirthDate,
|
birthDate: formattedBirthDate,
|
||||||
idType: formData.value.idType,
|
idType: formData.value.idType,
|
||||||
idFile: formData.value.idCardFile,
|
idFile: formData.value.idCardFile,
|
||||||
@@ -220,13 +241,16 @@ const disabledDate = (current: Dayjs) => {
|
|||||||
|
|
||||||
// 获取状态颜色
|
// 获取状态颜色
|
||||||
const getStatusColor = (status: Api.KYC.KYCStatus) => {
|
const getStatusColor = (status: Api.KYC.KYCStatus) => {
|
||||||
switch (status) {
|
const normalizedStatus = status.toUpperCase();
|
||||||
case 0:
|
switch (normalizedStatus) {
|
||||||
|
case 'UNVERIFIED':
|
||||||
return 'warning'; // 未认证:橙色警告
|
return 'warning'; // 未认证:橙色警告
|
||||||
case 1:
|
case 'PENDING':
|
||||||
return 'processing'; // 认证中:蓝色处理中
|
return 'processing'; // 认证中:蓝色处理中
|
||||||
case 2:
|
case 'VERIFIED':
|
||||||
return 'success'; // 已认证:绿色成功
|
return 'success'; // 已认证:绿色成功
|
||||||
|
case 'REJECTED':
|
||||||
|
return 'error'; // 已拒绝:红色错误
|
||||||
default:
|
default:
|
||||||
return 'default';
|
return 'default';
|
||||||
}
|
}
|
||||||
@@ -234,13 +258,16 @@ const getStatusColor = (status: Api.KYC.KYCStatus) => {
|
|||||||
|
|
||||||
// 获取状态文本
|
// 获取状态文本
|
||||||
const getStatusText = (status: Api.KYC.KYCStatus) => {
|
const getStatusText = (status: Api.KYC.KYCStatus) => {
|
||||||
switch (status) {
|
const normalizedStatus = status.toUpperCase();
|
||||||
case 0:
|
switch (normalizedStatus) {
|
||||||
|
case 'UNVERIFIED':
|
||||||
return '未认证';
|
return '未认证';
|
||||||
case 1:
|
case 'PENDING':
|
||||||
return '认证中';
|
return '认证中';
|
||||||
case 2:
|
case 'VERIFIED':
|
||||||
return '已认证';
|
return '已认证';
|
||||||
|
case 'REJECTED':
|
||||||
|
return '已拒绝';
|
||||||
default:
|
default:
|
||||||
return '未知状态';
|
return '未知状态';
|
||||||
}
|
}
|
||||||
@@ -271,7 +298,7 @@ onMounted(() => {
|
|||||||
</a-tag>
|
</a-tag>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="kycStatus === 2" class="verified-info">
|
<div v-if="kycStatus === 'VERIFIED'" class="verified-info">
|
||||||
<div class="info-item">
|
<div class="info-item">
|
||||||
<span class="label">认证姓名:</span>
|
<span class="label">认证姓名:</span>
|
||||||
<span class="value">{{ kycInfo.fullName }}</span>
|
<span class="value">{{ kycInfo.fullName }}</span>
|
||||||
@@ -293,7 +320,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 认证表单 -->
|
<!-- 认证表单 -->
|
||||||
<div v-if="kycStatus !== 2" class="form-card">
|
<div v-if="kycStatus === 'UNVERIFIED' || kycStatus === 'REJECTED'" class="form-card">
|
||||||
<div class="form-header">
|
<div class="form-header">
|
||||||
<h2 class="form-title">认证信息</h2>
|
<h2 class="form-title">认证信息</h2>
|
||||||
<p class="form-desc">请填写真实的个人信息,所有信息仅用于身份认证</p>
|
<p class="form-desc">请填写真实的个人信息,所有信息仅用于身份认证</p>
|
||||||
@@ -392,7 +419,7 @@ onMounted(() => {
|
|||||||
<a-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
:disabled="kycStatus === 1"
|
:disabled="kycStatus === 'PENDING'"
|
||||||
@click="submitKYC"
|
@click="submitKYC"
|
||||||
class="submit-btn"
|
class="submit-btn"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user