feat(admin): 新增陪诊员入驻申请与全局角色守卫
- 新增 pages/apply 入驻申请页:填写资料、上传证件、查看审核状态 - 新增 utils/role.js 统一角色解析与管理端页面守卫 - app.js 包装 Page 构造器集中做 onShow 守卫,无身份用户重定向至申请页 - 订单、客户、档案、统计等按角色区分能力:陪诊员不请求档案接口,改用订单快照 - 订单列表支持待取消订单一键同意取消;新增订单价格由服务目录决定只读展示
This commit is contained in:
+44
-20
@@ -1,5 +1,5 @@
|
||||
// pages/home/index.js
|
||||
const API = require('../../utils/api.js')
|
||||
const role = require('../../utils/role.js')
|
||||
|
||||
// 取消与 status 解耦:展示状态优先取 cancelStatus
|
||||
function resolveDisplayStatus(order) {
|
||||
@@ -9,22 +9,33 @@ function resolveDisplayStatus(order) {
|
||||
return order?.status || 'pending'
|
||||
}
|
||||
|
||||
// 快捷入口:type=quick 为快捷操作(琥珀浅色系),type=function 为功能入口(暖铜主色系),分行显示。
|
||||
// 管理员与陪诊员共用同一套入口配置,但陪诊员不展示档案/客户等管理员能力
|
||||
const ADMIN_ENTRIES = [
|
||||
{ type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#E8A96B' },
|
||||
{ type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#E8A96B' },
|
||||
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
||||
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#C26A2E' },
|
||||
{ type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#C26A2E' },
|
||||
{ type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#C26A2E' },
|
||||
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
||||
]
|
||||
|
||||
const ATTENDANT_ENTRIES = [
|
||||
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#E8A96B' },
|
||||
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#C26A2E' },
|
||||
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#C26A2E' }
|
||||
]
|
||||
|
||||
Page({
|
||||
data: {
|
||||
today: '',
|
||||
greeting: '',
|
||||
todayText: '',
|
||||
recentOrders: [],
|
||||
// 快捷入口:type=quick 为快捷操作(橙色系),type=function 为功能入口(绿色系),分行显示
|
||||
quickEntries: [
|
||||
{ type: 'quick', icon: 'add-circle', name: '增加预约', url: '/pages/order/orderEdit', color: '#ff8f4d' },
|
||||
{ type: 'quick', icon: 'file-add', name: '增加档案', url: '/pages/healthprofile/profileInfo', color: '#ff8f4d' },
|
||||
{ type: 'quick', icon: 'lightbulb-circle-filled', name: 'AI办公', url: '/pages/ai/index', isTab: true, color: '#ff8f4d' },
|
||||
{ type: 'function', icon: 'bill', name: '预约订单', url: '/pages/order/index', color: '#1abc9c' },
|
||||
{ type: 'function', icon: 'heart', name: '健康档案', url: '/pages/healthprofile/index', color: '#1abc9c' },
|
||||
{ type: 'function', icon: 'user', name: '注册用户', url: '/pages/customer/index', color: '#1abc9c' },
|
||||
{ type: 'function', icon: 'user-circle', name: '个人信息', url: '/pages/me/index', color: '#1abc9c' }
|
||||
],
|
||||
role: '',
|
||||
isAdmin: false,
|
||||
quickEntries: [],
|
||||
online: true,
|
||||
profile: {
|
||||
name: '',
|
||||
@@ -57,21 +68,34 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.loadUser()
|
||||
const now = new Date();
|
||||
const today = now.toISOString().substring(0, 10);
|
||||
const hour = now.getHours();
|
||||
const greeting = hour < 6 ? '夜深了' : hour < 9 ? '早上好' : hour < 12 ? '上午好' : hour < 14 ? '中午好' : hour < 18 ? '下午好' : '晚上好';
|
||||
const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][now.getDay()];
|
||||
this.setData({ today, greeting, todayText: `${now.getMonth() + 1}月${now.getDate()}日 ${week}` });
|
||||
this.getRecentOrders();
|
||||
this.getStats();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadUser()
|
||||
this.getRecentOrders();
|
||||
this.getStats();
|
||||
this.init()
|
||||
},
|
||||
|
||||
/**
|
||||
* 先解析角色再取数:管理员看全量,陪诊员只看本人订单
|
||||
*/
|
||||
init() {
|
||||
return role.ensureRole()
|
||||
.then(r => {
|
||||
this.setData({
|
||||
role: r,
|
||||
isAdmin: r === 'admin',
|
||||
quickEntries: r === 'admin' ? ADMIN_ENTRIES : (r === 'attendant' ? ATTENDANT_ENTRIES : [])
|
||||
})
|
||||
this.loadUser()
|
||||
this.getRecentOrders()
|
||||
this.getStats()
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
loadUser() {
|
||||
@@ -104,8 +128,8 @@ Page({
|
||||
const feeOf = (item) => Number(item.payment && item.payment.totalFee) || 0;
|
||||
|
||||
const [todayRes, completedRes] = await Promise.all([
|
||||
API.escort.getAllRecords({ appointmentDate: todayStr }),
|
||||
API.escort.getAllRecords({ status: 'completed' })
|
||||
role.queryOrders({ appointmentDate: todayStr }),
|
||||
role.queryOrders({ status: 'completed' })
|
||||
]);
|
||||
|
||||
// 今日收益:当日已完成订单的费用合计
|
||||
@@ -129,7 +153,7 @@ Page({
|
||||
* 加载近7日订单(含6天前至今及未来订单,按预约时间倒序,最多10条)
|
||||
*/
|
||||
async getRecentOrders() {
|
||||
const res = await API.escort.getAllRecords({ page: 1, pageSize: 50 });
|
||||
const res = await role.queryOrders({ page: 1, pageSize: 50 });
|
||||
if (res.code !== 0) return;
|
||||
|
||||
const start = new Date();
|
||||
|
||||
Reference in New Issue
Block a user