Compare commits

...
2 Commits
Author SHA1 Message Date
17792275749andClaude Opus 4.7 4e51432b8a feat(userManagement): 删除成员确认文字区分他人添加
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-02 19:15:20 +08:00
17792275749andClaude Opus 4.7 8f5ccdd7e3 fix(supplementPersonal): 查询报错时提交前重新查询直到成功
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-02 19:15:14 +08:00
2 changed files with 36 additions and 11 deletions
@@ -18,6 +18,8 @@ Page({
readonly: false,
/** 是否展示「复用信息」确认弹框 */
showConfirmModal: false,
/** 查询接口是否报错(报错时提交前需重新查询) */
queryError: false,
},
/** 姓名/身份证变动后,查询回填的信息失效,统一清空 */
@@ -31,6 +33,7 @@ Page({
height: '',
weight: '',
readonly: false,
queryError: false,
})
},
@@ -66,9 +69,9 @@ Page({
const serverResult = res.result
// 优先按服务器返回的身份证解析,未查到则回退用户输入
const { gender, age, sex, birthday } = parseIdCard(serverResult?.idCard || this.data.idCard)
this.setData({ gender, age, sex, birthday })
this.setData({ gender, age, sex, birthday, queryError: false })
if (!serverResult) {
wx.showToast({ title: res.msg || '未查询到用户信息', icon: 'none' })
// wx.showToast({ title: res.msg || '未查询到用户信息', icon: 'none' })
return
}
// flag=101:身份证已存在,弹框确认是否复用
@@ -93,7 +96,11 @@ Page({
})
return
}
}).catch(() => {})
}).catch(() => {
// 查询报错:仍按身份证解析性别/年龄,标记需重新查询
const { gender, age, sex, birthday } = parseIdCard(this.data.idCard)
this.setData({ gender, age, sex, birthday, queryError: true })
})
},
// 复用已有信息:关闭弹框直接提交
@@ -116,8 +123,8 @@ Page({
this.setData({ weight: e.detail.value })
},
onSubmit() {
const { name, idCard, gender, sex, birthday, height, weight, serverResult } = this.data
async onSubmit() {
const { name, idCard, height, weight } = this.data
const heightNum = parseFloat(height)
const weightNum = parseFloat(weight)
@@ -125,7 +132,7 @@ Page({
wx.showToast({ title: '请填写姓名', icon: 'none' })
return
}
if (!gender) {
if (!this.data.gender || !this.data.age || !this.data.birthday) {
wx.showToast({ title: '请填写正确的身份证号', icon: 'none' })
return
}
@@ -133,13 +140,28 @@ Page({
wx.showToast({ title: '请填写身高', icon: 'none' })
return
}
if (!serverResult) {
wx.showToast({ title: '请先验证姓名与身份证号', icon: 'none' })
let sex = this.data.sex
let birthday = this.data.birthday
// 查询接口报错 → 重新查询,成功后再提交
if (this.data.queryError) {
try {
const res = await getUserInfoByIdCard({ idCard, realname: name })
const result = res.result
const parsed = parseIdCard(result?.idCard || idCard)
this.setData({ serverResult: result, ...parsed, queryError: false })
sex = parsed.sex
birthday = parsed.birthday
} catch (err: any) {
console.error('[supplementPersonal] 重新查询失败:', err)
wx.showToast({ title: err?.msg || err?.message || '查询失败,请重试', icon: 'none' })
return
}
}
updateUser({
...serverResult,
...(this.data.serverResult || {}),
idCard,
realname: name,
height: heightNum,
@@ -410,9 +410,12 @@ Page({
onTapDelete(e: WechatMiniprogram.TouchEvent) {
const item = e.currentTarget.dataset.item as MemberItem
if (item.delFlag === 1) return
const content = item.relationType === 3
? `${item.name}」成员为他人添加,请确认是否删除?`
: `是否确认删除「${item.name}」?`
wx.showModal({
title: '删除用户',
content: `是否确认删除「${item.name}」?`,
content,
cancelText: '取消',
confirmText: '删除',
confirmColor: '#F24439',