diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index f033143..caa0405 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -57,5 +57,5 @@ } ] }, - "lastUpdated": 1776019574605 + "lastUpdated": 1776019986045 } \ No newline at end of file diff --git a/.workbuddy/memory/2026-04-13.md b/.workbuddy/memory/2026-04-13.md new file mode 100644 index 0000000..a3a0ee3 --- /dev/null +++ b/.workbuddy/memory/2026-04-13.md @@ -0,0 +1,35 @@ +# 2026-04-13 工作日志 + +## 完成的工作 + +### 1. 阿里云实人认证接入 +**目的**:为 user/userVerify 页面添加阿里云身份证二要素核验 + +**后端改动**(JAVA/websopy-java): +- pom.xml:添加 `com.aliyun:cloudauth20190307:2.2.4` 依赖 +- application.yml:添加 `cloudauth` 配置项(accessKeyId、accessKeySecret、endpoint、regionId) +- 新增 `CloudAuthProperties.java`:配置属性类 +- 新增 `IdVerificationService.java`:实人认证服务 +- 新增 `IdVerificationController.java`:实人认证 API 控制器 + +**前端改动**(VUE/websopy-mp): +- api/system/userVerify/index.ts:添加 `verifyIdCard()` API 调用 +- user/userVerify/index.tsx: + - 导入 verifyIdCard + - 修改 submitSucceed 函数:个人认证时先调用实名校验,核验通过后再提交 + +### 2. 调研结论 +- **城市服务实名校验**:已于2021年11月停止开放,不可用 +- **阿里云实人认证**:推荐方案,0.2元/次,有100次免费试用额度 +- **接入方式**:身份证二要素核验(姓名+身份证号)最简单 + +## 待办事项 +- [x] 配置阿里云 AccessKey(在 application-prod.yml 中设置 cloudauth.accessKeyId 和 cloudauth.accessKeySecret) +- [ ] 在阿里云实人认证控制台开通服务并充值 +- [ ] 测试验证接口是否正常工作 + +## 阿里云 AccessKey 配置 +- 项目:websopy-java +- 文件:application-prod.yml +- accessKeyId: LTAI4GKGZ9Z2Z8JZ77c3GNZP +- 备注:与 OSS 使用同一个 AccessKey diff --git a/src/api/system/userVerify/index.ts b/src/api/system/userVerify/index.ts index 21416e7..5162ad3 100644 --- a/src/api/system/userVerify/index.ts +++ b/src/api/system/userVerify/index.ts @@ -128,3 +128,24 @@ export async function submit(data: UserVerify) { } return Promise.reject(new Error(res.message)); } + +/** + * 阿里云实人认证 - 身份证二要素核验 + * 验证姓名和身份证号是否一致 + */ +export async function verifyIdCard(realName: string, idCard: string) { + const res = await request.post>( + SERVER_API_URL + '/id-verification/verify-id-card', + null, + { params: { realName, idCard } } + ); + if (res.code === 0) { + return res.data; + } + return Promise.reject(new Error(res.message)); +} diff --git a/src/user/userVerify/index.tsx b/src/user/userVerify/index.tsx index c4889e4..7804ead 100644 --- a/src/user/userVerify/index.tsx +++ b/src/user/userVerify/index.tsx @@ -11,7 +11,7 @@ import { Checkbox, } from '@nutui/nutui-react-taro' import {UserVerify} from "@/api/system/userVerify/model"; -import {addUserVerify, myUserVerify, updateUserVerify} from "@/api/system/userVerify"; +import {addUserVerify, myUserVerify, updateUserVerify, verifyIdCard} from "@/api/system/userVerify"; import {uploadFile} from "@/api/system/file"; function Index() { @@ -62,7 +62,7 @@ function Index() { }; // 提交表单 - const submitSucceed = (values: any) => { + const submitSucceed = async (values: any) => { console.log('提交表单', values); if (FormData.status != 2 && FormData.status != undefined) return false; @@ -113,6 +113,36 @@ function Index() { }); return false; } + + // 个人认证:先调用阿里云实人认证进行身份核验 + if (FormData.type == 0) { + Taro.showLoading({ title: '身份核验中...' }); + try { + const verifyResult = await verifyIdCard(FormData.realName!, FormData.idCard!); + Taro.hideLoading(); + + if (!verifyResult.isMatch) { + Taro.showToast({ + title: '身份信息不一致,请核实后重新填写', + icon: 'none', + duration: 3000 + }); + return false; + } + + // 核验通过,继续提交 + } catch (error: any) { + Taro.hideLoading(); + console.error('身份核验失败', error); + Taro.showToast({ + title: error.message || '身份核验失败,请稍后重试', + icon: 'none', + duration: 3000 + }); + return false; + } + } + const saveOrUpdate = isUpdate ? updateUserVerify : addUserVerify; saveOrUpdate({...FormData, status: 0}).then(() => { Taro.showToast({title: `提交成功`, icon: 'success'})