feat(attendant): 展示实习/正式身份与实习只读提示

- 角色解析缓存陪诊师阶段与等级,实习仍可进入工作台

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

- 申请页文案说明审核通过后为实习陪诊师、转正后可接单
This commit is contained in:
lik
2026-11-10 12:02:08 +08:00
parent a8b896846b
commit 51b6ef497b
7 changed files with 104 additions and 12 deletions
+3 -3
View File
@@ -9,7 +9,7 @@
<view class="hero">
<view class="hero-badge">待审核</view>
<text class="hero-title">申请已提交</text>
<text class="hero-desc">审核通过后重新进入小程序即可接单。期间无需重复提交。</text>
<text class="hero-desc">审核通过后成为实习陪诊师,可先查看订单;管理员转正后即可接单。期间无需重复提交。</text>
</view>
<view class="card">
@@ -39,7 +39,7 @@
<view class="hero">
<view class="hero-badge hero-badge-ok">已通过</view>
<text class="hero-title">审核已通过</text>
<text class="hero-desc">权限正在同步,点击下方按钮重新进入。</text>
<text class="hero-desc">你已成为实习陪诊师,权限正在同步,点击下方按钮进入工作台。</text>
</view>
<button class="submit-btn" bindtap="onRetry">重新进入</button>
<view class="foot-note">当前微信账号:{{accountName}}</view>
@@ -49,7 +49,7 @@
<block wx:else>
<view class="hero">
<text class="hero-title">成为陪诊师</text>
<text class="hero-desc">提交资料并通过审核后,即可查看订单、接单并使用 AI 办公。</text>
<text class="hero-desc">提交资料并通过审核后成为实习陪诊师,可先查看订单;管理员转正后即可接单。</text>
</view>
<view class="reject-box" wx:if="{{rejectReason}}">
+9 -3
View File
@@ -35,11 +35,12 @@ Page({
recentOrders: [],
role: '',
isAdmin: false,
isIntern: false,
levelText: '',
quickEntries: [],
online: true,
profile: {
name: '',
level: '初级陪诊师',
avatar: ''
},
todayIncome: 0,
@@ -84,11 +85,16 @@ Page({
* 先解析角色再取数:管理员看全量,陪诊员只看本人订单
*/
init() {
return role.ensureRole()
.then(r => {
return role.ensureRoleSafe()
.then((detail) => {
const r = detail.role
const attendant = detail.attendant || null
this.setData({
role: r,
isAdmin: r === 'admin',
// 实习陪诊师可进工作台查看,但不能接单:首页给一条只读提示
isIntern: !!(attendant && attendant.stage === 'intern'),
levelText: r === 'admin' ? '管理员' : (attendant ? attendant.text : ''),
quickEntries: r === 'admin' ? ADMIN_ENTRIES : (r === 'attendant' ? ATTENDANT_ENTRIES : [])
})
this.loadUser()
+8 -2
View File
@@ -11,8 +11,8 @@
<view class="profile-info">
<view class="name-row">
<text class="name">{{profile.name}}</text>
<view class="level-tag">
<text class="level-text">{{profile.level}}</text>
<view class="level-tag" wx:if="{{levelText}}">
<text class="level-text">{{levelText}}</text>
</view>
</view>
<text class="greeting">{{greeting}},{{todayText}}</text>
@@ -45,6 +45,12 @@
</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">
<text class="section-title">快捷入口</text>
+18
View File
@@ -118,6 +118,24 @@ page {
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 {
display: flex;
align-items: center;
+20 -1
View File
@@ -1,4 +1,6 @@
// pages/me/index.js
const role = require('../../utils/role.js')
// 性别映射
const SEX_MAP = {
male: '男',
@@ -7,11 +9,28 @@ const SEX_MAP = {
Page({
data: {
user: {}
user: {},
identityText: ''
},
onShow() {
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-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-left">
<t-icon name="user" size="36rpx" color="#C26A2E" />
+39 -3
View File
@@ -15,6 +15,33 @@ let cachedRole = null
let cachedRoleOk = false
let pending = 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',
text: stage === 'intern' ? '实习陪诊师' : `正式陪诊师 · ${gradeText}`
}
}
function rolesOf(entry) {
if (!entry) return []
@@ -77,15 +104,21 @@ async function resolveRoleDetail() {
}
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 {
const res = await API.employee.getMe()
if (!res || res.code !== 0) return { ok: false, role: 'none' }
const employee = res.data ? res.data.employee : null
// 实习与正式都算陪诊师:实习能进主页面,只是不能接单
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' }
} catch (e) {
// 员工接口异常:解析失败,不据此判定为无身份
@@ -126,7 +159,9 @@ function ensureRole(force) {
* @returns {Promise<{ok: boolean, role: "admin"|"attendant"|"none"}>}
*/
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
pendingSafe = resolveRoleDetail()
@@ -157,6 +192,7 @@ function resetRole() {
cachedRoleOk = false
pending = null
pendingSafe = null
cachedAttendant = null
applyAppRole(null)
}