feat(admin): 新增陪诊员入驻申请与全局角色守卫
- 新增 pages/apply 入驻申请页:填写资料、上传证件、查看审核状态 - 新增 utils/role.js 统一角色解析与管理端页面守卫 - app.js 包装 Page 构造器集中做 onShow 守卫,无身份用户重定向至申请页 - 订单、客户、档案、统计等按角色区分能力:陪诊员不请求档案接口,改用订单快照 - 订单列表支持待取消订单一键同意取消;新增订单价格由服务目录决定只读展示
This commit is contained in:
@@ -2,6 +2,44 @@
|
||||
import config from './config';
|
||||
import createBus from './utils/eventBus';
|
||||
const API = require('./utils/api.js');
|
||||
const role = require('./utils/role.js');
|
||||
|
||||
// ==================== 全局页面守卫 ====================
|
||||
// 无身份用户(role=none)只能停留在入驻申请页,其余页面在 onShow 时统一重定向。
|
||||
// 包装全局 Page 构造器集中处理,避免在 10 个页面各写一遍、漏掉某个入口就绕过去了。
|
||||
const ROLE_WHITELIST = ['pages/apply/index'];
|
||||
let redirecting = false;
|
||||
|
||||
function guardPage(route) {
|
||||
if (!route || ROLE_WHITELIST.indexOf(route) > -1) return;
|
||||
|
||||
role
|
||||
.ensureRoleSafe()
|
||||
.then((detail) => {
|
||||
// 解析失败(用户服务抖动 / 断网)不跳转:
|
||||
// 把解析失败当成"无身份"会将在职陪诊师误踢到申请页
|
||||
if (!detail.ok || detail.role !== 'none') return;
|
||||
if (redirecting) return;
|
||||
|
||||
redirecting = true;
|
||||
wx.reLaunch({
|
||||
url: '/pages/apply/index',
|
||||
complete: () => setTimeout(() => { redirecting = false; }, 800),
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
const rawPage = Page;
|
||||
Page = function (options = {}) {
|
||||
const rawOnShow = options.onShow;
|
||||
options.onShow = function (...args) {
|
||||
const result = rawOnShow && rawOnShow.apply(this, args);
|
||||
guardPage(this.route);
|
||||
return result;
|
||||
};
|
||||
return rawPage(options);
|
||||
};
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
|
||||
Reference in New Issue
Block a user