feat(admin): 新增陪诊员入驻申请与全局角色守卫
- 新增 pages/apply 入驻申请页:填写资料、上传证件、查看审核状态 - 新增 utils/role.js 统一角色解析与管理端页面守卫 - app.js 包装 Page 构造器集中做 onShow 守卫,无身份用户重定向至申请页 - 订单、客户、档案、统计等按角色区分能力:陪诊员不请求档案接口,改用订单快照 - 订单列表支持待取消订单一键同意取消;新增订单价格由服务目录决定只读展示
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// components/order-stats/index.js
|
||||
// 首页订单统计卡片:全部完成 / 本月完成 / 未完成
|
||||
const API = require('../../utils/api.js')
|
||||
const role = require('../../utils/role.js')
|
||||
|
||||
Component({
|
||||
data: {
|
||||
@@ -27,7 +27,7 @@ Component({
|
||||
* 费用取 payment.totalFee 合计
|
||||
*/
|
||||
load() {
|
||||
API.escort.getAllRecords({ page: 1, pageSize: 200 })
|
||||
role.queryOrders({ page: 1, pageSize: 200 })
|
||||
.then(res => {
|
||||
if (res.code !== 0) return
|
||||
const records = res.data.records || []
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
// 第一行:姓名 + 性别(左) · 年龄(右)
|
||||
// 第二行:电话(左,可选拨打) · 所在地(右)
|
||||
//
|
||||
// 两种用法:
|
||||
// 三种用法:
|
||||
// 1. 直接传展示字段(name/sexLabel/ageText/mobile/locationText),适用于列表批量渲染
|
||||
// 2. 只传 profile-id,组件内部加载档案:优先读全局缓存(utils/store.js),未命中再请求
|
||||
// 加载完成后触发 loaded 事件(携带档案原始文档),展示字段以加载结果为准
|
||||
// 3. 传 snapshot(订单 patient 快照):档案不可读(陪诊员无权限 / 档案已删除)时兜底展示,
|
||||
// 避免患者姓名电话为空
|
||||
const store = require('../../utils/store.js')
|
||||
const { calcAge } = require('../../utils/format.js')
|
||||
|
||||
@@ -19,18 +21,42 @@ Component({
|
||||
locationText: { type: String, value: '' },
|
||||
// 是否显示"拨打"并触发 call 事件
|
||||
dial: { type: Boolean, value: false },
|
||||
// 订单患者快照(escort_record.patient):档案加载失败时的兜底
|
||||
snapshot: {
|
||||
type: Object,
|
||||
value: null,
|
||||
observer(newVal) {
|
||||
if (newVal) this.applySnapshot(newVal)
|
||||
}
|
||||
},
|
||||
// 是否允许读取完整档案:陪诊员传 false,避免必然的 403 与信息越权
|
||||
canLoadProfile: {
|
||||
type: Boolean,
|
||||
value: true
|
||||
},
|
||||
// 健康档案ID:传入后组件内部加载,展示字段以加载结果为准
|
||||
profileId: {
|
||||
type: String,
|
||||
value: '',
|
||||
observer(newVal) {
|
||||
if (newVal) this.loadProfile(newVal)
|
||||
if (!newVal) return
|
||||
if (this.data.canLoadProfile) this.loadProfile(newVal)
|
||||
else if (this.data.snapshot) this.applySnapshot(this.data.snapshot)
|
||||
}
|
||||
},
|
||||
// 是否读取缓存:true 缓存优先(默认),false 直接请求最新数据(请求成功后仍回填缓存)
|
||||
useCache: { type: Boolean, value: true }
|
||||
},
|
||||
|
||||
lifetimes: {
|
||||
attached() {
|
||||
if (this.data.snapshot) this.applySnapshot(this.data.snapshot)
|
||||
if (this.data.profileId && this.data.canLoadProfile) {
|
||||
this.loadProfile(this.data.profileId)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onCallTap() {
|
||||
if (!this.data.mobile) return
|
||||
@@ -38,9 +64,14 @@ Component({
|
||||
},
|
||||
|
||||
/**
|
||||
* 按档案ID加载:缓存优先,未命中再请求
|
||||
* 按档案ID加载:缓存优先,未命中再请求;失败时回落到订单快照
|
||||
*/
|
||||
loadProfile(id) {
|
||||
// 陪诊员没有档案读取权限:即使 observer 早于属性赋值触发也直接走快照
|
||||
if (!this.data.canLoadProfile) {
|
||||
this.applySnapshot(this.data.snapshot)
|
||||
return
|
||||
}
|
||||
const cached = store.getProfile(id)
|
||||
if (cached) {
|
||||
this.applyProfile(cached)
|
||||
@@ -49,13 +80,17 @@ Component({
|
||||
const API = require('../../utils/api.js')
|
||||
API.healthProfile.getProfileById(id)
|
||||
.then(res => {
|
||||
if (res.code !== 0 || !res.data || !res.data.profile) return
|
||||
if (res.code !== 0 || !res.data || !res.data.profile) {
|
||||
this.applySnapshot(this.data.snapshot)
|
||||
return
|
||||
}
|
||||
const profile = res.data.profile
|
||||
store.cacheProfile(profile)
|
||||
this.applyProfile(profile)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('获取健康档案失败', err)
|
||||
this.applySnapshot(this.data.snapshot)
|
||||
})
|
||||
},
|
||||
|
||||
@@ -75,6 +110,22 @@ Component({
|
||||
locationText: [loc.province, loc.city].filter(Boolean).join(' ')
|
||||
})
|
||||
this.triggerEvent('loaded', { profile })
|
||||
},
|
||||
|
||||
/**
|
||||
* 订单快照兜底:只在档案不可读时使用,因此不触发 loaded 事件
|
||||
*/
|
||||
applySnapshot(snapshot) {
|
||||
const p = snapshot || {}
|
||||
if (!p.name && !p.mobile) return
|
||||
const age = calcAge(p.birth)
|
||||
const sexLabel = p.sex === 'male' ? '男' : (p.sex === 'female' ? '女' : '')
|
||||
this.setData({
|
||||
name: p.name || '',
|
||||
sexLabel,
|
||||
ageText: age ? `${age}岁` : '',
|
||||
mobile: p.mobile || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user