Compare commits
2
Commits
00394bf8c4
...
4e51432b8a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e51432b8a | ||
|
|
8f5ccdd7e3 |
@@ -18,6 +18,8 @@ Page({
|
|||||||
readonly: false,
|
readonly: false,
|
||||||
/** 是否展示「复用信息」确认弹框 */
|
/** 是否展示「复用信息」确认弹框 */
|
||||||
showConfirmModal: false,
|
showConfirmModal: false,
|
||||||
|
/** 查询接口是否报错(报错时提交前需重新查询) */
|
||||||
|
queryError: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 姓名/身份证变动后,查询回填的信息失效,统一清空 */
|
/** 姓名/身份证变动后,查询回填的信息失效,统一清空 */
|
||||||
@@ -31,6 +33,7 @@ Page({
|
|||||||
height: '',
|
height: '',
|
||||||
weight: '',
|
weight: '',
|
||||||
readonly: false,
|
readonly: false,
|
||||||
|
queryError: false,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -66,9 +69,9 @@ Page({
|
|||||||
const serverResult = res.result
|
const serverResult = res.result
|
||||||
// 优先按服务器返回的身份证解析,未查到则回退用户输入
|
// 优先按服务器返回的身份证解析,未查到则回退用户输入
|
||||||
const { gender, age, sex, birthday } = parseIdCard(serverResult?.idCard || this.data.idCard)
|
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) {
|
if (!serverResult) {
|
||||||
wx.showToast({ title: res.msg || '未查询到用户信息', icon: 'none' })
|
// wx.showToast({ title: res.msg || '未查询到用户信息', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// flag=101:身份证已存在,弹框确认是否复用
|
// flag=101:身份证已存在,弹框确认是否复用
|
||||||
@@ -93,7 +96,11 @@ Page({
|
|||||||
})
|
})
|
||||||
return
|
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 })
|
this.setData({ weight: e.detail.value })
|
||||||
},
|
},
|
||||||
|
|
||||||
onSubmit() {
|
async onSubmit() {
|
||||||
const { name, idCard, gender, sex, birthday, height, weight, serverResult } = this.data
|
const { name, idCard, height, weight } = this.data
|
||||||
const heightNum = parseFloat(height)
|
const heightNum = parseFloat(height)
|
||||||
const weightNum = parseFloat(weight)
|
const weightNum = parseFloat(weight)
|
||||||
|
|
||||||
@@ -125,7 +132,7 @@ Page({
|
|||||||
wx.showToast({ title: '请填写姓名', icon: 'none' })
|
wx.showToast({ title: '请填写姓名', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!gender) {
|
if (!this.data.gender || !this.data.age || !this.data.birthday) {
|
||||||
wx.showToast({ title: '请填写正确的身份证号', icon: 'none' })
|
wx.showToast({ title: '请填写正确的身份证号', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -133,13 +140,28 @@ Page({
|
|||||||
wx.showToast({ title: '请填写身高', icon: 'none' })
|
wx.showToast({ title: '请填写身高', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!serverResult) {
|
|
||||||
wx.showToast({ title: '请先验证姓名与身份证号', icon: 'none' })
|
let sex = this.data.sex
|
||||||
return
|
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({
|
updateUser({
|
||||||
...serverResult,
|
...(this.data.serverResult || {}),
|
||||||
idCard,
|
idCard,
|
||||||
realname: name,
|
realname: name,
|
||||||
height: heightNum,
|
height: heightNum,
|
||||||
|
|||||||
@@ -410,9 +410,12 @@ Page({
|
|||||||
onTapDelete(e: WechatMiniprogram.TouchEvent) {
|
onTapDelete(e: WechatMiniprogram.TouchEvent) {
|
||||||
const item = e.currentTarget.dataset.item as MemberItem
|
const item = e.currentTarget.dataset.item as MemberItem
|
||||||
if (item.delFlag === 1) return
|
if (item.delFlag === 1) return
|
||||||
|
const content = item.relationType === 3
|
||||||
|
? `「${item.name}」成员为他人添加,请确认是否删除?`
|
||||||
|
: `是否确认删除「${item.name}」?`
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '删除用户',
|
title: '删除用户',
|
||||||
content: `是否确认删除「${item.name}」?`,
|
content,
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
confirmText: '删除',
|
confirmText: '删除',
|
||||||
confirmColor: '#F24439',
|
confirmColor: '#F24439',
|
||||||
|
|||||||
Reference in New Issue
Block a user