This commit is contained in:
25
src/utils/auth.js
Normal file
25
src/utils/auth.js
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user