This commit is contained in:
Your Name
2026-06-02 18:33:25 +08:00
parent 62f74888f3
commit 15e9c486f9
11 changed files with 731 additions and 674 deletions
+63 -12
View File
@@ -1264,6 +1264,47 @@ async function applyCard(card) {
await fetchGamifyState()
}
function readUserMobile() {
try {
const userData = uni.getStorageSync('userData') || {}
return String(userData.mobile || userData.phone || '').trim()
} catch (e) {
return ''
}
}
/** 无就诊卡时:已绑定手机号则快捷建档(与 weekly 一致) */
async function ensureDailyContextByPhone() {
if (diagnosisId.value) return true
const res = await proxy.apiUrl({
url: '/api/tcm/dailyEnsurePhoneContext',
method: 'POST',
data: {}
}, false)
if (res && res.code === 1 && res.data && res.data.diagnosis_id) {
await applyCard({
id: res.data.diagnosis_id,
patient_id: res.data.patient_id,
patient_name: res.data.patient_name || '',
age: res.data.age || 0,
gender: res.data.gender || 0
})
if (res.data.created) {
await fetchCardList()
}
return true
}
if (res && res.data && res.data.need_mobile) {
return 'need_mobile'
}
showUserToast(formatUserMessage(res?.msg, '无法加载记录'))
return false
}
async function onSelectCard(card) {
if (!card || Number(card.id) === Number(diagnosisId.value)) return
bloodRecords.value = []
@@ -2680,13 +2721,12 @@ function onChartTouch(e) {
function readUserContext() {
try {
const userData = uni.getStorageSync('userData')
if (userData && userData.diagnosis) {
if (!patientId.value) patientId.value = Number(userData.diagnosis.patient_id) || 0
if (!diagnosisId.value) diagnosisId.value = Number(userData.diagnosis.id) || 0
if (!patientName.value) patientName.value = userData.diagnosis.patient_name || ''
if (!age.value) age.value = Number(userData.diagnosis.age) || 0
if (!gender.value) gender.value = Number(userData.diagnosis.gender) || 0
}
if (!userData) return
const name = String(userData.real_name || userData.nickname || '').trim()
if (!patientName.value && name) patientName.value = name
const sex = Number(userData.sex)
if (!gender.value && (sex === 1 || sex === 2)) gender.value = sex === 1 ? 1 : 0
if (!age.value && userData.age) age.value = Number(userData.age) || 0
} catch (e) {}
}
@@ -2755,17 +2795,28 @@ async function bootstrap(options) {
if (!target) target = list[0]
await applyCard(target)
} else {
if (passedDiagnosisId) diagnosisId.value = passedDiagnosisId
if (passedPatientId) patientId.value = passedPatientId
diagnosisId.value = passedDiagnosisId || 0
patientId.value = passedPatientId || 0
if (passedPatientName) patientName.value = passedPatientName
if (passedAge) age.value = passedAge
if (passedGender) gender.value = passedGender
if (!diagnosisId.value || !patientId.value) {
readUserContext()
if (!patientName.value) readUserContext()
if (!diagnosisId.value && readUserMobile()) {
await ensureDailyContextByPhone()
}
if (!diagnosisId.value) {
authChecking.value = false
redirectToCardEntry()
if (readUserMobile()) {
showUserToast('暂时无法加载记录,请稍后重试')
} else {
showUserToast('请先在统计页授权手机号后再查看记录')
}
setTimeout(() => {
const pages = getCurrentPages()
if (pages.length > 1) uni.navigateBack()
else uni.redirectTo({ url: '/tongji/pages/weekly' })
}, 1600)
return
}
}