From 8b5d4dafeb0b262f88de0ef2372e76c6abc6c2c7 Mon Sep 17 00:00:00 2001 From: leiyun Date: Fri, 29 May 2026 00:27:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/mp.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/controller/mp.js b/src/controller/mp.js index 6c0268c..d326d9f 100644 --- a/src/controller/mp.js +++ b/src/controller/mp.js @@ -93,7 +93,12 @@ module.exports = class extends Base { patient = await this.model('patient') .field('id, patient_no, name, phone, status, auth_status') .where({ id: user.patient_id, is_deleted: 0 }).find(); - if (think.isEmpty(patient)) patient = null; + if (think.isEmpty(patient)) { + // 关联的患者已被删除,清除关联 + await userModel.where({ id: user.id }).update({ patient_id: 0 }); + user.patient_id = 0; + patient = null; + } } return this.json({ code: 0, data: { token, userInfo: { id: user.id, nickname: user.nickname || '', avatar: user.avatar || '',