feat(addUser): 身份证合法时未填姓名则前端先解析性别年龄生日

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-09-03 11:39:33 +08:00
co-authored by Claude Opus 4.7
parent 8284bf107b
commit fb7c33c05f
+8 -2
View File
@@ -233,10 +233,16 @@ Page({
if (idCard.length === 18) this.validateIdCard() if (idCard.length === 18) this.validateIdCard()
}, },
/** 身份证合法且姓名已填则查询 */ /** 身份证合法则解析:姓名已填走接口查询,未填先前端解析 */
validateIdCard() { validateIdCard() {
const { idCard, name } = this.data.form const { idCard, name } = this.data.form
if (isIdCardValid(idCard) && name) this.fetchUser() if (!isIdCardValid(idCard)) return
if (name) {
this.fetchUser()
return
}
const { gender, age, sex, birthday } = parseIdCard(idCard)
this.setData({ 'form.gender': gender, 'form.age': age, 'form.sex': sex, birthday })
}, },
/** 查询身份证对应的用户信息,101 复用 */ /** 查询身份证对应的用户信息,101 复用 */