feat: 首页接单开关接入服务端落库

This commit is contained in:
lik
2026-11-10 15:13:53 +08:00
parent 5ae8a62475
commit 5fdcf8ea4c
4 changed files with 42 additions and 8 deletions
+2
View File
@@ -42,6 +42,8 @@ const API = {
// 当前账号的员工档案:登录即可访问,用于判定在职陪诊员身份
employee: {
getMe: () => request.get('/health/employee/me'),
// 首页接单开关:仅在职正式陪诊师可切换
setOnline: (isOnline) => request.patch('/health/employee/me/online', { isOnline }),
// 共享订单时的陪诊师候选(在职陪诊师,含实习)
getShareableAttendants: () => request.get('/health/employee/shareable-attendants'),
},
+7
View File
@@ -39,6 +39,7 @@ function normalizeAttendant(employee) {
grade,
star,
canAcceptOrder: stage === 'certified',
isOnline: info.isOnline === true,
text: stage === 'intern' ? '实习陪诊师' : `正式陪诊师 · ${gradeText}`
}
}
@@ -189,6 +190,11 @@ function getAttendantSync() {
return cachedAttendant
}
// 接单开关切换成功后同步快照,避免 onShow 复用旧值把开关弹回去
function setAttendantOnline(isOnline) {
if (cachedAttendant) cachedAttendant.isOnline = !!isOnline
}
/**
* 退出登录 / 清除缓存后重置,避免沿用上一个账号的角色
*/
@@ -242,6 +248,7 @@ module.exports = {
ensureRoleSafe,
getRoleSync,
getAttendantSync,
setAttendantOnline,
resetRole,
queryOrders,
guardAdminPage