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
+13 -12
View File
@@ -218,8 +218,6 @@ Page({
const name = e.detail.value const name = e.detail.value
this.setData({ this.setData({
'form.name': name, 'form.name': name,
'form.gender': '',
'form.age': '',
serverResult: null, serverResult: null,
hasQueried: false, hasQueried: false,
readonly: false readonly: false
@@ -231,16 +229,19 @@ Page({
onIdCardInput(e: WechatMiniprogram.Input) { onIdCardInput(e: WechatMiniprogram.Input) {
const idCard = (e.detail.value || '').trim().toUpperCase() const idCard = (e.detail.value || '').trim().toUpperCase()
this.setData({ if (this.isIdCardValid(idCard)) {
'form.idCard': idCard, const parsed = this.parseIdCard(idCard)
'form.gender': '', this.setData({
'form.age': '', 'form.idCard': idCard,
serverResult: null, 'form.gender': parsed.gender,
hasQueried: false, 'form.age': parsed.age,
readonly: false })
}) } else {
if (this.data.form.name.trim() && this.isIdCardValid(idCard)) { this.setData({
this.fetchUserInfoByIdCard(this.data.form.name.trim(), idCard) 'form.idCard': idCard,
'form.gender': '',
'form.age': '',
})
} }
}, },
+9 -12
View File
@@ -140,8 +140,6 @@ Page({
const name = e.detail.value const name = e.detail.value
this.setData({ this.setData({
'form.name': name, 'form.name': name,
'form.gender': '',
'form.age': '',
serverResult: null, serverResult: null,
hasQueried: false, hasQueried: false,
readonly: false readonly: false
@@ -153,16 +151,15 @@ Page({
onIdCardInput(e: WechatMiniprogram.Input) { onIdCardInput(e: WechatMiniprogram.Input) {
const idCard = (e.detail.value || '').trim().toUpperCase() const idCard = (e.detail.value || '').trim().toUpperCase()
this.setData({ if (!this.data.isFamily) {
'form.idCard': idCard, this.setData({ 'form.idCard': idCard })
'form.gender': '', return
'form.age': '', }
serverResult: null, if (this.isIdCardValid(idCard)) {
hasQueried: false, const parsed = this.parseIdCard(idCard)
readonly: false this.setData({ 'form.idCard': idCard, 'form.gender': parsed.gender, 'form.age': parsed.age })
}) } else {
if (this.data.isFamily && this.data.form.name.trim() && this.isIdCardValid(idCard)) { this.setData({ 'form.idCard': idCard, 'form.gender': '', 'form.age': '' })
this.fetchUserInfoByIdCard(this.data.form.name.trim(), idCard)
} }
}, },