fix(addMember, editMember): 身份证号输入时立即解析性别年龄,不再清空已有值

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-06-12 11:08:56 +08:00
co-authored by Claude Opus 4.7
parent 9b011b82a7
commit ea8f828702
2 changed files with 22 additions and 24 deletions
+8 -7
View File
@@ -218,8 +218,6 @@ Page({
const name = e.detail.value
this.setData({
'form.name': name,
'form.gender': '',
'form.age': '',
serverResult: null,
hasQueried: false,
readonly: false
@@ -231,16 +229,19 @@ Page({
onIdCardInput(e: WechatMiniprogram.Input) {
const idCard = (e.detail.value || '').trim().toUpperCase()
if (this.isIdCardValid(idCard)) {
const parsed = this.parseIdCard(idCard)
this.setData({
'form.idCard': idCard,
'form.gender': parsed.gender,
'form.age': parsed.age,
})
} else {
this.setData({
'form.idCard': idCard,
'form.gender': '',
'form.age': '',
serverResult: null,
hasQueried: false,
readonly: false
})
if (this.data.form.name.trim() && this.isIdCardValid(idCard)) {
this.fetchUserInfoByIdCard(this.data.form.name.trim(), idCard)
}
},
+9 -12
View File
@@ -140,8 +140,6 @@ Page({
const name = e.detail.value
this.setData({
'form.name': name,
'form.gender': '',
'form.age': '',
serverResult: null,
hasQueried: false,
readonly: false
@@ -153,16 +151,15 @@ Page({
onIdCardInput(e: WechatMiniprogram.Input) {
const idCard = (e.detail.value || '').trim().toUpperCase()
this.setData({
'form.idCard': idCard,
'form.gender': '',
'form.age': '',
serverResult: null,
hasQueried: false,
readonly: false
})
if (this.data.isFamily && this.data.form.name.trim() && this.isIdCardValid(idCard)) {
this.fetchUserInfoByIdCard(this.data.form.name.trim(), idCard)
if (!this.data.isFamily) {
this.setData({ 'form.idCard': idCard })
return
}
if (this.isIdCardValid(idCard)) {
const parsed = this.parseIdCard(idCard)
this.setData({ 'form.idCard': idCard, 'form.gender': parsed.gender, 'form.age': parsed.age })
} else {
this.setData({ 'form.idCard': idCard, 'form.gender': '', 'form.age': '' })
}
},