Compare commits

...
5 Commits
Author SHA1 Message Date
lik 5fdcf8ea4c feat: 首页接单开关接入服务端落库 2026-11-10 15:13:53 +08:00
lik 5ae8a62475 fix(order): 共享保存失败后刷新最新状态,接单入口排除取消中订单 2026-11-10 12:54:22 +08:00
lik d70d9703ad feat(order): 订单池接单与共享入口,实习陪诊师只读
列表展示未分配/共享给我标记并新增接单按钮;详情页支持接单与共享给在职陪诊师,实习仅可查看脱敏信息。
2026-11-10 12:28:06 +08:00
lik 51b6ef497b feat(attendant): 展示实习/正式身份与实习只读提示
- 角色解析缓存陪诊师阶段与等级,实习仍可进入工作台

- 首页与个人中心展示身份文案,实习期给出不能接单的提示

- 申请页文案说明审核通过后为实习陪诊师、转正后可接单
2026-11-10 12:02:08 +08:00
lik a8b896846b chore: 项目更名为 wxapp_companion(文档与 projectname 同步) 2026-11-10 10:40:52 +08:00
16 changed files with 624 additions and 45 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# 陪诊端(管理端)配色方案 # 陪诊端(管理端)配色方案
> 适用项目:`ui/wxapp_escort_admin` > 适用项目:`ui/wxapp_companion`
> 主题方向:商务暖色 · 琥珀金 × 深咖 > 主题方向:商务暖色 · 琥珀金 × 深咖
> 设计约束:**纯色填充,不使用任何渐变** > 设计约束:**纯色填充,不使用任何渐变**
+3 -3
View File
@@ -9,7 +9,7 @@
<view class="hero"> <view class="hero">
<view class="hero-badge">待审核</view> <view class="hero-badge">待审核</view>
<text class="hero-title">申请已提交</text> <text class="hero-title">申请已提交</text>
<text class="hero-desc">审核通过后重新进入小程序即可接单。期间无需重复提交。</text> <text class="hero-desc">审核通过后成为实习陪诊师,可先查看订单;管理员转正后即可接单。期间无需重复提交。</text>
</view> </view>
<view class="card"> <view class="card">
@@ -39,7 +39,7 @@
<view class="hero"> <view class="hero">
<view class="hero-badge hero-badge-ok">已通过</view> <view class="hero-badge hero-badge-ok">已通过</view>
<text class="hero-title">审核已通过</text> <text class="hero-title">审核已通过</text>
<text class="hero-desc">权限正在同步,点击下方按钮重新进入。</text> <text class="hero-desc">你已成为实习陪诊师,权限正在同步,点击下方按钮进入工作台。</text>
</view> </view>
<button class="submit-btn" bindtap="onRetry">重新进入</button> <button class="submit-btn" bindtap="onRetry">重新进入</button>
<view class="foot-note">当前微信账号:{{accountName}}</view> <view class="foot-note">当前微信账号:{{accountName}}</view>
@@ -49,7 +49,7 @@
<block wx:else> <block wx:else>
<view class="hero"> <view class="hero">
<text class="hero-title">成为陪诊师</text> <text class="hero-title">成为陪诊师</text>
<text class="hero-desc">提交资料并通过审核后,即可查看订单、接单并使用 AI 办公。</text> <text class="hero-desc">提交资料并通过审核后成为实习陪诊师,可先查看订单;管理员转正后即可接单。</text>
</view> </view>
<view class="reject-box" wx:if="{{rejectReason}}"> <view class="reject-box" wx:if="{{rejectReason}}">
+40 -9
View File
@@ -1,5 +1,6 @@
// pages/home/index.js // pages/home/index.js
const role = require('../../utils/role.js') const role = require('../../utils/role.js')
const API = require('../../utils/api.js')
// 取消与 status 解耦:展示状态优先取 cancelStatus // 取消与 status 解耦:展示状态优先取 cancelStatus
function resolveDisplayStatus(order) { function resolveDisplayStatus(order) {
@@ -35,11 +36,14 @@ Page({
recentOrders: [], recentOrders: [],
role: '', role: '',
isAdmin: false, isAdmin: false,
isIntern: false,
levelText: '',
quickEntries: [], quickEntries: [],
online: true, online: false,
showOnlineSwitch: false,
onlineSaving: false,
profile: { profile: {
name: '', name: '',
level: '初级陪诊师',
avatar: '' avatar: ''
}, },
todayIncome: 0, todayIncome: 0,
@@ -84,12 +88,22 @@ Page({
* 先解析角色再取数:管理员看全量,陪诊员只看本人订单 * 先解析角色再取数:管理员看全量,陪诊员只看本人订单
*/ */
init() { init() {
return role.ensureRole() return role.ensureRoleSafe()
.then(r => { .then((detail) => {
const r = detail.role
const attendant = detail.attendant || null
// 接单开关只对正式陪诊师展示:管理员无接单身份,实习陪诊师不可接单
const isIntern = !!(attendant && attendant.stage === 'intern')
const showOnlineSwitch = r === 'attendant' && !isIntern
this.setData({ this.setData({
role: r, role: r,
isAdmin: r === 'admin', isAdmin: r === 'admin',
quickEntries: r === 'admin' ? ADMIN_ENTRIES : (r === 'attendant' ? ATTENDANT_ENTRIES : []) // 实习陪诊师可进工作台查看,但不能接单:首页给一条只读提示
isIntern,
levelText: r === 'admin' ? '管理员' : (attendant ? attendant.text : ''),
quickEntries: r === 'admin' ? ADMIN_ENTRIES : (r === 'attendant' ? ATTENDANT_ENTRIES : []),
showOnlineSwitch,
online: showOnlineSwitch && attendant ? attendant.isOnline === true : false
}) })
this.loadUser() this.loadUser()
this.getRecentOrders() this.getRecentOrders()
@@ -112,10 +126,27 @@ Page({
.catch(() => {}) .catch(() => {})
}, },
toggleOnline() { async toggleOnline() {
this.setData({ if (!this.data.showOnlineSwitch || this.data.onlineSaving) return
online: !this.data.online const next = !this.data.online
}) // 先乐观更新,请求失败再回滚
this.setData({ online: next, onlineSaving: true })
try {
const res = await API.employee.setOnline(next)
if (!res || res.code !== 0) {
throw new Error((res && res.msg) || '切换失败,请重试')
}
const info = res.data && res.data.employee ? res.data.employee.attendantInfo : null
const actual = info && typeof info.isOnline === 'boolean' ? info.isOnline : next
this.setData({ online: actual })
role.setAttendantOnline(actual)
wx.showToast({ title: actual ? '已开启接单' : '已暂停接单', icon: 'none' })
} catch (e) {
this.setData({ online: !next })
wx.showToast({ title: (e && e.message) || '切换失败,请重试', icon: 'none' })
} finally {
this.setData({ onlineSaving: false })
}
}, },
async getStats() { async getStats() {
+9 -3
View File
@@ -11,14 +11,14 @@
<view class="profile-info"> <view class="profile-info">
<view class="name-row"> <view class="name-row">
<text class="name">{{profile.name}}</text> <text class="name">{{profile.name}}</text>
<view class="level-tag"> <view class="level-tag" wx:if="{{levelText}}">
<text class="level-text">{{profile.level}}</text> <text class="level-text">{{levelText}}</text>
</view> </view>
</view> </view>
<text class="greeting">{{greeting}},{{todayText}}</text> <text class="greeting">{{greeting}},{{todayText}}</text>
</view> </view>
</view> </view>
<view class="online-switch" bindtap="toggleOnline"> <view class="online-switch" wx:if="{{showOnlineSwitch}}" bindtap="toggleOnline">
<text class="switch-text">{{online ? '接单中' : '休息中'}}</text> <text class="switch-text">{{online ? '接单中' : '休息中'}}</text>
<view class="switch-track {{online ? 'on' : 'off'}}"> <view class="switch-track {{online ? 'on' : 'off'}}">
<view class="switch-thumb"></view> <view class="switch-thumb"></view>
@@ -45,6 +45,12 @@
</view> </view>
</view> </view>
<!-- 实习期只读提示 -->
<view class="intern-tip" wx:if="{{isIntern}}">
<t-icon name="info-circle" size="32rpx" color="#C26A2E" />
<text class="intern-tip-text">实习期可查看订单,暂不能接单;管理员转正后即可接单。</text>
</view>
<!-- 快捷入口 --> <!-- 快捷入口 -->
<view class="section"> <view class="section">
<text class="section-title">快捷入口</text> <text class="section-title">快捷入口</text>
+18
View File
@@ -118,6 +118,24 @@ page {
color: rgba(255, 255, 255, 0.65); color: rgba(255, 255, 255, 0.65);
} }
/* === 实习期只读提示 === */
.intern-tip {
display: flex;
align-items: center;
margin-top: 20rpx;
padding: 18rpx 24rpx;
background-color: #FBEFE4;
border: 1rpx solid #EBD3BE;
border-radius: 20rpx;
}
.intern-tip-text {
margin-left: 12rpx;
font-size: 24rpx;
line-height: 1.5;
color: #8A5A32;
}
.online-switch { .online-switch {
display: flex; display: flex;
align-items: center; align-items: center;
+20 -1
View File
@@ -1,4 +1,6 @@
// pages/me/index.js // pages/me/index.js
const role = require('../../utils/role.js')
// 性别映射 // 性别映射
const SEX_MAP = { const SEX_MAP = {
male: '男', male: '男',
@@ -7,11 +9,28 @@ const SEX_MAP = {
Page({ Page({
data: { data: {
user: {} user: {},
identityText: ''
}, },
onShow() { onShow() {
this.loadUser() this.loadUser()
this.loadIdentity()
},
/**
* 身份文案:管理员/实习陪诊师/正式陪诊师·等级
*/
loadIdentity() {
role
.ensureRoleSafe()
.then((detail) => {
const attendant = detail.attendant || null
this.setData({
identityText: detail.role === 'admin' ? '管理员' : (attendant ? attendant.text : '')
})
})
.catch(() => {})
}, },
/** /**
+7
View File
@@ -14,6 +14,13 @@
<!-- 详细信息 --> <!-- 详细信息 -->
<view class="info-card"> <view class="info-card">
<view class="info-item" wx:if="{{identityText}}">
<view class="info-left">
<t-icon name="award" size="36rpx" color="#C26A2E" />
<text class="info-label">身份</text>
</view>
<text class="info-value">{{identityText}}</text>
</view>
<view class="info-item"> <view class="info-item">
<view class="info-left"> <view class="info-left">
<t-icon name="user" size="36rpx" color="#C26A2E" /> <t-icon name="user" size="36rpx" color="#C26A2E" />
+56 -4
View File
@@ -60,9 +60,11 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
// 角色:管理员可新增预约,陪诊员只看本人订单 // 角色:管理员可新增预约,陪诊员只看订单池/本人订单
role: '', role: '',
isAdmin: false, isAdmin: false,
// 实习陪诊师:能看到未分配订单,但不能接单
isIntern: false,
// 统计 // 统计
stats: { stats: {
total: 0, total: 0,
@@ -92,9 +94,13 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
// 先解析角色:陪诊员走本人订单接口,管理员走全量接口 // 先解析角色:陪诊员走订单池接口,管理员走全量接口
role.ensureRole().then(r => { role.ensureRoleSafe().then(({ role: r, attendant }) => {
this.setData({ role: r, isAdmin: r === 'admin' }) this.setData({
role: r,
isAdmin: r === 'admin',
isIntern: Boolean(attendant && attendant.stage === 'intern')
})
this.loadOrderList(); this.loadOrderList();
}) })
}, },
@@ -147,12 +153,23 @@ Page({
return orders.map(order => { return orders.map(order => {
const age = calcAge(order.patient?.birth) const age = calcAge(order.patient?.birth)
const displayStatus = resolveDisplayStatus(order) const displayStatus = resolveDisplayStatus(order)
// 接单/共享标记由服务端按身份计算;未分配 = attendant.id 为空
const isPoolOrder = Boolean(order.isPoolOrder)
const assignedToMe = Boolean(order.attendantAssignedToMe)
return { return {
...order, ...order,
displayStatus, displayStatus,
statusText: STATUS_MAP[displayStatus]?.text || displayStatus, statusText: STATUS_MAP[displayStatus]?.text || displayStatus,
patientFirstChar: (order.patient?.name || '?')[0], patientFirstChar: (order.patient?.name || '?')[0],
patientAgeText: age ? `${age}岁` : '', patientAgeText: age ? `${age}岁` : '',
isPoolOrder,
assignedToMe,
sharedToMe: Boolean(order.attendantSharedToMe),
// 取消中/已取消的池订单不给接单入口,避免接完即被取消确认
canAccept: !this.data.isAdmin && !this.data.isIntern && isPoolOrder
&& order.cancelStatus !== 'requested' && order.cancelStatus !== 'cancelled',
// 状态流转只对自己已接的订单开放,管理员保持全量可操作
canOperate: this.data.isAdmin || assignedToMe,
schedule: { schedule: {
...order.schedule, ...order.schedule,
dateText: this.formatDate(order.schedule?.date) dateText: this.formatDate(order.schedule?.date)
@@ -276,6 +293,18 @@ Page({
const order = this.data.orderList.find(item => item._id === id); const order = this.data.orderList.find(item => item._id === id);
if (!order) return; if (!order) return;
if (action === 'accept') {
wx.showModal({
title: '确认接单',
content: '接单后该订单将从其他陪诊师的未分配列表中移除,确认接单?',
confirmColor: '#C26A2E',
success: (res) => {
if (res.confirm) this.acceptOrder(id);
}
});
return;
}
const isCancelRequest = action === 'cancel' && order.displayStatus === 'cancel_requested'; const isCancelRequest = action === 'cancel' && order.displayStatus === 'cancel_requested';
const actionMap = { const actionMap = {
confirm: { title: '确认订单', content: '确认接受此订单?', nextStatus: 'confirmed' }, confirm: { title: '确认订单', content: '确认接受此订单?', nextStatus: 'confirmed' },
@@ -309,6 +338,29 @@ Page({
}); });
}, },
/**
* 接单:服务端会再次校验身份与订单是否已被接走
*/
acceptOrder(id) {
wx.showLoading({ title: '接单中...' });
API.escort.acceptRecord(id)
.then(res => {
wx.hideLoading();
if (res.code !== 0) {
wx.showToast({ title: res.msg || '接单失败', icon: 'none' });
this.refreshData();
return;
}
wx.showToast({ title: '接单成功', icon: 'success' });
this.refreshData();
})
.catch(err => {
console.error('接单失败', err);
wx.hideLoading();
wx.showToast({ title: '网络错误,请重试', icon: 'none' });
});
},
/** /**
* 更新订单状态 * 更新订单状态
*/ */
+24
View File
@@ -223,6 +223,30 @@ page {
margin-bottom: 12rpx; margin-bottom: 12rpx;
} }
.card-tags {
display: flex;
align-items: center;
gap: 10rpx;
margin-right: auto;
}
.order-tag {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 20rpx;
font-weight: 500;
}
.tag-pool {
background: #EEF3EE;
color: #5B7A5B;
}
.tag-shared {
background: #FBF0DC;
color: #A97712;
}
.order-no { .order-no {
font-size: 24rpx; font-size: 24rpx;
color: @muted; color: @muted;
+16 -5
View File
@@ -62,6 +62,10 @@
> >
<!-- 卡片头部 --> <!-- 卡片头部 -->
<view class="card-top"> <view class="card-top">
<view class="card-tags">
<text class="order-tag tag-pool" wx:if="{{item.isPoolOrder}}">未分配</text>
<text class="order-tag tag-shared" wx:if="{{item.sharedToMe}}">共享给我</text>
</view>
<view class="status-badge status-{{item.displayStatus}}"> <view class="status-badge status-{{item.displayStatus}}">
<text>{{item.statusText}}</text> <text>{{item.statusText}}</text>
</view> </view>
@@ -113,28 +117,35 @@
<view class="action-area"> <view class="action-area">
<view <view
class="action-btn btn-ghost" class="action-btn btn-ghost"
wx:if="{{item.displayStatus === 'pending'}}" wx:if="{{item.displayStatus === 'pending' && item.canOperate}}"
data-id="{{item._id}}" data-id="{{item._id}}"
data-action="cancel" data-action="cancel"
catchtap="onOrderAction" catchtap="onOrderAction"
>取消</view> >取消</view>
<view <view
class="action-btn btn-solid" class="action-btn btn-solid"
wx:if="{{item.displayStatus === 'pending'}}" wx:if="{{item.canAccept}}"
data-id="{{item._id}}"
data-action="accept"
catchtap="onOrderAction"
>接单</view>
<view
class="action-btn btn-solid"
wx:if="{{item.displayStatus === 'pending' && item.canOperate}}"
data-id="{{item._id}}" data-id="{{item._id}}"
data-action="confirm" data-action="confirm"
catchtap="onOrderAction" catchtap="onOrderAction"
>确认</view> >确认</view>
<view <view
class="action-btn btn-solid" class="action-btn btn-solid"
wx:if="{{item.displayStatus === 'confirmed'}}" wx:if="{{item.displayStatus === 'confirmed' && item.canOperate}}"
data-id="{{item._id}}" data-id="{{item._id}}"
data-action="start" data-action="start"
catchtap="onOrderAction" catchtap="onOrderAction"
>开始服务</view> >开始服务</view>
<view <view
class="action-btn btn-solid" class="action-btn btn-solid"
wx:if="{{item.displayStatus === 'in_progress'}}" wx:if="{{item.displayStatus === 'in_progress' && item.canOperate}}"
data-id="{{item._id}}" data-id="{{item._id}}"
data-action="complete" data-action="complete"
catchtap="onOrderAction" catchtap="onOrderAction"
@@ -142,7 +153,7 @@
<!-- 待取消订单:列表内可直接同意取消 --> <!-- 待取消订单:列表内可直接同意取消 -->
<view <view
class="action-btn btn-solid" class="action-btn btn-solid"
wx:if="{{item.displayStatus === 'cancel_requested'}}" wx:if="{{item.displayStatus === 'cancel_requested' && item.canOperate}}"
data-id="{{item._id}}" data-id="{{item._id}}"
data-action="cancel" data-action="cancel"
catchtap="onOrderAction" catchtap="onOrderAction"
+164 -11
View File
@@ -75,8 +75,10 @@ Page({
data: { data: {
orderId: '', orderId: '',
loaded: false, loaded: false,
// 角色:管理员可查看档案与退款操作,陪诊员只看服务必需信息 // 角色:管理员可查看档案与退款操作,陪诊员按接单/共享关系展示操作
isAdmin: false, isAdmin: false,
isIntern: false,
canAcceptOrder: false,
// 订单数据 // 订单数据
order: null, order: null,
// 格式化后的显示字段 // 格式化后的显示字段
@@ -97,6 +99,18 @@ Page({
completingRefund: false, completingRefund: false,
attendantSexText: '', attendantSexText: '',
sexRequirementText: '', sexRequirementText: '',
// 接单 / 共享状态:未分配订单可从详情页接单,已接订单可共享给其他陪诊师
isPoolOrder: false,
assignedToMe: false,
sharedToMe: false,
desensitized: false,
showAcceptBtn: false,
showShareBtn: false,
// 共享弹窗
showSharePanel: false,
shareCandidates: [],
selectedShareIds: [],
sharing: false,
// 操作按钮配置 // 操作按钮配置
showConfirmBtn: false, showConfirmBtn: false,
showCancelBtn: false, showCancelBtn: false,
@@ -108,9 +122,13 @@ Page({
onLoad(options) { onLoad(options) {
const id = options.id || '' const id = options.id || ''
this.setData({ orderId: id }) this.setData({ orderId: id })
// 先解析角色:详情页按角色决定是否读取档案、是否展示退款操作 // 先解析角色:详情页按角色决定是否读取档案、是否展示退款与接单/共享操作
role.ensureRole().then(r => { role.ensureRoleSafe().then(({ role: r, attendant }) => {
this.setData({ isAdmin: r === 'admin' }) this.setData({
isAdmin: r === 'admin',
isIntern: Boolean(attendant && attendant.stage === 'intern'),
canAcceptOrder: Boolean(attendant && attendant.canAcceptOrder)
})
if (id) this.loadOrderDetail(id) if (id) this.loadOrderDetail(id)
}) })
}, },
@@ -154,6 +172,12 @@ Page({
const escort = order.escort || {} const escort = order.escort || {}
const meta = order.meta || {} const meta = order.meta || {}
const isPoolOrder = !attendant.id
const assignedToMe = Boolean(order.attendantAssignedToMe)
const sharedToMe = Boolean(order.attendantSharedToMe)
// 管理员保持全量操作;陪诊师只能操作自己已接的订单
const canOperate = this.data.isAdmin || assignedToMe
this.setData({ this.setData({
loaded: true, loaded: true,
order: order, order: order,
@@ -182,14 +206,23 @@ Page({
completingRefund: false, completingRefund: false,
attendantSexText: attendant.sex === 'male' ? '男' : attendant.sex === 'female' ? '女' : '', attendantSexText: attendant.sex === 'male' ? '男' : attendant.sex === 'female' ? '女' : '',
sexRequirementText: escort.sexRequirement === 'male' ? '要求男陪诊' : escort.sexRequirement === 'female' ? '要求女陪诊' : '不限', sexRequirementText: escort.sexRequirement === 'male' ? '要求男陪诊' : escort.sexRequirement === 'female' ? '要求女陪诊' : '不限',
// 操作按钮(任何状态下均可编辑订单信息) // 接单 / 共享:未分配订单正式陪诊师可接(取消中/已取消除外),已接订单仅接单本人可共享
showEditBtn: true, isPoolOrder,
showConfirmBtn: cancelStatus === 'none' && status === 'pending', assignedToMe,
showCancelBtn: cancelStatus === 'requested' sharedToMe,
|| (cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')), desensitized: Boolean(order.desensitized),
showAcceptBtn: !this.data.isAdmin && this.data.canAcceptOrder && isPoolOrder
&& order.cancelStatus !== 'requested' && order.cancelStatus !== 'cancelled',
showShareBtn: !this.data.isAdmin && assignedToMe,
// 操作按钮:支付/状态流转仍只对已接订单开放
showEditBtn: this.data.isAdmin
|| (assignedToMe && status !== 'pending' && status !== 'cancelled'),
showConfirmBtn: canOperate && cancelStatus === 'none' && status === 'pending',
showCancelBtn: canOperate && (cancelStatus === 'requested'
|| (cancelStatus === 'none' && (status === 'pending' || status === 'confirmed'))),
cancelBtnText: cancelStatus === 'requested' ? '同意取消' : '取消订单', cancelBtnText: cancelStatus === 'requested' ? '同意取消' : '取消订单',
showStartBtn: cancelStatus === 'none' && status === 'confirmed', showStartBtn: canOperate && cancelStatus === 'none' && status === 'confirmed',
showCompleteBtn: cancelStatus === 'none' && status === 'in_progress' showCompleteBtn: canOperate && cancelStatus === 'none' && status === 'in_progress'
}) })
}, },
@@ -219,6 +252,126 @@ Page({
}) })
}, },
// 接单:正式陪诊师把未分配订单接到自己名下
onAccept() {
wx.showModal({
title: '确认接单',
content: '接单后该订单将从其他陪诊师的未分配列表中移除,确认接单?',
confirmColor: '#C26A2E',
success: (res) => {
if (!res.confirm) return
wx.showLoading({ title: '接单中...' })
API.escort.acceptRecord(this.data.orderId)
.then(result => {
wx.hideLoading()
if (result.code !== 0) {
wx.showToast({ title: result.msg || '接单失败', icon: 'none' })
return
}
wx.showToast({ title: '接单成功', icon: 'success' })
this.loadOrderDetail(this.data.orderId)
})
.catch(err => {
wx.hideLoading()
console.error('接单失败', err)
wx.showToast({ title: '网络错误,请重试', icon: 'none' })
})
}
})
},
// 打开共享弹窗:候选为所有在职陪诊师(含实习),已共享的默认勾选
onShare() {
if (this.data.showSharePanel) return
wx.showLoading({ title: '加载中...' })
API.employee.getShareableAttendants()
.then(res => {
wx.hideLoading()
if (res.code !== 0) {
wx.showToast({ title: res.msg || '加载失败', icon: 'none' })
return
}
const sharedIds = this.data.order?.attendantSharedEmployeeIds || []
const candidates = (res.data?.attendants || []).map(item => ({
...item,
selected: sharedIds.indexOf(item.employeeId) > -1
}))
this.setData({
showSharePanel: true,
shareCandidates: candidates,
selectedShareIds: sharedIds.slice()
})
})
.catch(err => {
wx.hideLoading()
console.error('加载共享名单失败', err)
wx.showToast({ title: '网络错误,请重试', icon: 'none' })
})
},
onToggleShareTarget(e) {
const employeeId = e.currentTarget.dataset.id
const selected = this.data.selectedShareIds.slice()
const index = selected.indexOf(employeeId)
if (index > -1) selected.splice(index, 1)
else selected.push(employeeId)
this.setData({
selectedShareIds: selected,
shareCandidates: this.data.shareCandidates.map(item => ({
...item,
selected: selected.indexOf(item.employeeId) > -1
}))
})
},
onCloseShare() {
if (this.data.sharing) return
this.setData({ showSharePanel: false })
},
// 保存共享关系:新增调用 share,取消调用 unshare,最后刷新详情
onConfirmShare() {
if (this.data.sharing) return
const current = this.data.order?.attendantSharedEmployeeIds || []
const selected = this.data.selectedShareIds
const toAdd = selected.filter(id => current.indexOf(id) === -1)
const toRemove = current.filter(id => selected.indexOf(id) === -1)
if (toAdd.length === 0 && toRemove.length === 0) {
this.setData({ showSharePanel: false })
return
}
this.setData({ sharing: true })
wx.showLoading({ title: '保存中...' })
const tasks = []
if (toAdd.length) tasks.push(API.escort.shareRecord(this.data.orderId, { employeeIds: toAdd }))
if (toRemove.length) tasks.push(API.escort.unshareRecord(this.data.orderId, { employeeIds: toRemove }))
Promise.all(tasks)
.then(results => {
wx.hideLoading()
const failed = results.find(res => res.code !== 0)
if (failed) {
// 部分失败也要关面板并刷新:以服务端最新共享状态为准,避免勾选态错位
wx.showToast({ title: failed.msg || '部分保存失败,已刷新最新状态', icon: 'none' })
} else {
wx.showToast({ title: '共享已更新', icon: 'success' })
}
this.setData({ showSharePanel: false })
this.loadOrderDetail(this.data.orderId)
})
.catch(err => {
wx.hideLoading()
console.error('更新共享失败', err)
wx.showToast({ title: '网络错误,请重试', icon: 'none' })
})
.finally(() => {
this.setData({ sharing: false })
})
},
noop() {},
// 编辑订单 // 编辑订单
onEdit() { onEdit() {
wx.navigateTo({ wx.navigateTo({
+44 -3
View File
@@ -9,11 +9,20 @@
<!-- 顶部状态栏 --> <!-- 顶部状态栏 -->
<view class="status-header status-{{statusClass}}"> <view class="status-header status-{{statusClass}}">
<view class="status-content"> <view class="status-content">
<text class="status-text">{{statusText}}</text> <view class="status-title-row">
<text class="status-text">{{statusText}}</text>
<text class="order-tag tag-pool" wx:if="{{isPoolOrder}}">未分配</text>
<text class="order-tag tag-shared" wx:if="{{sharedToMe}}">共享给我</text>
</view>
<text class="status-desc">{{statusDesc}}</text> <text class="status-desc">{{statusDesc}}</text>
</view> </view>
</view> </view>
<!-- 实习陪诊师看未分配订单:服务端已脱敏 -->
<view class="tip-banner" wx:if="{{desensitized}}">
<text>实习陪诊师仅可查看脱敏信息,接单后可见完整资料</text>
</view>
<!-- 患者信息 --> <!-- 患者信息 -->
<view class="info-section"> <view class="info-section">
<text class="section-title">患者信息</text> <text class="section-title">患者信息</text>
@@ -25,7 +34,7 @@
snapshot="{{order.patient}}" snapshot="{{order.patient}}"
can-load-profile="{{isAdmin}}" can-load-profile="{{isAdmin}}"
use-cache="{{false}}" use-cache="{{false}}"
dial="{{true}}" dial="{{!desensitized}}"
bind:call="callPhone" bind:call="callPhone"
bindtap="onProfileTap" bindtap="onProfileTap"
/> />
@@ -193,14 +202,46 @@
</view> </view>
<!-- 底部操作 --> <!-- 底部操作 -->
<view class="bottom-actions" wx:if="{{showEditBtn || showConfirmBtn || showCancelBtn || showStartBtn || showCompleteBtn || showQueryRefundBtn || showManualRefundBtn}}"> <view class="bottom-actions" wx:if="{{showEditBtn || showConfirmBtn || showCancelBtn || showStartBtn || showCompleteBtn || showQueryRefundBtn || showManualRefundBtn || showAcceptBtn || showShareBtn}}">
<view class="action-btn btn-ghost" wx:if="{{showQueryRefundBtn}}" bindtap="onQueryRefund">查询退款结果</view> <view class="action-btn btn-ghost" wx:if="{{showQueryRefundBtn}}" bindtap="onQueryRefund">查询退款结果</view>
<view class="action-btn btn-ghost" wx:if="{{showManualRefundBtn}}" bindtap="onCompleteManualRefund">确认已退款</view> <view class="action-btn btn-ghost" wx:if="{{showManualRefundBtn}}" bindtap="onCompleteManualRefund">确认已退款</view>
<view class="action-btn btn-ghost" wx:if="{{showShareBtn}}" bindtap="onShare">共享给陪诊师</view>
<view class="action-btn btn-ghost" wx:if="{{showEditBtn}}" bindtap="onEdit">编辑订单</view> <view class="action-btn btn-ghost" wx:if="{{showEditBtn}}" bindtap="onEdit">编辑订单</view>
<view class="action-btn btn-ghost" wx:if="{{showCancelBtn}}" bindtap="onCancel">{{cancelBtnText}}</view> <view class="action-btn btn-ghost" wx:if="{{showCancelBtn}}" bindtap="onCancel">{{cancelBtnText}}</view>
<view class="action-btn btn-solid" wx:if="{{showAcceptBtn}}" bindtap="onAccept">接单</view>
<view class="action-btn btn-solid" wx:if="{{showConfirmBtn}}" bindtap="onConfirm">确认订单</view> <view class="action-btn btn-solid" wx:if="{{showConfirmBtn}}" bindtap="onConfirm">确认订单</view>
<view class="action-btn btn-solid" wx:if="{{showStartBtn}}" bindtap="onStart">开始服务</view> <view class="action-btn btn-solid" wx:if="{{showStartBtn}}" bindtap="onStart">开始服务</view>
<view class="action-btn btn-solid" wx:if="{{showCompleteBtn}}" bindtap="onComplete">完成服务</view> <view class="action-btn btn-solid" wx:if="{{showCompleteBtn}}" bindtap="onComplete">完成服务</view>
</view> </view>
</block> </block>
<!-- 共享弹窗:候选为在职陪诊师(含实习) -->
<view class="share-mask" wx:if="{{showSharePanel}}" catchtap="onCloseShare">
<view class="share-panel" catchtap="noop">
<view class="share-header">
<text class="share-title">共享给陪诊师</text>
<text class="share-close" catchtap="onCloseShare">关闭</text>
</view>
<scroll-view scroll-y class="share-list">
<view
class="share-item"
wx:for="{{shareCandidates}}"
wx:key="employeeId"
data-id="{{item.employeeId}}"
catchtap="onToggleShareTarget"
>
<view class="share-check {{item.selected ? 'checked' : ''}}">{{item.selected ? '✓' : ''}}</view>
<view class="share-meta">
<text class="share-name">{{item.name || '陪诊师'}}</text>
<text class="share-stage">{{item.stageText}}{{item.gradeText ? ' · ' + item.gradeText : ''}}</text>
</view>
</view>
<view class="share-empty" wx:if="{{shareCandidates.length === 0}}">暂无可共享的陪诊师</view>
</scroll-view>
<view class="share-actions">
<view class="share-btn ghost" catchtap="onCloseShare">取消</view>
<view class="share-btn solid" catchtap="onConfirmShare">保存({{selectedShareIds.length}})</view>
</view>
</view>
</view>
</view> </view>
+161 -1
View File
@@ -275,12 +275,13 @@ page {
padding-bottom: calc(24rpx + env(safe-area-inset-bottom)); padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
box-shadow: 0 -4rpx 24rpx rgba(0, 0, 0, 0.06); box-shadow: 0 -4rpx 24rpx rgba(0, 0, 0, 0.06);
display: flex; display: flex;
flex-wrap: wrap;
gap: 20rpx; gap: 20rpx;
z-index: 100; z-index: 100;
} }
.action-btn { .action-btn {
flex: 1; flex: 1 1 200rpx;
padding: 24rpx 0; padding: 24rpx 0;
border-radius: 28rpx; border-radius: 28rpx;
font-size: 28rpx; font-size: 28rpx;
@@ -299,3 +300,162 @@ page {
color: #A3988B; color: #A3988B;
border: 1rpx solid #F0EAE2; border: 1rpx solid #F0EAE2;
} }
/* === 接单 / 共享标识 === */
.status-title-row {
display: flex;
align-items: center;
gap: 14rpx;
margin-bottom: 12rpx;
}
.status-title-row .status-text {
margin-bottom: 0;
}
.order-tag {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 20rpx;
font-weight: 500;
}
.tag-pool {
background: rgba(255, 255, 255, 0.2);
color: #fff;
}
.tag-shared {
background: rgba(255, 255, 255, 0.2);
color: #fff;
}
.tip-banner {
margin: 24rpx 32rpx 0;
padding: 20rpx 24rpx;
border-radius: 20rpx;
background: #FBF0DC;
color: #A97712;
font-size: 24rpx;
line-height: 1.5;
}
/* === 共享弹窗 === */
.share-mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.45);
z-index: 200;
display: flex;
align-items: flex-end;
}
.share-panel {
width: 100%;
max-height: 78vh;
background: #ffffff;
border-radius: 32rpx 32rpx 0 0;
padding: 32rpx 32rpx calc(32rpx + env(safe-area-inset-bottom));
display: flex;
flex-direction: column;
}
.share-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
}
.share-title {
font-size: 32rpx;
font-weight: 600;
color: #3A322B;
}
.share-close {
font-size: 26rpx;
color: #A3988B;
}
.share-list {
flex: 1;
max-height: 56vh;
}
.share-item {
display: flex;
align-items: center;
padding: 24rpx 8rpx;
border-bottom: 1rpx solid #F5EFE8;
}
.share-check {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
border: 2rpx solid #D9CFC3;
margin-right: 24rpx;
font-size: 24rpx;
line-height: 40rpx;
text-align: center;
color: #fff;
}
.share-check.checked {
background: #C26A2E;
border-color: #C26A2E;
}
.share-meta {
display: flex;
flex-direction: column;
}
.share-name {
font-size: 28rpx;
color: #3A322B;
font-weight: 500;
}
.share-stage {
font-size: 22rpx;
color: #A3988B;
margin-top: 6rpx;
}
.share-empty {
padding: 60rpx 0;
text-align: center;
font-size: 26rpx;
color: #A3988B;
}
.share-actions {
display: flex;
gap: 20rpx;
margin-top: 24rpx;
}
.share-btn {
flex: 1;
padding: 24rpx 0;
border-radius: 28rpx;
font-size: 28rpx;
font-weight: 600;
text-align: center;
}
.share-btn.ghost {
background: #FAF6F1;
color: #A3988B;
border: 1rpx solid #F0EAE2;
}
.share-btn.solid {
background: #C26A2E;
color: #fff;
}
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"libVersion": "3.16.1", "libVersion": "3.16.1",
"projectname": "wxapp_escort_admin", "projectname": "wxapp_companion",
"condition": {}, "condition": {},
"setting": { "setting": {
"urlCheck": false, "urlCheck": false,
+8
View File
@@ -21,6 +21,10 @@ const API = {
updateRecord: (id, data) => request.put(`/health/escort-record/${id}`, data), updateRecord: (id, data) => request.put(`/health/escort-record/${id}`, data),
updateStatus: (id, data) => request.patch(`/health/escort-record/${id}/status`, data), updateStatus: (id, data) => request.patch(`/health/escort-record/${id}/status`, data),
deleteRecord: (id) => request.delete(`/health/escort-record/${id}`), deleteRecord: (id) => request.delete(`/health/escort-record/${id}`),
// 陪诊师接单 / 共享 / 取消共享:可见范围与身份全部由服务端判定
acceptRecord: (id) => request.post(`/health/escort-record/${id}/accept`),
shareRecord: (id, data) => request.post(`/health/escort-record/${id}/share`, data),
unshareRecord: (id, data) => request.post(`/health/escort-record/${id}/unshare`, data),
// 退款回调丢失时的人工兜底:主动查询微信退款结果并补写终态 // 退款回调丢失时的人工兜底:主动查询微信退款结果并补写终态
queryRefund: (id) => request.post(`/health/escort-record/${id}/refund/query`), queryRefund: (id) => request.post(`/health/escort-record/${id}/refund/query`),
// 线下/人工退款完成后核销:确认已退款,把订单置为「已退款」 // 线下/人工退款完成后核销:确认已退款,把订单置为「已退款」
@@ -38,6 +42,10 @@ const API = {
// 当前账号的员工档案:登录即可访问,用于判定在职陪诊员身份 // 当前账号的员工档案:登录即可访问,用于判定在职陪诊员身份
employee: { employee: {
getMe: () => request.get('/health/employee/me'), getMe: () => request.get('/health/employee/me'),
// 首页接单开关:仅在职正式陪诊师可切换
setOnline: (isOnline) => request.patch('/health/employee/me/online', { isOnline }),
// 共享订单时的陪诊师候选(在职陪诊师,含实习)
getShareableAttendants: () => request.get('/health/employee/shareable-attendants'),
}, },
// 陪诊师入驻申请:提交/查询本人只要求登录,审核接口仅管理员 // 陪诊师入驻申请:提交/查询本人只要求登录,审核接口仅管理员
+52 -3
View File
@@ -15,6 +15,34 @@ let cachedRole = null
let cachedRoleOk = false let cachedRoleOk = false
let pending = null let pending = null
let pendingSafe = null let pendingSafe = null
// 陪诊师阶段/等级快照:仅用于展示身份文案与实习只读提示,不参与权限判定
let cachedAttendant = null
const GRADE_LABELS = { bronze: '青铜', silver: '白银', gold: '黄金', diamond: '钻石' }
/**
* 阶段/等级归一化:后端已归一化,这里兼容旧接口与缺字段的情况
* @param {Object|null} employee 员工档案
* @returns {{stage: string, grade: string, star: number, canAcceptOrder: boolean, text: string}}
*/
function normalizeAttendant(employee) {
const info = (employee && employee.attendantInfo) || {}
const stage = info.stage === 'intern' ? 'intern' : 'certified'
const grade = GRADE_LABELS[info.grade] ? info.grade : 'bronze'
const rawStar = Number(info.star)
const star = grade === 'diamond' && isFinite(rawStar)
? Math.max(0, Math.min(5, Math.floor(rawStar)))
: 0
const gradeText = `${GRADE_LABELS[grade]}${grade === 'diamond' && star ? ' ' + '★'.repeat(star) : ''}`
return {
stage,
grade,
star,
canAcceptOrder: stage === 'certified',
isOnline: info.isOnline === true,
text: stage === 'intern' ? '实习陪诊师' : `正式陪诊师 · ${gradeText}`
}
}
function rolesOf(entry) { function rolesOf(entry) {
if (!entry) return [] if (!entry) return []
@@ -77,15 +105,21 @@ async function resolveRoleDetail() {
} }
if (!user) return { ok: false, role: 'none' } if (!user) return { ok: false, role: 'none' }
if (isAdminUser(user)) return { ok: true, role: 'admin' } if (isAdminUser(user)) {
cachedAttendant = null
return { ok: true, role: 'admin' }
}
try { try {
const res = await API.employee.getMe() const res = await API.employee.getMe()
if (!res || res.code !== 0) return { ok: false, role: 'none' } if (!res || res.code !== 0) return { ok: false, role: 'none' }
const employee = res.data ? res.data.employee : null const employee = res.data ? res.data.employee : null
// 实习与正式都算陪诊师:实习能进主页面,只是不能接单
if (employee && employee.status === 'active' && employee.role === 'attendant') { if (employee && employee.status === 'active' && employee.role === 'attendant') {
return { ok: true, role: 'attendant' } cachedAttendant = normalizeAttendant(employee)
return { ok: true, role: 'attendant', attendant: cachedAttendant }
} }
cachedAttendant = null
return { ok: true, role: 'none' } return { ok: true, role: 'none' }
} catch (e) { } catch (e) {
// 员工接口异常:解析失败,不据此判定为无身份 // 员工接口异常:解析失败,不据此判定为无身份
@@ -126,7 +160,9 @@ function ensureRole(force) {
* @returns {Promise<{ok: boolean, role: "admin"|"attendant"|"none"}>} * @returns {Promise<{ok: boolean, role: "admin"|"attendant"|"none"}>}
*/ */
function ensureRoleSafe(force) { function ensureRoleSafe(force) {
if (!force && cachedRole && cachedRoleOk) return Promise.resolve({ ok: true, role: cachedRole }) if (!force && cachedRole && cachedRoleOk) {
return Promise.resolve({ ok: true, role: cachedRole, attendant: cachedAttendant })
}
if (!force && pendingSafe) return pendingSafe if (!force && pendingSafe) return pendingSafe
pendingSafe = resolveRoleDetail() pendingSafe = resolveRoleDetail()
@@ -149,6 +185,16 @@ function getRoleSync() {
return cachedRole return cachedRole
} }
// 陪诊师阶段/等级快照(仅展示用),需先调用 ensureRole/ensureRoleSafe
function getAttendantSync() {
return cachedAttendant
}
// 接单开关切换成功后同步快照,避免 onShow 复用旧值把开关弹回去
function setAttendantOnline(isOnline) {
if (cachedAttendant) cachedAttendant.isOnline = !!isOnline
}
/** /**
* 退出登录 / 清除缓存后重置,避免沿用上一个账号的角色 * 退出登录 / 清除缓存后重置,避免沿用上一个账号的角色
*/ */
@@ -157,6 +203,7 @@ function resetRole() {
cachedRoleOk = false cachedRoleOk = false
pending = null pending = null
pendingSafe = null pendingSafe = null
cachedAttendant = null
applyAppRole(null) applyAppRole(null)
} }
@@ -200,6 +247,8 @@ module.exports = {
ensureRole, ensureRole,
ensureRoleSafe, ensureRoleSafe,
getRoleSync, getRoleSync,
getAttendantSync,
setAttendantOnline,
resetRole, resetRole,
queryOrders, queryOrders,
guardAdminPage guardAdminPage