feat: 新增实名认证功能,整合KYC组件到用户管理页面,支持用户实名认证请求的处理
This commit is contained in:
135
src/views/user/components/kyc.vue
Normal file
135
src/views/user/components/kyc.vue
Normal file
@@ -0,0 +1,135 @@
|
||||
<script lang="ts" setup>
|
||||
import { h, useTemplateRef } from 'vue';
|
||||
import { NImage } from 'naive-ui';
|
||||
import dayjs from 'dayjs';
|
||||
import { client, safeClient } from '@/service/api';
|
||||
import type { TableBaseColumns, TableFetchData, TableInst } from '@/components/table';
|
||||
|
||||
defineOptions({
|
||||
name: 'KycDialog'
|
||||
});
|
||||
|
||||
enum WithdrawStatus {
|
||||
unverified = '未审核',
|
||||
pending = '审核中',
|
||||
approved = '已通过',
|
||||
rejected = '已拒绝'
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
userId: string;
|
||||
}>();
|
||||
|
||||
const tableInst = useTemplateRef<TableInst>('tableInst');
|
||||
|
||||
const fetchData: TableFetchData = ({ pagination, filter }) => {
|
||||
return safeClient(() =>
|
||||
client.api.admin.kyc.methods.get({ query: { userId: props.userId, ...pagination, ...filter } })
|
||||
);
|
||||
};
|
||||
|
||||
const columns: TableBaseColumns = [
|
||||
{
|
||||
key: 'documentName',
|
||||
title: '证件名称'
|
||||
},
|
||||
{
|
||||
key: 'documentNumber',
|
||||
title: '证件号码'
|
||||
},
|
||||
{
|
||||
key: 'fileId1',
|
||||
title: '证件照片正面',
|
||||
render: (row: any) => {
|
||||
return h(NImage, { src: row.fileId1, width: 100 });
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'fileId2',
|
||||
title: '证件照片背面',
|
||||
render: (row: any) => {
|
||||
return h(NImage, { src: row.fileId2, width: 100 });
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'status',
|
||||
title: '审核状态',
|
||||
render: (row: any) => {
|
||||
return WithdrawStatus[row.status];
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
title: '创建时间',
|
||||
render: (row: any) => {
|
||||
return dayjs(row.createdAt).format('YYYY-MM-DD HH:mm');
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'operations',
|
||||
title: '操作',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
operations: (row: any) => [
|
||||
{
|
||||
contentText: '通过',
|
||||
size: 'small',
|
||||
type: 'primary',
|
||||
ghost: true,
|
||||
visible: row.status === 'pending',
|
||||
onClick: () => {
|
||||
window.$dialog?.warning({
|
||||
title: '确认通过该实名认证请求吗?',
|
||||
content: '通过后将无法撤销',
|
||||
positiveText: '通过',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await safeClient(() =>
|
||||
client.api.admin.kyc.methods({ id: row.id }).approve.post({
|
||||
reviewNote: `${dayjs().format('YYYY-MM-DD HH:mm')} 通过审核。`
|
||||
})
|
||||
);
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
contentText: '拒绝',
|
||||
size: 'small',
|
||||
type: 'error',
|
||||
ghost: true,
|
||||
visible: row.status === 'pending',
|
||||
onClick: () => {
|
||||
window.$dialog?.warning({
|
||||
title: '确认拒绝该实名认证请求吗?',
|
||||
content: '拒绝后将无法撤销',
|
||||
positiveText: '拒绝',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
await safeClient(() =>
|
||||
client.api.admin.kyc.methods({ id: row.id }).reject.post({
|
||||
rejectionReason: `${dayjs().format('YYYY-MM-DD HH:mm')} 拒绝通过。`
|
||||
})
|
||||
);
|
||||
tableInst.value?.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableBase
|
||||
ref="tableInst"
|
||||
:fetch-data="fetchData"
|
||||
:columns="columns"
|
||||
:scroll-x="1200"
|
||||
:show-header-operation="false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="css" scoped></style>
|
||||
@@ -9,6 +9,7 @@ import Address from './components/address.vue';
|
||||
import Payment from './components/payment.vue';
|
||||
import Withdraw from './components/withdraw.vue';
|
||||
import Team from './components/team.vue';
|
||||
import Kyc from './components/kyc.vue';
|
||||
|
||||
const dialog = useDialog();
|
||||
|
||||
@@ -64,7 +65,7 @@ const columns: TableBaseColumns = [
|
||||
title: '用户钱包',
|
||||
showIcon: false,
|
||||
style: { width: '1000px' },
|
||||
content: () => h(Wallet, { userId: row.userId })
|
||||
content: () => h(Wallet, { userId: row.id })
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -76,7 +77,7 @@ const columns: TableBaseColumns = [
|
||||
title: '收货地址',
|
||||
showIcon: false,
|
||||
style: { width: '1000px' },
|
||||
content: () => h(Address, { userId: row.userId })
|
||||
content: () => h(Address, { userId: row.id })
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -88,7 +89,7 @@ const columns: TableBaseColumns = [
|
||||
title: '收款方式',
|
||||
showIcon: false,
|
||||
style: { width: '1000px' },
|
||||
content: () => h(Payment, { userId: row.userId })
|
||||
content: () => h(Payment, { userId: row.id })
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -100,7 +101,7 @@ const columns: TableBaseColumns = [
|
||||
title: '提现订单',
|
||||
showIcon: false,
|
||||
style: { width: '1000px' },
|
||||
content: () => h(Withdraw, { userId: row.userId })
|
||||
content: () => h(Withdraw, { userId: row.id })
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -115,7 +116,7 @@ const columns: TableBaseColumns = [
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
const { data } = await safeClient(() =>
|
||||
client.api.admin.user_security({ userId: row.userId })['transaction-password'].reset.post()
|
||||
client.api.admin.user_security({ userId: row.id })['transaction-password'].reset.post()
|
||||
);
|
||||
|
||||
dialog.success({
|
||||
@@ -137,6 +138,18 @@ const columns: TableBaseColumns = [
|
||||
content: () => h(Team, { code: row.userProfile.referralCode })
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
contentText: '实名认证',
|
||||
size: 'small',
|
||||
onClick: () => {
|
||||
dialog.create({
|
||||
title: '实名认证',
|
||||
showIcon: false,
|
||||
style: { width: '1000px' },
|
||||
content: () => h(Kyc, { userId: row.id })
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user