feat: 添加假登录和权限控制
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Agent
2026-03-24 00:36:40 +00:00
parent 7ca2e1d5a4
commit 17f6b49e5d
4 changed files with 141 additions and 11 deletions

25
src/utils/auth.js Normal file
View File

@@ -0,0 +1,25 @@
/**
* 权限判断工具
*/
export function getRole() {
return uni.getStorageSync('role') || 'guest'
}
export function isAdmin() {
return getRole() === 'admin'
}
export function isCustomer() {
return getRole() === 'customer'
}
export function canCreateOrder() {
// 只有管理员/销售可以创建订单,顾客不可以
return !isCustomer()
}
export function canViewAllOrders() {
// 只有管理员/销售可以查看全部订单
return !isCustomer()
}